MainMenu_index.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /*
  3. * Incluir en cada página para pintar el menú. Se necesita conexión de base de datos.
  4. * * @author Alejandro
  5. */
  6. class MainMenu {
  7. //put your code here
  8. private $xtpl, $menu, $pdo;
  9. /**
  10. * @param int $usr_id Id del usuario actual
  11. * @param int $menu_selected Id del menú seleccionado
  12. * @param PDO $this->pdo Conexión de base de datos
  13. */
  14. function __construct($titulo, $pdo, $menuArr){
  15. $this->titulo = trim($titulo);
  16. $this->menu = $menuArr;
  17. $this->pdo = $pdo;
  18. }
  19. private function creaMenu($id, $nombre){
  20. $this->xtpl->assign("MENU_ID", $id);
  21. $this->xtpl->assign("MENU_NOMBRE", $nombre);
  22. $this->xtpl->parse("main.sidebar.menus.menu.inactivo");
  23. $this->xtpl->parse("main.sidebar.menus.menu.collapsed");
  24. }
  25. public function printMenu(){
  26. require_once("./include/xTemplate/xtemplate.class.php");
  27. $this->xtpl = new XTemplate('./tpl/main_menu.tpl.html');
  28. //$this->xtpl->assign("LOGO_LINK", "main.php");
  29. $rutaLogo = "/img/logo_lasalle.png";
  30. //$rutaLogo = 'img/60_logo.svg'; //logo 60
  31. $this->xtpl->assign("LOGO_IMG", $rutaLogo);
  32. $stmt = $this->pdo->prepare('Select * from fs_sistema(null)');
  33. if(!$stmt->execute()){
  34. echo "Error al obtener sistemas";
  35. print_r($stmt->errorInfo());
  36. exit();
  37. }
  38. $sistemasArr = $stmt->fetchAll();
  39. $stmt->closeCursor();
  40. $stmt = null;
  41. //Menus superadmin
  42. /*
  43. foreach($sistemasArr as $sistema){
  44. $this->xtpl->assign("TEXTO", $sistema["Sistema_nombre"]);
  45. $this->xtpl->parse("main.sistemas.list.texto");
  46. }
  47. $this->xtpl->parse("main.sistemas.list");
  48. $this->xtpl->parse("main.sistemas");*/
  49. foreach($this->menu as $apsaOld){
  50. $this->xtpl->assign("MENU_LINK", $apsaOld["link"]);
  51. $this->xtpl->assign("MENU_NOMBRE", $apsaOld["nombre"]);
  52. $this->xtpl->parse("main.sidebar.menus.menu_link");
  53. }
  54. $this->xtpl->parse("main.sidebar.menus");
  55. $this->xtpl->parse("main.sidebar");
  56. $this->xtpl->parse("main.menu_index");
  57. if($this->titulo != "")
  58. $this->xtpl->assign("TITULO", $this->titulo);
  59. $this->xtpl->parse("main");
  60. $this->xtpl->out("main");
  61. }
  62. function printMenuFooter(){
  63. }
  64. /*
  65. * @return string Texto con el código HTML del menú
  66. */
  67. public function textMenu(){
  68. return $this->xtpl->text("main");
  69. }
  70. }