source: trunk/Common/Page.php@ 473

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