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
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
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 == $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
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 $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 = '>';
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 .= " $img ";
00132 }
00133 }
00134 $last = count($customs) - 1;
00135 foreach ($customs as $i=>$custom) $result .= ($i == $last ? strip_tags($custom).'</span>' : $custom." $img ");
00136 return $result;
00137 }
00138
00139 }
00140
00141 class mosPathway extends aliroPathway {
00142
00143 }