aliroTemplateBase.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*******************************************************************************
00004  * Aliro - the modern, accessible content management system
00005  *
00006  * Aliro is open source software, free to use, and licensed under GPL.
00007  * You can find the full licence at http://www.gnu.org/copyleft/gpl.html GNU/GPL
00008  *
00009  * The author freely draws attention to the fact that Aliro derives from Mambo,
00010  * software that is controlled by the Mambo Foundation.  However, this section
00011  * of code is totally new.  If it should contain any fragments that are similar
00012  * to Mambo, please bear in mind (1) there are only so many ways to do things
00013  * and (2) the author of Aliro is also the author and copyright owner for large
00014  * parts of Mambo 4.6.
00015  *
00016  * Tribute should be paid to all the developers who took Mambo to the stage
00017  * it had reached at the time Aliro was created.  It is a feature rich system
00018  * that contains a good deal of innovation.
00019  *
00020  * Your attention is also drawn to the fact that Aliro relies on other items of
00021  * open source software, which is very much in the spirit of open source.  Aliro
00022  * wishes to give credit to those items of code.  Please refer to
00023  * http://aliro.org/credits for details.  The credits are not included within
00024  * the Aliro package simply to avoid providing a marker that allows hackers to
00025  * identify the system.
00026  *
00027  * Copyright in this code is strictly reserved by its author, Martin Brampton.
00028  * If it seems appropriate, the copyright will be vested in the Aliro Organisation
00029  * at a suitable time.
00030  *
00031  * Copyright (c) 2007 Martin Brampton
00032  *
00033  * http://aliro.org
00034  *
00035  * counterpoint@aliro.org
00036  *
00037  * aliroTemplateBase is a base class for building templates.
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         // This needs sorting out!!!!
00056         // needed to seperate the ISO number from the language file constant _ISO for XML declaration
00057         // $iso = explode( '=', _ISO );
00058         // $this->iso = _ISO;
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     // Returns an array of all the screen areas that have been constructed by this template
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     // Define the HTML for a single error message
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     // Define the HTML for the whole set of error messages, given the messages
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         // Obtain the <head> information accumulated by the system
00189         $headerstuff = $this->request->showHead();
00190         // If there is a logged in user, then make the editor available
00191         if (aliroUser::getInstance()->id) $headerstuff .= aliroEditor::getInstance()->initEditor();
00192         return $headerstuff;
00193     }
00194 
00195     protected function debugOutput () {
00196         // Acquire debug information
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     // Only the most basic HTML combined with the output of the invoked component
00221     // Can be overriden by a template if required
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 }

Generated on Wed May 14 13:01:56 2008 for ALIRO by  doxygen 1.5.5