. * */ if (!defined('BASEPATH')) exit ('No direct script access allowed'); /** * Returns a variable width string of spaces. * Generated HTML indentation. It is more convenient to * generate clean indented HTML when you need to read it for analysis. * * @param unknown_type $nb */ function tab($nb) { $pattern = ' '; $res = ""; for ($i = 0; $i < $nb; $i++) { $res .= $pattern; } return $res; } /** * Generates a menu. Basically a menu is just a structured * list of anchors. This menu may have conditional sub items. The * goal is to support disabled or invisible entries according to the user * level of authorization. */ class Menu { protected $CI; /** * Constructor */ public function __construct ($attrs = array ()) { $this->CI = & get_instance(); } /** * Génération d'un menu en HTML * @param unknown_type $menu */ public function html ($menu, $level = 0, $li = false, $button_class = "") { $ul_attr = 'data-role="listview" data-divider-theme="b" data-inset="true"'; $li_attr = 'data-theme="c"'; $anchor_attr = 'data-transition="slide"'; $res = ""; // Si on est pas admin if (!$this->CI->dx_auth->is_admin()) { // Et qu'une autorisation est requise if (isset($menu['role']) && $menu['role']) { // Et qu'on ne l'a pas if (!$this->CI->dx_auth->is_logged_in()) { return $res; } if (!$this->CI->dx_auth->is_role($menu['role'], true, true)) { // Boum return $res; } } } $class = (isset($menu['class'])) ? 'class="' . $menu['class'] .'"' : ""; $href = (isset($menu['url'])) ? 'href="' . $menu['url'] .'"' : ''; $label = (isset($menu['label'])) ? $menu['label'] : ''; if ($li) $res .= "
  • "; if ($href || $label) $res .= "$label"; if (isset($menu['submenu'])) { // $res .= tab($level) . "