本文整理汇总了PHP中MenuItem类的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem类的具体用法?PHP MenuItem怎么用?PHP MenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPostDetailMenuItems
public function getPostDetailMenuItems($post) {
$template_path = Utils::getPluginViewDirectory('hellothinkup').'hellothinkup.inline.view.tpl';
$menu_items = array();
//Define a menu item
$hello_menu_item_1 = new MenuItem("Data vis 1", "First data visualization", $template_path,
'Hello ThinkUp Plugin Menu Header');
//Define a dataset to be displayed when that menu item is selected
$hello_menu_item_dataset_1 = new Dataset("replies_1", 'PostDAO', "getRepliesToPost",
array($post->post_id, $post->network, 'location') );
//Associate dataset with menu item
$hello_menu_item_1->addDataset($hello_menu_item_dataset_1);
//Add menu item to menu items array
$menu_items['data_vis_1'] = $hello_menu_item_1;
//Define a menu item
$hello_menu_item_2 = new MenuItem("Data vis 2", "Second data visualization", $template_path);
//Define a dataset to be displayed when that menu item is selected
$hello_menu_item_dataset_2 = new Dataset("replies_2", 'PostDAO', "getRepliesToPost",
array($post->post_id, $post->network, 'location') );
//Associate dataset with menu item
$hello_menu_item_2->addDataset($hello_menu_item_dataset_2);
//Add menu item to menu items array
$menu_items['data_vis_2'] = $hello_menu_item_2;
return $menu_items;
}
示例2: getPostDetailMenuItems
public function getPostDetailMenuItems($post) {
$menus = array();
$map_template_path = Utils::getPluginViewDirectory('geoencoder').'geoencoder.map.tpl';
//Define a menu item
$map_menu_item = new MenuItem("Response Map", "", $map_template_path, 'Geoencoder');
//Define a dataset to be displayed when that menu item is selected
$map_menu_item_dataset_1 = new Dataset("geoencoder_map", 'PostDAO', "getRelatedPosts",
array($post->post_id, $post->network, 'location') );
//Associate dataset with menu item
$map_menu_item->addDataset($map_menu_item_dataset_1);
//Add menu item to menu
$menus["geoencoder_map"] = $map_menu_item;
$nearest_template_path = Utils::getPluginViewDirectory('geoencoder').'geoencoder.nearest.tpl';
//Define a menu item
$nearest_menu_item = new MenuItem("Nearest Responses", "", $nearest_template_path);
//Define a dataset to be displayed when that menu item is selected
$nearest_dataset = new Dataset("geoencoder_nearest", 'PostDAO', "getRelatedPosts",
array($post->post_id, $post->network, !Session::isLoggedIn()));
//Associate dataset with menu item
$nearest_menu_item->addDataset($nearest_dataset);
$nearest_dataset_2 = new Dataset("geoencoder_options", 'PluginOptionDAO', 'getOptionsHash',
array('geoencoder', true));
$nearest_menu_item->addDataset($nearest_dataset_2);
//Add menu item to menu
$menus["geoencoder_nearest"] = $nearest_menu_item;
return $menus;
}
示例3: write_child
function write_child()
{
$all_childs = $this->data["childs"];
$child = new MenuItem($this->menu_layout_dir, $all_childs[$this->current_index], $this->level + 1);
$this->current_index += 1;
$child->render();
}
示例4: __construct
function __construct()
{
//-----vytvorenie objektu menu
$menu = new MenuItem();
$menu->menuAction();
//-----vytvorenie objektu node
$node = new node();
$node->nodeAction();
MT::addContent($menu->render(), 'leftHolder');
try {
if (isset($_GET['id_menu_item']) or isset($_GET['addMenuItem']) or isset($_GET['changeMenuItem'])) {
MT::addTemplate(APP_DIR . '/templates/admin/modulHolder.phtml', 'modulHolder');
MT::addVar('modulHolder', 'type_modul', dibi::fetchAll("SELECT * FROM [type_modul] WHERE visible_for_user='1'"));
}
//zobrazenie zmeny polozky pre menu
if (isset($_GET['changeMenuItem'])) {
$menu->showChangeMenuItem($_GET['id_menu_item']);
}
if (isset($_GET['id_menu_item']) and !isset($_GET['changeMenuItem'])) {
$node->showModul();
}
//pridanie polozky do menu
if (isset($_GET['addMenuItem'])) {
$menu->showAddMenuItem();
}
//zachytenie vynimie
} catch (NodeException $e) {
echo '<div style="border: 2px solid red; padding: 5px;">' . $e->getMessage() . '</div>';
exit;
}
}
示例5: __construct
function __construct($page_object, $array_menu)
{
parent::__construct();
$this->render = new Menu();
$wsp_admin_url = WSP_ADMIN_URL;
$menu_items = new MenuItems();
foreach ($array_menu['MenuItems']['MenuItem'] as $menuitems) {
eval("\$page_icon_16 = \"" . $menuitems['Menu_attr']['icon_16'] . "\";");
if (find($menuitems['Menu_attr']['name'], "__(", 0, 0) > 0) {
eval("\$page_title = " . $menuitems['Menu_attr']['name'] . ";");
} else {
eval("\$page_title = \"" . $menuitems['Menu_attr']['name'] . "\";");
}
eval("\$page_link = \"" . $menuitems['Menu_attr']['url'] . "\";");
if ($menuitems['Menu_attr']['url'] == "\$wsp_admin_url/admin.html") {
$page_title = "";
}
$menu_item = new MenuItem($page_title, $page_link, $page_icon_16);
if (isset($_GET['menu'])) {
if ($page_link == $wsp_admin_url . "/admin.html?menu=" . $_GET['menu']) {
$menu_item->setCurrent();
}
}
$menu_items->add($menu_item);
$sub_menu_items = new MenuItems();
if (!isset($menuitems['MenuItems']['MenuItem'][0])) {
$sub_menuitems = $menuitems['MenuItems'];
} else {
$sub_menuitems = $menuitems['MenuItems']['MenuItem'];
}
$nb_sub_menu = 0;
foreach ($sub_menuitems as $menuitem) {
eval("\$page_icon_16 = \"" . $menuitem['Menu_attr']['icon_16'] . "\";");
if (find($menuitem['Menu_attr']['name'], "__(", 0, 0) > 0) {
eval("\$page_title = " . $menuitem['Menu_attr']['name'] . ";");
} else {
eval("\$page_title = \"" . $menuitem['Menu_attr']['name'] . "\";");
}
eval("\$page_link = \"" . $menuitem['Menu_attr']['url'] . "\";");
$sub_menu_item = new MenuItem($page_title, $page_link, $page_icon_16);
if ($page_link == $_GET['p'] . ".html") {
$sub_menu_item->setCurrent();
$menu_item->setCurrent();
}
$sub_menu_items->add($sub_menu_item);
$nb_sub_menu++;
}
if ($nb_sub_menu > 0) {
$menu_item->setMenuItems($sub_menu_items);
}
}
$this->render->setMenuItems($menu_items);
$this->render->activateSupersubs();
list($strAdminLogin, $strAdminPasswd, $strAdminRights) = getWspUserRightsInfo("admin");
if ($strAdminLogin == "admin" && $strAdminPasswd == sha1("admin")) {
$modalbox = new DialogBox(__(CHANGE_PASSWD), new Url($page_object->getBaseLanguageURL() . "wsp-admin/change-passwd.call"));
$modalbox->modal()->setWidth(400);
$page_object->addObject($modalbox);
}
}
示例6: createItem
public function createItem($name, array $options = array())
{
$item = new MenuItem($name, $this);
$options = array_merge(
array(
'uri' => null,
'label' => null,
'attributes' => array(),
'linkAttributes' => array(),
'childrenAttributes' => array(),
'labelAttributes' => array(),
'display' => true,
'displayChildren' => true,
),
$options
);
$item
->setUri($options['uri'])
->setLabel($options['label'])
->setAttributes($options['attributes'])
->setLinkAttributes($options['linkAttributes'])
->setChildrenAttributes($options['childrenAttributes'])
->setLabelAttributes($options['labelAttributes'])
->setDisplay($options['display'])
->setDisplayChildren($options['displayChildren'])
;
return $item;
}
示例7: addItem
/**
* Adiciona um item ao menu.
* @param string $name Texto que será exibido ao usuário
* @param string $link Link do item do menu
* @return MenuItem O item do menu recém adicionado
*/
public function addItem($name, $link)
{
$menuItem = new MenuItem();
$anchor = $menuItem->addChild(new Anchor($link));
$anchor->addChild(new Text($name));
$this->addChild($menuItem);
return $menuItem;
}
示例8: build
static function build($menu_name, $content_dir_name)
{
$final_root = self::get_menu_entries($content_dir_name);
$final_root["key"] = $menu_name;
$menu_layout_dir = new Dir(self::MENU_LAYOUT_FOLDER . $menu_name . "/");
$root_item = new MenuItem($menu_layout_dir, $final_root, 0);
$root_item->render();
}
示例9: createFromNode
/**
* Create a menu item from a NodeInterface
*
* @param NodeInterface $node
* @return MenuItem
*/
public function createFromNode(NodeInterface $node)
{
$item = new MenuItem($node->getName(), $this->getUriFromNode($node), $node->getAttributes());
$item->setLabel($node->getLabel());
foreach ($node->getChildren() as $childNode) {
$item->addChild($this->createFromNode($childNode));
}
return $item;
}
示例10: __construct
/**
* MenuItem constructor.
*/
public function __construct($id)
{
$this->id = $id;
if (is_null(static::$current)) {
static::$current = $this;
$this->level(0);
} else {
static::$current = addItem($this);
$this->level(static::$current->level() + 1);
}
}
示例11: testConstructor
/**
* Test constructor
*/
public function testConstructor()
{
$tab = new MenuItem('my_short_name', "Name of My Tab");
$this->assertEqual($tab->short_name, 'my_short_name');
$this->assertEqual($tab->name, 'Name of My Tab');
$this->assertEqual($tab->description, '');
$this->assertEqual($tab->view_template, 'inline.view.tpl');
$datasets = $tab->getDatasets();
$this->assertIsA($datasets, 'array');
$this->assertEqual(sizeof($datasets), 0);
}
示例12: MenuItem
/**
* Creates new menuitem and adds it to items list
*
* @param string $name
* Internal name of item
* @param string $text
* Text to show
* @param string $url
* Optional url for linking
*
* @return MenuItem Reference to the created child item.
*/
public function &createItem($name, $text, $url = '')
{
$menu_item = new MenuItem();
$menu_item->setName($name);
$menu_item->setText($text);
if ($url) {
$menu_item->setUrl($url);
}
$this->items[$name] = $menu_item;
return $this->items[$name];
}
示例13: buildTree
/**
* Recursively creates a tree from the pages array
*
* @param MenuItem parent MenuItem object under which the tree is build
* @param array pageIdx indices of pages for this tree
*/
private function buildTree(MenuItem &$parent, $pageIdx)
{
foreach ($pageIdx as $i) {
if ($this->pages[$i]->parent == $parent->get('id')) {
$child = $parent->addChild($this->pages[$i]);
$this->buildTree($child, array_diff($pageIdx, array($i)));
if ($this->pid == $this->pages[$i]->id) {
$parent->getRoot()->setCurrentItem($child);
}
}
}
}
示例14: getItems
public function getItems()
{
$user = Transaction::getInstance()->getUser();
$items = array();
foreach ($this->xml->item as $element) {
$item = new MenuItem($this, $element);
if ($item->getId() == $this->mainMenuId) {
$item->setSelected(true);
}
if (!$item->isAdminOnly() || $user->isAdmin()) {
$items[] = $item;
}
}
return $items;
}
示例15: loadModel
/**
* Возвращает модель по указанному идентификатору
* Если модель не будет найдена - возникнет HTTP-исключение.
*
* @param integer идентификатор нужной модели
*
* @return void
*
* @throws CHttpException If MenuItem record not found
*/
public function loadModel($id)
{
if (($model = MenuItem::model()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('MenuModule.menu', 'Page was not found!'));
}
return $model;
}