aliroPathway.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  * aliroPathway handles the pathway or breadcrumb trail.  The management of the
00038  * pathway is primarily the responsibility of each component.  Aliro simply makes
00039  * it easy for the component to deal with it by providing simple to use methods.
00040  * The details of how the trail is displayed are the responsibility of the template.
00041  *
00042  */
00043 
00044 class aliroPathway {
00045     private static $instance = __CLASS__;
00046     private $_names = array();
00047     private $_urls = array();
00048     private $sef = null;
00049     private $custom_pathway = array();
00050 
00051     private function __construct () {
00052         $this->sef = aliroSEF::getInstance();
00053         if ($home = aliroMenuHandler::getInstance()->getHome()) {
00054             $this->_names[] = $home->name;
00055             $this->_urls[] = $this->sef->sefRelToAbs($home->link);
00056         }
00057     }
00058 
00059     private function __clone () {
00060         // Declared to enforce singleton
00061     }
00062 
00063     public static function getInstance () {
00064         return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
00065     }
00066 
00067     public function getPathway () {
00068         $data = new stdClass();
00069         $data->names = $this->_names;
00070         $data->urls = $this->_urls;
00071         $data->custom = $this->custom_pathway;
00072         return $data;
00073     }
00074 
00075     public function setPathway ($data) {
00076         $this->_names = $data->names;
00077         $this->_urls = $data->urls;
00078         $this->_custom_pathway = $data->custom;
00079     }
00080 
00081     public function addItem ($name, $givenurl='') {
00082         if (!$name) return;
00083         $next = count($this->_names);
00084         $url = $this->sef->sefRelToAbs($givenurl);
00085         if ($next > 0 AND $url AND $url == $this->_urls[$next-1]) return;
00086         $this->_names[$next] = $name;
00087         $this->_urls[$next] = $url;
00088     }
00089 
00090     function reduceToOne () {
00091         for ($i = count($this->_names) - 1; $i > 0; $i--) {
00092             unset($this->_names[$i]);
00093             unset($this->_urls[$i]);
00094         }
00095     }
00096 
00097     function reduceByOne () {
00098         array_pop($this->_names);
00099         array_pop($this->_urls);
00100     }
00101 
00102     // The next two functions are deprecated and should not be used - addItem is much easier!
00103     function getCustomPathWay() {
00104         return $this->custom_pathway;
00105     }
00106 
00107     function appendPathWay($html) {
00108         $this->custom_pathway[] = $html;
00109     }
00110 
00111     function makePathway () {
00112         $customs = $this->getCustomPathWay();
00113         $last = count($this->_names) - 1;
00114         if (0 == $last AND 0 == count($customs)) return '';
00115         $starthtml = $result = "<span class='pathway'>";
00116         $config = aliroCore::getInstance();
00117         $rootpath = criticalInfo::getInstance()->absolute_path;
00118         $mainframe = mosMainFrame::getInstance();
00119         $imgPath =  'templates/'.$mainframe->getTemplate().'/images/arrow.png';
00120         if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='{$config->getCfg('live_site')}/$imgPath' border='0' alt='arrow' />";
00121         else {
00122             $imgPath = '/images/M_images/arrow.png';
00123             if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='{$config->getCfg('live_site')}/images/M_images/arrow.png' alt='arrow' />";
00124             else $img = '&gt;';
00125         }
00126         foreach ($this->_names as $i=>$name) {
00127             if ($i === $last AND count($customs) == 0) $result .= "$name</span>";
00128            else {
00129                 $sefurl = $this->sef->sefRelToAbs($this->_urls[$i]);
00130                 $result .= "<a href='$sefurl' class='pathway'>$name</a>";
00131                 $result .= "&nbsp;$img&nbsp;";
00132             }
00133         }
00134         $last = count($customs) - 1;
00135         foreach ($customs as $i=>$custom) $result .= ($i == $last ? strip_tags($custom).'</span>' : $custom."&nbsp;$img&nbsp;");
00136         //return ($starthtml == $result) ? '' : $result;
00137         // This is a temporary fix for Jim Galley
00138         return ($starthtml == $result) ? '<span class="pathway">Home</span>' : $result;
00139     }
00140 
00141 }
00142 
00143 class mosPathway extends aliroPathway {
00144     // Provided purely for backwards compatability
00145 }

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