source: trunk/Common/Page.php@ 438

Last change on this file since 438 was 438, checked in by chronos, 12 years ago
  • Přesunuto: Soubory s třídamy přesunuty do podsložky Common. Aktualizovány odkazy mezi soubory.
File size: 8.3 KB
Line 
1<?php
2
3class Page extends Module
4{
5 var $TimeStart;
6 var $FormatHTML = false;
7 var $ShowRuntimeInfo = false;
8 var $PathTree = array('Rozcestník',
9 'index.php' => '',
10 'missing.php' => '',
11 'manualy.php' => 'Manuály',
12 'is' => array('',
13 'index.php' => 'Správa dat',
14 'topologie.php' => 'Topologie sítě',
15 ),
16 'network.php' => 'Technické informace',
17 'map' => array('',
18 'index.php' => 'Mapa sítě',
19 ),
20 'tv' => array('',
21 'index.php' => 'Síťová televize',
22 ),
23 'network' => array('',
24 'administration.php' => 'Administrace sítě',
25 'dostupnost.php' => 'Dostupnost zařízení',
26 'restart.php' => 'Restart služeb',
27 ),
28 'nabidky_pripojeni.php' => 'Nabídky připojení',
29 'telseznam.php' => 'Telefonní seznam',
30 'merak.php' => 'Měřič spotřeby',
31 'tkr.php' => 'Kanály kabelové televize',
32 'LogShow.php' => 'Záznamy operací',
33 'share' => array('Prohledat sdílení',
34 'index.php' => '',
35 'firefox.php' => 'Integrace do prohlížeče',
36 ),
37 'hostlist.php' => 'Seznam počítačů',
38 'userlist.php' => 'Seznam uživatelů',
39 'farnost' => array('',
40 'index.php' => 'Rozpis mší',
41 ),
42 'finance' => array('Finance',
43 'index.php' => '',
44 'spotreba.php' => 'Spotřeba',
45 'zivnost.php' => 'Daňová evidence',
46 'prepocet.php' => 'Přepočet financí',
47 'changes.php' => 'Změny',
48 'tarify.php' => 'Tarify',
49 'inventory.php' => 'Skladové zásoby',
50 'clenove.php' => 'Seznam členů',
51 'zarizeni.php' => 'Zařízení',
52 'strom.php' => 'Strom zařízení',
53 'srovnani.php' => 'Porovnání tarifů s konkurencí',
54 'bills_manage.php' => 'Faktury',
55 'monthly_overall.php' => 'Měsíční přehledy',
56 'manage.php' => 'Správa financí',
57 'faktury' => array('',
58 'index.php' => 'Faktury za internet',
59 ),
60 ),
61 'statistic' => array('',
62 'trafficview.php' => 'Vytížení internetu',
63 'index.php' => 'Statistika',
64 'trafficview2.php' => 'Statistika',
65 'bandwidth.php' => 'Zatížení internetu',
66 'bandwidth_full.php' => 'Zatížení internetu všech počítačů',
67 ),
68 'fotbal.php' => 'Fotbal',
69 'webcam' => array('',
70 'index.php' => 'Web kamera',
71 ),
72 'navody.php' => 'Návody',
73 'ukoly.php' => 'Plánované projekty',
74 'otevreno.php' => 'Otvírací doby',
75 'aktuality' => array('',
76 'index.php' => 'Aktuality',
77 'subscription.php' => 'RSS aktuality',
78 ),
79 'sluzby.php' => 'Služby',
80 'history.php' => 'Historie',
81 'docs' => array('',
82 'zapisy' => array('',
83 'zapisy.php' => 'Zápisy ze schůzí',
84 ),
85 ),
86 'jidelna' => array('',
87 'index.php' => 'Jídelníček',
88 'menuedit.php' => 'Editace jídelníčku',
89 ),
90 'backup' => array('',
91 'index.php' => 'Nastavení zálohování',
92 ),
93 'mapa.php' => 'Mapa webu',
94 );
95
96 function __construct()
97 {
98 global $Config;
99
100 $this->FormatHTML = $Config['Web']['FormatHTML'];
101 $this->ShowRuntimeInfo = $Config['Web']['ShowRuntimeInfo'];
102 }
103
104 function SystemMessage($Title, $Text)
105 {
106 return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div</td></tr></table>');
107 //ShowFooter();
108 //die();
109 }
110
111 function ShowHeader($Title, $Path)
112 {
113 $ScriptName = $_SERVER['SCRIPT_NAME'];
114 while(strpos($ScriptName, '//') !== false)
115 $ScriptName = str_replace('//', '/', $ScriptName);
116 $PathTreePath = '/';
117 $PathTreeItem = $this->PathTree;
118 $Navigation = '<a href="'.$this->System->Config['Web']['RootFolder'].$PathTreePath.'">'.$PathTreeItem[0].'</a> &gt; ';
119 $ScriptName = substr($ScriptName, strlen($this->System->Config['Web']['RootFolder']));
120 $ScriptNameParts = explode('/', $ScriptName);
121 array_shift($ScriptNameParts);
122 foreach($ScriptNameParts as $ScriptNamePart)
123 {
124 //echo($ScriptNamePart.'<br />');
125 if(array_key_exists($ScriptNamePart, $PathTreeItem))
126 {
127 if(is_array($PathTreeItem[$ScriptNamePart]))
128 {
129 $PathTreeItem = $PathTreeItem[$ScriptNamePart];
130 $PathTreePath .= $ScriptNamePart.'/';
131 if($PathTreeItem[0] != '')
132 $Navigation .= '<a href="'.$this->System->Config['Web']['RootFolder'].$PathTreePath.'">'.$PathTreeItem[0].'</a> &gt; ';
133 } else
134 {
135 if($PathTreeItem[$ScriptNamePart] != '')
136 $Navigation .= '<a href="'.$this->System->Config['Web']['RootFolder'].$PathTreePath.$ScriptNamePart.'">'.$PathTreeItem[$ScriptNamePart].'</a> &gt; ';
137 }
138 }
139 }
140 $Navigation = substr($Navigation, 0, -6);
141
142 $BodyParam = '';
143 if(isset($this->Load)) $BodyParam .= ' onload="'.$this->Load.'"';
144 if(isset($this->Unload)) $BodyParam .= ' onunload="'.$this->Unload.'"';
145 $Output = '<?xml version="1.0" encoding="'.$this->System->Config['Web']['Charset'].'"?>'."\n".
146 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
147 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
148 '<head><link rel="stylesheet" href="'.$this->System->Config['Web']['RootFolder'].'/style/'.$this->System->Config['Web']['Style'].'/style.css" type="text/css" media="all" />'.
149 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->System->Config['Web']['Charset'].'" />'.
150 '<script type="text/javascript" src="'.$this->System->Config['Web']['RootFolder'].'/style/'.$this->System->Config['Web']['Style'].'/global.js"></script>'.
151 '<title>'.$this->System->Config['Web']['Title'].' - '.$Path.'</title>
152 </head><body'.$BodyParam.'>
153 <div id="Title">'.$Title.'</div>
154 <div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
155 if($this->System->Config['Web']['UserSupport'] == 1)
156 {
157 if($this->System->Modules['User']->User['Id'] == $this->System->Modules['User']->AnonymousUserId)
158 $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a> <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>';
159 else $Output .= $this->System->Modules['User']->User['Name'].' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=Logout">Odhlásit</a>';
160 } else $Output .= '&nbsp;';
161// <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>';
162 $Output .= '</div></div>';
163 return($Output);
164 }
165
166 function ShowFooter()
167 {
168 global $ScriptTimeStart;
169 $Time = round(GetMicrotime() - $ScriptTimeStart, 2);
170 $Output = '<div id="Footer">
171 <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' |';
172 if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |';
173 $Output .= '</i></div></body></html>';
174 return($Output);
175 }
176
177 function GetOutput()
178 {
179 $Output = $this->Show();
180 $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Output;
181 $Output .= $this->ShowFooter();
182 if($this->FormatHTML == true) echo($this->FormatOutput($Output));
183 else echo($Output);
184 }
185
186 // Funkce formatovani vystupu
187 function FormatOutput($s)
188 {
189 $out = '';
190 $nn = 0;
191 $n = 0;
192 while($s != '')
193 {
194 $start = strpos($s, '<');
195 $end = strpos($s, '>');
196 if($start != 0)
197 {
198 $end = $start - 1;
199 $start = 0;
200 }
201 $line = trim(substr($s, $start, $end + 1));
202 if(strlen($line) > 0)
203 if($line[0] == '<')
204 {
205 if($s[$start + 1] == '/')
206 {
207 $n = $n - 2;
208 $nn = $n;
209 } else
210 {
211 if(strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);
212 else $cmd = substr($line, 1, strlen($line) - 2);
213 //echo('['.$cmd.']');
214 if(strpos($s, '</'.$cmd.'>')) $n = $n + 2;
215 }
216 }// else $line = '['.$line.']';
217 //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
218 if($line != '') $out .= (str_repeat(' ', $nn).$line."\n");
219 $s = substr($s, $end + 1, strlen($s));
220 $nn = $n;
221 }
222 return($out);
223 }
224}
225
226?>
Note: See TracBrowser for help on using the repository browser.