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<?php
namespace App;
use \Lib\Paginador;
include('./Lib/fpdf/FPDF.php');
abstract class Controller
{
private $enlaces;
private $paginador;
private $pdf;
function __construct() {
$this->enlaces = [];
$this->paginador = new Paginador();
$this->pdf = new \FPDF();
}
public function redirect_administrador
($file = array(), $dates = array()) { try {
$this->checkEnlace();
$ns = explode('\\', get_called_class
()); $path = $this->createFile(APPLICATION_PATH
. DS
. "View" . DS
. str_replace("Controller", "", $ns[1]) . DS
. $file[0], $dates); $menu = $this->createFile(APPLICATION_PATH . DS . 'Public' . DS . 'manejo_menu.php');
echo $this->createFile(APPLICATION_PATH
. DS
. 'Public' . DS
. 'manejo.php', array('content' => $path, 'menu' => $menu, 'enlaces' => $this->getEnlaces())); }
catch (Exception $ex) {
echo $ex->getMessage();
}
}
public function redirect_todos
($file = array(), $dates = array()) { try {
$ns = explode('\\', get_called_class
()); $path = $this->createFile(APPLICATION_PATH
. DS
. "View" . DS
. str_replace("Controller", "", $ns[1]) . DS
. $file[0], $dates); echo $this->createFile(APPLICATION_PATH
. DS
. 'Public' . DS
. 'principal.php', array('content' => $path)); }
catch (Exception $ex) {
echo $ex->getMessage();
}
}
private function createFile
($file, $dates = array()) { try {
require $file;
}
catch (Exception $ex) {
echo $ex->getMessage();
}
}
protected function getPaginator() {
return $this->paginador;
}
protected function getPdf() {
return $this->pdf;
}
protected function checkUser() {
if (Session::get("log_in") != null and Session::get("log_in")->getRol()->getNombre() == $this->getTypeRole()) {
return true;
} else {
Session::set("msg", "Debe loguearse como " . $this->getMessageRole() . " para acceder.");
header("Location:index.php?c=todos&a=index"); }
}
protected function getTypeRole() {
$opciones = $this->getRoles();
foreach($opciones as $opcion){
if(Session::get("log_in")->getRol()->getNombre() == $opcion){
return $opcion;
}
}
return null;
}
protected function clean($cadena){
}
/*----------para el tema de los enlaces----------*/
protected function checkEnlace(){
$this->enlaces[$this->generateTitle()] = $_SERVER['REQUEST_URI'];
}
protected function getEnlaces(){
return $this->enlaces;
}
private function generateTitleAction(){
$d = explode("=", $_SERVER['REQUEST_URI']); return $d1[0];
}
private function generateTitleEntity(){
$d = explode("=", $_SERVER['REQUEST_URI']); return $d1[0];
}
private function generateTitle(){
$array = [$this->generateTitleAction(), $this->generateTitleEntity()];
if($array[0] == "index"){
return $this->removeRare($array[1]);
} else if($array[0] == "add"){
return "Crear ".$this->removePlural($array[1]);
} else if($array[0] == "edit"){
return "Editar ".$this->removePlural($array[1]);
} else if($array[0] == "view"){
return "Ver ".$this->removePlural($array[1]);
} else {
return $array[0]." ".$array[1];
}
}
private function removePlural($palabra){
$cambio = "";
if($this->endsWith($palabra, "bles")){
$cambio = rtrim($palabra, "s"); } else if($this->endsWith($palabra, "es")){
$cambio = rtrim($palabra, "es"); } else if($this->endsWith($palabra, "s")){
$cambio = rtrim($palabra, "s"); } else if($this->endsWith($palabra, "p")){
$cambio = rtrim($palabra, "p"); } else if($this->endsWith($palabra, "v")){
$cambio = rtrim($palabra, "v"); } else {
$cambio = $palabra;
}
}
private function removeRare($palabra){
$cambio = "";
if($this->endsWith($palabra, "p")){
$cambio = rtrim($palabra, "p")."s"; } else if($this->endsWith($palabra, "v")){
$cambio = rtrim($palabra, "v")."s"; } else {
$cambio = $palabra;
}
}
function startsWith($haystack, $needle) {
// search backwards starting from haystack length characters from the end
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; }
function endsWith($haystack, $needle) {
// search forward starting from end minus needle length characters
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false); }
protected function getMessageRole() { }
protected function getRoles(){}
}
manejo.php
Código PHP:
Ver original<!DOCTYPE html>
<html lang="en">
<head>
<title>Buenos Servicios</title>
</head>
<body>
<?php echo $menu; ?>
<section id="main-content">
<section class="wrapper">
<br />
<?php
foreach ($enlaces as $key => $value) {
if($key != $last){ ?>
<a href="<?php echo $enlaces[$key]; ?>">
<?php echo $key; ?>
</a>
<b>></b>
<?php
} else { ?>
<a href="<?php echo $enlaces[$key]; ?>">
<?php echo $key; ?>
</a>
<?php
}
?>
<?php } ?>
<br />
<?php
if (\App\Session::get('msg')!=null) {
echo \App\Session::get('msg')."<br /><br />";
\App\Session::set('msg', "");
}
echo $content;
?>
</section>
</section>
</body>
</html>
Espero sus respuestas y saludos.