當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。