Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/06/2016, 22:00
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Camino de hipervínculos en Php

Hola a todos, quería hacerles una consulta, estoy con mis compañeros haciendo un sistema para AMRUS S.A (Bueno Servicios Aereos) y con mis compañeros queremos hacer un sistema accesible para la empresa, entre eso esta esto de los hipervínculos, la idea es esto:

Aplicaciones > Crear Aplicacion

pero sólo me toma el primero y ahi es dónde no sé que hacer para que tome los próximos seleccionados, pongo el código:

Controller.php

Código PHP:
Ver original
  1. <?php
  2. namespace App;
  3. use \Lib\Paginador;
  4. include('./Lib/fpdf/FPDF.php');
  5. abstract class Controller
  6. {
  7.     private $enlaces;
  8.     private $paginador;
  9.     private $pdf;
  10.     function __construct() {
  11.         session_start();
  12.         $this->enlaces = [];
  13.         $this->paginador = new Paginador();
  14.         $this->pdf = new \FPDF();
  15.     }
  16.     public function redirect_administrador($file = array(), $dates = array()) {
  17.         try {
  18.             $this->checkEnlace();
  19.             $ns = explode('\\', get_called_class());
  20.             $path = $this->createFile(APPLICATION_PATH . DS . "View" . DS . str_replace("Controller", "", $ns[1]) . DS . $file[0], $dates);
  21.             $menu = $this->createFile(APPLICATION_PATH . DS . 'Public' . DS . 'manejo_menu.php');
  22.             echo $this->createFile(APPLICATION_PATH . DS . 'Public' . DS . 'manejo.php', array('content' => $path, 'menu' => $menu, 'enlaces' => $this->getEnlaces()));
  23.         }
  24.         catch (Exception $ex) {
  25.             echo $ex->getMessage();
  26.         }
  27.     }
  28.     public function redirect_todos($file = array(), $dates = array()) {        
  29.         try {
  30.             $ns = explode('\\', get_called_class());
  31.             $path = $this->createFile(APPLICATION_PATH . DS . "View" . DS . str_replace("Controller", "", $ns[1]) . DS . $file[0], $dates);
  32.             echo $this->createFile(APPLICATION_PATH . DS . 'Public' . DS . 'principal.php', array('content' => $path));
  33.         }
  34.         catch (Exception $ex) {
  35.             echo $ex->getMessage();
  36.         }
  37.     }
  38.     private function createFile($file, $dates = array()) {
  39.         try {
  40.             extract($dates);
  41.             ob_start();
  42.             require $file;
  43.             return ob_get_clean();
  44.         }
  45.         catch (Exception $ex) {
  46.             echo $ex->getMessage();
  47.         }
  48.     }
  49.     protected function getPaginator() {
  50.         return $this->paginador;
  51.     }
  52.     protected function getPdf() {
  53.         return $this->pdf;
  54.     }    
  55.     protected function checkUser() {                
  56.         if (Session::get("log_in") != null and Session::get("log_in")->getRol()->getNombre() == $this->getTypeRole()) {
  57.             return true;
  58.         } else {
  59.             Session::set("msg", "Debe loguearse como " . $this->getMessageRole() . " para acceder.");
  60.             header("Location:index.php?c=todos&a=index");
  61.         }
  62.     }    
  63.     protected function getTypeRole() {
  64.         $opciones = $this->getRoles();
  65.         foreach($opciones as $opcion){
  66.             if(Session::get("log_in")->getRol()->getNombre() == $opcion){
  67.                 return $opcion;
  68.             }
  69.         }
  70.         return null;
  71.     }
  72.     protected function clean($cadena){
  73.         return htmlentities($cadena);
  74.     }
  75.     /*----------para el tema de los enlaces----------*/
  76.     protected function checkEnlace(){
  77.         $this->enlaces[$this->generateTitle()] = $_SERVER['REQUEST_URI'];        
  78.     }
  79.     protected function getEnlaces(){
  80.         return $this->enlaces;
  81.     }
  82.     private function generateTitleAction(){
  83.         $d = explode("=", $_SERVER['REQUEST_URI']);
  84.         $d1 = explode("&", $d[2]);
  85.         return $d1[0];
  86.     }
  87.     private function generateTitleEntity(){
  88.         $d = explode("=", $_SERVER['REQUEST_URI']);        
  89.         $d1 = explode("&", $d[1]);
  90.         return $d1[0];
  91.     }
  92.     private function generateTitle(){
  93.         $array = [$this->generateTitleAction(), $this->generateTitleEntity()];
  94.         if($array[0] == "index"){
  95.             return $this->removeRare($array[1]);
  96.         } else if($array[0] == "add"){
  97.             return "Crear ".$this->removePlural($array[1]);
  98.         } else if($array[0] == "edit"){
  99.             return "Editar ".$this->removePlural($array[1]);
  100.         } else if($array[0] == "view"){
  101.             return "Ver ".$this->removePlural($array[1]);    
  102.         } else {
  103.             return $array[0]." ".$array[1];
  104.         }        
  105.     }
  106.     private function removePlural($palabra){
  107.         $cambio = "";
  108.         if($this->endsWith($palabra, "bles")){
  109.             $cambio = rtrim($palabra, "s");
  110.         } else if($this->endsWith($palabra, "es")){
  111.             $cambio = rtrim($palabra, "es");
  112.         } else if($this->endsWith($palabra, "s")){
  113.             $cambio = rtrim($palabra, "s");
  114.         } else if($this->endsWith($palabra, "p")){
  115.             $cambio = rtrim($palabra, "p");
  116.         } else if($this->endsWith($palabra, "v")){
  117.             $cambio = rtrim($palabra, "v");
  118.         } else {
  119.             $cambio = $palabra;
  120.         }
  121.         return ucwords($cambio);
  122.     }
  123.     private function removeRare($palabra){
  124.         $cambio = "";
  125.         if($this->endsWith($palabra, "p")){
  126.             $cambio = rtrim($palabra, "p")."s";
  127.         } else if($this->endsWith($palabra, "v")){
  128.             $cambio = rtrim($palabra, "v")."s";
  129.         } else {
  130.             $cambio = $palabra;
  131.         }
  132.         return ucwords($cambio);
  133.     }
  134.     function startsWith($haystack, $needle) {
  135.         // search backwards starting from haystack length characters from the end
  136.         return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
  137.     }
  138.     function endsWith($haystack, $needle) {
  139.         // search forward starting from end minus needle length characters
  140.         return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false);
  141.     }
  142.     protected function getMessageRole() { }
  143.     protected function getRoles(){}
  144. }

