本文整理汇总了PHP中ElggMenuItem类的典型用法代码示例。如果您正苦于以下问题:PHP ElggMenuItem类的具体用法?PHP ElggMenuItem怎么用?PHP ElggMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ElggMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenuItem
public function getMenuItem(ElggMenuItem $parent, $top_only = false)
{
if ($parent) {
$menu_item = array('name' => "{$parent->getName()}:{$this->guid}", 'parent_name' => "{$parent->getName()}", 'text' => "<img class=\"hj-categories-tree-icon\" src=\"{$this->getIconURL('tiny')}\" width=\"12\" />" . $this->title . ' (' . $this->getFiledEntitiesCount() . ')', 'href' => $this->getURL(), 'class' => 'hj-categories-menu-child', 'priority' => $this->priority, 'data' => array('category_guid' => $this->guid));
} else {
$menu_item = array('name' => "{$this->guid}", 'text' => "<img class=\"hj-categories-tree-icon\" src=\"{$this->getIconURL('tiny')}\" width=\"12\" />" . $this->title . ' (' . $this->getFiledEntitiesCount() . ')', 'href' => $this->getURL(), 'class' => 'hj-categories-menu-root', 'priority' => $this->priority, 'data' => array('category_guid' => $this->guid));
}
$menu_item = ElggMenuItem::factory($menu_item);
$return[] = $menu_item;
// Empty menu item to create html markup
if ($this->canEdit() && elgg_get_context() == 'category') {
$add_new = array('name' => "{$menu_item->getName()}:addnew", 'parent_name' => "{$menu_item->getName()}", 'text' => '', 'item_class' => 'hidden', 'href' => false, 'priority' => 1);
$return[] = ElggMenuItem::factory($add_new);
}
if (!$top_only) {
$children = $this->getChildren();
if (is_array($children)) {
foreach ($children as $child) {
$submenu = $child->getMenuItem($menu_item);
if (is_array($submenu)) {
foreach ($submenu as $submenu_item) {
$return[] = $submenu_item;
}
}
}
}
}
return $return;
}
示例2: logbrowser_user_hover_menu
/**
* Add to the user hover menu
*/
function logbrowser_user_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
$url = "admin/overview/logbrowser?user_guid={$user->guid}";
$item = new ElggMenuItem('logbrowser', elgg_echo('logbrowser:explore'), $url);
$item->setSection('admin');
$return[] = $item;
return $return;
}
示例3: album_link_hover_menu
function album_link_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
$url = elgg_get_site_url() . "photos/owner/" . $user->username;
$item = new ElggMenuItem('album_link_hover', elgg_echo("album_link:album_link", array($user->name)), $url);
$item->setSection('action');
$return[] = $item;
return $return;
}
示例4: donation_user_hover_menu
function donation_user_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
$url = "action/donation/add?guid={$user->guid}";
$url = elgg_add_action_tokens_to_url($url);
$item = new ElggMenuItem('donation', elgg_echo('donation:add'), $url);
$item->setSection('admin');
$return[] = $item;
return $return;
}
示例5: hover_menu
function hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
if ($user->spam_throttle_suspension > time() && elgg_is_admin_logged_in()) {
$url = "action/spam_throttle/unsuspend?guid={$user->guid}";
$item = new \ElggMenuItem("spam_throttle_unsuspend", elgg_echo("spam_throttle:unsuspend"), $url);
$item->setConfirmText(elgg_echo('spam_throttle:unsuspend:confirm'));
$item->setSection('admin');
$return[] = $item;
}
return $return;
}
示例6: user_hover_hook
/**
*
* @param type $hook
* @param type $type
* @param type $returnvalue
* @param type $params
* @return ElggMenuItem
*/
function user_hover_hook($hook, $type, $returnvalue, $params)
{
$user = $params['entity'];
$url = elgg_get_site_url() . "activity_tabs/user/{$user->username}";
$item = new \ElggMenuItem('activity_tabs_user_activity', elgg_echo('activity_tabs'), $url);
if ($type == 'menu:user_hover') {
$item->setSection('action');
$item->setLinkClass('activity-tabs-user-hover');
$item->setPriority(200);
}
$returnvalue[] = $item;
return $returnvalue;
}
示例7: badges_user_hover_menu
/**
* Add to the user hover menu
*/
function badges_user_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
$url = "admin/administer_utilities/elggx_badges?tab=assign&user_guid={$user->guid}";
$item = new ElggMenuItem('badges', elgg_echo('badges:assign_badge'), $url);
$item->setSection('admin');
$return[] = $item;
$url = "admin/administer_utilities/elggx_badges?tab=unassign&user_guid={$user->guid}";
$item = new ElggMenuItem('badges', elgg_echo('badges:unassign_badge'), $url);
$item->setSection('admin');
$return[] = $item;
return $return;
}
示例8: reportedcontent_user_hover_menu
/**
* Add report user link to hover menu
*/
function reportedcontent_user_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
$profile_url = urlencode($user->getURL());
$name = urlencode($user->name);
$url = "reportedcontent/add?address={$profile_url}&title={$name}";
if (elgg_is_logged_in() && elgg_get_logged_in_user_guid() != $user->guid) {
$item = new ElggMenuItem('reportuser', elgg_echo('reportedcontent:user'), $url);
$item->setSection('action');
$return[] = $item;
}
return $return;
}
示例9: hflts_user_hover_menu
function hflts_user_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
//if (elgg_is_admin_logged_in() != $user->guid) supuestamente esto es para que no vea mi propia valoracion
if (elgg_is_admin_logged_in()) {
$url = "hflts/{$user->username}";
$item = new \ElggMenuItem('hflts:user', elgg_echo('hflts:menuhover'), $url);
$item->setSection('admin');
//default + elgg_get_logged_in_user_guid() | admin + elgg_is_admin_logged_in
//$item->setConfirmText(elgg_echo('confirm'));//saca un are you sure
$return[] = $item;
}
return $return;
}
示例10: odt_editor_file_menu_title_hook
/**
* Add a button to the file page to allow the user to create a new document
*
* @param string $hook the 'route' hook
* @param string $type for the 'file' page handler
* @param bool $return_value tells which page is handled, contains:
* $return_value['handler'] => requested handler
* $return_value['segments'] => url parts ($page)
* @param null $params no params provided
*/
function odt_editor_file_menu_title_hook($hook, $type, $return_value, $params)
{
if (elgg_in_context('file')) {
$return_value[] = ElggMenuItem::factory(array("name" => "view", "text" => elgg_echo('odt_editor:newdocument'), "class" => "elgg-button elgg-button-action", "id" => "file_tools_list_new_document_toggle", "priority" => 50));
}
return $return_value;
}
示例11: likes_river_menu_setup
/**
* Add a like button to river actions
*/
function likes_river_menu_setup($hook, $type, $return, $params)
{
if (elgg_is_logged_in()) {
$item = $params['item'];
// only like group creation #3958
if ($item->type == "group" && $item->view != "river/group/create") {
return $return;
}
// don't like users #4116
if ($item->type == "user") {
return $return;
}
$object = $item->getObjectEntity();
if (!elgg_in_context('widgets') && $item->annotation_id == 0) {
if ($object->canAnnotate(0, 'likes')) {
$hasLiked = elgg_annotation_exists($object->guid, 'likes');
// Always register both. That makes it super easy to toggle with javascript
$return[] = ElggMenuItem::factory(array('name' => 'like', 'href' => elgg_add_action_tokens_to_url("/action/likes/add?guid={$object->guid}"), 'text' => elgg_view_icon('thumbs-up'), 'title' => elgg_echo('likes:likethis'), 'item_class' => $hasLiked ? 'hidden' : '', 'priority' => 100));
$return[] = ElggMenuItem::factory(array('name' => 'unlike', 'href' => elgg_add_action_tokens_to_url("/action/likes/delete?guid={$object->guid}"), 'text' => elgg_view_icon('thumbs-up-alt'), 'title' => elgg_echo('likes:remove'), 'item_class' => $hasLiked ? '' : 'hidden', 'priority' => 100));
// likes count
$count = elgg_view('likes/count', array('entity' => $object));
if ($count) {
$return[] = ElggMenuItem::factory(array('name' => 'likes_count', 'text' => $count, 'href' => false, 'priority' => 101));
}
}
}
}
return $return;
}
示例12: blog_tools_init
/**
* This function gets called during the system initialization
*
* @return void
*/
function blog_tools_init()
{
// extend css
elgg_extend_view('css/elgg', 'css/blog_tools/site.css');
// extra blog views
elgg_extend_view('object/blog', 'blog_tools/full/navigation');
elgg_extend_view('object/blog', 'blog_tools/full/owner');
elgg_extend_view('object/blog', 'blog_tools/full/related');
elgg_extend_view('blog/sidebar', 'blog_tools/full/related');
// register event handlers
elgg_register_event_handler('upgrade', 'system', '\\ColdTrick\\BlogTools\\Upgrade::moveBlogIcons');
// register plugin hook handlers
elgg_register_plugin_hook_handler('entity:url', 'object', '\\ColdTrick\\BlogTools\\Widgets::widgetUrl');
elgg_register_plugin_hook_handler('cron', 'daily', '\\ColdTrick\\BlogTools\\Cron::daily');
elgg_register_plugin_hook_handler('route', 'blog', '\\ColdTrick\\BlogTools\\Router::blog');
elgg_register_plugin_hook_handler('register', 'menu:entity', '\\ColdTrick\\BlogTools\\EntityMenu::register');
elgg_register_plugin_hook_handler('group_tool_widgets', 'widget_manager', '\\ColdTrick\\BlogTools\\Widgets::groupTools');
elgg_register_plugin_hook_handler('permissions_check:comment', 'object', '\\ColdTrick\\BlogTools\\Access::blogCanComment');
elgg_register_plugin_hook_handler('view_vars', 'input/form', '\\ColdTrick\\BlogTools\\Views::blogEditFormVars');
// extend editmenu
elgg_extend_view('editmenu', 'blog_tools/editmenu');
// add featured filter menu item
elgg_register_menu_item('filter', ElggMenuItem::factory(['name' => 'featured', 'text' => elgg_echo('status:featured'), 'context' => 'blog', 'href' => 'blog/featured', 'priority' => 600]));
// register index widget
elgg_register_widget_type('index_blog', elgg_echo('blog'), elgg_echo('blog_tools:widgets:index_blog:description'), ['index'], true);
elgg_register_widget_type('blog', elgg_echo('blog'), elgg_echo('blog:widget:description'), ['profile', 'dashboard', 'groups']);
// overrule blog actions
elgg_register_action('blog/save', dirname(__FILE__) . '/actions/blog/save.php');
elgg_register_action('blog/auto_save_revision', dirname(__FILE__) . '/actions/blog/auto_save_revision.php');
// register actions
elgg_register_action('blog_tools/toggle_metadata', dirname(__FILE__) . '/actions/toggle_metadata.php', 'admin');
elgg_register_action('blog_tools/upgrades/move_icons', dirname(__FILE__) . '/actions/upgrades/move_icons.php', 'admin');
}
示例13: pool_entity_menu
/**
* Set up entity menu for pool objects
*
* @param string $hook 'register'
* @param string $type 'menu:entity'
* @param ElggMenuItem[] $return
* @param array $params
* @return ElggMenuItem[]
*/
function pool_entity_menu($hook, $type, $return, $params)
{
$handler = elgg_extract('handler', $params, false);
if ($handler != 'task_pool') {
return $return;
}
if (elgg_is_logged_in()) {
$entity = $params['entity'];
$user_guid = elgg_get_logged_in_user_guid();
if ($entity->isMember($user_guid)) {
$text = elgg_echo('pool:leave');
} else {
$text = elgg_echo('pool:join');
}
$return[] = ElggMenuItem::factory(array('name' => 'test', 'text' => "<span>{$text}</span>", 'href' => "action/pool/toggle_membership?pool_guid={$entity->guid}&user_guid={$user_guid}", 'priority' => 150, 'is_action' => true));
if (elgg_is_admin_logged_in()) {
$return[] = ElggMenuItem::factory(array('name' => 'edit', 'text' => elgg_echo('edit'), 'href' => "admin/pool/save?guid={$entity->guid}"));
$return[] = ElggMenuItem::factory(array('name' => 'delete', 'text' => elgg_view_icon('delete'), 'href' => "action/pool/admin/delete?guid={$entity->guid}", 'is_action' => true, 'confirm' => elgg_echo('question:areyousure'), 'priority' => 200));
if ($entity->countMembers()) {
$return[] = ElggMenuItem::factory(array('name' => 'shift', 'text' => elgg_echo('pool:shift'), 'href' => "action/pool/shift?guid={$entity->guid}", 'priority' => 150, 'is_action' => true, 'confirm' => elgg_echo('question:areyousure')));
}
}
}
return $return;
}
示例14: register
/**
* Set folder breadcrumb menu
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param ElggMenuItem[] $return_value current return value
* @param array $params supplied params
*
* @return void|ElggMenuItem[]
*/
public static function register($hook, $type, $return_value, $params)
{
if (empty($params) || !is_array($params)) {
return;
}
$container = elgg_get_page_owner_entity();
/* @var $folder \ElggObject */
$folder = elgg_extract('entity', $params);
if (elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
$container = $folder->getContainerEntity();
$priority = 9999999;
$return_value[] = \ElggMenuItem::factory(['name' => "folder_{$folder->getGUID()}", 'text' => $folder->getDisplayName(), 'href' => false, 'priority' => $priority]);
$parent_guid = (int) $folder->parent_guid;
while (!empty($parent_guid)) {
$parent = get_entity($parent_guid);
if (!elgg_instanceof($parent, 'object', FILE_TOOLS_SUBTYPE)) {
break;
}
$priority--;
$return_value[] = \ElggMenuItem::factory(['name' => "folder_{$parent->getGUID()}", 'text' => $parent->getDisplayName(), 'href' => $parent->getURL(), 'priority' => $priority]);
$parent_guid = (int) $parent->parent_guid;
}
}
// make main folder item
$main_folder_options = ['name' => 'main_folder', 'text' => elgg_echo('file_tools:list:folder:main'), 'priority' => 0];
if ($container instanceof \ElggGroup) {
$main_folder_options['href'] = "file/group/{$container->getGUID()}/all#";
} else {
$main_folder_options['href'] = "file/owner/{$container->username}/all#";
}
$return_value[] = \ElggMenuItem::factory($main_folder_options);
return $return_value;
}
示例15: blog_tools_init
/**
* This function gets called during the system initialization
*
* @return void
*/
function blog_tools_init()
{
// extend css
elgg_extend_view("css/elgg", "css/blog_tools/site");
elgg_extend_view("js/elgg", "js/blog_tools/site");
// extra blog views
elgg_extend_view("object/blog", "blog_tools/full/navigation");
elgg_extend_view("object/blog", "blog_tools/full/owner");
elgg_extend_view("object/blog", "blog_tools/full/related");
elgg_extend_view("blog/sidebar", "blog_tools/full/related");
// register event handlers
elgg_register_event_handler("delete", "object", array("\\ColdTrick\\BlogTools\\DeleteHandler", "cleanupBlogIcon"));
// register plugin hook handlers
elgg_register_plugin_hook_handler("entity:url", "object", array("\\ColdTrick\\BlogTools\\Widgets", "widgetUrl"));
elgg_register_plugin_hook_handler("cron", "daily", array("\\ColdTrick\\BlogTools\\Cron", "daily"));
elgg_register_plugin_hook_handler("entity:icon:url", "object", array("\\ColdTrick\\BlogTools\\EntityIcon", "blogIcon"));
elgg_register_plugin_hook_handler("route", "blog", array("\\ColdTrick\\BlogTools\\Router", "blog"));
elgg_register_plugin_hook_handler("register", "menu:entity", array("\\ColdTrick\\BlogTools\\EntityMenu", "register"));
elgg_register_plugin_hook_handler("group_tool_widgets", "widget_manager", array("\\ColdTrick\\BlogTools\\Widgets", "groupTools"));
elgg_register_plugin_hook_handler("permissions_check:comment", "object", array("\\ColdTrick\\BlogTools\\Access", "blogCanComment"));
// extend editmenu
elgg_extend_view("editmenu", "blog_tools/editmenu");
// add featured filter menu item
elgg_register_menu_item("filter", ElggMenuItem::factory(array("name" => "featured", "text" => elgg_echo("blog_tools:menu:filter:featured"), "context" => "blog", "href" => "blog/featured", "priority" => 600)));
// register index widget
elgg_register_widget_type("index_blog", elgg_echo("blog"), elgg_echo("blog_tools:widgets:index_blog:description"), array("index"), true);
elgg_register_widget_type("blog", elgg_echo("blog"), elgg_echo("blog:widget:description"), array("profile", "dashboard", "groups"));
// overrule blog actions
elgg_register_action("blog/save", dirname(__FILE__) . "/actions/blog/save.php");
elgg_register_action("blog/auto_save_revision", dirname(__FILE__) . "/actions/blog/auto_save_revision.php");
// register actions
elgg_register_action("blog_tools/toggle_metadata", dirname(__FILE__) . "/actions/toggle_metadata.php", "admin");
}