Exemplo n.º 1
0
 static function NeedBaseBreadcrumb($pathway, $aparams)
 {
     global $FSSRoute_menus;
     // need to determine if a base pathway item needs adding or not
     // get any menu items for fss
     FSS_Helper::GetRouteMenus();
     $lastpath = $pathway->getPathway();
     // no pathway, so must have to add
     if (count($lastpath) == 0) {
         return true;
     }
     $lastpath = $lastpath[count($lastpath) - 1];
     $link = $lastpath->link;
     $parts = FSSRoute::SplitURL($link);
     if (!array_key_exists('Itemid', $parts)) {
         return true;
     }
     //print_p($parts);
     if (!array_key_exists($parts['Itemid'], $FSSRoute_menus)) {
         //echo "Item ID not found<br>";
         return true;
     }
     $ok = true;
     /*foreach($FSSRoute_menus[$parts['Itemid']] as $key => $value)
     		{
     			if ($value != "")
     			{
     				if (!array_key_exists($key,$aparams))
     				{
     					$ok = false;
     					break;
     				}
     			
     				if ($aparams[$key] != $value)
     				{
     					$ok = false;
     					break;		
     				}
     			}
     		}*/
     foreach ($aparams as $key => $value) {
         if ($value != "") {
             if (!array_key_exists($key, $FSSRoute_menus[$parts['Itemid']])) {
                 $ok = false;
                 break;
             }
             if ($FSSRoute_menus[$parts['Itemid']][$key] != $value) {
                 $ok = false;
                 break;
             }
         }
     }
     if ($ok) {
         return false;
     }
     /*print_p($aparams);
     		print_p($FSSRoute_menus[$parts['Itemid']]);*/
     return true;
 }
Exemplo n.º 2
0
 static function _($url, $xhtml = false, $ssl = null, $d = false)
 {
     // skip any external urls
     if (strpos($url, "option") !== false && strpos($url, "option=com_fss") === false) {
         return JRoute::_($url, $xhtml, $ssl);
     }
     global $FSSRoute_debug;
     global $FSSRoute_menus;
     global $FSSRoute_access;
     self::$d = $d;
     // get any menu items for fss
     FSS_Helper::GetRouteMenus();
     // Get the router
     $router = JFactory::getApplication()->getRouter();
     // if the url dont start with index.php, we need to add the exisitng url to what we want
     if (substr($url, 0, 9) != "index.php") {
         //echo "Making FUll URL: $url<br>";
         $url = self::_fullURL($router, $url);
         //echo "Resut : $url<br>";
     }
     $uri = new JURI($url);
     // work out is we are in an Itemid already, if so, set it as the best match
     if ($uri->hasVar('Itemid')) {
         $bestmatch = $uri->getVar('Itemid');
     } else {
         $bestmatch = '';
     }
     $bestcount = 0;
     $uriquery = $uri->toString(array('query'));
     $urivars = FSSRoute::SplitURL($uriquery);
     $sourcevars = FSSRoute::SplitURL($url);
     // check through the menu item for the current url, and add any items to the new url that are missing
     if ($bestmatch && array_key_exists($bestmatch, $FSSRoute_menus)) {
         foreach ($FSSRoute_menus[$bestmatch] as $key => $value) {
             if (!array_key_exists($key, $urivars) && !array_key_exists($key, $sourcevars)) {
                 $urivars[$key] = $value;
             }
         }
     }
     $current_access = 0;
     if (array_key_exists(FSS_Input::getInt('Itemid'), $FSSRoute_access)) {
         $current_access = $FSSRoute_access[FSS_Input::getInt('Itemid')];
     }
     if ($d) {
         echo "Incoming Link : {$url}<br>";
         echo "Cur Item ID : " . FSS_Input::getInt('Itemid') . "<br>";
         //print_p($FSSRoute_menus);
     }
     foreach ($FSSRoute_menus as $id => $vars) {
         if ($d) {
             echo "{$id} => <Br>";
             print_p($vars);
         }
         // need to check if the access level is the same
         if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
             if ($d) {
                 echo "No Access<br>";
             }
             continue;
         }
         $count = FSSRoute::MatchVars($urivars, $vars);
         if (FSS_Input::getInt('Itemid') == $id && $count > 0) {
             if ($d) {
                 echo "Current ItemId: increase count<br>";
             }
             $count++;
         }
         if ($d) {
             echo "Count: {$count}<br>";
         }
         if ($count > $bestcount) {
             if ($d) {
                 echo "New best match - {$id}<br>";
             }
             $bestcount = $count;
             $bestmatch = $id;
         }
     }
     if ($bestcount == 0 && array_key_exists('view', $sourcevars) && substr($sourcevars['view'], 0, 6) == "admin_") {
         foreach ($FSSRoute_menus as $id => $item) {
             // need to check if the access level is the same
             if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                 continue;
             }
             if ($item['view'] == "admin") {
                 $bestcount = 1;
                 $bestmatch = $id;
             }
         }
     }
     // no match found, try to fallback on the main support menu id
     if ($bestcount == 0) {
         foreach ($FSSRoute_menus as $id => $item) {
             // need to check if the access level is the same
             if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                 continue;
             }
             if ($item['view'] == "main") {
                 $bestcount = 1;
                 $bestmatch = $id;
             }
         }
     }
     if ($bestcount == 0) {
         // still no match found, use any fss menu
         if (count($FSSRoute_menus) > 0) {
             foreach ($FSSRoute_menus as $id => $item) {
                 // need to check if the access level is the same
                 if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                     continue;
                 }
                 $bestcount = 1;
                 $bestmatch = $id;
                 break;
             }
         }
     }
     if ($d) {
         echo "Best Found : {$bestcount}, {$bestmatch}<br>";
     }
     // sticky menu items
     if (FSS_Settings::get('sticky_menus_type')) {
         $cur_item_id = FSS_Input::GetInt("Itemid");
         if ($cur_item_id > 0) {
             $sticky_ids = explode(";", FSS_Settings::get('sticky_menus'));
             if (FSS_Settings::get('sticky_menus_type') == 1 && in_array($cur_item_id, $sticky_ids) || FSS_Settings::get('sticky_menus_type') == 2 && !in_array($cur_item_id, $sticky_ids)) {
                 $bestcount = 0;
                 $uri->setVar('Itemid', $cur_item_id);
             }
         }
     }
     if ($bestcount > 0) {
         $uri->setVar('Itemid', $bestmatch);
         // we need to remove parameters that are in the main url as well as the sub one
         // wait till 2.2 for this change as it may break stuff
     }
     if ($d) {
         echo "Using : " . $uri->toString(array('path', 'query', 'fragment')) . "<br>";
     }
     return JRoute::_($uri->toString(array('path', 'query', 'fragment')), $xhtml, $ssl);
 }