当前位置: 首页>>代码示例>>PHP>>正文


PHP get_entity函数代码示例

本文整理汇总了PHP中get_entity函数的典型用法代码示例。如果您正苦于以下问题:PHP get_entity函数的具体用法?PHP get_entity怎么用?PHP get_entity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_entity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bookmark_tools_get_folders

function bookmark_tools_get_folders($container_guid = 0)
{
    $result = false;
    if (empty($container_guid)) {
        $container_guid = elgg_get_page_owner_guid();
    }
    if (!empty($container_guid)) {
        $options = array("type" => "object", "subtype" => BOOKMARK_TOOLS_SUBTYPE, "container_guid" => $container_guid, "limit" => false);
        if ($folders = elgg_get_entities($options)) {
            $parents = array();
            foreach ($folders as $folder) {
                $parent_guid = (int) $folder->parent_guid;
                if (!empty($parent_guid)) {
                    if ($temp = get_entity($parent_guid)) {
                        if ($temp->getSubtype() != BOOKMARK_TOOLS_SUBTYPE) {
                            $parent_guid = 0;
                        }
                    } else {
                        $parent_guid = 0;
                    }
                } else {
                    $parent_guid = 0;
                }
                if (!array_key_exists($parent_guid, $parents)) {
                    $parents[$parent_guid] = array();
                }
                $parents[$parent_guid][] = $folder;
            }
            $result = bookmark_tools_sort_folders($parents, 0);
        }
    }
    return $result;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:33,代码来源:functions.php

示例2: createWidget

 /**
  * @see elgg_create_widget
  * @access private
  * @since 1.9.0
  */
 public function createWidget($owner_guid, $handler, $context, $access_id = null)
 {
     if (empty($owner_guid) || empty($handler) || !$this->validateType($handler)) {
         return false;
     }
     $owner = get_entity($owner_guid);
     if (!$owner) {
         return false;
     }
     $widget = new \ElggWidget();
     $widget->owner_guid = $owner_guid;
     $widget->container_guid = $owner_guid;
     // @todo - will this work for group widgets?
     if (isset($access_id)) {
         $widget->access_id = $access_id;
     } else {
         $widget->access_id = get_default_access();
     }
     if (!$widget->save()) {
         return false;
     }
     // private settings cannot be set until \ElggWidget saved
     $widget->handler = $handler;
     $widget->context = $context;
     return $widget->getGUID();
 }
开发者ID:cyrixhero,项目名称:Elgg,代码行数:31,代码来源:WidgetsService.php

示例3: subsite_manager_siteid_hook

function subsite_manager_siteid_hook($hook, $type, $return, $params)
{
    global $SUBSITE_MANAGER_CUSTOM_DOMAIN;
    $result = false;
    elgg_register_classes(dirname(__FILE__) . "/classes/");
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "") {
        $protocol = "https";
    } else {
        $protocol = "http";
    }
    if (strpos($_SERVER["HTTP_HOST"], "www.") === 0) {
        $alt_host = str_replace("www.", "", $_SERVER["HTTP_HOST"]);
    } else {
        $alt_host = "www." . $_SERVER["HTTP_HOST"];
    }
    $url = $protocol . "://" . $_SERVER["HTTP_HOST"] . "/";
    $alt_url = $protocol . "://" . $alt_host . "/";
    if ($site = get_site_by_url($url)) {
        $result = $site->getGUID();
    } elseif ($site = get_site_by_url($alt_url)) {
        $result = $site->getGUID();
    } else {
        // no site found, forward to main site
        $default_site_guid = (int) datalist_get("default_site");
        $default_site = get_entity($default_site_guid);
        forward($default_site->url);
    }
    return $result;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:29,代码来源:system.php

示例4: odt_editor_page_handler

/**
 * Dispatches odt_editor pages.
 * URLs take the form of
 *  Save as:       odt_editor/saveas/<guid>
 *
 * @param array $page
 * @return bool
 */
function odt_editor_page_handler($page)
{
    $odt_editor_pages_dir = elgg_get_plugins_path() . 'odt_editor/pages';
    $page_type = $page[0];
    switch ($page_type) {
        case 'saveas':
            set_input('guid', $page[1]);
            include "{$odt_editor_pages_dir}/odt_editor/saveas.php";
            break;
        case 'create':
            $container = get_entity($page[1]);
            if (!$container) {
                $container = get_loggedin_userid();
            }
            // show new document in WebODF editor page
            // 0 as indicator for new document
            set_input('guid', 0);
            set_input('container_guid', $page[1]);
            include "{$odt_editor_pages_dir}/file/odt_editor.php";
            $result = false;
            break;
        case 'gettemplate':
            include "{$odt_editor_pages_dir}/odt_editor/gettemplate.php";
            break;
        default:
            return false;
    }
    return true;
}
开发者ID:pleio,项目名称:odt_editor,代码行数:37,代码来源:page_handlers.php

示例5: recursive_breadcrumb

/**
 * View a single blogbook
 *
 * @package Elggtblogs
 */
function recursive_breadcrumb($tblog)
{
    if ($tblog->parent_guid != '') {
        recursive_breadcrumb(get_entity($tblog->parent_guid));
    }
    elgg_push_breadcrumb($tblog->title, "/blogbook/view/{$tblog->guid}");
}
开发者ID:mustafabicer,项目名称:elggplugins,代码行数:12,代码来源:view.php

示例6: registerUserHover

 /**
  * Adds menu items to the user hover menu
  *
  * @param string $hook        hook name
  * @param string $entity_type hook type
  * @param array  $returnvalue current return value
  * @param array  $params      parameters
  *
  * @return array
  */
 public static function registerUserHover($hook, $entity_type, $returnvalue, $params)
 {
     $guid = get_input('guid');
     $user = elgg_extract('entity', $params);
     if (empty($guid) || empty($user)) {
         return;
     }
     $event = get_entity($guid);
     if (!$event instanceof \Event) {
         return;
     }
     if (!$event->canEdit()) {
         return;
     }
     $result = $returnvalue;
     // kick from event (assumes users listed on the view page of an event)
     $href = 'action/event_manager/event/rsvp?guid=' . $event->getGUID() . '&user=' . $user->getGUID() . '&type=' . EVENT_MANAGER_RELATION_UNDO;
     $item = \ElggMenuItem::factory(['name' => 'event_manager_kick', 'text' => elgg_echo('event_manager:event:relationship:kick'), 'href' => $href, 'is_action' => true, 'section' => 'action']);
     $result[] = $item;
     $user_relationship = $event->getRelationshipByUser($user->getGUID());
     if ($user_relationship == EVENT_MANAGER_RELATION_ATTENDING_PENDING) {
         // resend confirmation
         $href = 'action/event_manager/event/resend_confirmation?guid=' . $event->getGUID() . '&user=' . $user->getGUID();
         $item = \ElggMenuItem::factory(['name' => 'event_manager_resend_confirmation', 'text' => elgg_echo("event_manager:event:menu:user_hover:resend_confirmation"), 'href' => $href, 'is_action' => true, 'section' => 'action']);
         $result[] = $item;
     }
     if (in_array($user_relationship, [EVENT_MANAGER_RELATION_ATTENDING_PENDING, EVENT_MANAGER_RELATION_ATTENDING_WAITINGLIST])) {
         // move to attendees
         $href = 'action/event_manager/attendees/move_to_attendees?guid=' . $event->getGUID() . '&user=' . $user->getGUID();
         $item = \ElggMenuItem::factory(['name' => 'event_manager_move_to_attendees', 'text' => elgg_echo('event_manager:event:menu:user_hover:move_to_attendees'), 'href' => $href, 'is_action' => true, 'section' => 'action']);
         $result[] = $item;
     }
     return $result;
 }
开发者ID:coldtrick,项目名称:event_manager,代码行数:44,代码来源:Menus.php

示例7: anypage_widgets_convert

/**
 * Anypage Widgets convert
 *
 * Convers a description/text into content with widgets.
 * It replaces BBCode tags with content from widgets, for example:
 * [WIDGET:home]
 *
 * @param string $description Description to transform
 *
 * @return string Transformed description
 */
function anypage_widgets_convert($description)
{
    return preg_replace_callback('/\\[WIDGET:[^]]+\\]/', function ($matches) {
        $paramsString = substr(strip_tags($matches[0]), 8, -1);
        $params = (array) explode(':', $paramsString);
        if (!isset($params[0])) {
            return 'Widget ID not defined.';
        }
        $widget = get_entity($params[0]);
        if (!myvox_instanceof($widget, 'object', 'widget')) {
            return 'Widget not found.';
        }
        $style = '';
        foreach ($params as $param) {
            $subparam = explode('|', $param);
            switch ($subparam[0]) {
                case 'style':
                    if (isset($subparam[1]) && isset($subparam[2])) {
                        $style .= $subparam[1] . ': ' . $subparam[2] . ';';
                    }
                    break;
            }
        }
        return myvox_view('anypage_widgets/widget', array('body' => myvox_view_entity($widget), 'style' => $style));
    }, $description);
}
开发者ID:centillien,项目名称:anypage_widgets,代码行数:37,代码来源:start.php

示例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);
}
开发者ID:n8b,项目名称:VMN,代码行数:38,代码来源:page_handlers.php

