00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 abstract class aliroTemplateBase {
00042 protected $screenarea = array();
00043 protected $live_site = '';
00044 protected $sitename = '';
00045 protected $iso = '';
00046 protected $request = null;
00047 protected $areas = array();
00048 protected $isMain = false;
00049 protected $translations = array();
00050
00051 public function __construct () {
00052 $this->request = aliroUserRequest::getInstance();
00053 $this->live_site = $this->request->getCfg('live_site');
00054 $this->sitename = $this->request->getCfg('sitename');
00055
00056
00057
00058
00059 $this->iso = 'charset=utf-8';
00060 foreach ($this->areas as $area) $this->screenarea[$area['position']] = new aliroUserScreenArea ($area['position'], $area['min'], $area['max'], $area['style']);
00061 }
00062
00063
00064 public function positions () {
00065 return $this->screenarea;
00066 }
00067
00068 protected function T_ ($string) {
00069 return T_($string);
00070 }
00071
00072 protected function show ($string) {
00073 return $string;
00074 }
00075
00076 protected function overlib () {
00077 return $this->request->requestOverlib();
00078 }
00079
00080 }
00081
00082 abstract class aliroMainTemplateBase extends aliroTemplateBase {
00083 protected $colours = array();
00084 protected $mainmenu = '';
00085 protected $username = '';
00086 protected $versiontext = '';
00087
00088 public function __construct () {
00089 parent::__construct();
00090 }
00091
00092 protected function mainBody () {
00093 return aliroComponentHandler::getInstance()->mosMainBody();
00094 }
00095
00096 protected function getTimeMessage () {
00097 return aliro::getInstance()->getTimeMessage();
00098 }
00099
00100 protected function errorMessage () {
00101 $messages = $this->request->pullErrorMessages();
00102 if (count($messages)) {
00103 $msghtml = '';
00104 foreach ($this->colours as $severity=>$colour) if (isset($messages[$severity])) {
00105 foreach ($messages[$severity] as $text) {
00106 $msghtml .= $this->oneErrorMessage ($colour, $text);
00107 }
00108 }
00109 $html = $this->errorSet($msghtml);
00110 }
00111 else $html = '';
00112 return $html;
00113 }
00114
00115
00116 protected function oneErrorMessage ($colour, $text) {
00117 return <<<ONE_ERROR_MESSAGE
00118 <div class="$colour errormessage">
00119 $text
00120 </div>
00121 ONE_ERROR_MESSAGE;
00122
00123 }
00124
00125
00126 protected function errorSet ($errorsHTML) {
00127 return <<<FULL_MESSAGE_SET
00128 <!-- start Error Message area -->
00129 <div id="errormessage">
00130 $errorsHTML
00131 <!-- end Error Message area -->
00132 </div>
00133 FULL_MESSAGE_SET;
00134
00135 }
00136
00137 protected function xhtml_10_trans () {
00138 return <<<DOCTYPE
00139 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00140
00141 DOCTYPE;
00142
00143 }
00144
00145 protected function xhtml_10_strict () {
00146 return <<<DOCTYPE
00147 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00148
00149 DOCTYPE;
00150
00151 }
00152
00153 protected function xhtml_11 () {
00154 return <<<DOCTYPE
00155 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
00156
00157 DOCTYPE;
00158
00159 }
00160
00161 }
00162
00163 abstract class aliroUserTemplateBase extends aliroMainTemplateBase {
00164 protected $favicon = '#';
00165 protected $colours = array();
00166 protected $template_uri= '';
00167
00168 public function __construct () {
00169 parent::__construct();
00170 $this->isMain = true;
00171 $this->template_uri = $this->live_site.'/templates/'.$this->tname;
00172 }
00173
00174 protected function __get ($property) {
00175 switch ($property) {
00176 case 'pathway':
00177 return aliroPathway::getInstance();
00178 case 'thispage':
00179 return $this->request->getCfg('sef') ? aliroSEF::getInstance()->sefRelToAbs(substr($_SERVER['REQUEST_URI'],1)) : '';
00180 case 'version':
00181 return new version();
00182 default:
00183 return null;
00184 }
00185 }
00186
00187 protected function prepareHeader () {
00188
00189 $headerstuff = $this->request->showHead();
00190
00191 if (aliroUser::getInstance()->id) $headerstuff .= aliroEditor::getInstance()->initEditor();
00192 return $headerstuff;
00193 }
00194
00195 protected function debugOutput () {
00196
00197 $this->screenarea['debug']->setData($this->request->getDebug());
00198 return $this->screenarea['debug']->getData();
00199 }
00200
00201 protected function header () {
00202 if (!method_exists($this, $this->doctype)) $doctype = 'xhtml_10_trans';
00203 else $doctype = $this->doctype;
00204 $iso = _ISO;
00205 $request = aliroRequest::getInstance();
00206 foreach ((array) $this->cssname as $css) $request->addCSS("/templates/$this->tname/$css");
00207
00208 return <<<HEADER
00209 {$this->$doctype()}
00210 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
00211 <head>
00212 <meta http-equiv="Content-type" content="text/html; $iso" />
00213 {$this->prepareHeader()}
00214 </head>
00215
00216 HEADER;
00217
00218 }
00219
00220
00221
00222 public function component_render () {
00223 echo <<<COMPONENT_HTML
00224 {$this->header ()}
00225
00226 <body>
00227 {$this->mainBody()}
00228 </body>
00229 </html>
00230
00231 COMPONENT_HTML;
00232
00233 }
00234 }