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


PHP elgg_extract函数代码示例

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


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

示例1: 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"]);
}
开发者ID:pleio,项目名称:simplesaml,代码行数:40,代码来源:events.php

示例2: friend_request_entity_menu_handler

function friend_request_entity_menu_handler($hook, $type, $returnvalue, $params)
{
    $result = $returnvalue;
    if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) {
        $entity = elgg_extract("entity", $params);
        if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) {
            if (!empty($result) && !is_array($result)) {
                $result = array($result);
            } elseif (empty($result)) {
                $result = array();
            }
            // are we friends
            if (!$entity->isFriendOf($user->getGUID())) {
                // no, check if pending request
                if (check_entity_relationship($user->getGUID(), "friendrequest", $entity->getGUID())) {
                    // pending request
                    $result[] = ElggMenuItem::factory(array("name" => "friend_request", "text" => elgg_echo("friend_request:friend:add:pending"), "href" => "friend_request/" . $user->username . "#friend_request_sent_listing", "priority" => 500));
                } else {
                    // add as friend
                    $result[] = ElggMenuItem::factory(array("name" => "add_friend", "text" => elgg_echo("friend:add"), "href" => "action/friends/add?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
                }
            } else {
                // is friend, se remove friend link
                $result[] = ElggMenuItem::factory(array("name" => "remove_friend", "text" => elgg_echo("friend:remove"), "href" => "action/friends/remove?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500));
            }
        }
    }
    return $result;
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:29,代码来源:hooks.php

示例3: combinedParams

 /**
  * Change search params for combined search
  *
  * @param string $hook         the name of the hook
  * @param string $type         the type of the hook
  * @param mixed  $return_value current return value
  * @param array  $params       supplied params
  *
  * @return void|mixed
  */
 public static function combinedParams($hook, $type, $return_value, $params)
 {
     $combined_search_type = elgg_extract('combined', $params);
     if (empty($combined_search_type)) {
         return;
     }
     switch ($combined_search_type) {
         case 'objects':
             $subtypes = elgg_extract('subtype', $return_value);
             if (empty($subtypes)) {
                 return;
             }
             if (in_array(\ElggQuestion::SUBTYPE, $subtypes)) {
                 // add answers
                 $subtypes[] = \ElggAnswer::SUBTYPE;
             }
             $return_value['subtype'] = $subtypes;
             break;
         case 'all':
             $type_subtype_pairs = elgg_extract('type_subtype_pairs', $return_value);
             if (empty($type_subtype_pairs) || empty($type_subtype_pairs['object'])) {
                 return;
             }
             if (in_array(\ElggQuestion::SUBTYPE, $type_subtype_pairs['object'])) {
                 // add answers
                 $type_subtype_pairs['object'][] = \ElggAnswer::SUBTYPE;
             }
             $return_value['type_subtype_pairs'] = $type_subtype_pairs;
             break;
         default:
             return;
     }
     return $return_value;
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:44,代码来源:SearchAdvanced.php

示例4: notifications_log_sent_message

/**
 * Logs the notification sent
 *
 * @param string $hook   "send"
 * @param string $type   "all"
 * @param mixed  $return Result
 * @param array  $params Hook params
 * @return mixed
 */
function notifications_log_sent_message($hook, $type, $return, $params)
{
    list($hook_type, $method) = explode(':', $type);
    if ($hook_type != 'notification') {
        return;
    }
    $notification = elgg_extract('notification', $params);
    $recipient = $notification->getRecipient();
    $sender = $notification->getSender();
    $content = array('status' => $return === false ? 'failed' : 'sent', 'subject' => $notification->subject, 'summary' => $notification->summary, 'body' => $notification->body);
    $description = 'instant';
    $event = elgg_extract('event', $params);
    if ($event) {
        $action = $event->getAction();
        $actor = $event->getActor();
        $object = $event->getObject();
        $event_data = array('action' => $action, 'object' => is_callable(array($object, 'toObject')) ? $object->toObject() : array('guid' => $object->guid, 'id' => $object->id), 'actor' => is_callable(array($actor, 'toObject')) ? $actor->toObject() : array('guid' => $event->getActorGUID()));
        $content = array_merge($content, $event_data);
        $description = str_replace(':', '_', $event->getDescription());
    }
    $name = implode('_', array($method, "TO-{$recipient->guid}", "FROM-{$sender->guid}", $description, time()));
    $dirname = elgg_get_config('dataroot') . '/notifications_log/';
    if (!is_dir($dirname)) {
        mkdir($dirname, 0700, true);
    }
    $filename = "{$dirname}{$name}.json";
    file_put_contents($filename, json_encode($content));
}
开发者ID:hypeJunction,项目名称:Elgg-notifications_log,代码行数:37,代码来源:start.php

示例5: 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++;
             }
         }
     }
 }
开发者ID:coldtrick,项目名称:todos,代码行数:41,代码来源:Todo.php

