Source for file page.class.php

Documentation is available at page.class.php


1 <?php
2 /**
3 * @version $Id: page.class.php,v 1.9 2003/09/17 10:42:18 cybot_tm Exp $
4 * @category phpTimeSheet
5 * @package phpTimeSheet
6 */
7
8 /**
9 *
10 */
11 define('TEMPLATE','template.inc.php');
12 define('PTS_URL_FAVICON','/favicon.ico');
13 define('PTS_URL_STYLE','style.css');
14 define('DOCTYPE','<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
15 define('XML','<?xml version="1.0" encoding="iso-8859-1"?>');
16
17 /**
18 * Class Page
19 *
20 * @package phpTimeSheet
21 * @author Sebastian Mendel <info@sebastianmendel.de>
22 * @version $Id: page.class.php,v 1.9 2003/09/17 10:42:18 cybot_tm Exp $
23 */
24 class Page
25 {
26 // variablen
27
28 // Meta Tags
29 var $scripts = array();
30 var $P = array();
31 var $M = array();
32 var $H = array();
33 var $L = array();
34 var $Error = array();
35 var $Info = array();
36
37 function Page($template = TEMPLATE) {
38 // page overall
39 $this->P['title'] = 'Zeiterfassung';
40
41 // http header / http-equiv
42 // standard document content type
43 $this->H['Content-Type'] = 'text/html; charset=iso-8859-1';
44 // standard css content type
45 $this->H['Content-Style-Type'] = 'text/css';
46 // standard css-file
47 $this->H['Default-Style'] = 'standard';
48
49 // linked documents
50 // style sheets
51 $this->L[] = array('href' => PTS_URL_STYLE, 'rel' => 'stylesheet', 'type' => 'text/css', 'title' => 'standard');
52 // favicon
53 $this->L[] = array('href' => PTS_URL_FAVICON, 'rel' => 'SHORTCUT ICON');
54
55 $this->P['subtitle'] = '';
56 }
57
58 function SetError($Message)
59 {
60 $this->Error[] = $Message;
61 return true;
62 }
63
64 function SetInfo($Message)
65 {
66 $this->Info[] = $Message;
67 return true;
68 }
69
70 function printPage(&$content) {
71 echo XML . "\n";
72 echo DOCTYPE . "\n";
73 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" dir="ltr" >' . "\n";
74 echo $this->getHead();
75 echo '<body><table id="maintable" align="center"><tr><td id="maincell" align="center">' . "\n";
76 echo $this->GetHtmlMessages();
77 echo $content;
78 echo '</td></tr></table></body>' . "\n";
79 echo '</html>' . "\n";
80 }
81
82 function GetHtmlMessages()
83 {
84 $return = '';
85 if ( ! empty($this->Error) )
86 {
87 $return .= '<div class="alertbox">';
88 $br = '';
89 foreach ( $this->Error as $message )
90 {
91 $return .= $br . $message . "\n";
92 $br = '<br />';
93 }
94 $return .= '</div><br />';
95 }
96
97 if ( ! empty($this->Info) )
98 {
99 $return .= '<div class="messagebox">';
100 $br = '';
101 foreach ( $this->Info as $message )
102 {
103 $return .= $br . $message . "\n";
104 $br = '<br />';
105 }
106 $return .= '</div><br />';
107 }
108 return $return;
109 }
110
111 function getHead() {
112 $head = "<head>\n";
113 $head .= $this->getTitle();
114 $head .= $this->getLinks();
115 $head .= $this->getMetatags_httpequiv();
116 $head .= $this->getMetatags();
117 $head .= $this->getScripts();
118 $head .= "</head>\n";
119 return $head;
120 }
121
122 function getTitle() {
123 $title = '<title>';
124 $title .= $this->P['title'];
125 if ( ! empty($this->P['subtitle']) )
126 $title .= ' - ' . $this->P['subtitle'];
127 $title .= '</title>' . "\n";
128 return $title;
129 }
130
131 function getScripts() {
132 $return = '';
133 if ( ! empty($this->scripts) ) {
134 foreach ( $this->scripts as $script )
135 $return .= $script . "\n";
136 }
137 return $return;
138 }
139
140 function getMetatags() {
141 $return = '';
142 if ( ! empty($this->M) ) {
143 foreach ( $this->M as $tagname => $tagcontent )
144 $return .= '<meta name="' . $tagname . '" content="' . $tagcontent . '" />' . "\n";
145 }
146 return $return;
147 }
148
149 function getMetatags_httpequiv() {
150 $return = '';
151 if ( ! empty($this->H) ) {
152 foreach ( $this->H as $tagname => $tagcontent )
153 $return .= '<meta http-equiv="' . $tagname . '" content="' . $tagcontent . '" />' . "\n";
154 }
155 return $return;
156 }
157
158 function getLinks() {
159 $return = '';
160 if ( ! empty($this->L) ) {
161 foreach ( $this->L as $link ) {
162 $return .= '<link ';
163 foreach ( $link as $attribut => $value )
164 $return .= $attribut . '="' . $value . '" ';
165 $return .= '/>' . "\n";
166 }
167 }
168 return $return;
169 }
170 }
171 ?>

Documentation generated on Fri, 26 Sep 2003 15:39:49 +0200 by phpDocumentor 1.2.2