本文整理汇总了PHP中elgg_in_context函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_in_context函数的具体用法?PHP elgg_in_context怎么用?PHP elgg_in_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_in_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pool_init
/**
* Initialize the plugin
*/
function pool_init()
{
$actions_path = elgg_get_plugins_path() . 'pool/actions/pool/';
elgg_register_action('pool/admin/save', $actions_path . 'save.php', 'admin');
elgg_register_action('pool/admin/delete', $actions_path . 'delete.php', 'admin');
elgg_register_action('pool/toggle_membership', $actions_path . 'toggle_membership.php');
elgg_register_action('pool/shift', $actions_path . 'shift.php', 'admin');
elgg_register_action('pool/remove', $actions_path . 'remove.php', 'admin');
elgg_register_action('pool/reorder', $actions_path . 'reorder.php', 'admin');
if (elgg_in_context('activity')) {
elgg_extend_view('page/elements/sidebar', 'pool/sidebar');
}
elgg_register_plugin_hook_handler('register', 'menu:entity', 'pool_entity_menu');
elgg_register_plugin_hook_handler('entity:url', 'object', 'pool_url_handler');
elgg_register_page_handler('pool', 'pool_page_handler');
elgg_register_menu_item('site', array('name' => 'pool', 'href' => 'pool/all', 'text' => elgg_echo('pool:all')));
// Register cron hook for each of the periods
foreach (array('daily', 'weekly', 'monthly') as $period) {
elgg_register_plugin_hook_handler('cron', $period, 'pool_assign_new_turn_cron');
}
// Rearrange lists when user is banned or deleted
elgg_register_event_handler('delete', 'user', 'pool_remove_user');
elgg_register_event_handler('ban', 'user', 'pool_remove_user');
// This is used instead of elgg_register_admin_menu_item() because we
// don't want to create a separate menu section
elgg_register_menu_item('page', array('name' => 'pools', 'href' => 'admin/pool/list', 'text' => elgg_echo('admin:pool:list'), 'context' => 'admin', 'section' => 'administer'));
}
示例2: developers_setup_menu
function developers_setup_menu()
{
if (elgg_in_context('admin')) {
elgg_register_admin_menu_item('develop', 'settings', 'developers');
elgg_register_admin_menu_item('develop', 'preview', 'developers');
}
}
示例3: 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() || elgg_in_context('widgets')) {
return;
}
$item = $params['item'];
/* @var ElggRiverItem $item */
// only like group creation #3958
if ($item->type == "group" && $item->view != "river/group/create") {
return;
}
// don't like users #4116
if ($item->type == "user") {
return;
}
if ($item->annotation_id != 0) {
return;
}
$object = $item->getObjectEntity();
if (!$object || !$object->canAnnotate(0, 'likes')) {
return;
}
$hasLiked = \Elgg\Likes\DataService::instance()->currentUserLikesEntity($object->guid);
// Always register both. That makes it super easy to toggle with javascript
$return[] = ElggMenuItem::factory(array('name' => 'likes', '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;
}
示例4: gvdislikes_river_menu_setup
/**
* Add a like button to river actions
*/
function gvdislikes_river_menu_setup($hook, $type, $return, $params)
{
if (elgg_is_logged_in()) {
$item = $params['item'];
// only dislike group creation #3958
if ($item->type == "group" && $item->view != "river/group/create") {
return $return;
}
// don't dislike 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')) {
// dislike button
$options = array('name' => 'dislikes', 'href' => false, 'text' => elgg_view('dislikes/button', array('entity' => $object)), 'is_action' => true, 'priority' => 102);
$return[] = ElggMenuItem::factory($options);
// likes count
$count = elgg_view('dislikes/count', array('entity' => $object));
if ($count) {
$options = array('name' => 'dislikes_count', 'text' => $count, 'href' => false, 'priority' => 103);
$return[] = ElggMenuItem::factory($options);
}
}
}
}
return $return;
}
示例5: 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;
}
示例6: widget_manager_write_access_hook
/**
* Returns a ACL for use in widgets
*
* @param string $hook_name name of the hook
* @param string $entity_type type of the hook
* @param string $return_value current return value
* @param array $params hook parameters
*
* @return array
*/
function widget_manager_write_access_hook($hook_name, $entity_type, $return_value, $params)
{
if (!elgg_in_context('widget_access')) {
return $return_value;
}
$widget = elgg_extract('entity', $params['input_params']);
if ($widget instanceof ElggWidget) {
$widget_context = $widget->context;
if ($widget_context == 'groups') {
$group = $widget->getContainerEntity();
if (!empty($group->group_acl)) {
$return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
}
} elseif ($widget->getContainerGUID() === elgg_get_site_entity()->getGUID()) {
// admins only have the following options for index widgets
if (elgg_is_admin_logged_in()) {
$return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
} elseif (elgg_can_edit_widget_layout($widget_context)) {
// for non admins that can manage this widget context
$return_value = [ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
}
}
} elseif (elgg_in_context('index') && elgg_is_admin_logged_in()) {
// admins only have the following options for index widgets
$return_value = [ACCESS_PRIVATE => elgg_echo('access:admin_only'), ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_LOGGED_OUT => elgg_echo('LOGGED_OUT'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
} elseif (elgg_in_context('groups')) {
$group = elgg_get_page_owner_entity();
if (!empty($group->group_acl)) {
$return_value = [$group->group_acl => elgg_echo('groups:group') . ': ' . $group->name, ACCESS_LOGGED_IN => elgg_echo('LOGGED_IN'), ACCESS_PUBLIC => elgg_echo('PUBLIC')];
}
}
return $return_value;
}
示例7: elgg_modifications_pagesetup
function elgg_modifications_pagesetup()
{
$user = elgg_get_logged_in_user_entity();
if (!$user) {
return;
}
if (elgg_in_context("accept_terms")) {
return;
}
$site = elgg_get_site_entity();
if ($site->isPublicPage()) {
return;
}
if (!empty($_SESSION["terms_accepted"])) {
return;
}
if (elgg_get_plugin_setting("accept_terms", "elgg_modifications") === "no") {
return;
}
$user_ts = $user->getPrivateSetting("general_terms_accepted");
if (empty($user_ts)) {
$_SESSION["terms_forward_from"] = current_page_url();
forward("accept_terms");
} else {
// user has accepted the terms, so don't check again
$_SESSION["terms_accepted"] = $user_ts;
}
}
示例8: izap_entity_menu_setup
/**
*
* Hook to create control menu for all entities for izap-elgg-bridge compatible
* plugins. (access, edit, like, delete)
* @param <type> $hook
* @param <type> $type
* @param <type> $return
* @param <type> $params
* @return <type>
*
*/
function izap_entity_menu_setup($hook, $type, $return, $params)
{
if (elgg_in_context('widgets')) {
return $return;
}
$allowed_sub_types = array(GLOBAL_IZAP_VIDEOS_SUBTYPE, GLOBAL_IZAP_ECOMMERCE_SUBTYPE, GLOBAL_IZAP_CONTEST_CHALLENGE_SUBTYPE, GLOBAL_IZAP_CONTEST_QUIZ_SUBTYPE);
$entity = $params['entity'];
if (!in_array($entity->getSubtype(), $allowed_sub_types)) {
return $return;
}
$handler = elgg_extract('handler', $params, false);
// access
$access = elgg_view('output/access', array('entity' => $entity));
$options = array('name' => 'access', 'text' => $access, 'href' => false, 'priority' => 100);
$return[] = ElggMenuItem::factory($options);
if ($entity->canEdit() && $handler) {
if (isset($params['vars']) && $params['vars'] != '') {
if (!is_array($params['vars'])) {
$vars = array($params['vars']);
} else {
$vars = $params['vars'];
}
} else {
$vars = array($entity->getGUID());
}
// edit link
$options = array('name' => 'edit', 'text' => elgg_echo('edit'), 'title' => elgg_echo('edit:this'), 'href' => IzapBase::setHref(isset($params['page_owner']) ? array('page_owner' => $params['page_owner'], 'context' => $handler, 'action' => 'edit', 'vars' => $vars) : array('context' => $handler, 'action' => 'edit', 'vars' => $vars)), 'priority' => 200);
$return[] = ElggMenuItem::factory($options);
// delete link
$options = array('name' => 'delete', 'text' => elgg_view_icon('delete'), 'title' => elgg_echo('delete:this'), 'href' => IzapBase::deleteLink(array('guid' => $entity->getGUID(), 'only_url' => true)), 'confirm' => elgg_echo('deleteconfirm'), 'priority' => 300);
$return[] = ElggMenuItem::factory($options);
}
return $return;
}
示例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: jssor_entity_menu_setup
function jssor_entity_menu_setup($hook, $type, $return, $params)
{
if (elgg_in_context('widgets')) {
return $return;
}
$entity = $params['entity'];
$handler = elgg_extract('handler', $params, false);
if ($handler != 'photos') {
return $return;
}
if (elgg_instanceof($entity, 'object', 'image')) {
$album = $entity->getContainerEntity();
$url = 'jssor/album?guid=' . $album->getGUID() . '&i=' . $entity->getGUID();
$params = array('href' => $url, 'text' => elgg_echo('jssor:gallery:view'));
$text = elgg_view('output/url', $params);
$options = array('name' => 'gallery_view', 'text' => $text, 'priority' => 40);
$return[] = ElggMenuItem::factory($options);
}
if (elgg_instanceof($entity, 'object', 'album')) {
$album = $entity;
$offset = get_input('offset');
if ($offset) {
$url = 'jssor/album?guid=' . $album->getGUID() . '&o=' . get_input('offset');
} else {
$url = 'jssor/album?guid=' . $album->getGUID();
}
$params = array('href' => $url, 'text' => elgg_echo('jssor:gallery:view'));
$text = elgg_view('output/url', $params);
$options = array('name' => 'gallery_view', 'text' => $text, 'priority' => 40);
$return[] = ElggMenuItem::factory($options);
}
return $return;
}
示例11: translation_editor_plugins_boot_event
/**
* This function is executed during the 'plugins_boot' event, before most plugins are initialized
*
* @return void
*/
function translation_editor_plugins_boot_event()
{
// add the custom_keys_locations to language paths
$custom_keys_path = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . 'custom_keys' . DIRECTORY_SEPARATOR;
if (is_dir($custom_keys_path)) {
register_translations($custom_keys_path);
}
// force creation of static to prevent reload of unwanted translations
reload_all_translations();
if (elgg_in_context('translation_editor') || elgg_in_context('settings') || elgg_in_context('admin')) {
translation_editor_reload_all_translations();
}
translation_editor_load_custom_languages();
if (!elgg_in_context('translation_editor')) {
// remove disabled languages
translation_editor_unregister_translations();
}
// load custom translations
$user_language = get_current_language();
$elgg_default_language = 'en';
$load_languages = [$user_language, $elgg_default_language];
$load_languages = array_unique($load_languages);
$disabled_languages = translation_editor_get_disabled_languages();
foreach ($load_languages as $language) {
if (empty($disabled_languages) || !in_array($language, $disabled_languages)) {
// add custom translations
translation_editor_load_translations($language);
}
}
}
示例12: hflts_init
function hflts_init()
{
elgg_register_page_handler('hflts', 'hflts_page_handler');
// add to site links only in case of make the model result public
/*if (elgg_is_logged_in()) {
$item = new \ElggMenuItem('hflts', elgg_echo('hflts'), 'hflts');
elgg_register_menu_item('site', $item);
}*/
//Puedo informar del karma en el dashboard o justo debajo del icono del usuario
elgg_extend_view('icon/user/default', 'hflts/icon');
//guardar la configuración seleccionada en el formulario de settings
$action_base = elgg_get_plugins_path() . 'hflts/actions/hflts';
//If you want to make an action available to only admins or open it up to unauthenticated users, you can pass ‘admin’ or ‘public’
elgg_register_action('hflts/settings', "{$action_base}/settings.php", 'admin');
if (elgg_in_context('admin')) {
elgg_register_menu_item('page', array('name' => 'hflts_settings', 'href' => 'admin/hflts/settings', 'text' => elgg_echo('hflts:settings'), 'context' => 'admin', 'priority' => 10, 'section' => 'teranga'));
}
//register CSS file
elgg_extend_view('css/elgg', 'hflts/css');
//teranga add user_hover_menu entry
elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'hflts_user_hover_menu');
elgg_register_plugin_hook_handler('admin:teranga:import', 'system', 'hflts_import_external_data');
/* to handle mcdm objects
elgg_register_event_handler('create','object', 'hflts_mcdm_object');
elgg_register_event_handler('delete','object', 'hflts_mcdm_object');
elgg_register_event_handler('delete','entity', 'hflts_mcdm_object');
*/
}
示例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: group_tools_pagesetup
function group_tools_pagesetup()
{
$user = elgg_get_logged_in_user_entity();
$page_owner = elgg_get_page_owner_entity();
if (elgg_in_context("groups") && $page_owner instanceof ElggGroup) {
if ($page_owner->forum_enable == "no") {
// unset if not enabled for this plugin
elgg_unregister_widget_type("group_forum_topics");
}
if (!empty($user)) {
// check for admin transfer
$admin_transfer = elgg_get_plugin_setting("admin_transfer", "group_tools");
if ($admin_transfer == "admin" && $user->isAdmin()) {
elgg_extend_view("groups/edit", "group_tools/forms/admin_transfer", 400);
} elseif ($admin_transfer == "owner" && ($page_owner->getOwnerGUID() == $user->getGUID() || $user->isAdmin())) {
elgg_extend_view("groups/edit", "group_tools/forms/admin_transfer", 400);
}
// check multiple admin
if (elgg_get_plugin_setting("multiple_admin", "group_tools") == "yes") {
// extend group members sidebar list
elgg_extend_view("groups/sidebar/members", "group_tools/group_admins", 400);
// remove group tool options for group admins
if ($page_owner->getOwnerGUID() != $user->getGUID() && !$user->isAdmin()) {
remove_group_tool_option("group_multiple_admin_allow");
}
}
// invitation management
if ($page_owner->canEdit()) {
$request_options = array("type" => "user", "relationship" => "membership_request", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true, "count" => true);
$invite_options = array("type" => "user", "relationship" => "invited", "relationship_guid" => $page_owner->getGUID(), "count" => true);
$postfix = "";
if ($requests = elgg_get_entities_from_relationship($request_options)) {
$postfix = " [" . $requests . "]";
} elseif ($invited = elgg_get_entities_from_relationship($invite_options)) {
$postfix = " [" . $invited . "]";
}
if (!$page_owner->isPublicMembership() || !empty($requests)) {
elgg_register_menu_item('page', array('name' => 'membership_requests', 'text' => elgg_echo('groups:membershiprequests') . $postfix, 'href' => "groups/requests/" . $page_owner->getGUID()));
} elseif (!empty($invited)) {
elgg_register_menu_item('page', array('name' => 'membership_requests', 'text' => elgg_echo('group_tools:menu:invitations') . $postfix, 'href' => "groups/requests/" . $page_owner->getGUID()));
}
}
// group mail options
if ($page_owner->canEdit() && elgg_get_plugin_setting("mail", "group_tools") == "yes") {
elgg_register_menu_item('page', array('name' => 'mail', 'text' => elgg_echo('group_tools:menu:mail'), 'href' => "groups/mail/" . $page_owner->getGUID()));
}
}
}
if ($page_owner instanceof ElggGroup) {
if (!$page_owner->isPublicMembership()) {
if (elgg_get_plugin_setting("search_index", "group_tools") != "yes") {
// closed groups should be indexed by search engines
elgg_extend_view("page/elements/head", "metatags/noindex");
}
}
// cleanup sidebar
elgg_extend_view("page/elements/sidebar", "group_tools/sidebar/cleanup");
}
}
示例15: developers_setup_menu
function developers_setup_menu()
{
if (elgg_in_context('admin')) {
elgg_register_admin_menu_item('develop', 'inspect', 'develop_tools');
elgg_register_admin_menu_item('develop', 'preview', 'develop_tools');
elgg_register_menu_item('page', array('name' => 'dev_settings', 'href' => 'admin/developers/settings', 'text' => elgg_echo('settings'), 'context' => 'admin', 'priority' => 10, 'section' => 'develop'));
}
}