示例6: handle

 /**
  * {@inheritdoc}
  */
 public function handle(ElggEntity $entity)
 {
     $shortname = $this->getShortname();
     $future_value = $_FILES[$shortname];
     $value = $_FILES[$shortname];
     $error_type = elgg_extract('error', $value);
     $has_uploaded_file = $error_type != UPLOAD_ERR_NO_FILE;
     if (!$has_uploaded_file) {
         return $entity;
     }
     $params = array('field' => $this, 'entity' => $entity, 'upload_name' => $shortname, 'future_value' => $future_value);
     // Allow plugins to prevent files from being uploaded
     if (!elgg_trigger_plugin_hook('handle:upload:before', 'prototyper', $params, true)) {
         return $entity;
     }
     $previous_upload = $this->getValues($entity);
     if ($previous_upload instanceof ElggFile) {
         $previous_upload->delete();
     }
     $result = hypeApps()->uploader->handle($shortname, array('container_guid' => $entity->guid, 'origin' => 'prototyper', 'prototyper_field' => $shortname, 'access_id' => $entity->access_id));
     /* @var $result ElggFile[] */
     $future_value = $result[0];
     $params = array('field' => $this, 'entity' => $entity, 'upload_name' => $shortname, 'value' => $future_value);
     elgg_trigger_plugin_hook('handle:upload:after', 'prototyper', $params, $result);
     return $entity;
 }
开发者ID:hypejunction,项目名称:hypeprototyper,代码行数:29,代码来源:UploadField.php

示例7: entity_view_counter_get_configured_entity_types

function entity_view_counter_get_configured_entity_types()
{
    static $result;
    if (!isset($result)) {
        $result = false;
        // get registered entity types and plugin setting
        if (($registered_types = elgg_get_config("registered_entities")) && ($setting = elgg_get_plugin_setting("entity_types", "entity_view_counter"))) {
            $setting = json_decode($setting, true);
            $temp_result = array();
            foreach ($registered_types as $type => $subtypes) {
                if (elgg_extract($type, $setting)) {
                    $temp_result[$type] = array();
                    if (!empty($subtypes) && is_array($subtypes)) {
                        foreach ($subtypes as $subtype) {
                            if (elgg_extract($subtype, $setting[$type])) {
                                $temp_result[$type][] = $subtype;
                            }
                        }
                    }
                }
            }
            if (!empty($temp_result)) {
                $result = $temp_result;
            }
        }
    }
    return $result;
}
开发者ID:pleio,项目名称:entity_view_counter,代码行数:28,代码来源:functions.php

示例8: pool_entity_menu

/**
 * Set up entity menu for pool objects
 *
 * @param string $hook 'register'
 * @param string $type 'menu:entity'
 * @param ElggMenuItem[] $return
 * @param array $params
 * @return ElggMenuItem[]
 */
function pool_entity_menu($hook, $type, $return, $params)
{
    $handler = elgg_extract('handler', $params, false);
    if ($handler != 'task_pool') {
        return $return;
    }
    if (elgg_is_logged_in()) {
        $entity = $params['entity'];
        $user_guid = elgg_get_logged_in_user_guid();
        if ($entity->isMember($user_guid)) {
            $text = elgg_echo('pool:leave');
        } else {
            $text = elgg_echo('pool:join');
        }
        $return[] = ElggMenuItem::factory(array('name' => 'test', 'text' => "<span>{$text}</span>", 'href' => "action/pool/toggle_membership?pool_guid={$entity->guid}&user_guid={$user_guid}", 'priority' => 150, 'is_action' => true));
        if (elgg_is_admin_logged_in()) {
            $return[] = ElggMenuItem::factory(array('name' => 'edit', 'text' => elgg_echo('edit'), 'href' => "admin/pool/save?guid={$entity->guid}"));
            $return[] = ElggMenuItem::factory(array('name' => 'delete', 'text' => elgg_view_icon('delete'), 'href' => "action/pool/admin/delete?guid={$entity->guid}", 'is_action' => true, 'confirm' => elgg_echo('question:areyousure'), 'priority' => 200));
            if ($entity->countMembers()) {
                $return[] = ElggMenuItem::factory(array('name' => 'shift', 'text' => elgg_echo('pool:shift'), 'href' => "action/pool/shift?guid={$entity->guid}", 'priority' => 150, 'is_action' => true, 'confirm' => elgg_echo('question:areyousure')));
            }
        }
    }
    return $return;
}
开发者ID:juho-jaakkola,项目名称:elgg-pool,代码行数:34,代码来源:start.php

示例9: buildTransaction

 /**
  * Build the named transaction based on an array of information from the route hook
  *
  * @param array $page_information the routing information
  *
  * @return void
  */
 protected static function buildTransaction($page_information)
 {
     if (empty($page_information) || !is_array($page_information)) {
         return;
     }
     $transaction = [];
     $identifier = elgg_extract('identifier', $page_information);
     if (!empty($identifier)) {
         $transaction[] = $identifier;
     }
     // filter out usernames
     $usernames = self::getUsernamesToIgnore();
     $segments = elgg_extract('segments', $page_information);
     if (!empty($segments) && is_array($segments)) {
         foreach ($segments as $segment) {
             if (is_numeric($segment) || in_array($segment, $usernames)) {
                 $transaction[] = '*';
                 break;
             } else {
                 $transaction[] = $segment;
             }
         }
     }
     newrelic_name_transaction('/' . implode('/', $transaction));
 }
