public static function selectAppropriateMenu($is_in_game) { $menus = MenuDAO::selectAll(); $appropriateMenu = array(); foreach ($menus as $menu) { if ($menu->is_in_game == $is_in_game) { $appropriateMenu[] = $menu; } } return $appropriateMenu; }
public function montaMenuPrincipal() { $dao = new MenuDAO(); $resultado = $dao->getMenuPrincipal(); foreach ($resultado as $r) { $filhos = $dao->getFilhos($r['idmenu']); if (count($filhos) == 0) { $texto = $this->formataTexto($r['texto']); $target = is_null($r['target']) ? '' : ' target="_blank"'; echo "<li><a href='{$this->getBaseUrl()}{$r['endereco']}' {$target}><i class='icon fa {$r['icone']}'></i> {$texto} </a></li>"; } else { $texto = $this->formataTexto($r['texto']); echo "<li><span><i class='icon fa {$r['icone']}'></i>{$texto}</span><ul>"; foreach ($filhos as $f) { $texto = $this->formataTexto($f['texto']); $target = is_null($f['target']) ? '' : ' target="_blank"'; if ($this->podeInserir($f['endereco'])) { echo "<li><a href='{$this->getBaseUrl()}{$f['endereco']}' {$target}> {$texto} </a></li>"; } } echo "</ul></li>"; } } }
/** * statictics by years. * @return array year => revenues */ public function staticticsByYears() { $menuDao = new MenuDAO(); $years = $menuDao->getAllYearOnMenu(); $result = array(); for ($i = 0; $i < 12; $i++) { $fromMonth = date("Y-m-d H:i:s", mktime(0, 0, 0, $i, 1, $year)); $toMonth = date("Y-m-d H:i:s", mktime(0, 0, 0, $i + 1, 1, $year)); $foods = $this->staticticsFoodByTime($fromYear, $toYear); $revenues = 0; foreach ($foods as $food) { $revenues += $food["TongDoanhThu"]; } $result[$year] = $revenues; } return $result; }
if (isset($_SESSION["id"])) { $user = UtilisateurDAO::selectById(intval($_SESSION["id"])); //$planet = PlaneteDAO::selectPlaneteParId(...); //Language $langage = LangueDAO::selectById($user->id_language); //Est dans le jeu (pour le menu) $isInGame = true; } else { //Language $langage = LangueDAO::selectById($tabLangue[$_SESSION['language']]); //Est dans le jeu (pour le menu) $isInGame = false; } //Gestion des menus require_once NAME_DIRECTORY_CONTROLLERS . DIRECTORY_SEPARATOR . 'menu.php'; $listMenus = MenuDAO::selectAppropriateMenu($isInGame); $parse['navbar_menus'] = getMenu($listMenus); //------------------------------------------------------------------------------- } catch (Exception $ex) { echo $ex->getMessage(); } //Gestion des langues $langimg = ""; foreach ($langues as $value => $langue) { $bloc["code"] = $langue->code; $bloc["name"] = utf8_encode($langue->name); $bloc["theme"] = Page::getDirectoryTheme(); $bloc["value"] = $value; $langimg .= Page::construirePagePartielle("part_navbar_login_langue", $bloc); } $parse['dir_controllers'] = NAME_DIRECTORY_CONTROLLERS;
<?php /* IMPORTS */ require 'DTO/Menu/MenuDTO.php'; require 'DAO/Menu/MenuDAO.php'; /* RECEPCION DE DATOS */ $rol = $_SESSION["TypeUser"]; /* DEFINICION DE OBJETOS */ $obj = new MenuDTO($rol); $conex = new MenuDAO(); /* CONTROL DE ACCIONES */ $conex->LoadMenu($obj);