source: trunk/www/Base/Html.php

Last change on this file was 93, checked in by chronos, 11 years ago
  • Fixed: System variable as parameter to constructors of descendents of Module class.
  • Removed: End PHP mark "?>" from all files.
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1<?php
2
3class HTML
4{
5 function ShowArray($Value)
6 {
7 echo('<pre style="font-size: 8pt;">');
8 print_r($Value);
9 echo('</pre>');
10 }
11
12 // Funkce formatovani vystupu
13 function FormatOutput($Text)
14 {
15 $Indentation = 2;
16
17 $Output = '';
18 $Indent = 0;
19 $IndentNew = 0;
20 while($Text != '')
21 {
22 $Start = strpos($Text, '<');
23 $End = strpos($Text, '>');
24 if($Start != 0)
25 {
26 $End = $Start - 1;
27 $Start = 0;
28 }
29 $Line = trim(substr($Text, $Start, $End + 1));
30 if(strlen($Line) > 0)
31 if($Line[0] == '<')
32 {
33 if($Text[$Start + 1] == '/')
34 {
35 $IndentNew = $IndentNew - $Indentation;
36 $Indent = $IndentNew;
37 } else
38 {
39 if(strpos($Line, ' ')) $Command = substr($Line, 1, strpos($Line, ' ') - 1);
40 else $Command = substr($Line, 1, strlen($Line) - $Indentation);
41 if(strpos($Text, '</'.$Command.'>')) $IndentNew = $IndentNew + $Indentation;
42 }
43 }
44 if($Line != '') $Output .= (str_repeat(' ', $Indent).$Line."\n");
45 $Text = substr($Text, $End + 1, strlen($Text));
46 $Indent = $IndentNew;
47 }
48 return($Output);
49 }
50
51 function NotBlank($Text)
52 {
53 if($Text == '') return('&nbsp'); else return($Text);
54 }
55
56 function MakeLink($Target, $Title)
57 {
58 return('<a href="'.$Target.'">'.$Title.'</a>');
59 }
60
61 function Table($Table, $Class)
62 {
63 $Result = '<table class="'.$Class.'">';
64 if(array_key_exists('Header', $Table))
65 {
66 $Result .= '<tr>';
67 foreach($Table['Header'] as $Item)
68 $Result .= '<th>'.$Item.'</th>';
69 $Result .= '</tr>';
70 }
71 foreach($Table['Rows'] as $Row)
72 {
73 $Result .= '<tr>';
74 foreach($Row as $Index => $Item)
75 {
76 if($Index == 0) $Class = ' class="Header"'; else $Class = '';
77 $Result .= '<td'.$Class.'>'.$Item.'</td>';
78 }
79 $Result .= '</tr>';
80 }
81 $Result .= '</table>';
82 return($Result);
83 }
84
85 // Zobrazení číselný seznamu stránek
86 function PageList($QueryStringVar, $Page, $TotalCount, $CountPerPage, $Around = 10)
87 {
88 $QueryStringArray = GetQueryStringArray();
89 $Count = ceil($TotalCount / $CountPerPage);
90 $Result = '';
91 if($Count > 1)
92 {
93 if($Page > 0)
94 {
95 $QueryStringArray[$QueryStringVar] = 0;
96 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">&lt;&lt;</a> ';
97 $QueryStringArray[$QueryStringVar] = $Page - 1;
98 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">&lt;</a> ';
99 }
100 $PagesMax = $Count - 1;
101 $PagesMin = 0;
102 if($PagesMax > ($Page + $Around)) $PagesMax = $Page + $Around;
103 if($PagesMin < ($Page - $Around))
104 {
105 $Result .= ' .. ';
106 $PagesMin = $Page - $Around;
107 }
108 for($i = $PagesMin; $i <= $PagesMax; $i++)
109 {
110 if($i == $Page) $Result .= '<strong>';
111 $QueryStringArray[$QueryStringVar] = $i;
112 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">'.($i + 1).'</a> ';
113 if($i == $Page) $Result .= '</strong>';
114 }
115 if($PagesMax < ($Count - 1)) $Result .= ' .. ';
116 if($Page < ($Count - 1))
117 {
118 $QueryStringArray[$QueryStringVar] = $Page + 1;
119 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">&gt;</a> ';
120 $QueryStringArray[$QueryStringVar] = $Count - 1;
121 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">&gt;&gt;</a>';
122 }
123 }
124 return($Result);
125 }
126}
Note: See TracBrowser for help on using the repository browser.