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 00072 public function setData ($data) { 00073 $this->screen_data = $data; 00074 } 00075 00076 public function addData ($data) { 00077 $this->screen_data .= $data; 00078 } 00079 00080 public function getData () { 00081 return $this->screen_data; 00082 } 00083 00084 } 00085 00086 class aliroUserScreenArea extends aliroScreenArea { 00087 00088 public function countModules () { 00089 return aliroModuleHandler::getInstance()->countModules($this->name, false); 00090 } 00091 00092 public function loadModules ($template) { 00093 $modules = aliroModuleHandler::getInstance()->getModules($this->name, false); 00094 foreach ($modules as $module) { 00095 // Could add output directly into module object, but this method captures any diagnostic etc output 00096 echo $module->renderModule($this, $template); 00097 } 00098 } 00099 00100 } 00101 00102 class aliroAdminScreenArea extends aliroScreenArea { 00103 00104 public function countModules () { 00105 return aliroModuleHandler::getInstance()->countModules($this->name, true); 00106 } 00107 00108 public function loadModules ($template) { 00109 $modules = aliroModuleHandler::getInstance()->getModules($this->name, true); 00110 $authoriser = aliroAuthoriser::getInstance(); 00111 foreach ($modules as $module) { 00112 if ($authoriser->checkUserPermission ('view', 'aliroModule', $module->id)) { 00113 // $moduleid was second parameter, but not being supplied??? 00114 // if ($moduleid AND $moduleid != $module->id) echo $module->renderModuleTitle($this, $template); 00115 echo $module->renderModule($this, $template); 00116 } 00117 } 00118 } 00119 00120 }
1.5.5