Foros del Web » Programando para Internet » PHP »

Camino de hipervínculos en Php

Estas en el tema de Camino de hipervínculos en Php en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 18/06/2016, 22:00
Avatar de 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.
  #2 (permalink)  
Antiguo 19/06/2016, 20:18
Avatar de detective_jd  
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Respuesta: Camino de hipervínculos en Php

Hola a todos, verán estuvimos mirando en internet y vimos que la funcionalidad se llama Migas de Pan, sobre eso encontramos este código:

Controller.php

Código PHP:
Ver original
  1. function breadcrumbs($separator = ' &raquo; ', $home = 'Inicio') {
  2. $path = array_filter(explode('=', $_SERVER['REQUEST_URI']));
  3. $c= explode("&", $path[1])[0];
  4. $a =$path[2];
  5. $base = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://localhost/BuenoSoftMVC/index.php?c=access&a=index';
  6. $breadcrumbs = [];
  7. array_push($breadcrumbs, "<a href=".$base.">".$home."</a>");
  8. $last = end(array_keys($path));
  9. foreach ($path AS $x => $crumb) {
  10. $title = ucwords(str_replace(Array('.php', '_'), Array('', ' '), $crumb));
  11. if ($x != $last) {
  12. $href="?c=".$c."&a=".$a;
  13. array_push($breadcrumbs, "<a href=".$href.">".$c."</a>");
  14. } else {
  15. array_push($breadcrumbs, $title);
  16. }
  17. }
  18. return implode($separator, array_unique($breadcrumbs));
  19. }

manejo.php

Código PHP:
Ver original
  1. <?php echo $menu; ?>
  2. <section id="main-content">
  3. <section class="wrapper">
  4. <br />
  5. <?php
  6. echo $enlaces;
  7. ?>
  8. <br />
  9. <?php
  10. if (\App\Session::get('msg')!=null) {
  11. echo \App\Session::get('msg')."<br /><br />";
  12. \App\Session::set('msg', "");
  13. }
  14. echo $content;
  15. ?>
  16. </section>

Pero en dónde me dice aplicaciones me da la ruta del agregar y no del listado, por favor este es un buen y gran proyecto.

Espero su respuesta y saludos.
  #3 (permalink)  
Antiguo 20/06/2016, 09:01
Avatar de haggenx  
Fecha de Ingreso: febrero-2007
Ubicación: México
Mensajes: 823
Antigüedad: 17 años, 2 meses
Puntos: 24
Respuesta: Camino de hipervínculos en Php

¿Pero que necesitas, que te genere el rastro basandote en el URL, o que ponga los títulos de cada web por la que paso?

Ejemplo:
Código:
http://www.miweb.com/servicios/pagina.php  Home > servicios
http://www.miweb.com/servicios/pagina.php  Home > Servicios ofrecidos
__________________
Mi blog informático http://marjuanm.blogspot.mx
Fanpage del blog https://www.facebook.com/pages/Mis-p...36397183215592
  #4 (permalink)  
Antiguo 25/08/2016, 23:22
Avatar de detective_jd  
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Respuesta: Camino de hipervínculos en Php

Hola, gracias por responder en realidad que ponga los títulos de cada web por la que paso, cómo me sugieres que haga las migas de pan??

Saludos.
  #5 (permalink)  
Antiguo 01/02/2017, 19:34
Avatar de detective_jd  
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Respuesta: Camino de hipervínculos en Php

Al final quedó resuelto. Saludos

Etiquetas: html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:31.