开发者ID:coldtrick,项目名称:newrelic,代码行数:32,代码来源:Router.php

示例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;
}
开发者ID:sh3llc0de,项目名称:elgg-jssor,代码行数:33,代码来源:start.php

示例11: 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;
 }
开发者ID:coldtrick,项目名称:file_tools,代码行数:43,代码来源:FolderBreadcrumb.php

示例12: email

 /**
  * Prevent outgoing e-mail to non test panel members
  *
  * @param string $hook        the name of the hook
  * @param string $type        the type of the hook
  * @param array  $returnvalue the current return value
  * @param array  $params      supplied params
  *
  * @return void|false
  */
 public static function email($hook, $type, $returnvalue, $params)
 {
     if (empty($returnvalue) || !is_array($returnvalue)) {
         // someone else already send the emails
         return;
     }
     if (!test_panel_limit_notifications()) {
         // don't limit e-mails
         return;
     }
     $to = elgg_extract('to', $returnvalue);
     if (empty($to) || !is_string($to)) {
         // don't know how to handle this
         return;
     }
     $to = EmailHandler::sanitizeEmail($to);
     elgg_log("Test panel processing: {$to}", 'INFO');
     $allowed_emails = test_panel_get_panel_members_email_addresses();
     if (empty($allowed_emails) || !is_array($allowed_emails)) {
         // nobody is allowed (shouldn't happen)
         return false;
     }
     if (!in_array($to, $allowed_emails)) {
         // user is not allowed to get e-mails
         elgg_log("Test panel blocked: {$to}", 'NOTICE');
         return false;
     }
     // user is a panel member, so can receive e-mails
 }
开发者ID:coldtrick,项目名称:test_panel,代码行数:39,代码来源:EmailHandler.php

示例13: fileTools

 /**
  * Handle /file_tools URLs
  *
  * @param array $page URL segments
  *
  * @return bool
  */
 public static function fileTools($page)
 {
     switch (elgg_extract(0, $page)) {
         case 'list':
             elgg_ajax_gatekeeper();
             $params = [];
             elgg_set_page_owner_guid(elgg_extract(1, $page));
             $folder_guid = get_input('folder_guid', false);
             if ($folder_guid !== false) {
                 $params['folder_guid'] = (int) $folder_guid;
                 $params['draw_page'] = false;
             }
             if (isset($page[2])) {
                 $params['folder_guid'] = (int) $page[2];
             }
             echo elgg_view_resource('file_tools/file/list', $params);
             return true;
             break;
         case 'folder':
             switch (elgg_extract(1, $page)) {
                 case 'new':
                     elgg_set_page_owner_guid(elgg_extract(2, $page));
                     echo elgg_view_resource('file_tools/folder/new');
                     return true;
                     break;
                 case 'edit':
                     $params = ['folder_guid' => (int) elgg_extract(2, $page)];
                     echo elgg_view_resource('file_tools/folder/edit', $params);
                     return true;
                     break;
             }
             break;
     }
     return false;
 }
开发者ID:coldtrick,项目名称:file_tools,代码行数:42,代码来源:PageHandler.php

示例14: ckeditor_extended_htmlawed_config

/**
 * Extends the current config of htmlawed
 *
 * @param string $hook        hookname
 * @param string $type        hooktype
 * @param array  $returnvalue returnvalue
 * @param array  $params      params
 *
 * @return void
 */
function ckeditor_extended_htmlawed_config($hook_name, $entity_type, $return_value, $params)
{
    if (!is_array($return_value)) {
        return $return_value;
    }
    // Extend valid input elements
    $htmlawed_elements = elgg_get_plugin_setting('htmlawed_elements', 'ckeditor_extended');
    if (!empty($htmlawed_elements)) {
        $ext_tags_array = explode(',', $htmlawed_elements);
        $elements = '*';
        foreach ($ext_tags_array as $fulltag) {
            $fulltag = trim(str_replace(array('[', ']'), ' ', $fulltag));
            $fulltag = explode(' ', $fulltag);
            $tag = $fulltag[0];
            $elements .= '+' . $tag;
        }
        $return_value['elements'] = $elements;
    }
    $htmlawed_schemes = elgg_get_plugin_setting('htmlawed_schemes', 'ckeditor_extended');
    if (!empty($htmlawed_schemes)) {
        $current_schemes = elgg_extract('schemes', $return_value, '*:http');
        $htmlawed_schemes = $current_schemes . ',' . ltrim($htmlawed_schemes, ',');
        $return_value['schemes'] = $htmlawed_schemes;
    }
    return $return_value;
}
开发者ID:coldtrick,项目名称:ckeditor_extended,代码行数:36,代码来源:hooks.php

示例15: 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;
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:36,代码来源:EntityMenu.php


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