本文整理汇总了PHP中elgg_get_context函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_context函数的具体用法?PHP elgg_get_context怎么用?PHP elgg_get_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gvfriendrequest_pagesetup
function gvfriendrequest_pagesetup()
{
$context = elgg_get_context();
$page_owner = elgg_get_page_owner_entity();
// Remove link to friendsof
elgg_unregister_menu_item("page", "friends:of");
if ($user = elgg_get_logged_in_user_entity()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$class = "elgg-icon elgg-icon-users";
$text = "<span class='{$class}'></span>";
$tooltip = elgg_echo('gvtheme:myfriends');
if ($count > 0) {
$text .= "<span class=\"messages-new\">{$count}</span>";
$tooltip = elgg_echo("friend_request:unreadcount", array($count));
}
$params = array("name" => "friends", "href" => "friend_request/" . $user->username, "text" => $text, "section" => 'alt', "title" => $tooltip);
elgg_register_menu_item("topbar", $params);
}
}
// Show menu link in the correct context
if (in_array($context, array("friends", "friendsof", "collections")) && !empty($page_owner) && $page_owner->canEdit()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$extra = " (" . $count . ")";
} else {
$extra = "";
}
// add menu item
$menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections"), "section" => "friend_request");
elgg_register_menu_item("page", $menu_item);
}
}
示例2: 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;
}
示例3: widget_manager_get_widget_setting
function widget_manager_get_widget_setting($widget_handler, $setting, $context = null)
{
$result = false;
if (is_null($context)) {
$context = elgg_get_context();
}
static $widget_settings;
if (!isset($widget_settings)) {
$widget_settings = array();
}
if (!isset($widget_settings[$context])) {
$widget_settings[$context] = array();
}
if (!isset($widget_settings[$context][$widget_handler])) {
$widget_settings[$context][$widget_handler] = array();
}
if (isset($widget_settings[$context][$widget_handler][$setting])) {
return $widget_settings[$context][$widget_handler][$setting];
}
if (!empty($widget_handler) && !empty($setting)) {
if ($plugin_setting = elgg_get_plugin_setting($context . "_" . $widget_handler . "_" . $setting, "widget_manager")) {
if ($plugin_setting == "yes") {
$result = true;
}
} elseif ($setting == "can_add" || $setting == "can_remove") {
$result = true;
}
$widget_settings[$context][$widget_handler][$setting] = $result;
}
return $result;
}
示例4: profile_manager_group_override
/**
* function to replace group profile fields
*
* @param $hook_name
* @param $entity_type
* @param $return_value
* @param $parameters
* @return unknown_type
*/
function profile_manager_group_override($hook_name, $entity_type, $return_value, $parameters)
{
global $CONFIG;
$result = $return_value;
// Get all custom group fields
$options = array("type" => "object", "subtype" => CUSTOM_PROFILE_FIELDS_GROUP_SUBTYPE, "limit" => false, "owner_guid" => $CONFIG->site_guid);
$group_fields = elgg_get_entities($options);
if ($group_fields) {
$result = array();
$ordered = array();
// Order the group fields and filter some types out
foreach ($group_fields as $group_field) {
if ($group_field->admin_only != "yes" || elgg_is_admin_logged_in()) {
$ordered[$group_field->order] = $group_field;
}
}
ksort($ordered);
// build the correct list
$result["name"] = "text";
foreach ($ordered as $group_field) {
$result[$group_field->metadata_name] = $group_field->metadata_type;
// should it be handled as tags? TODO: is this still needed? Yes it is, it handles presentation of these fields in listing mode
if (elgg_get_context() == "search" && ($group_field->output_as_tags == "yes" || $group_field->metadata_type == "multiselect")) {
$result[$group_field->metadata_name] = "tags";
}
}
}
return $result;
}
示例5: translation_editor_plugins_boot_event
function translation_editor_plugins_boot_event()
{
global $CONFIG;
run_function_once("translation_editor_version_053");
// add the custom_keys_locations to language paths
$custom_keys_path = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR . "custom_keys" . DIRECTORY_SEPARATOR;
if (is_dir($custom_keys_path)) {
$CONFIG->language_paths[$custom_keys_path] = true;
}
// force creation of static to prevent reload of unwanted translations
reload_all_translations();
translation_editor_load_custom_languages();
if (elgg_get_context() != "translation_editor") {
// remove disabled languages
translation_editor_unregister_translations();
}
// load custom translations
$user_language = get_current_language();
$elgg_default_language = "en";
$load_languages = array($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);
}
}
}
示例6: views_counter_pagesetup
/**
* Set some views_counter links on elgg system
*/
function views_counter_pagesetup()
{
if (elgg_is_admin_logged_in() && elgg_get_context() == 'admin' || elgg_get_context() == 'views_counter') {
$item = new ElggMenuItem('views_counter_admin', elgg_echo('views_counter:admin_page'), elgg_get_site_url() . 'views_counter/list_entities/user');
elgg_register_menu_item('page', $item);
}
}
示例7: add_submenus
/**
* Sets up submenus. Triggered on pagesetup.
*
*/
function add_submenus()
{
$plugins_base = elgg_get_site_url() . "plugins";
if (elgg_get_context() == 'admin') {
elgg_register_admin_menu_item('administer', 'statistics', 'community_plugins');
elgg_register_admin_menu_item('administer', 'utilities', 'community_plugins');
elgg_register_admin_menu_item('configure', 'community_plugins', 'settings');
return;
}
if (elgg_get_context() != "plugins") {
return;
}
$page_owner = elgg_get_page_owner_entity();
if (elgg_is_logged_in() && elgg_get_page_owner_guid() == elgg_get_logged_in_user_guid()) {
elgg_register_menu_item('page', array('href' => "{$plugins_base}/developer/{$page_owner->username}", 'name' => 'plugins:yours', 'text' => elgg_echo("plugins:yours", array(elgg_echo('plugins:types:')))));
} else {
if (elgg_get_page_owner_guid()) {
$title = elgg_echo("plugins:user", array($page_owner->name, elgg_echo('plugins:types:')));
elgg_register_menu_item('page', array('href' => "{$plugins_base}/developer/{$page_owner->username}", 'name' => 'plugins:user', 'text' => $title));
}
}
elgg_register_menu_item('page', array('href' => '/plugins', 'name' => 'plugins:all', 'text' => elgg_echo('plugins:all')));
// add upload link when viewing own plugin page
if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
elgg_register_menu_item('page', array('href' => "{$plugins_base}/new/project/{$page_owner->username}", 'name' => 'plugins:upload', 'text' => elgg_echo('plugins:upload')));
}
}
示例8: widget_manager_pagesetup
function widget_manager_pagesetup()
{
$context = elgg_get_context();
if (elgg_is_admin_logged_in() && $context == "admin") {
// move defaultwidgets menu item
elgg_unregister_menu_item("page", "appearance:default_widgets");
elgg_register_menu_item('page', array('name' => "appearance:default_widgets", 'href' => "admin/appearance/default_widgets", 'text' => elgg_echo("admin:appearance:default_widgets"), 'context' => 'admin', 'parent_name' => "widgets", 'section' => "configure"));
// add own menu items
elgg_register_admin_menu_item('configure', 'manage', 'widgets');
if (elgg_get_plugin_setting("custom_index", "widget_manager") == "1|0") {
// a special link to manage homepages that are only available if logged out
elgg_register_menu_item('page', array('name' => "admin:widgets:manage:index", 'href' => elgg_get_site_url() . "?override=true", 'text' => elgg_echo("admin:widgets:manage:index"), 'context' => 'admin', 'parent_name' => "widgets", 'section' => "configure"));
}
}
// update fixed widgets if needed
if (in_array($context, array("profile", "dashboard")) && ($page_owner_guid = elgg_get_page_owner_guid())) {
// only check things if you are viewing a profile or dashboard page
$fixed_ts = elgg_get_plugin_setting($context . "_fixed_ts", "widget_manager");
if (empty($fixed_ts)) {
// there should always be a fixed ts, so fix it now. This situation only occurs after activating widget_manager the first time.
$fixed_ts = time();
elgg_set_plugin_setting($context . "_fixed_ts", $fixed_ts, "widget_manager");
}
// get the ts of the profile/dashboard you are viewing
$user_fixed_ts = elgg_get_plugin_user_setting($context . "_fixed_ts", $page_owner_guid, "widget_manager");
if ($user_fixed_ts < $fixed_ts) {
widget_manager_update_fixed_widgets($context, $page_owner_guid);
}
}
if (widget_manager_multi_dashboard_enabled()) {
if (get_input("internal_dashboard") == "yes") {
elgg_set_view_location("page/default", dirname(__FILE__) . "/views_alt/");
}
}
}
示例9: friend_request_pagesetup
function friend_request_pagesetup()
{
$context = elgg_get_context();
$page_owner = elgg_get_page_owner_entity();
// Remove link to friendsof
elgg_unregister_menu_item("page", "friends:of");
if ($user = elgg_get_logged_in_user_entity()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$params = array("name" => "friend_request", "href" => "friend_request/" . $user->username, "text" => elgg_view_icon("user") . "<span class='friend-request-new'>" . $count . "</span>", "title" => elgg_echo("friend_request:menu"), "priority" => 301);
elgg_register_menu_item("topbar", $params);
}
}
// Show menu link in the correct context
if (in_array($context, array("friends", "friendsof", "collections", "messages")) && !empty($page_owner) && $page_owner->canEdit()) {
$options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true);
if ($count = elgg_get_entities_from_relationship($options)) {
$extra = " [" . $count . "]";
} else {
$extra = "";
}
// add menu item
$menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections", "messages"), "section" => "friend_request");
elgg_register_menu_item("page", $menu_item);
}
}
示例10: filtermenu_hook
/**
* Hook into filter menu to replace destinations with our own
*
* @param type $hook
* @param type $type
* @param type $returnvalue
* @param type $params
* @return type
*/
function filtermenu_hook($hook, $type, $returnvalue, $params)
{
if (elgg_get_context() != 'activity_tabs' || !elgg_is_logged_in()) {
return $returnvalue;
}
$check = $returnvalue;
foreach ($check as $key => $item) {
switch ($item->getName()) {
case 'all':
$url = elgg_get_site_url() . 'activity/all';
$item->setHref($url);
$returnvalue[$key] = $item;
break;
case 'mine':
$url = elgg_get_site_url() . 'activity/owner/' . elgg_get_logged_in_user_entity()->username;
$item->setHref($url);
$returnvalue[$key] = $item;
break;
case 'friend':
$url = elgg_get_site_url() . 'activity/friends/' . elgg_get_logged_in_user_entity()->username;
$item->setHref($url);
$returnvalue[$key] = $item;
break;
default:
break;
}
}
return $returnvalue;
}
示例11: hydra_theme_init
function hydra_theme_init()
{
elgg_unextend_view('page/elements/header', 'search/header');
elgg_extend_view('page/elements/sidebar', 'search/header', 0);
if (elgg_get_context() != "admin") {
elgg_require_js("lorea_hydra/js");
}
$bower = elgg_get_site_url() . "mod/lorea_hydra/vendors/bower_components/";
elgg_register_css("bootstrap", "{$bower}bootstrap/dist/css/bootstrap.css", 0);
elgg_register_css("bootstrap-select", "{$bower}bootstrap-select/dist/css/bootstrap-select.min.css");
elgg_register_css("jasny", "{$bower}jasny-bootstrap/dist/css/jasny-bootstrap.min.css");
elgg_register_css("lorea_hydra", elgg_get_site_url() . "mod/hydra_theme/css/lorea_hydra.css", 10000);
elgg_define_js("bootstrap", array("src" => "{$bower}bootstrap/dist/js/bootstrap.min.js"));
//elgg_register_js("bootstrap", "{$bower}bootstrap/dist/js/bootstrap.min.js");
elgg_register_js("bootstrap-select", "{$bower}bootstrap-select/dist/js/bootstrap-select.min.js");
elgg_register_js("jasny", "{$bower}jasny-bootstrap/dist/js/jasny-bootstrap.min.js");
elgg_register_js("lorea_hydra", elgg_get_site_url() . "mod/hydra_theme/css/lorea_hydra.css", 10000);
if (elgg_get_context() != "admin") {
elgg_load_css("bootstrap");
elgg_load_css("bootstrap-select");
elgg_load_css("lorea_hydra");
elgg_load_css("jasny");
elgg_load_js("bootstrap");
elgg_load_js("jasny");
elgg_load_js("bootstrap-select");
elgg_load_js("lorea_hydra");
}
}
示例12: todos_filter_menu_register
/**
* Adds the filter menu for todos
*
* @param string $hook name of the hook
* @param string $type type of the hook
* @param ElggMenuItem[] $return return value
* @param array $params hook parameters
*
* @return ElggMenuItem[]
*/
function todos_filter_menu_register($hook, $type, $return, $params)
{
if (elgg_get_context() !== 'todos') {
return $return;
}
$page_owner = elgg_get_page_owner_entity();
if (todos_enabled_for_container($page_owner)) {
$base_url = 'todos';
if (elgg_instanceof($page_owner, 'group')) {
$base_url .= "/group/{$page_owner->getGUID()}/all";
}
$return[] = ElggMenuItem::factory(array('name' => 'active', 'text' => elgg_echo('todos:filter:active'), 'href' => $base_url));
$return[] = ElggMenuItem::factory(array('name' => 'completed', 'text' => elgg_echo('todos:filter:completed'), 'href' => "{$base_url}?filter=completed"));
if ($page_owner instanceof ElggGroup) {
$return[] = ElggMenuItem::factory(array('name' => 'assigned_per_user', 'text' => elgg_echo('todos:filter:assigned_per_user'), 'href' => "todos/assigned_per_user/{$page_owner->getGUID()}"));
}
$return[] = ElggMenuItem::factory(array('name' => 'overdue', 'text' => elgg_echo('todos:filter:overdue'), 'href' => "{$base_url}?filter=overdue"));
}
$user = elgg_get_logged_in_user_entity();
if (!empty($user)) {
$href = "todos/assigned/{$user->username}";
if (elgg_instanceof($page_owner, 'group')) {
$href .= "/{$page_owner->getGUID()}";
}
$return[] = ElggMenuItem::factory(array('name' => 'assigned', 'text' => elgg_echo('todos:filter:assigned'), 'href' => $href));
}
return $return;
}
示例13: elgg_clean_init
function elgg_clean_init()
{
elgg_unextend_view('page/elements/header', 'search/header');
elgg_extend_view('page/elements/sidebar', 'search/header', 0);
if (elgg_get_context() != "admin") {
elgg_require_js("elgg_clean/js");
}
elgg_register_event_handler('pagesetup', 'system', 'elgg_clean_pagesetup', 1000);
elgg_register_plugin_hook_handler('head', 'page', 'elgg_clean_setup_head');
$bower = elgg_get_site_url() . "mod/elgg_clean/vendors/bower_components/";
elgg_register_css("bootstrap", "{$bower}bootstrap/dist/css/bootstrap.css", 0);
elgg_register_css("open", "http://fonts.googleapis.com/css?family=Open+Sans:400,700,700italic,400italic");
elgg_register_css("passion", "http://fonts.googleapis.com/css?family=Passion+One");
elgg_register_css("elgg_clean", elgg_get_site_url() . "mod/elgg_clean/css/elgg_clean.css", 10000);
elgg_register_css("font-awesome", "{$bower}fontawesome/css/font-awesome.min.css");
elgg_register_css("bootstrap-select", "{$bower}bootstrap-select/dist/css/bootstrap-select.min.css");
elgg_register_css("jasny", "{$bower}jasny-bootstrap/dist/css/jasny-bootstrap.min.css");
elgg_register_css("fuelux", "{$bower}fuelux/dist/css/fuelux.min.css");
elgg_register_css("agency", elgg_get_site_url() . "mod/elgg_clean/css/agency.css", 20000);
elgg_register_css("home", elgg_get_site_url() . "mod/elgg_clean/css/home.css", 30000);
elgg_register_js('respond', '{$bower}respond/src/respond.js');
elgg_define_js("bootstrap", array("src" => "{$bower}bootstrap/dist/js/bootstrap.min.js"));
elgg_register_js("bootstrap-select", "{$bower}bootstrap-select/dist/js/bootstrap-select.min.js");
elgg_register_js("jasny", "{$bower}jasny-bootstrap/dist/js/jasny-bootstrap.min.js");
elgg_register_js("agency", elgg_get_site_url() . "mod/elgg_clean/js/agency.js");
elgg_register_js("cbpAnimatedHeader", elgg_get_site_url() . "mod/elgg_clean/js/cbpAnimatedHeader.js");
elgg_register_js("classie", elgg_get_site_url() . "mod/elgg_clean/js/classie.js");
elgg_register_js("contact_me", elgg_get_site_url() . "mod/elgg_clean/js/contact_me.js");
elgg_register_js("scrollspy", "{$bower}scrollspy/jquery.scrollspy.js");
elgg_register_js("parallax", "{$boder}jquery-parallax/scripts/jquery.parallax-1.13.js");
elgg_register_js("scrollto", "{$bower}jquery-parallax/scripts/jquery.scrollTo-1.4.2-min.js");
elgg_define_js('fuelux', array('src' => "{$bower}fuelux/dist/js/fuelux.min.js"));
if (elgg_get_context() != "admin") {
elgg_load_js('respond');
elgg_load_js("bootstrap");
elgg_load_js("jscolor");
elgg_load_js("elgg_clean");
elgg_load_js("bootstrap-select");
elgg_load_js("jasny");
elgg_load_js("agency");
elgg_load_js("parallax");
elgg_load_js("scrollto");
elgg_require_js("fuelux");
elgg_load_css("bootstrap");
elgg_load_css("open");
elgg_load_css("passion");
elgg_load_css("font-awesome");
elgg_load_css("bootstrap-select");
elgg_load_css("elgg_clean");
elgg_load_css("jasny");
elgg_load_css("fuelux");
elgg_load_css("agency");
}
// non-members do not get visible links to RSS feeds
if (!elgg_is_logged_in()) {
elgg_unregister_plugin_hook_handler('output:before', 'layout', 'elgg_views_add_rss_link');
}
elgg_register_action("elgg_clean/contact", elgg_get_plugins_path() . "elgg_clean/actions/contact.php", "public");
}
示例14: permissions_check
/**
*
* @param type $hook
* @param type $type
* @param type $return
* @param type $params
* @return boolean
*/
function permissions_check($hook, $type, $return, $params)
{
$context = elgg_get_context();
if ($context == "AU_anonymous_comments_permissions") {
return true;
}
return $return;
}
示例15: permissions_check
/**
* overwrites permissions for creating an administrator
*
* @param type $h
* @param type $t
* @param type $r
* @param type $p
* @return boolean|null
*/
function permissions_check($h, $t, $r, $p)
{
$context = elgg_get_context();
if ($context == "au_cas_auth_make_admin") {
return true;
}
return $r;
}