manejo.php

Código PHP:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.     <head>
  4.        <title>Buenos Servicios</title>
  5.   </head>
  6.     <body>
  7.         <?php echo $menu; ?>
  8.         <section id="main-content">
  9.             <section class="wrapper">
  10.                 <br />
  11.                 <?php
  12.                     end($enlaces);
  13.                     $last = key($enlaces);
  14.                     foreach ($enlaces as $key => $value) {
  15.                         if($key != $last){ ?>
  16.                             <a href="<?php echo $enlaces[$key]; ?>">
  17.                                 <?php echo $key; ?>
  18.                             </a>
  19.                             &nbsp;<b>></b>&nbsp;
  20.                     <?php                        
  21.                         } else { ?>
  22.                             <a href="<?php echo $enlaces[$key]; ?>">
  23.                                 <?php echo $key; ?>
  24.                             </a>
  25.                     <?php        
  26.                         }
  27.                     ?>
  28.                 <?php } ?>
  29.                 <br />
  30.                 <?php
  31.                     if (\App\Session::get('msg')!=null) {  
  32.                         echo \App\Session::get('msg')."<br /><br />";
  33.                         \App\Session::set('msg', "");                    
  34.                     }
  35.                     echo $content;        
  36.                 ?>
  37.             </section>            
  38.         </section>
  39.     </body>
  40. </html>

Espero sus respuestas y saludos.