示例9: post

 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     $user = elgg_get_logged_in_user_entity();
     $object = get_entity($params->guid);
     if (!$object || !$object->canWriteToContainer(0, 'object', 'comment')) {
         throw new GraphException("You are not allowed to comment on this object", 403);
     }
     $comment_text = $params->comment;
     $comment = new ElggComment();
     $comment->owner_guid = $user->guid;
     $comment->container_guid = $object->guid;
     $comment->description = $comment_text;
     $comment->access_id = $object->access_id;
     if (!$comment->save()) {
         throw new GraphException(elgg_echo("generic_comment:failure"));
     }
     // Notify if poster wasn't owner
     if ($object->owner_guid != $user->guid) {
         $owner = $object->getOwnerEntity();
         notify_user($owner->guid, $user->guid, elgg_echo('generic_comment:email:subject', array(), $owner->language), elgg_echo('generic_comment:email:body', array($object->title, $user->name, $comment->description, $comment->getURL(), $user->name, $user->getURL()), $owner->language), array('object' => $comment, 'action' => 'create'));
     }
     $return = array('nodes' => array('comment' => $comment));
     // Add to river
     $river_id = elgg_create_river_item(array('view' => 'river/object/comment/create', 'action_type' => 'comment', 'subject_guid' => $user->guid, 'object_guid' => $comment->guid, 'target_guid' => $object->guid));
     if ($river_id) {
         $river = elgg_get_river(array('ids' => $river_id));
         $return['nodes']['activity'] = $river ? $river[0] : $river_id;
     }
     return $return;
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:33,代码来源:ObjectComments.php

