Files
inventario2/Menu.php
Ricardo Montañana c54f604b47 -Cambiado el alineamiento del fuente en varios archivos
-Cambiado el menú para poder elegir si se abre en la misma hoja en una diferente
-Mantenimiento ahora el contenido se centra en la página.
-El fichero pdf ahora se puede grabar en disco y se puede visualizar en una ventana nueva.
2014-02-14 00:18:47 +01:00

53 lines
2.0 KiB
PHP

<?php
/**
* @package Inventario
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* This file is part of Inventario.
* Inventario is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Inventario is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Inventario. If not, see <http://www.gnu.org/licenses/>.
*
*/
//
// Esta clase generará el menú de la aplicación.
class Menu {
private $opciones;
public function __construct($fichero)
{
$contenido=@file_get_contents($fichero) or
die("<h1>No puedo generar el menú. No puedo acceder al fichero $fichero</h1>");
// Obtenemos la lista de pares Opción|Enlace
$elementos=explode("\n", $contenido);
foreach($elementos as $elemento) {
list($tipo, $opcion, $enlace, $destino)=explode('|', $elemento);
// Los guardamos en la matriz de opciones
if ($tipo)
$this->opciones[]=$tipo.",".$opcion.",".$enlace.",".$destino;
}
}
public function insertaMenu()
{
$salida="";
reset($this->opciones);
foreach($this->opciones as $opcion) {
list($tipo,$opcion,$enlace,$destino)=explode(",",$opcion);
if ($tipo==2)
$salida.='<a href="'.$enlace.'" target="'.$destino.'">'.$opcion.'</a><br />';
else
$salida.='<label class="key">'.$opcion.'</label><br/>';
}
return $salida;
}
}
?>