本文整理汇总了PHP中ElggMenuItem::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggMenuItem::factory方法的具体用法?PHP ElggMenuItem::factory怎么用?PHP ElggMenuItem::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggMenuItem
的用法示例。
在下文中一共展示了ElggMenuItem::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: donation_footer_menu_hook
function donation_footer_menu_hook($hook, $type, $return_value, $params)
{
//if (elgg_get_plugin_setting("add_donation_footer_menu_item", "donation") == "yes") {
$return_value[] = ElggMenuItem::factory(array("name" => "donations", "text" => elgg_echo("donation"), "href" => "donation"));
//}
return $return_value;
}
示例2: 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;
}
示例3: 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');
}
示例4: 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 ($item->annotation_id == 0) {
if ($object->canAnnotate(0, 'likes')) {
// like button
$options = array('name' => 'likes', 'href' => false, 'text' => elgg_view('likes/button', array('entity' => $object)), 'is_action' => true, 'priority' => 100);
$return[] = ElggMenuItem::factory($options);
// likes count
$count = elgg_view('likes/count', array('entity' => $object));
if ($count) {
$options = array('name' => 'likes_count', 'text' => $count, 'href' => false, 'priority' => 101);
$return[] = ElggMenuItem::factory($options);
}
}
}
}
return $return;
}
示例5: 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;
}
示例6: register
/**
* Add some menu items to the entity menu
*
* @param string $hook "register"
* @param string $entity_type "menu:entity"
* @param ElggMenuItem[] $returnvalue the current menu items
* @param array $params supplied params
*
* @return ElggMenuItem[]
*/
public static function register($hook, $entity_type, $returnvalue, $params)
{
if (empty($params) || !is_array($params)) {
return $returnvalue;
}
$entity = elgg_extract("entity", $params);
if (empty($entity) || !elgg_instanceof($entity, "object", "blog")) {
return $returnvalue;
}
// only published blogs
if ($entity->status == "draft") {
return $returnvalue;
}
if (!elgg_in_context("widgets") && elgg_is_admin_logged_in()) {
$returnvalue[] = \ElggMenuItem::factory(array("name" => "blog-feature", "text" => elgg_echo("blog_tools:toggle:feature"), "href" => "action/blog_tools/toggle_metadata?guid=" . $entity->getGUID() . "&metadata=featured", "item_class" => empty($entity->featured) ? "" : "hidden", "is_action" => true, "priority" => 175));
$returnvalue[] = \ElggMenuItem::factory(array("name" => "blog-unfeature", "text" => elgg_echo("blog_tools:toggle:unfeature"), "href" => "action/blog_tools/toggle_metadata?guid=" . $entity->getGUID() . "&metadata=featured", "item_class" => empty($entity->featured) ? "hidden" : "", "is_action" => true, "priority" => 176));
}
if ($entity->canComment()) {
$returnvalue[] = \ElggMenuItem::factory(array("name" => "comments", "text" => elgg_view_icon("speech-bubble"), "title" => elgg_echo("comment:this"), "href" => $entity->getURL() . "#comments"));
$comment_count = $entity->countComments();
if ($comment_count) {
$returnvalue[] = \ElggMenuItem::factory(array("name" => "comments_count", "text" => $comment_count, "title" => elgg_echo("comments"), "href" => false));
}
}
return $returnvalue;
}
示例7: registerItem
/**
* @param string $identifier
* @param array $options
* @return ElggMenuItem
*/
public function registerItem($identifier, array $options)
{
$options['name'] = $identifier;
$item = MenuItem::factory($options);
$this->items[$identifier] = $item;
return $item;
}
示例8: register
/**
* Add a menu item to the user hover dropdown
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param \ElggMenuItem[] $return_value current menu items
* @param array $params supplied params
*
* @return void|\ElggMenuItem[]
*/
public static function register($hook, $type, $return_value, $params)
{
static $user_dirs;
if (!elgg_is_admin_logged_in()) {
return;
}
if (empty($params) || !is_array($params)) {
return;
}
$user = elgg_extract('entity', $params);
if (!$user instanceof \ElggUser) {
return;
}
if (!isset($user_dirs)) {
$user_dirs = [];
}
// save in a static for performance when viewing user listings
if (!isset($user_dirs[$user->getGUID()])) {
$user_dirs[$user->getGUID()] = false;
$edl = new \Elgg\EntityDirLocator($user->getGUID());
$path = $edl->getPath();
if (is_dir(elgg_get_data_path() . $path)) {
$path = substr($path, 0, -1);
$user_dirs[$user->getGUID()] = \ElggMenuItem::factory(['name' => 'dataroot-browser', 'text' => elgg_echo('dataroot_browser:menu:user_hover'), 'href' => elgg_http_add_url_query_elements('admin/administer_utilities/dataroot_browser', ['dir' => $path]), 'is_trusted' => true, 'section' => 'admin']);
}
}
if (empty($user_dirs[$user->getGUID()])) {
return;
}
$return_value[] = $user_dirs[$user->getGUID()];
return $return_value;
}
示例9: 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;
}
示例10: custom_river_menu_setup
function custom_river_menu_setup($hook, $type, $return, $params)
{
$item = $params['item'];
$options = array('name' => 'delete', 'href' => elgg_add_action_tokens_to_url("action/river/delete?id={$item->id}&subjectId={$item->subject_guid}"), 'text' => elgg_view_icon('delete'), 'title' => elgg_echo('delete'), 'confirm' => elgg_echo('deleteconfirm'), 'priority' => 200);
$return[] = ElggMenuItem::factory($options);
return $return;
}
示例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: 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;
}
示例13: event_manager_entity_menu
function event_manager_entity_menu($hook, $entity_type, $returnvalue, $params)
{
$result = $returnvalue;
if (elgg_in_context("widgets")) {
return $result;
}
if (($entity = elgg_extract("entity", $params)) && elgg_instanceof($entity, "object", Event::SUBTYPE)) {
$attendee_menu_options = array("name" => "attendee_count", "priority" => 50, "text" => elgg_echo("event_manager:event:relationship:event_attending:entity_menu", array($entity->countAttendees())), "href" => false);
$result[] = ElggMenuItem::factory($attendee_menu_options);
// change some of the basic menus
if (!empty($result) && is_array($result)) {
foreach ($result as &$item) {
switch ($item->getName()) {
case "edit":
$item->setHref("events/event/edit/" . $entity->getGUID());
break;
case "delete":
$href = elgg_get_site_url() . "action/event_manager/event/delete?guid=" . $entity->getGUID();
$href = elgg_add_action_tokens_to_url($href);
$item->setHref($href);
$item->setConfirmText(elgg_echo("deleteconfirm"));
break;
}
}
}
// show an unregister link for non logged in users
if (!elgg_is_logged_in() && $entity->register_nologin) {
$result[] = ElggMenuItem::factory(array("name" => "unsubscribe", "text" => elgg_echo("event_manager:menu:unsubscribe"), "href" => "events/unsubscribe/" . $entity->getGUID() . "/" . elgg_get_friendly_title($entity->title), "priority" => 300));
}
}
return $result;
}
示例14: 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");
}
示例15: friend_request_entity_menu_handler
function friend_request_entity_menu_handler($hook, $type, $returnvalue, $params)
{
$result = $returnvalue;
if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) {
$entity = elgg_extract("entity", $params);
if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) {
if (!empty($result) && !is_array($result)) {
$result = array($result);
} elseif (empty($result)) {
$result = array();
}
// are we friends
if (!$entity->isFriendOf($user->getGUID())) {
// no, check if pending request
if (check_entity_relationship($user->getGUID(), "friendrequest", $entity->getGUID())) {
// pending request
$result[] = ElggMenuItem::factory(array("name" => "friend_request", "text" => elgg_echo("friend_request:friend:add:pending"), "href" => "friend_request/" . $user->username . "#friend_request_sent_listing", "priority" => 500));
} else {
// add as friend
$result[] = ElggMenuItem::factory(array("name" => "add_friend", "text" => elgg_echo("friend:add"), "href" => "action/friends/add?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
}
} else {
// is friend, se remove friend link
$result[] = ElggMenuItem::factory(array("name" => "remove_friend", "text" => elgg_echo("friend:remove"), "href" => "action/friends/remove?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
}
}
}
return $result;
}