当前位置: 首页>>代码示例>>PHP>>正文


PHP ElggMenuItem::setContext方法代码示例

本文整理汇总了PHP中ElggMenuItem::setContext方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggMenuItem::setContext方法的具体用法?PHP ElggMenuItem::setContext怎么用?PHP ElggMenuItem::setContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElggMenuItem的用法示例。


在下文中一共展示了ElggMenuItem::setContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: factory

 /**
  * ElggMenuItem factory method
  *
  * This static method creates an ElggMenuItem from an associative array.
  * Required keys are name, text, and href.
  *
  * @param array $options Option array of key value pairs
  *
  * @return ElggMenuItem or null on error
  */
 public static function factory($options)
 {
     if (!isset($options['name']) || !isset($options['text'])) {
         return null;
     }
     if (!isset($options['href'])) {
         $options['href'] = '';
     }
     $item = new ElggMenuItem($options['name'], $options['text'], $options['href']);
     unset($options['name']);
     unset($options['text']);
     unset($options['href']);
     // special catch in case someone uses context rather than contexts
     if (isset($options['context'])) {
         $options['contexts'] = $options['context'];
         unset($options['context']);
     }
     // make sure contexts is set correctly
     if (isset($options['contexts'])) {
         $item->setContext($options['contexts']);
         unset($options['contexts']);
     }
     if (isset($options['link_class'])) {
         $item->setLinkClass($options['link_class']);
         unset($options['link_class']);
     } elseif (isset($options['class'])) {
         elgg_deprecated_notice("ElggMenuItem::factory() does not accept 'class' key anymore, use 'link_class' instead", 1.9);
         $item->setLinkClass($options['class']);
         unset($options['class']);
     }
     if (isset($options['item_class'])) {
         $item->setItemClass($options['item_class']);
         unset($options['item_class']);
     }
     if (isset($options['data']) && is_array($options['data'])) {
         $item->setData($options['data']);
         unset($options['data']);
     }
     foreach ($options as $key => $value) {
         if (isset($item->data[$key])) {
             $item->data[$key] = $value;
         } else {
             $item->{$key} = $value;
         }
     }
     return $item;
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:57,代码来源:ElggMenuItem.php

示例2: factory

 /**
  * ElggMenuItem factory method
  *
  * This static method creates an ElggMenuItem from an associative array.
  * Required keys are name, text, and href.
  *
  * @param array $options Option array of key value pairs
  *
  * @return ElggMenuItem or NULL on error
  */
 public static function factory($options)
 {
     if (!isset($options['name']) || !isset($options['text'])) {
         return NULL;
     }
     if (!isset($options['href'])) {
         $options['href'] = '';
     }
     $item = new ElggMenuItem($options['name'], $options['text'], $options['href']);
     unset($options['name']);
     unset($options['text']);
     unset($options['href']);
     // special catch in case someone uses context rather than contexts
     if (isset($options['context'])) {
         $options['contexts'] = $options['context'];
         unset($options['context']);
     }
     // make sure contexts is set correctly
     if (isset($options['contexts'])) {
         $item->setContext($options['contexts']);
         unset($options['contexts']);
     }
     if (isset($options['link_class'])) {
         $item->setLinkClass($options['link_class']);
         unset($options['link_class']);
     }
     if (isset($options['item_class'])) {
         $item->setItemClass($options['item_class']);
         unset($options['item_class']);
     }
     if (isset($options['data']) && is_array($options['data'])) {
         $item->setData($options['data']);
         unset($options['data']);
     }
     foreach ($options as $key => $value) {
         if (isset($item->data[$key])) {
             $item->data[$key] = $value;
         } else {
             $item->{$key} = $value;
         }
     }
     return $item;
 }
开发者ID:duanhv,项目名称:mdg-social,代码行数:53,代码来源:ElggMenuItem.php

示例3: testInContextWithParticularContext

 public function testInContextWithParticularContext()
 {
     $item = new \ElggMenuItem('name', 'text', 'url');
     $item->setContext(array('blog', 'bookmarks'));
     $this->assertTrue($item->inContext('blog'));
     $this->assertFalse($item->inContext('file'));
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:7,代码来源:ElggMenuItemTest.php

示例4: elgg_echo

    elgg_register_menu_item('page', array('name' => elgg_echo("faq:ask"), 'text' => elgg_echo("faq:ask"), 'href' => elgg_get_site_url() . "faq/ask", 'section' => 'b', 'context' => 'faq'));
}
if (elgg_is_admin_logged_in()) {
    elgg_register_menu_item('page', array('name' => elgg_echo("faq:add"), 'text' => elgg_echo("faq:add"), 'href' => elgg_get_site_url() . "faq/add", 'section' => 'c', 'context' => 'faq'));
    elgg_register_menu_item('page', array('name' => elgg_echo("faq:asked", array(getUserQuestionsCount())), 'text' => elgg_echo("faq:asked", array(getUserQuestionsCount())), 'href' => elgg_get_site_url() . "faq/asked", 'section' => 'c', 'context' => 'faq'));
}
?>

<div class="elgg-module elgg-module-aside">
	<div class="elgg-head">
		<h3><?php 
echo elgg_echo('faq:sidebar:categories');
?>
</h3>
	</div>
	<div>
		<?php 
$cats = getCategories();
$category_links = '';
foreach ($cats as $id => $cat) {
    $url = "faq/list?categoryId=" . $id;
    $item = new ElggMenuItem($cat, $cat, $url);
    $item->setContext('faq');
    $item->setSection('d');
    $category_links .= elgg_view('navigation/menu/elements/item', array('item' => $item));
}
echo $category_links;
?>
	</div>
</div>
开发者ID:Facyla,项目名称:faq,代码行数:30,代码来源:sidebar.php

示例5: elgg_echo

<div class="elgg-module elgg-module-aside">
	<div class="elgg-head">
		<h3><?php 
echo elgg_echo('celebrations:list_monthly');
?>
</h3>
	</div>
	<div>
		<?php 
$filterid = $vars['filterid'];
for ($i = 1; $i <= 12; $i += 1) {
    $url = elgg_get_site_url() . "celebrations/celebrations/{$i}/{$filterid}";
    $item = new ElggMenuItem("celebrations_month_{$i}", elgg_echo("celebrations:month:{$i}"), $url);
    $item->setContext('celebrations');
    $item->setSection('a');
    $celebrations_monthly .= elgg_view('navigation/menu/elements/item', array('item' => $item));
}
echo "<ul>" . $celebrations_monthly . "</ul>";
?>
	</div>
</div>
开发者ID:iionly,项目名称:celebrations,代码行数:21,代码来源:sidebar.php


注:本文中的ElggMenuItem::setContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。