source: client/php/Global.php

Last change on this file was 79, checked in by chronos, 8 years ago
  • Fixed: Do not include non-existing files.
File size: 2.7 KB
Line 
1<?php
2
3function HumanDate($Time)
4{
5 return(date('j.n.Y', $Time));
6}
7
8function GetMicrotime()
9{
10 list($Usec, $Sec) = explode(" ", microtime());
11 return ((float)$Usec + (float)$Sec);
12}
13
14function ShowPage($Content)
15{
16 global $Config, $ReleaseTime, $Revision;
17
18 $Output = '<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'"?>'."\n".
19 '<!DOCTYPE html>'.
20 '<html>'.
21 '<head>'.
22 '<meta http-equiv="Content-Language" content="cs"/>'.
23 '<meta http-equiv="content-type" content="text/html; charset='.$Config['Web']['Charset'].'" />'.
24 '<meta name="robots" content="all" />'.
25 '<title>'.$Config['Web']['Title'].'</title>'.
26 '<link rel="StyleSheet" href="style/style.css" type="text/css" media="all"/>'.
27 '</head><body>';
28 $Output .= $Content;
29 $Output .= '<br/><div style="text-align: center; font-size: small;">Verze: '.$Revision.' ('.HumanDate($ReleaseTime).')'.
30 ' &nbsp; <a href="http://svn.zdechov.net/trac/statistic/browser/trunk">Zdrojový kód</a> &nbsp; '.
31 '<a href="http://svn.zdechov.net/trac/statistic/log/trunk?verbose=on">Historie změn</a></div>';
32 $Output .= '</body></html>';
33 echo($Output);
34}
35
36function MakeLink($Target, $Title)
37{
38 return('<a href="'.$Target.'">'.$Title.'</a>');
39}
40
41function Table($Table)
42{
43 $Result = '<table cellspacing="0" class="BasicTable">';
44 $Result .= '<tr>';
45 foreach($Table['Header'] as $Item)
46 $Result .= '<th>'.$Item.'</th>';
47 $Result .= '</tr>';
48 foreach($Table['Rows'] as $Row)
49 {
50 $Result .= '<tr>';
51 foreach($Row as $Item)
52 $Result .= '<td>'.$Item.'</td>';
53 $Result .= '</tr>';
54 }
55 $Result .= '</table>';
56 return($Result);
57}
58
59function ShowEditTable($ClassName, $Values)
60{
61 global $Classes, $Types;
62 $Class = $Classes[$ClassName];
63 $Table = array(
64 'Header' => array('Položka', 'Hodnota'),
65 'Rows' => array(),
66 );
67
68 foreach($Class as $Index => $Item)
69 {
70 if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];
71 switch($Item['Type'])
72 {
73 case 'Boolean':
74 if($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';
75 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>';
76 break;
77 case 'String':
78 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';
79 break;
80 case 'Integer':
81 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">';
82 break;
83 default:
84 $Edit = 'Neznámý typ';
85 }
86 array_push($Table['Rows'], array($Item['Caption'], $Edit));
87 }
88 $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat');
89 return($Output);
90}
Note: See TracBrowser for help on using the repository browser.