示例10: phpmailer_extract_from_email

/**
 * Determine the best from email address
 *
 * @return string with email address
 */
function phpmailer_extract_from_email()
{
    global $CONFIG;
    $from_email = '';
    $site = get_entity($CONFIG->site_guid);
    // If there's an email address, use it - but only if its not from a user.
    if (isset($from->email) && !$from instanceof ElggUser) {
        $from_email = $from->email;
        // Has the current site got a from email address?
    } else {
        if ($site && isset($site->email)) {
            $from_email = $site->email;
            // If we have a url then try and use that.
        } else {
            if (isset($from->url)) {
                $breakdown = parse_url($from->url);
                $from_email = 'noreply@' . $breakdown['host'];
                // Handle anything with a url
                // If all else fails, use the domain of the site.
            } else {
                $from_email = 'noreply@' . get_site_domain($CONFIG->site_guid);
            }
        }
    }
    return $from_email;
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:31,代码来源:start.php

示例11: badges_userpoints

/**
 * This method is called when a users points are updated.
 * We check to see what the users current balance is and
 * assign the appropriate badge.
 */
function badges_userpoints($hook, $type, $return, $params)
{
    if ($params['entity']->badges_locked) {
        return true;
    }
    $points = $params['entity']->userpoints_points;
    $badge = get_entity($params['entity']->badges_badge);
    $options = array('type' => 'object', 'subtype' => 'badge', 'limit' => false, 'order_by_metadata' => array('name' => 'badges_userpoints', 'direction' => DESC, 'as' => integer));
    $options['metadata_name_value_pairs'] = array(array('name' => 'badges_userpoints', 'value' => $points, 'operand' => '<='));
    $entities = elgg_get_entities_from_metadata($options);
    if ((int) elgg_get_plugin_setting('lock_high', 'elggx_badges')) {
        if ($badge->badges_userpoints > $entities[0]->badges_userpoints) {
            return true;
        }
    }
    if ($badge->guid != $entities[0]->guid) {
        $params['entity']->badges_badge = $entities[0]->guid;
        if (!elgg_trigger_plugin_hook('badges:update', 'object', array('entity' => $user), true)) {
            $params['entity']->badges_badge = $badge->guid;
            return false;
        }
        // Announce it on the river
        $user_guid = $params['entity']->getGUID();
        elgg_delete_river(array("view" => 'river/object/badge/assign', "subject_guid" => $user_guid, "object_guid" => $user_guid));
        elgg_delete_river(array("view" => 'river/object/badge/award', "subject_guid" => $user_guid, "object_guid" => $user_guid));
        elgg_create_river_item(array('view' => 'river/object/badge/award', 'action_type' => 'award', 'subject_guid' => $user_guid, 'object_guid' => $user_guid));
    }
    return true;
}
开发者ID:iionly,项目名称:elggx_badges,代码行数:34,代码来源:start.php

示例12: renderURLHTML

 public static function renderURLHTML($url)
 {
     $favicon = "http://g.etfv.co/{$url}";
     if (class_exists('UFCOE\\Elgg\\Url')) {
         $sniffer = new Url();
         $guid = $sniffer->getGuid($url);
         if ($entity = get_entity($guid)) {
             $favicon = $entity->getIconURL('tiny');
             if (elgg_instanceof($entity->user)) {
                 $text = "@{$entity->username}";
             } else {
                 $text = isset($entity->name) ? $entity->name : $entity->title;
             }
         }
     }
     if (!$text) {
         $embedder = new Embedder($url);
         $meta = $embedder->extractMeta('oembed');
         if ($meta->title) {
             $text = $meta->title;
         } else {
             $text = elgg_get_excerpt($url, 35);
         }
     }
     return elgg_view('output/url', array('text' => "<span class=\"favicon\" style=\"background-image:url({$favicon})\"></span><span class=\"link\">{$text}</span>", 'href' => $url, 'class' => 'extractor-link'));
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:26,代码来源:Extractor.php

示例13: elgg_tokeninput_explode_field_values

/**
 * Unserialize tokeninput field values before performing an action
 */
function elgg_tokeninput_explode_field_values($hook, $type, $return, $params)
{
    $elgg_tokeninput_fields = (array) get_input('elgg_tokeninput_fields', array());
    $elgg_tokneinput_autocomplete = (array) get_input('elgg_tokeninput_autocomplete', array());
    if (!empty($elgg_tokeninput_fields)) {
        foreach ($elgg_tokeninput_fields as $field_name) {
            $values = explode(',', get_input($field_name, ''));
            if (in_array($field_name, $elgg_tokneinput_autocomplete)) {
                foreach ($values as $key => $value) {
                    $user = get_entity($value);
                    if ($user instanceof ElggUser) {
                        $values[$key] = $user->username;
                    }
                }
                if (sizeof($values) === 1) {
                    $values = array_values($values)[0];
                }
            }
            set_input($field_name, $values);
        }
    }
    set_input('elgg_tokeninput_fields', null);
    set_input('elgg_tokeninput_autocomplete', null);
    return $return;
}
开发者ID:n8b,项目名称:VMN,代码行数:28,代码来源:start.php

示例14: getResponse

 /**
  * Handle a request for a file
  *
  * @param Request $request HTTP request
  * @return Response
  */
 public function getResponse($request)
 {
     $response = new Response();
     $response->prepare($request);
     $path = implode('/', $request->getUrlSegments());
     if (!preg_match('~download-file/g(\\d+)$~', $path, $m)) {
         return $response->setStatusCode(400)->setContent('Malformatted request URL');
     }
     $this->application->start();
     $guid = (int) $m[1];
     $file = get_entity($guid);
     if (!$file instanceof ElggFile) {
         return $response->setStatusCode(404)->setContent("File with guid {$guid} does not exist");
     }
     $filenameonfilestore = $file->getFilenameOnFilestore();
     if (!is_readable($filenameonfilestore)) {
         return $response->setStatusCode(404)->setContent('File not found');
     }
     $last_updated = filemtime($filenameonfilestore);
     $etag = '"' . $last_updated . '"';
     $response->setPublic()->setEtag($etag);
     if ($response->isNotModified($request)) {
         return $response;
     }
     $response = new BinaryFileResponse($filenameonfilestore, 200, array(), false, 'attachment');
     $response->prepare($request);
     $expires = strtotime('+1 year');
     $expires_dt = (new DateTime())->setTimestamp($expires);
     $response->setExpires($expires_dt);
     $response->setEtag($etag);
     return $response;
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:38,代码来源:DownloadFileHandler.php

示例15: tearDown

 /**
  * Remove the entities that are created for each test
  */
 protected function tearDown()
 {
     foreach ($this->guids as $guid) {
         $e = get_entity($guid);
         $e->delete();
     }
 }
开发者ID:ibou77,项目名称:elgg,代码行数:10,代码来源:RelationshipsTest.php


注:本文中的get_entity函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。