aliroScreenArea.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  * aliroScreenArea is the abstract class used to define a browser area - the locations
00038  * into which module output is placed.  It also provides a static method for building
00039  * the output for all screen areas for a template.  The output is captured at this point,
00040  * so that module code is able to create new information in the HTML header etc.
00041  *
00042  * aliroUserScreenArea and aliroAdminScreenArea are the classes that are actually
00043  * instantiated on the user and admin sides respectively.  Further work is needed
00044  * clarify the operation of admin side modules.
00045  *
00046  */
00047 
00048 abstract class aliroScreenArea {
00049     public $name = '';
00050     public $min_width = 0;
00051     public $max_width = 0;
00052     public $style = 0;
00053     protected $screen_data = '';
00054 
00055     public function __construct ($name, $min_width, $max_width, $style) {
00056         $this->name = $name;
00057         $this->min_width = $min_width;
00058         $this->max_width = $max_width;
00059         $this->style = $style;
00060     }
00061 
00062     public static function prepareTemplate ($template) {
00063         $areas = $template->positions();
00064         foreach ($areas as $area) {
00065             ob_start();
00066             $area->loadModules($template);
00067             $area->setData(ob_get_contents());
00068             ob_end_clean();
00069         }
00070     }
00071     public function setData ($data) {
00072         $this->screen_data = $data;
00073     }
00074 
00075     public function addData ($data) {
00076         $this->screen_data .= $data;
00077     }
00078 
00079     public function getData () {
00080         return $this->screen_data;
00081     }
00082 
00083 }
00084 
00085 class aliroUserScreenArea extends aliroScreenArea {
00086 
00087     public function countModules () {
00088         return aliroModuleHandler::getInstance()->countModules($this->name, false);
00089     }
00090 
00091     public function loadModules ($template) {
00092         $modules = aliroModuleHandler::getInstance()->getModules($this->name, false);
00093         foreach ($modules as $module) {
00094             // Could add output directly into module object, but this method captures any diagnostic etc output
00095             echo $module->renderModule($this, $template);
00096         }
00097     }
00098 
00099 }
00100 
00101 class aliroAdminScreenArea extends aliroScreenArea {
00102 
00103     public function countModules () {
00104         return aliroModuleHandler::getInstance()->countModules($this->name, true);
00105     }
00106 
00107     public function loadModules ($template) {
00108         $modules = aliroModuleHandler::getInstance()->getModules($this->name, true);
00109         $authoriser = aliroAuthoriser::getInstance();
00110         foreach ($modules as $module) {
00111             if ($authoriser->checkUserPermission ('view', 'aliroModule', $module->id)) {
00112                 // $moduleid was second parameter, but not being supplied???
00113                 // if ($moduleid AND $moduleid != $module->id) echo $module->renderModuleTitle($this, $template);
00114                 echo $module->renderModule($this, $template);
00115             }
00116         }
00117     }
00118 
00119 }

Generated on Thu Apr 17 13:03:27 2008 for ALIRO by  doxygen 1.5.5