public function setAttributes() { $hrefWithoutBeginning = str_replace(BEGINNING_OF_URL, '', MenuElement::makeUrlOfCurrentPage(array('ampersand' => '%26'))); $urlParts = explode('?', $hrefWithoutBeginning); if (strstr($urlParts[0], '/')) { $aliasWithoutSlash = explode('/', $urlParts[0]); $alias = $aliasWithoutSlash[0]; } else { $alias = $urlParts[0]; } $thisAlias = $alias; $this->href = strtr($this->translate(array('property' => 'href', 'isSlug' => true)), '&', '&'); $hrefWithoutBeginning = str_replace(BEGINNING_OF_URL, '', $this->href); $urlParts = explode('?', $hrefWithoutBeginning); if (strstr($urlParts[0], '/')) { $aliasWithoutSlash = explode('/', $urlParts[0]); $alias = $aliasWithoutSlash[0]; } else { $alias = $urlParts[0]; } if ($alias === $thisAlias) { $this->active = TRUE; } if (strpos($this->href, '[ID-OF-USER]') !== FALSE) { if (isset($_SESSION['idUser'])) { $this->href = str_replace('[ID-OF-USER]', '&idHuman=' . $_SESSION['idUser'], $this->href); } else { $this->href = str_replace('[ID-OF-USER]', '&idHuman=', $this->href); } } }
/** * This function builds a menu. * * @access public * @author kalmer:piiskop<*****@*****.**> * @param int $parameters['type'] * the type of the menu * @return string the menu * @uses ROOT_FOLDER for getting the correct PHP-file */ public static function buildMenu($parameters) { require_once ROOT_FOLDER . '/MenuElement.php'; $menuElements = MenuElement::getListOfTypeMenuElement(array('forAutocompletion' => false, 'type' => $parameters['type'])); $menu = ''; foreach ($menuElements as $idMenuElement => $menuElement) { require_once ROOT_FOLDER . '/MenuElementView.php'; $menu .= MenuElementView::buildMenuElement(array('menuElement' => $menuElement['object'], 'type' => $parameters['type'])); } return $menu; }
/** * This function queries all the menu elements and returns them in an * autocomplete * array if needed. * * @access public * @param boolean $parameters['forAutocompletion'] * Do we prepare the array * for the autocompletion mechanism? * @param integer $parameters['idOfParent'] * the ID of the page the * list of page news we want * @return int[] <code>NULL</code>, if there are no order person available * or * the query is erroneous or the array with keys */ public static function getListOfTypeMenuElement($parameters) { $structuredKeys = array(); foreach (MenuElement::$rawMenuElements as $idMenuElement => $menuElement) { $object = new MenuElement(); //new MenuElement $object->id = $idMenuElement; //object id = idMenuElement $object->setCompleteMenuElement(); //and setCompleteMenuElement $keys[] = $idMenuElement; $title = $menuElement['label']; $structuredKeys[$idMenuElement] = array('id' => $idMenuElement, 'object' => $object, 'title' => $title); $values[] = $title; } if (isset($parameters['forAutocompletion']) && $parameters['forAutocompletion']) { $a[] = $values; $a[] = $keys; return $a; } else { return $structuredKeys; } }
/** * This function queries all the menu elements and returns them in an * autocomplete * array if needed. * * @access public * @return int[] <code>NULL</code>, if there are no order person available * or * the query is erroneous or the array with keys */ public static function getListOfTypeMenuElement($parameters) { if (isset($parameters['type'])) { $structuredKeys = array(); $values = array(); $keys = array(); foreach (MenuElement::$rawMenuElements as $id => $array) { $object = new MenuElement(); if ($array['type'] === $parameters['type']) { $object->setId($id); $object->setCompleteMenuElement(); $keys[] = $id; $title = $array['label']; $structuredKeys[$id] = array('id' => $id, 'object' => $object, 'title' => $title); $values[] = $title; } } if (isset($parameters['forAutocompletion']) && $parameters['forAutocompletion']) { $a[] = $values; $a[] = $keys; return $a; } else { return $structuredKeys; } } else { exit('Milline menüü?'); } }