Exemplo n.º 1
0
 /**
  * @param string 	$siteName
  * @param string 	$ReturnType
  * @param string 	$maxRange
  * @param int 		$initRange
  * @param bool 		$byVariable // envie o nome da variavel quando for para pegar valor de variavel de navegação
  * @return array or string
  */
 static function getURI($siteName = "", $ReturnType = Navigation::URI_RETURN_TYPE_ARRAY, $maxRange = FALSE, $initRange = 0, $byVariable = NULL)
 {
     $siteName = str_replace(array("http://www", "http://", "//"), "", $siteName);
     //sa o ultimo caracter for /, tira
     $siteName = DataHandler::removeLastBar($siteName);
     $url = "";
     if ($byVariable) {
         //$url = Navigation::get($byVariable);
         $url = explode("/", Navigation::get($byVariable));
     } else {
         $url = $_SERVER["REQUEST_URI"];
         if ($url[0] == "/") {
             $url = substr($url, 1, strlen($url));
         }
         $url = explode("/", $url);
     }
     if (strpos($siteName, "/")) {
         //echo "tem barra";exit();
         $siteName = explode("/", $siteName);
     }
     //tirando o nome do site só do início
     if (is_array($siteName)) {
         for ($i = 0; $i < count($siteName); $i++) {
             if ($url[$i] == $siteName[$i]) {
                 $url[$i] = "";
             }
         }
     } else {
         $url[0] = str_replace("{$siteName}", "", $url[0]);
     }
     $url = implode("/", $url);
     //$url = str_replace("$siteName", "", $_SERVER["REQUEST_URI"]);
     $url = str_replace("//", "/", $url);
     //transforma a url em array
     $url = preg_replace("/(^\\/)/", '', $url);
     $tempArray = explode("/", $url);
     if ($initRange > 0 || $maxRange !== FALSE) {
         $tempTotal = 0;
         if ($maxRange !== FALSE) {
             //echo Debug::li("maxRange $maxRange : initRange $initRange");
             $tempTotal = $maxRange;
         } else {
             $tempTotal = count($tempArray);
         }
         $tempTotal = $tempTotal + 1;
         if ($tempTotal > count($tempArray)) {
             $tempTotal = count($tempArray);
         }
         $tempArray = array_slice($tempArray, $initRange, $tempTotal);
     }
     //filtra a array conforme as regras
     $tempArrayFiltrada = array();
     for ($i = 0; $i < count($tempArray); $i++) {
         if ($tempArray[$i] != "") {
             $tempArrayFiltrada[] = $tempArray[$i];
         }
     }
     unset($tempArray);
     switch ($ReturnType) {
         case Navigation::URI_RETURN_TYPE_STRING:
             $url = implode("/", $tempArrayFiltrada);
             return $url;
             break;
         case Navigation::URI_RETURN_TYPE_ARRAY:
         default:
             return $tempArrayFiltrada;
             break;
     }
     return $url;
 }
Exemplo n.º 2
0
 /**
  * Return current page.
  *
  * @return Navigation_Page
  */
 public static function get_current_page()
 {
     if (Navigation::$current === null) {
         Navigation::get();
     }
     return Navigation::$current;
 }
Exemplo n.º 3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $items = Navigation::get()->all();
     $categorys = NavigationCategory::get()->all();
     return View::make('navigation.index', compact('items', 'categorys'));
 }