00001 <?php
00006 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
00007
00008 class aliroFullAdminMenu {
00009 private $entries = array();
00010 private $base = '';
00011 private $links = null;
00012
00013 public function __construct () {
00014 }
00015
00019 public function show() {
00020 $request = mos;
00021 $this->base = aliroRequest::getInstance()->getCfg('admin_site').'/';
00022 $cache = aliroSingletonObjectCache::getInstance();
00023 if ($cachedata = $cache->retrieve('aliroFullAdminMenu')) $results = $cachedata->results;
00024 else {
00025 $coredatabase = aliroCoreDatabase::getInstance();
00026 $coredatabase->setQuery("SELECT * FROM #__admin_menu WHERE published = 1");
00027 $results = $coredatabase->loadObjectList();
00028 $cachedata = new stdClass();
00029 $cachedata->results = $results;
00030 $cache->store($cachedata, 'aliroFullAdminMenu');
00031 }
00032 $max = $chosen = 0;
00033 if ($results) foreach ($results as $result) {
00034 $mcount = 0;
00035 $this->entries[$result->id] = $result;
00036 $query = substr($result->link, 10);
00037 $elements = explode ('&', $query);
00038 foreach ($elements as $element) {
00039 $parts = explode ('=', $element);
00040 if (isset($_REQUEST[$parts[0]]) AND isset($parts[1]) AND $_REQUEST[$parts[0]] == $parts[1]) $mcount++;
00041 }
00042 if ($mcount > $max) {
00043 $max = $mcount;
00044 $chosen = $result->id;
00045 }
00046 }
00047 $numbers = array();
00048 while ($chosen) {
00049 $numbers[] = $chosen;
00050 $chosen = $this->entries[$chosen]->parent;
00051 }
00052 $this->showLevel(0, $numbers, "\n<ul id='nav'>");
00053 $html = '';
00054 if ($this->links) {
00055 foreach ($this->links as $link) $html .= $link;
00056 }
00057 return $html;
00058 }
00059
00060 private function showLevel ($parent, $numbers, $liststart) {
00061 $authoriser = aliroAuthoriser::getInstance();
00062 $trigger = false;
00063 foreach ($this->entries as $entry) {
00064 if ($entry->parent != $parent) continue;
00065 if (!$authoriser->checkUserPermission('see', 'aliroMenu', $entry->id)) continue;
00066 if (!$trigger) {
00067 $this->links[] = $liststart;
00068 $trigger = true;
00069 }
00070 if ('placeholder' == $entry->type) $this->links[] = "\n\t<li>$entry->name";
00071 elseif ('url' == $entry->type) $this->links[] = "\n\t<li><a href='{$entry->link}'>$entry->name</a>";
00072 else $this->links[] = "\n\t<li><a href='{$this->base}{$entry->link}'>$entry->name</a>";
00073 $this->showLevel($entry->id, $numbers, "\n<ul>");
00074 $this->links[] = "</li>";
00075 }
00076 if ($trigger) $this->links[] = "\n</ul>";
00077 }
00078
00079 public static function clearCache () {
00080 $cache = aliroSingletonObjectCache::getInstance();
00081 $cache->delete('aliroFullAdminMenu');
00082 }
00083
00084 }
00085
00086 ?>