function renderMenu() { $menuItems = getMenuItems(); foreach ($menuItems as $menuItem) { if (isset($menuItem['condition']) && !$menuItem['condition']) { continue; } $selected = $menuItem['pageName'] === $_SESSION['currentPageName'] ? ' pure-menu-selected' : ''; echo '<li class="pure-menu-item' . $selected . '">' . '<a href="?p=' . $menuItem['pageName'] . '" class="pure-menu-link">' . $menuItem['caption'] . '</a></li>'; } }
function getMenuItems($f_arrItems, $f_iLevel = 1) { $szHtml = ''; foreach ($f_arrItems as $item) { if (!isset($GLOBALS['objItem']) || $GLOBALS['objItem']->id != $item->id) { $szHtml .= '<option value="' . $item->id . '"' . ((string) $GLOBALS['iParent'] === $item->id ? ' selected="1"' : '') . '>' . str_repeat('>> ', $f_iLevel) . $item->title . '</option>'; if (0 < count($c = $item->getMenuItems())) { $szHtml .= getMenuItems($c, $f_iLevel + 1); } } } return $szHtml; }
function get_recommended_items($url, $numberOfReviews) { $html_page = file_get_html($url); $all_reviews = extract_all_comments($html_page); $menu_url = getMenuURL($html_page); $menu_items = getMenuItems($menu_url); if ($menu_items !== false) { $menu_items_occurences; for ($i = 0; $i <= floor($numberOfReviews / 40); $i++) { $temp = $url . '?start=' . $i * 40; $html_page = file_get_html($temp); $all_reviews = extract_all_comments($html_page); $comments = strtolower(implode(' ', $all_reviews)); $index = 0; foreach ($menu_items as $menu_item) { $menu_item = strtolower($menu_item); $numberOfOccurences = substr_count($comments, $menu_item); if ($numberOfOccurences != 0 & strlen($menu_item) >= 4) { $menu_items_occurences[$menu_item] += $numberOfOccurences; } } } asort($menu_items_occurences); $recommended_items = '{'; if (!empty($menu_items_occurences) | !$menu_items_occurences) { $length = count($menu_items_occurences); $keys = array_keys($menu_items_occurences); $values = array_values($menu_items_occurences); if ($length >= 3) { $recommended_items .= '"' . $keys[$length - 1] . '": ' . $values[$length - 1] . ', "' . $keys[$length - 2] . '": ' . $values[$length - 2] . ', "' . $keys[$length - 3] . '": ' . $values[$length - 3] . '}'; } else { if ($length == 2) { $recommended_items .= '"' . $keys[$length - 1] . '": ' . $values[$length - 1] . ', "' . $keys[$length - 2] . '": ' . $values[$length - 2] . '}'; } else { $recommended_items .= '"' . $keys[$length - 1] . '": ' . $values[$length - 1] . '}'; } } } else { $recommended_items .= '}'; } } else { $typesOfFood = array('bacon', 'burrito', 'taco', 'burger', 'pizza', 'beef', 'chicken', 'pork', 'lamb', 'tuna', 'salmon', 'veggie', 'vegetarian', 'tofu'); $typesOfFood_occurences; for ($i = 0; $i <= floor($numberOfReviews / 40); $i++) { $temp = $url . '?start=' . $i * 40; $html_page = file_get_html($temp); $all_reviews = extract_all_comments($html_page); $comments = strtolower(implode(' ', $all_reviews)); $index = 0; foreach ($typesOfFood as $typeOfFood) { $numberOfOccurences = substr_count($comments, $typeOfFood); if ($numberOfOccurences != 0) { $typesOfFood_occurences[$typeOfFood] += $numberOfOccurences; } } } asort($typesOfFood_occurences); $recommended_items = '{'; if (!empty($typesOfFood_occurences)) { $length = count($typesOfFood_occurences); $keys = array_keys($typesOfFood_occurences); $values = array_values($typesOfFood_occurences); if ($length >= 3) { $recommended_items .= '"' . $keys[$length - 1] . '": ' . $values[$length - 1] . ', "' . $keys[$length - 2] . '": ' . $values[$length - 2] . ', "' . $keys[$length - 3] . '": ' . $values[$length - 3] . '}'; } else { if ($length == 2) { $recommended_items .= '"' . $keys[$length - 1] . '": ' . $values[$length - 1] . ', "' . $keys[$length - 2] . '": ' . $values[$length - 2] . '}'; } else { $recommended_items .= '"' . $keys[$length - 1] . '": ' . $values[$length - 1] . '}'; } } } else { $recommended_items .= '}'; } } echo $recommended_items; }
<div class="wrap"> <?php if ($msg != "") { ?> <div id="message" class="updated fade"><p><?php echo $msg; ?> </p></div><br /><?php } ?> <h2>Edit This Menu - <?php echo $menu->title; ?> </h2> <?php $menuitems = getMenuItems($_GET["id"]); include "menu.item.list.php"; ?> <div style="height: 10px;"></div> <form name="editcat" id="editcat" method="post" action="?page=mc-edit-menu&id=<?php echo $_GET["id"]; ?> " onsubmit="return validate(this)"> <input type="hidden" name="action" value="createmenuitem" /> <input type="hidden" name="id" value="<?php echo $_GET["id"]; ?> " /> <h2>Create New Menu Item</h2> <?php include "menu.item.table.php";
<br clear="all" /> <div class="subhead"> <label style="float: right"><?php echo gettext("Check All"); ?> <input type="checkbox" name="allbox" id="allbox" onclick="checkAll(this.form, 'ids[]', this.checked);" /> </label> </div> <ul class="page-list"> <?php if (isset($_GET['visible'])) { $visible = sanitize($_GET['visible']); } else { $visible = 'all'; } $items = getMenuItems($menuset, $visible); printItemsList($items); ?> </ul> </div> <br /> <span id="serializeOutput" /></span> <input name="update" type="hidden" value="Save Order" /> <p class="buttons"> <button class="serialize" type="submit" title="<?php echo gettext("Apply"); ?> "><img src="../../images/pass.png" alt="" /><strong><?php echo gettext("Apply"); ?> </strong></button>
/** * Prints a context sensitive menu of all pages as a unordered html list * * @param string $menuset the menu tree to output * @param string $option The mode for the menu: * "list" context sensitive toplevel plus sublevel pages, * "list-top" only top level pages, * "omit-top" only sub level pages * "list-sub" lists only the current pages direct offspring * @param string $css_id CSS id of the top level list * @param string $css_class_topactive class of the active item in the top level list * @param string $css_class CSS class of the sub level list(s) * @param string $css_class_active CSS class of the sub level list(s) * @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" (default) if you don't use it, it is not printed then. * @param int $showsubs Set to depth of sublevels that should be shown always. 0 by default. To show all, set to a true! Only valid if option=="list". * @param bool $counter TRUE (FALSE default) if you want the count of articles for Zenpage news categories or images/subalbums for albums. * @return string */ function printCustomMenu($menuset = 'default', $option = 'list', $css_id = '', $css_class_topactive = '', $css_class = '', $css_class_active = '', $showsubs = 0, $counter = false) { $itemcounter = ''; if ($css_id != "") { $css_id = " id='" . $css_id . "'"; } if ($showsubs === true) { $showsubs = 9999999999; } $sortorder = getCurrentMenuItem($menuset); $items = getMenuItems($menuset, getMenuVisibility()); if (count($items) == 0) { return; } // nothing to do $currentitem_parentid = @$items[$sortorder]['parentid']; if ($startlist = !($option == 'omit-top' || $option == 'list-sub')) { echo "<ul{$css_id}>"; } $pageid = @$items[$sortorder]['id']; $baseindent = max(1, count(explode("-", $sortorder))); $indent = 1; $open = array($indent => 0); $parents = array(NULL); $order = explode('-', $sortorder); $mylevel = count($order); $myparentsort = array_shift($order); for ($c = 0; $c <= $mylevel; $c++) { $parents[$c] = NULL; } foreach ($items as $item) { $itemarray = getItemTitleAndURL($item); $itemURL = $itemarray['url']; $itemtitle = $itemarray['title']; $level = max(1, count(explode('-', $item['sort_order']))); $process = $level <= $showsubs && $option == "list" || ($option == 'list' || $option == 'list-top') && $level == 1 || (($option == 'list' || $option == 'omit-top' && $level > 1) && ($item['id'] == $pageid || $item['parentid'] == $pageid || $level < $mylevel && $level > 1 && strpos($item['sort_order'], $myparentsort) === 0) || $level == $mylevel && $currentitem_parentid == $item['parentid']) || $option == 'list-sub' && $item['parentid'] == $pageid; if ($process && $itemarray['valid']) { if ($level > $indent) { echo "\n" . str_pad("\t", $indent, "\t") . "<ul class=\"{$css_class} menu_{$item['type']}\">\n"; $indent++; $parents[$indent] = NULL; $open[$indent] = 0; } else { if ($level < $indent) { $parents[$indent] = NULL; while ($indent > $level) { if ($open[$indent]) { $open[$indent]--; echo "</li>\n"; } $indent--; echo str_pad("\t", $indent, "\t") . "</ul>\n"; } } else { // level == indent, have not changed if ($open[$indent]) { // level = indent echo str_pad("\t", $indent, "\t") . "</li>\n"; $open[$indent]--; } else { echo "\n"; } } } if ($open[$indent]) { // close an open LI if it exists echo "</li>\n"; $open[$indent]--; } echo str_pad("\t", $indent - 1, "\t"); $open[$indent] += $item['include_li']; $parents[$indent] = $item['id']; if ($counter) { switch ($item['type']) { case 'album': $albumobj = newAlbum($item['link']); $numimages = $albumobj->getNumImages(); $numsubalbums = $albumobj->getNumAlbums(); $itemcounter = ' <span style="white-space:nowrap;"><small>('; if ($numsubalbums != 0) { $itemcounter .= sprintf(ngettext('%u album', '%u albums', $numsubalbums), $numsubalbums); } if ($numimages != 0) { if ($numsubalbums != 0) { $itemcounter .= ' '; } $itemcounter .= sprintf(ngettext('%u image', '%u images', $numimages), $numimages); } $itemcounter .= ')</small></span>'; break; case 'category': if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) { $published = "all"; } else { $published = "published"; } $catobj = newCategory($item['link']); $catcount = count($catobj->getArticles(0, $published)); $itemcounter = "<small> (" . $catcount . ")</small>"; break; } } if ($item['id'] == $pageid && !is_null($pageid)) { if ($level == 1) { // top level $class = $css_class_topactive; } else { $class = $css_class_active; } echo '<li class="menu_' . trim($item['type'] . ' ' . $class) . '">' . $itemtitle . $itemcounter; } else { if (strpos($sortorder, $item['sort_order']) === 0) { // we are in the heritage chain $class = ' ' . $css_class_active . '-' . ($mylevel - $level); } else { $class = ''; } if ($item['include_li']) { echo '<li class="menu_' . $item['type'] . $class . '">'; } if ($item['span_id'] || $item['span_class']) { echo '<span'; if ($item['span_id']) { echo ' id="' . $item['span_id'] . '"'; } if ($item['span_class']) { echo ' class="' . $item['span_class'] . '"'; } echo '>'; } switch ($item['type']) { case 'html': echo $item['link']; break; case 'menufunction': $i = strpos($itemURL, '('); if ($i) { if (function_exists(trim(substr($itemURL, 0, $i)))) { eval($itemURL); } } break; case 'menulabel': echo $itemtitle; break; default: if (empty($itemURL)) { $itemURL = FULLWEBPATH; } echo '<a href="' . $itemURL . '" title="' . html_encode(getBare($itemtitle)) . '">' . $itemtitle . '</a>' . $itemcounter; break; } if ($item['span_id'] || $item['span_class']) { echo '</span>'; } } } } // cleanup any hanging list elements while ($indent > 1) { if ($open[$indent]) { echo "</li>\n"; $open[$indent]--; } $indent--; echo str_pad("\t", $indent, "\t") . "</ul>"; } if ($open[$indent]) { echo "</li>\n"; $open[$indent]--; } else { echo "\n"; } if ($startlist) { echo "</ul>\n"; } }
function renderHTML(&$template) { if (isset($template->dbselect->table)) { if (!isset($template->dbselect->alias)) { $template->dbselect->alias = $template->dbselect->name; } $where = array(); foreach ($template->dbselect->where as $key => $val) { $val = getVar($val); $where[] = '`' . $key . '` = \'' . $val . '\''; } $db =& JFactory::getDBO(); $query = 'SELECT ' . '`' . $template->dbselect->name . '` as name, ' . '`' . $template->dbselect->alias . '` as alias' . ' FROM ' . $template->dbselect->table . ' WHERE ' . implode(' AND ', $where) . ' LIMIT 1'; $db->setQuery($query); $item = $db->loadObject(); } else { $item = new stdClass(); $item->name = JText::_($template->dbselect->name); if (!isset($template->dbselect->alias)) { $item->alias = $item->name; } else { $item->alias = $template->dbselect->alias; } } $item->alias = filterAlias($item->alias); $width = '100%'; $elements = array(); $elements[] = el('Title', '<input class="inputbox" type="text" name="name" style=width:' . $width . ';" maxlength="255" value="' . $item->name . '" />'); $elements[] = el('Alias', '<input class="inputbox" type="text" name="alias" style=width:' . $width . ';" maxlength="255" value="' . $item->alias . '" />'); $elements[] = el('Published', '<input type="radio" name="published" value="0" /> <label for="published0">' . JText::_('No') . '</label> <input type="radio" name="published" value="1" checked="checked" /> <label for="published1">' . JText::_('Yes') . '</label>'); $elements[] = el('Parent Item', getMenuItems('menuitem', $width)); if (isset($template->extras) && is_object($template->extras) && isset($template->extras->extra)) { if (!is_array($template->extras->extra)) { $template->extras->extra = array($template->extras->extra); } $extra_elements = array(); foreach ($template->extras->extra as $element) { if ($element->type == 'toggler') { if (isset($element->param)) { if (!isset($element->value)) { $element->value = ''; } $set_groups = explode('|', $element->param); $set_values = explode('|', $element->value); $ids = array(); foreach ($set_groups as $i => $group) { $count = $i; if ($count >= count($set_values)) { $count = 0; } $values = explode(',', $set_values[$count]); foreach ($values as $val) { $ids[] = $group . '.' . $val; } } $el = '</table><div id="' . rand(1000000, 9999999) . '___' . implode('___', $ids) . '" class="nntoggler nntoggler_horizontal" style="visibility: hidden;"><table width="100%" class="paramlist admintable" cellspacing="1">'; } else { $el = '</table></div><table width="100%" class="paramlist admintable" cellspacing="1">'; } $extra_elements[] = el('', $el); continue; } if (!isset($element->name) || !isset($element->type)) { continue; } if ($element->type == 'title') { $extra_elements[] = el('@spacer', JText::_($element->name)); continue; } if (!isset($element->param)) { continue; } if ($element->name == '') { $element->name = $element->param; } if ($element->param == '') { $element->param = strtolower($element->name); } if (!isset($element->value)) { $element->value = ''; } if (!isset($element->values)) { $element->values = new stdClass(); $element->values->value = $element->value; } if (!isset($element->default)) { $element->default = ''; } $style = ''; if (isset($element->style)) { $style = $element->style; } if ($element->type == 'radio' || $element->type == 'select') { $options = array(); if (!is_array($element->values->value)) { $element->values->value = array($element->values->value); } foreach ($element->values->value as $val) { $options[] = JHTML::_('select.option', $val->value, JText::_($val->name), 'value', 'text'); } } switch ($element->type) { case 'select': $el = JHTML::_('select.genericlist', $options, 'params[' . $element->param . ']', 'class="inputbox" style="' . $style . '"', 'value', 'text', $element->default, $element->param); break; case 'radio': $el = JHTML::_('select.radiolist', $options, 'params[' . $element->param . ']', 'class="inputbox" style="' . $style . '"', 'value', 'text', $element->default); // add breaks between each radio element $el = preg_replace('#(</label>)(\\s*<input )#i', '\\1<br />\\2', $el); break; case 'textarea': $el = '<textarea style="width:' . $width . ';height:100px;' . $style . '" name="params[' . $element->param . ']">' . $element->values->value . '</textarea>'; break; case 'hidden': $el = '<input type="hidden" style="' . $style . '" name="params[' . $element->param . ']" value="' . $element->values->value . '" />'; break; case 'text': default: $el = '<input type="text" name="params[' . $element->param . ']" style="width:' . $width . ';' . $style . '" value="' . $element->values->value . '" />'; break; } $extra_elements[] = el($element->name, $el); } if (!empty($extra_elements)) { $elements[] = el('@spacer', '<strong>' . JText::_('ATM_EXTRA_OPTIONS') . '</strong>'); $elements = array_merge($elements, $extra_elements); } } outputHTML($template, $elements); }
function displayRandomizedMenu($menuID, $numItems) { $items = getMenuItems($menuID); shuffle($items); $i = 0; $newitems = array(); foreach ($items as $item) { if ($i >= $numItems) { continue; } $newitems[] = $item; $i++; } displayMenuFromItems($newitems, 6, $menuID, true); }
/** * Displays all menu items. * * @param string $name Menu name * @return void */ public function displayItems($name) { if (!isset($this->menus[$name])) { return; } $items = getMenuItems($name); echo "<ul id='{$name}' class='ak-menu'>" . PHP_EOL; foreach ($items as $item) { echo " <li><a href='{$item['link']}'>{$item['title']}</a></li>" . PHP_EOL; } $menu .= "</ul>" . PHP_EOL; }
static function getAll($menu_name, $item_class = "", $parent = "ul", $child = "li", $child_wrapper = true) { $menus = Cache::get("menus", "page"); $return = NULL; if (!empty($menus[$menu_name])) { $menuarray = $menus[$menu_name]; if (!empty($menuarray)) { if (count($menuarray) > 1) { uasort($menuarray, function ($a, $b) { if ($a->weight == $b->weight) { return $a->name < $b->name ? -1 : 1; } return $a->weight < $b->weight ? -1 : 1; }); } foreach ($menuarray as $menuitemname => $menu) { $list_class = isset($menu->list_class) ? $menu->list_class : ""; $label = display("output/editor", array("value" => $menu->label)); if (isset($menu->title)) { $title = $menu->title; } else { $title = $menu->label; } if (isset($menu->page) && $menu->page == "#" || !isset($menu->page)) { $submenu = getMenuItems($menuitemname); $return .= "<{$child} class='dropdown {$item_class} {$list_class}'>"; $return .= "<a href='#' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false' title='{$title}'>" . $label . "</a>"; $return .= "<{$parent} class='dropdown-menu' role='menu'>"; $return .= $submenu; $return .= "</{$parent}>"; $return .= "</{$child}>"; } else { $link_class = isset($menu->link_class) && $menu->link_class ? $menu->link_class : NULL; $external = $menu->external; if (!$external) { $link = getSiteURL() . $menu->page; if (strpos($link, 'action') !== false) { $link = addTokenToURL($link); } } else { $link = $menu->page; } $active_class = $menuitemname == currentPage() || $menu->page == currentPage() ? "active" : NULL; if ($child_wrapper) { $return .= "<{$child} class='{$active_class} {$item_class} {$list_class}' title='{$title}'>"; } if ($menu->button_class) { $return .= "<form action='{$link}'>"; $return .= "<button class='{$menu->button_class}'>{$label}</button>"; $return .= "</form>"; } else { $return .= "<a class='{$link_class}' href='{$link}' title='{$title}' data-toggle='tooltip' data-placement='bottom'>{$label}</a>"; } if ($child_wrapper) { $return .= "</{$child}>"; } } } return $return; } } return NULL; }