本文整理汇总了PHP中elgg_get_entities_from_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_entities_from_metadata函数的具体用法?PHP elgg_get_entities_from_metadata怎么用?PHP elgg_get_entities_from_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_entities_from_metadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: routeAll
/**
* Check if requested page is a static page
*
* @param string $hook name of the hook
* @param string $type type of the hook
* @param array $return_value return value
* @param array $params hook parameters
*
* @return array
*/
public static function routeAll($hook, $type, $return_value, $params)
{
if (!is_array($return_value)) {
// someone else already routed this page
return;
}
/**
* $return_value contains:
* $return_value['identifier'] => requested handler
* $return_value['segments'] => url parts ($page)
*/
$identifier = elgg_extract('identifier', $return_value);
if (empty($identifier)) {
return;
}
$handlers = _elgg_services()->router->getPageHandlers();
if (elgg_extract($identifier, $handlers)) {
return;
}
$ia = elgg_set_ignore_access(true);
$entities = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => 1, 'metadata_name_value_pairs' => ['friendly_title' => $identifier], 'metadata_case_sensitive' => false]);
elgg_set_ignore_access($ia);
if (empty($entities)) {
return;
}
$entity = $entities[0];
if (!has_access_to_entity($entity) && !$entity->canEdit()) {
return;
}
$return_value['segments'] = ['view', $entity->getGUID()];
$return_value['identifier'] = 'static';
return $return_value;
}
示例2: getFolders
private function getFolders($parent, $limit = 100, $offset = 0, $count = false)
{
$dbprefix = elgg_get_config("dbprefix");
$options = array('type' => 'object', 'subtype' => 'folder', 'limit' => $limit, 'offset' => $offset);
if (!$count) {
$options['joins'] = "JOIN {$dbprefix}objects_entity oe ON e.guid = oe.guid";
$options['order_by'] = 'oe.title ASC';
} else {
$options['count'] = true;
}
if ($parent) {
if ($parent instanceof ElggUser | $parent instanceof ElggGroup) {
$options['container_guid'] = $parent->guid;
$options['metadata_name_value_pairs'] = array(array('name' => 'parent_guid', 'value' => 0));
} else {
$options['container_guid'] = $parent->container_guid;
$options['metadata_name_value_pairs'] = array(array('name' => 'parent_guid', 'value' => $parent->guid));
}
return elgg_get_entities_from_metadata($options);
} else {
if (!$count) {
return array();
} else {
return 0;
}
}
}
示例3: getGroup
/**
* @SWG\Get(
* path="/api/groups/{guid}/events",
* security={{"oauth2": {"all"}}},
* tags={"events"},
* summary="Find events in a specific group.",
* description="Find the most recent events from a specific group.",
* produces={"application/json"},
* @SWG\Parameter(
* name="guid",
* in="path",
* description="The guid of the specific group",
* required=true,
* type="integer",
* @SWG\Items(type="integer")
* ),
* @SWG\Parameter(
* name="offset",
* in="query",
* description="Offset the results by",
* default=0,
* required=false,
* type="integer",
* @SWG\Items(type="integer")
* ),
* @SWG\Parameter(
* name="limit",
* in="query",
* description="Limit the results by",
* default=20,
* required=false,
* type="integer",
* @SWG\Items(type="integer")
* ),
* @SWG\Response(
* response=200,
* description="Succesful operation.",
* @SWG\Schema(
* type="array",
* @SWG\Items(ref="#/definitions/Event")
* ),
* ),
* @SWG\Response(
* response="404",
* description="Could not find the requested event.",
* )
* )
*/
public function getGroup($request, $response, $args)
{
$currentUser = elgg_get_logged_in_user_entity();
$guid = (int) $args['guid'];
$group = get_entity($guid);
if (!$group | !$group instanceof \ElggGroup) {
return $response->withStatus(404);
}
$params = $request->getQueryParams();
$limit = (int) $params['limit'];
$offset = (int) $params['offset'];
if (!$limit | $limit < 0 | $limit > 50) {
$limit = 20;
}
$dbprefix = elgg_get_config("dbprefix");
$options = array('type' => 'object', 'subtype' => 'event', 'offset' => $offset, 'limit' => $limit, 'container_guid' => $group->guid, 'metadata_name_value_pairs' => array(array('name' => 'start_day', 'operand' => '>=', 'value' => mktime(0, 0, 1))), 'order_by_metadata' => array('name' => 'start_day', 'direction' => 'ASC', 'as' => 'integer'));
$entities = array();
foreach (elgg_get_entities_from_metadata($options) as $entity) {
$entities[] = $this->parseEvent($entity);
}
$options['count'] = true;
$total = elgg_get_entities_from_metadata($options);
$response = $response->withHeader('Content-type', 'application/json');
return $response->write(json_encode(array('total' => $total, 'entities' => $entities), JSON_PRETTY_PRINT));
}
示例4: notifications_editor_get_template_entity
/**
* Returns an entity template
*
* @param string $template_name Template name
* @param string $language Language
* @return Template|false
*/
function notifications_editor_get_template_entity($template_name, $language = 'en')
{
$templates = elgg_get_entities_from_metadata(array('types' => 'object', 'subtypes' => Template::SUBTYPE, 'metadata_name_value_pairs' => array(array('name' => 'template', 'value' => $template_name), array('name' => 'language', 'value' => $language)), 'limit' => 1));
if ($templates) {
return $templates[0];
}
$template_parts = explode(':', $template_name);
array_unshift($template_parts, 'notifications');
$template_folder = implode('/', $template_parts);
$template = new Template();
$template->subject = elgg_view("{$template_folder}/subject.{$language}.html");
if (!$template->subject && $language != 'en') {
$template->subject = elgg_view("{$template_folder}/subject.en.html");
}
$template->summary = elgg_view("{$template_folder}/summary.{$language}.html");
if (!$template->summary && $language != 'en') {
$template->summary = elgg_view("{$template_folder}/summary.en.html");
}
$template->body = elgg_view("{$template_folder}/body.{$language}.html");
if (!$template->body && $language != 'en') {
$template->body = elgg_view("{$template_folder}/body.en.html");
}
$template->template_folder = $template_folder;
$template->template = $template_name;
$template->language = $language;
return $template;
}
示例5: batch_delete_images
function batch_delete_images()
{
// delete
$log = elgg_get_config('mfp_log');
$log_time = elgg_get_config('mfp_logtime');
$options = array('type' => 'object', 'subtype' => 'image', 'metadata_name_value_pairs' => array('name' => 'mfp_delete_check', 'value' => $log_time), 'limit' => 0);
$images = new ElggBatch('elgg_get_entities_from_metadata', $options);
$images->setIncrementOffset(false);
$total = elgg_get_entities_from_metadata(array_merge($options, array('count' => true)));
file_put_contents($log, "Starting deletion of {$total} images" . "\n", FILE_APPEND);
$i = 0;
$count = 0;
foreach ($images as $image) {
$count++;
if ($image->delete()) {
$i++;
}
if ($count == 1 || !($count % 25)) {
$time = date('m/d/Y g:i:s a');
$j = $count - $i;
$message = "Deleted {$i}, skipped {$j}, of {$total} images as of {$time}";
file_put_contents($log, $message . "\n", FILE_APPEND);
}
}
$message = '<div class="done">Completed: Deleted ' . $i . ', skipped ' . $j . ', of ' . $total . '</div>';
file_put_contents($log, $message . "\n", FILE_APPEND);
}
示例6: group_get_groups
/**
* Web service to retrieve list of groups
*
* @param string $username Username
* @param string $limit Number of users to return
* @param string $offset Indexing offset, if any
*
* @return array
*/
function group_get_groups($context, $username, $limit, $offset)
{
if (!$username) {
$user = get_loggedin_user();
} else {
$user = get_user_by_username($username);
}
if ($context == "all") {
$groups = elgg_get_entities(array('types' => 'group', 'limit' => $limit, 'full_view' => FALSE));
}
if ($context == "mine" || $context == "user") {
$groups = $user->getGroups();
}
if ($context == "owned") {
$groups = elgg_get_entities(array('types' => 'group', 'owner_guid' => $user->guid, 'limit' => $limit, 'full_view' => FALSE));
}
if ($context == "featured") {
$groups = elgg_get_entities_from_metadata(array('metadata_name' => 'featured_group', 'metadata_value' => 'yes', 'types' => 'group', 'limit' => 10));
}
if ($groups) {
foreach ($groups as $single) {
$group['guid'] = $single->guid;
$group['name'] = $single->name;
$group['members'] = count($single->getMembers($limit = 0));
$group['avatar_url'] = get_entity_icon_url($single, 'small');
$return[] = $group;
}
} else {
$msg = elgg_echo('groups:none');
throw new InvalidParameterException($msg);
}
return $return;
}
示例7: hflts_page_handler
function hflts_page_handler($page)
{
if (elgg_extract(0, $page) === 'collective') {
$content = elgg_view('hflts/collective', array('nAlternativas' => $page[1], 'nCriterios' => $page[2], 'nExpertos' => $page[3], 'G' => $page[4], 'import_file' => $page[5], 'weight_file' => $page[6]));
$params = array('title' => 'DM con datos de samples/set_' . $page[5] . '.csv (' . $page[6] . ')', 'content' => $content, 'filter' => '');
$body = elgg_view_layout('content', $params);
echo elgg_view_page('hflts', $body);
return true;
}
set_input('username', $page[0]);
//necesario
$user = elgg_get_page_owner_entity();
// ej strem
$guid = elgg_get_page_owner_guid();
// id de strem
//aqui es donde tengo que filtrar por guid como en https://elgg.org/discussion/view/2268999/doubt-in-elgg-get-entities-from-metadata
$valorations = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => 'evaluation_content', 'metadata_name_value_pairs' => array('name' => 'user_guid', 'value' => $guid), 'limit' => $vars['entity']->num_display, 'pagination' => false, 'order_by_metadata' => ['name' => 'state', 'direction' => 'ASC', 'as' => 'text']]);
if (!$valorations) {
$valorations = '<p class="mtm">' . elgg_echo('evaluationcontent:none') . '</p>';
}
$content = elgg_view('hflts/driver', array('valorations' => $valorations));
$params = array('title' => 'Valoraciones de ' . $user->name, 'content' => $content, 'filter' => '');
$body = elgg_view_layout('content', $params);
echo elgg_view_page('hflts', $body);
}
示例8: moveToPosition
/**
* Reorders todo to new position
*
* @param int $offset new position
*
* @return void
*/
public function moveToPosition($offset)
{
$current_order = $this->order;
$options = array('type' => 'object', 'subtype' => $this::SUBTYPE, 'container_guid' => $this->container_guid, 'order_by_metadata' => array('name' => 'order', 'direction' => 'ASC', 'as' => 'integer'), 'limit' => false);
$entities = elgg_get_entities_from_metadata($options);
if (empty($entities)) {
// nothing to do
return;
}
$current_pos_entity = elgg_extract($offset, $entities);
if (!$current_pos_entity) {
return;
}
$new_order = $current_pos_entity->order;
$forward = false;
if ($current_order < $new_order) {
$forward = true;
}
$this->order = $new_order;
foreach ($entities as $entity) {
if ($entity->guid == $this->guid) {
continue;
}
if ($forward) {
if ($entity->order <= $new_order) {
$entity->order--;
}
} else {
if ($entity->order >= $new_order) {
$entity->order++;
}
}
}
}
示例9: 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 (!$container) {
return;
}
$top_pages = elgg_get_entities(array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => 0));
if (!$top_pages) {
return;
}
/* @var ElggObject[] $top_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 = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => 0));
if ($children) {
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;
}
示例10: get_likerating_byannotation
function get_likerating_byannotation($annotation_guid, $limit = 50)
{
$subtypeArray = array('like_rate');
$options = array('metadata_name' => "annotation_guid", 'metadata_value' => $annotation_guid, 'type' => 'object', 'subtypes' => $subtypeArray, 'limit' => $limit, 'offset' => $offset);
$list_object = elgg_get_entities_from_metadata($options);
return $list_object;
}
示例11: community_spam_messages_throttle
/**
* ban user if sending too many messages
*
* @param string $event
* @param string $type
* @param ElggObject $object
* @return bool
*/
function community_spam_messages_throttle($event, $type, $object)
{
if ($object->getSubtype() !== 'messages') {
return;
}
if (community_spam_is_new_user()) {
$msg_limit = elgg_get_plugin_setting('new_user_msg_limit', 'community_spam_tools');
} else {
$msg_limit = elgg_get_plugin_setting('msg_limit', 'community_spam_tools');
}
if (!$msg_limit) {
return;
}
// two message objects created per message but after they are saved,
// both are set to private so we only have access to one later on
$msg_limit = $msg_limit + 1;
$params = array('type' => 'object', 'subtype' => 'messages', 'created_time_lower' => time() - 5 * 60, 'metadata_names' => 'fromId', 'metadata_values' => elgg_get_logged_in_user_guid(), 'count' => true);
$num_msgs = elgg_get_entities_from_metadata($params);
if ($num_msgs > $msg_limit) {
$spammer = elgg_get_logged_in_user_entity();
$spammer->annotate('banned', 1);
// this integrates with ban plugin
$spammer->ban("Sent {$num_msgs} in 5 minutes");
return false;
}
}
示例12: pages_draw_child
function pages_draw_child($childentity, $path)
{
$child = "\n\t\t{\n";
$child .= "\t\t\t\"text\": \"<a href=\\\"{$childentity->getURL()}\\\">" . addslashes($childentity->title) . "</a>\"\n";
$extras = "";
$haschild = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $childentity->guid, 'limit' => 9999));
if ($haschild) {
if (in_array($childentity->guid, $path)) {
$extras .= "\t\t\t,\"expanded\": true";
$extras .= "\t\t\t,\"children\": [\n";
$childstring = "";
foreach ($haschild as $subchild) {
$childstringtemp = pages_draw_child($subchild, $path);
if (!empty($childstringtemp)) {
if (!empty($childstring)) {
$childstring .= ", ";
}
$childstring .= $childstringtemp;
}
}
$extras .= $childstring . "\n\t\t\t]\n";
} else {
$extras .= ",\t\t\t\"id\": \"{$childentity->getGUID()}\",\n\t\t\t\"hasChildren\": true\n";
}
}
$child .= $extras . "\t\t}";
return $child;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:28,代码来源:sidebarthis.php
示例13: testElggGetEntitiesFromMetadata
public function testElggGetEntitiesFromMetadata()
{
global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
$METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array();
$this->object->title = 'Meta Unit Test';
$this->object->save();
$this->create_metastring('metaUnitTest');
$this->create_metastring('tested');
// create_metadata returns id of metadata on success
$this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
// check value with improper case
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
$this->assertFalse(elgg_get_entities_from_metadata($options));
// compare forced case with ignored case
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
$case_true = elgg_get_entities_from_metadata($options);
$this->assertIsA($case_true, 'array');
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => FALSE);
$case_false = elgg_get_entities_from_metadata($options);
$this->assertIsA($case_false, 'array');
$this->assertIdentical($case_true, $case_false);
// check deprecated get_entities_from_metadata() function
$deprecated = get_entities_from_metadata('metaUnitTest', 'tested', '', '', 0, 10, 0, '', 0, FALSE, TRUE);
$this->assertIdentical($deprecated, $case_true);
// check entity list
//$this->dump(list_entities_from_metadata('metaUnitTest', 'Tested', '', '', 0, 10, TRUE, TRUE, TRUE, FALSE));
// clean up
$this->delete_metastrings();
$this->object->delete();
}
示例14: pleiofile_add_folder_to_zip
function pleiofile_add_folder_to_zip(ZipArchive &$zip_archive, ElggObject $folder, $folder_path = "")
{
if (!empty($zip_archive) && !empty($folder) && elgg_instanceof($folder, "object", "folder")) {
$folder_title = elgg_get_friendly_title($folder->title);
$zip_archive->addEmptyDir($folder_path . $folder_title);
$folder_path .= $folder_title . DIRECTORY_SEPARATOR;
$file_options = array("type" => "object", "subtype" => "file", "limit" => false, "relationship" => "folder_of", "relationship_guid" => $folder->getGUID());
// add files from this folder to the zip
if ($files = elgg_get_entities_from_relationship($file_options)) {
foreach ($files as $file) {
// check if the file exists
if ($zip_archive->statName($folder_path . $file->originalfilename) === false) {
// doesn't exist, so add
$zip_archive->addFile($file->getFilenameOnFilestore(), $folder_path . sanitize_file_name($file->originalfilename));
} else {
// file name exists, so create a new one
$ext_pos = strrpos($file->originalfilename, ".");
$file_name = substr($file->originalfilename, 0, $ext_pos) . "_" . $file->getGUID() . substr($file->originalfilename, $ext_pos);
$zip_archive->addFile($file->getFilenameOnFilestore(), $folder_path . sanitize_file_name($file_name));
}
}
}
// check if there are subfolders
$folder_options = array("type" => "object", "subtype" => "folder", "limit" => false, "metadata_name_value_pairs" => array("parent_guid" => $folder->getGUID()));
if ($sub_folders = elgg_get_entities_from_metadata($folder_options)) {
foreach ($sub_folders as $sub_folder) {
pleiofile_add_folder_to_zip($zip_archive, $sub_folder, $folder_path);
}
}
}
}
示例15: file_tools_object_handler_delete
function file_tools_object_handler_delete($event, $type, $object)
{
static $delete_files;
if (!empty($object) && elgg_instanceof($object, "object", FILE_TOOLS_SUBTYPE)) {
// find subfolders
$options = array("type" => "object", "subtype" => FILE_TOOLS_SUBTYPE, "container_guid" => $object->getContainerGUID(), "limit" => false, "metadata_name_value_pairs" => array("name" => "parent_guid", "value" => $object->getGUID()), "wheres" => array("(e.guid <> " . $object->getGUID() . ")"));
if ($subfolders = elgg_get_entities_from_metadata($options)) {
// delete subfolders
foreach ($subfolders as $subfolder) {
$subfolder->delete();
}
}
// fill the static, to delete files in a folder
if (!isset($delete_files)) {
$delete_files = false;
if (get_input("files") == "yes") {
$delete_files = true;
}
}
// should we remove files?
if ($delete_files) {
// find file in this folder
$options = array("type" => "object", "subtype" => "file", "container_guid" => $object->getContainerGUID(), "limit" => false, "relationship" => FILE_TOOLS_RELATIONSHIP, "relationship_guid" => $object->getGUID());
if ($files = elgg_get_entities_from_relationship($options)) {
// delete files in folder
foreach ($files as $file) {
$file->delete();
}
}
}
}
}