本文整理汇总了PHP中elgg_instanceof函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_instanceof函数的具体用法?PHP elgg_instanceof怎么用?PHP elgg_instanceof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_instanceof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: au_group_tag_menu_page_handler
function au_group_tag_menu_page_handler($page, $identifier)
{
//show the page of search results
// assumes url of group/guid/tag
// if the tag is 'all' then will display a tagcloud
switch ($page[0]) {
case 'group':
$entity = get_entity($page[1]);
if (!elgg_instanceof($entity, 'group') || $entity->au_group_tag_menu_enable == 'no') {
return false;
}
elgg_push_breadcrumb($entity->name, $entity->getURL());
//should be OK if this is empty
$tag = $page[2];
elgg_push_breadcrumb($tag);
if ($tag == "all") {
//show a tag cloud for all group tags
//arbitrarily set to a max of 640 tags - should be enough for anyone :-)
$title = elgg_echo("au_group_tag_menu:tagcloud");
$options = array('container_guid' => $entity->getGUID(), 'type' => 'object', 'threshold' => 0, 'limit' => 640, 'tag_names' => array('tags'));
$thetags = elgg_get_tags($options);
//make it an alphabetical tag cloud, not with most popular first
sort($thetags);
//find the highest tag count for scaling the font
$max = 0;
foreach ($thetags as $key) {
if ($key->total > $max) {
$max = $key->total;
}
}
$content = " ";
//loop through and generate tags so they display nicely
//in the group, not as a dumb search page
foreach ($thetags as $key) {
$url = elgg_get_site_url() . "group_tag_menu/group/" . $entity->getGUID() . "/" . urlencode($key->tag);
$taglink = elgg_view('output/url', array('text' => ' ' . $key->tag, 'href' => $url, 'title' => "{$key->tag} ({$key->total})", 'rel' => 'tag'));
// get the font size for the tag (taken from elgg's own tagcloud code - not sure I love this)
$size = round(log($key->total) / log($max + 0.0001) * 100) + 30;
if ($size < 100) {
$size = 100;
}
// generate the link
$content .= " <a href='{$url}' style='font-size:{$size}%'>" . $key->tag . "</a> ";
}
} else {
//show the results for the selected tag
$title = elgg_echo("au_group_tag_menu:title") . "{$tag}";
$options = array('type' => 'object', 'metadata_name' => 'tags', 'metadata_value' => $tag, 'container_guid' => $entity->guid, 'full_view' => false);
$content = elgg_list_entities_from_metadata($options);
}
//display the page
if (!$content) {
$content = elgg_echo('au_group_tag_menu:noresults');
}
$layout = elgg_view_layout('content', array('title' => elgg_view_title($title), 'content' => $content, 'filter' => false));
echo elgg_view_page($title, $layout);
break;
}
return true;
}
示例4: interactionsMenuSetup
/**
* Setups entity interactions menu
*
* @param string $hook "register"
* @param string $type "menu:interactions"
* @param array $menu Menu
* @param array $params Hook parameters
* @uses $params['entity'] An entity that we are interacting with
* @uses $params['active_tab'] Currently active tab, default to 'comments'
* @return array
*/
public static function interactionsMenuSetup($hook, $type, $menu, $params)
{
$entity = elgg_extract('entity', $params, false);
/* @var ElggEntity $entity */
if (!elgg_instanceof($entity)) {
return $menu;
}
$active_tab = elgg_extract('active_tab', $params);
// Commenting
$comments_count = $entity->countComments();
$can_comment = $entity->canComment();
if ($can_comment) {
$menu[] = ElggMenuItem::factory(array('name' => 'comments', 'text' => $entity instanceof Comment ? elgg_echo('interactions:reply:create') : elgg_echo('interactions:comment:create'), 'href' => "stream/comments/{$entity->guid}", 'priority' => 200, 'data-trait' => 'comments', 'item_class' => 'interactions-action'));
}
if ($can_comment || $comments_count) {
$menu[] = ElggMenuItem::factory(array('name' => 'comments:badge', 'text' => elgg_view('framework/interactions/elements/badge', array('entity' => $entity, 'icon' => 'comments', 'type' => 'comments', 'count' => $comments_count)), 'href' => "stream/comments/{$entity->guid}", 'selected' => $active_tab == 'comments', 'priority' => 100, 'data-trait' => 'comments', 'item_class' => 'interactions-tab'));
}
if (elgg_is_active_plugin('likes')) {
// Liking and unliking
$likes_count = $entity->countAnnotations('likes');
$can_like = $entity->canAnnotate(0, 'likes');
$does_like = elgg_annotation_exists($entity->guid, 'likes');
if ($can_like) {
$before_text = elgg_echo('interactions:likes:before');
$after_text = elgg_echo('interactions:likes:after');
$menu[] = ElggMenuItem::factory(array('name' => 'likes', 'text' => $does_like ? $after_text : $before_text, 'href' => "action/stream/like?guid={$entity->guid}", 'is_action' => true, 'priority' => 400, 'link_class' => 'interactions-state-toggler', 'item_class' => 'interactions-action', 'data-guid' => $entity->guid, 'data-trait' => 'likes', 'data-state' => $does_like ? 'after' : 'before'));
}
if ($can_like || $likes_count) {
$menu[] = ElggMenuItem::factory(array('name' => 'likes:badge', 'text' => elgg_view('framework/interactions/elements/badge', array('entity' => $entity, 'icon' => 'likes', 'type' => 'likes', 'count' => $likes_count)), 'href' => "stream/likes/{$entity->guid}", 'selected' => $active_tab == 'likes', 'data-trait' => 'likes', 'priority' => 300, 'item_class' => 'interactions-tab'));
}
}
return $menu;
}
示例5: cleanupBlogIcon
/**
* When a blog is removed also remove it's icons
*
* @param string $event 'delete'
* @param string $type 'object'
* @param ElggObject $object The ElggObject being removed
*
* @return void
*/
public static function cleanupBlogIcon($event, $type, $object)
{
if (!elgg_instanceof($object, "object", "blog", "ElggBlog")) {
return;
}
blog_tools_remove_blog_icon($object);
}
示例6: pages_get_navigation_tree
/**
* Produce the navigation tree
*
* @param ElggEntity $container Container entity for the pages
*
* @return array
*/
function pages_get_navigation_tree($container)
{
if (!elgg_instanceof($container)) {
return;
}
$top_pages = new ElggBatch('elgg_get_entities', array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => false));
/* @var ElggBatch $top_pages Batch of top level pages */
$tree = array();
$depths = array();
foreach ($top_pages as $page) {
$tree[] = array('guid' => $page->getGUID(), 'title' => $page->title, 'url' => $page->getURL(), 'depth' => 0);
$depths[$page->guid] = 0;
$stack = array();
array_push($stack, $page);
while (count($stack) > 0) {
$parent = array_pop($stack);
$children = new ElggBatch('elgg_get_entities_from_metadata', array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => false));
foreach ($children as $child) {
$tree[] = array('guid' => $child->getGUID(), 'title' => $child->title, 'url' => $child->getURL(), 'parent_guid' => $parent->getGUID(), 'depth' => $depths[$parent->guid] + 1);
$depths[$child->guid] = $depths[$parent->guid] + 1;
array_push($stack, $child);
}
}
}
return $tree;
}
示例7: testWriteAccessArray
/**
* https://github.com/Elgg/Elgg/pull/6393
* Hook handlers for 'access:collections:write','all' hook should respect
* group's content access mode and container write permissions
*/
public function testWriteAccessArray()
{
$membersonly = ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY;
$unrestricted = ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED;
$original_page_owner = elgg_get_page_owner_entity();
elgg_set_page_owner_guid($this->group->guid);
$ia = elgg_set_ignore_access(false);
// User is not a member of the group
// Member-only group
$this->group->setContentAccessMode($membersonly);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
// Unrestricted group
$this->group->setContentAccessMode($unrestricted);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
// User is a member (can write to container)
$this->group->join($this->user);
// Member-only group
$this->group->setContentAccessMode($membersonly);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
// Unrestricted group
$this->group->setContentAccessMode($unrestricted);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
elgg_set_ignore_access($ia);
$this->group->leave($this->user);
$original_page_owner_guid = elgg_instanceof($original_page_owner) ? $original_page_owner->guid : 0;
elgg_set_page_owner_guid($original_page_owner_guid);
}
示例8: group_tools_groupicon_page_handler
/**
* Take over the groupicon page handler for fallback
*
* @param array $page the url elements
*
* @return void
*/
function group_tools_groupicon_page_handler($page)
{
// group guid
if (!isset($page[0])) {
header("HTTP/1.1 400 Bad Request");
exit;
}
$group_guid = $page[0];
$group = get_entity($group_guid);
if (empty($group) || !elgg_instanceof($group, "group")) {
header("HTTP/1.1 400 Bad Request");
exit;
}
$owner_guid = $group->getOwnerGUID();
$icontime = (int) $group->icontime;
if (empty($icontime)) {
header("HTTP/1.1 404 Not Found");
exit;
}
// size
$size = "medium";
if (isset($page[1])) {
$icon_sizes = elgg_get_config("icon_sizes");
if (!empty($icon_sizes) && array_key_exists($page[1], $icon_sizes)) {
$size = $page[1];
}
}
$params = array("group_guid" => $group_guid, "guid" => $owner_guid, "size" => $size, "icontime" => $icontime);
$url = elgg_http_add_url_query_elements("mod/group_tools/pages/groups/thumbnail.php", $params);
forward($url);
}
示例9: simplesaml_login_event_handler
/**
* Take some actions during the login event of a user
*
* @param string $event 'login' is the event this function handles
* @param string $type 'user' is the type for this event
* @param ElggUser $object the current user trying to login
*
* @return void
*/
function simplesaml_login_event_handler($event, $type, $object)
{
if (empty($object) || !elgg_instanceof($object, "user")) {
return;
}
if (!isset($_SESSION["saml_attributes"]) || !isset($_SESSION["saml_source"])) {
return;
}
$saml_attributes = $_SESSION["saml_attributes"];
$source = $_SESSION["saml_source"];
if (!simplesaml_is_enabled_source($source)) {
return;
}
if (!simplesaml_validate_authentication_attributes($source, $saml_attributes)) {
return;
}
$saml_uid = elgg_extract("elgg:external_id", $saml_attributes);
if (!empty($saml_uid)) {
if (is_array($saml_uid)) {
$saml_uid = $saml_uid[0];
}
// save the external id so the next login will go faster
simplesaml_link_user($object, $source, $saml_uid);
}
// save the attributes to the user
simplesaml_save_authentication_attributes($object, $source, $saml_attributes);
// save source name for single logout
$_SESSION["saml_login_source"] = $source;
unset($_SESSION["saml_attributes"]);
unset($_SESSION["saml_source"]);
}
示例10: widget_manager_create_object_handler
/**
* Performs action when a widget is created
*
* @param string $event name of the system event
* @param string $object_type type of the event
* @param mixed $object object related to the event
*
* @return void
*/
function widget_manager_create_object_handler($event, $object_type, $object)
{
if (elgg_instanceof($object, "object", "widget", "ElggWidget")) {
$owner = $object->getOwnerEntity();
// Updates access for privately created widgets in a group or on site
if ((int) $object->access_id === ACCESS_PRIVATE) {
$old_ia = elgg_set_ignore_access();
if ($owner instanceof ElggGroup) {
$object->access_id = $owner->group_acl;
$object->save();
} elseif ($owner instanceof ElggSite) {
$object->access_id = ACCESS_PUBLIC;
$object->save();
}
elgg_set_ignore_access($old_ia);
}
// Adds a relation between a widget and a multidashboard object
$dashboard_guid = get_input("multi_dashboard_guid");
if ($dashboard_guid && widget_manager_multi_dashboard_enabled()) {
$dashboard = get_entity($dashboard_guid);
if (elgg_instanceof($dashboard, "object", MultiDashboard::SUBTYPE, "MultiDashboard")) {
add_entity_relationship($object->getGUID(), MultiDashboard::WIDGET_RELATIONSHIP, $dashboard->getGUID());
}
}
}
}
示例11: hj_forum_get_forum_category_input_options
function hj_forum_get_forum_category_input_options($entity = null, $container = null)
{
if ((elgg_instanceof($container, 'site') || elgg_instanceof($container, 'group')) && !HYPEFORUM_CATEGORIES_TOP) {
return false;
}
if (elgg_instanceof($container, 'object', 'hjforum') && !HYPEFORUM_CATEGORIES) {
return false;
}
if (!$entity && !$container) {
return false;
}
if (elgg_instanceof($container, 'object', 'hjforum') && !$container->enable_subcategories) {
return false;
}
$dbprefix = elgg_get_config('dbprefix');
$categories = elgg_get_entities(array('types' => 'object', 'subtypes' => 'hjforumcategory', 'limit' => 0, 'container_guids' => $container->guid, 'joins' => array("JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid"), 'order_by' => 'oe.title ASC'));
if ($categories) {
foreach ($categories as $category) {
$options_values[$category->guid] = $category->title;
}
if ($entity) {
$categories = $entity->getCategories('hjforumcategory');
$value = $categories[0]->guid;
}
$options = array('input_type' => 'dropdown', 'options_values' => $options_values, 'value' => $value);
} else {
if ($container->canWriteToContainer(0, 'object', 'hjforumcategory')) {
$options = array('input_type' => 'text', 'override_view' => 'output/url', 'text' => elgg_echo('hj:forum:create:category'), 'href' => "forum/create/category/{$container->guid}");
} else {
return false;
}
}
return $options;
}
示例12: groupTools
/**
* Add or remove widgets based on the group tool option
*
* @param string $hook 'group_tool_widgets'
* @param string $type 'widget_manager'
* @param array $return_value current enable/disable widget handlers
* @param array $params supplied params
*
* @return array
*/
public static function groupTools($hook, $type, $return_value, $params)
{
if (empty($params) || is_array($params)) {
return $return_value;
}
$entity = elgg_extract("entity", $params);
if (empty($entity) || !elgg_instanceof($entity, "group")) {
return $return_value;
}
if (!is_array($return_value)) {
$return_value = array();
}
if (!isset($return_value["enable"])) {
$return_value["enable"] = array();
}
if (!isset($return_value["disable"])) {
$return_value["disable"] = array();
}
// check different group tools for which we supply widgets
if ($entity->blog_enable == "yes") {
$return_value["enable"][] = "blog";
} else {
$return_value["disable"][] = "blog";
}
return $return_value;
}
示例13: elgg_solr_delete_entity
/**
* Delete entity event
*
* @param string $event "delete"
* @param string $type "object"|"group"|"user"
* @param ElggEntity $entity Entity
* @return void
*/
function elgg_solr_delete_entity($event, $type, $entity)
{
if (!elgg_instanceof($entity)) {
return;
}
if (!elgg_solr_is_registered_entity_type($entity->type, $entity->getSubtype())) {
return;
}
// if shutdown just do it, otherwise defer
if ($GLOBALS['shutdown_flag']) {
$client = elgg_solr_get_client();
$query = $client->createUpdate();
$query->addDeleteById($entity->guid);
$query->addCommit();
try {
$client->update($query);
} catch (Exception $ex) {
//something went wrong, lets cache the id and try again on cron
elgg_get_site_entity()->annotate('elgg_solr_delete_cache', $entity->guid, ACCESS_PUBLIC);
elgg_solr_debug_log($ex->getMessage());
}
} else {
elgg_solr_defer_index_delete($entity->guid);
}
}
示例14: au_landing_page_update
function au_landing_page_update($event, $type, $object)
{
if (!elgg_instanceof($object, 'page') && elgg_instanceof($object, 'page_top')) {
return true;
}
// only process this event once
if (elgg_get_config('page_update_notify_sent_' . $object->guid)) {
return true;
}
elgg_set_config('page_update_notify_sent_' . $object->guid, true);
// get revision history for the page
$revisions = $object->getAnnotations(array('annotation_name' => 'page', 'limit' => false));
// create an array of unique users to notify, excluding the current user
// and the object owner (as core notifies them)
$users = array();
foreach ($revisions as $revision) {
if ($revision->owner_guid != $object->owner_guid && $revision->owner_guid != elgg_get_logged_in_user_guid()) {
$users[] = $revision->owner_guid;
}
}
$users = array_unique($users);
// notify the users
if (count($users)) {
notify_user($users, elgg_get_logged_in_user_guid(), elgg_echo('au_landing:page:update:subject', array($object->title)), elgg_echo('au_landing:page:update:message', array($object->title, elgg_get_logged_in_user_entity()->name, $object->getURL())));
}
}
示例15: au_landing_subgroups_access
function au_landing_subgroups_access($group, $user, $limit, $returnvalue = array(), $depth = 0)
{
if (!elgg_instanceof($group, 'group')) {
return $returnvalue;
}
if (!elgg_instanceof($user, 'user')) {
return $returnvalue;
}
$depth++;
$children = \AU\SubGroups\get_subgroups($group, 0, true);
if (is_array($children) && count($children)) {
foreach ($children as $child) {
if ($child->isMember($user)) {
// it's a valid subgroup that we're a member of, add it to the access list
$label = '';
for ($i = 0; $i < min($depth, $limit); $i++) {
$label .= '--';
}
$label .= $child->name;
unset($returnvalue[$child->group_acl]);
//necessary because it may already be set in the wrong tree
$returnvalue[$child->group_acl] = $label;
$returnvalue = au_landing_subgroups_access($child, $user, $limit, $returnvalue, $depth);
}
}
}
return $returnvalue;
}