/** * Retourne le tableau des profiles autorisés pour la page en cours. * * @access public * @param string path optionnel, le nom de la page en cours sans l'extension * @return array of integer */ public function getProfileArrayForPage($path = false) { if (!$path) { $path = UrlTools::getPageNameFromURL(); } $nav = Navigation::singleton(); $nav->authFunction = array(Auth::singleton(), 'checkProfiles'); $nav->useCookie = true; $profiles = $nav->getProfileArrayForActivePage($path); return $profiles; }
/** * Parse the metadata and build the corresponding html code for each * navigation level. * * @access protected * @param array $metadata * @return void */ protected function parseMetadata($metadata = false, $indexStack = array()) { static $level = 1; if (isset($this->_html[$level])) { return; } $this->hasActiveItem[$level] = false; $children = false; if (!$this->renderer) { $this->renderer = new NavigationRendererDefault(); } if (!$metadata) { $metadata = $this->metadata; } $ret[] = $this->renderer->open($level); // Trade context $tradeContext = Preferences::get('TradeContext'); foreach ($metadata as $index => $data) { // formatte le tableau de l'élément avec les paramètres par défaut // et met son état à actif ou inactif if (isset($data['restrict_to']) && !call_user_func($this->authFunction, $data['restrict_to'], array('showErrorDialog' => false, 'redirect' => false))) { continue; } $this->handleData($data, $level, $index, $indexStack); if (isset($data['restrict_to'])) { $pn = UrlTools::getPageNameFromURL($data['link']); $this->authorizedProfiles[$pn] = $data['restrict_to']; } if (is_null($tradeContext) && isset($data['restrict_to_context']) || isset($data['restrict_to_context']) && array_intersect($data['restrict_to_context'], $tradeContext) == array()) { continue; } $id = implode('_', $indexStack); $id .= empty($id) ? $index : '_' . $index; $ret[] = $this->renderer->render($level, $index, $data, $this->useCookie, $id); if ($data['active'] && isset($data['children'])) { $stack = $indexStack; $stack[] = $index; $children = $data['children']; } else { if ($data['active']) { $this->activeTitle = $data['description']; } } } $ret[] = $this->renderer->close($level); $this->_html[$level] = implode("\n", $ret); if ($children) { $level++; $this->parseMetadata($children, $stack); } }