• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_subtype_from_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: filterObject

 public function filterObject($object)
 {
     global $CONFIG;
     $dbprefix = $CONFIG->dbprefix;
     $subtype = get_subtype_from_id($object->subtype);
     // do not index specific types of content
     if (in_array($subtype, array('messages', 'plugin', 'widget', 'custom_profile_field', 'custom_profile_field_category', 'reported_content', 'custom_group_field', 'custom_profile_type', 'gruop_widget', 'multi_dashboard'))) {
         return false;
     }
     $return = array();
     foreach (self::$entity_fields as $field) {
         $return[$field] = $object->{$field};
     }
     $return['title'] = $object->title;
     $return['description'] = elgg_strip_tags($object->description);
     // remove HTML
     $metastring_id = get_metastring_id('tags');
     if (!$metastring_id) {
         throw new Exception("No metastring id for tags found");
     }
     $metadata = get_data("SELECT md.access_id, v.string AS value FROM {$dbprefix}metadata md JOIN {$dbprefix}metastrings v ON md.value_id = v.id WHERE md.entity_guid = {$object->guid} AND md.name_id = {$metastring_id} AND md.enabled = 'yes'");
     if (count($metadata) > 0) {
         $return['tags'] = array();
         foreach ($metadata as $item) {
             if ($item->value) {
                 $return['tags'][] = $item->value;
             }
         }
     }
     return $return;
 }
开发者ID:rubenve,项目名称:elasticsearch,代码行数:31,代码来源:ESFilter.php


示例2: setup

 /**
  * Setup a mock entity
  *
  * @param int    $guid       GUID of the mock entity
  * @param string $type       Type of the mock entity
  * @param string $subtype    Subtype of the mock entity
  * @param array  $attributes Attributes of the mock entity
  * @return ElggEntity
  */
 public function setup($guid, $type, $subtype, array $attributes = [])
 {
     while (!isset($guid)) {
         $this->iterator++;
         if (!isset($this->row[$this->iterator])) {
             $guid = $this->iterator;
         }
     }
     if ($subtype) {
         $subtype_id = get_subtype_id($type, $subtype);
         if (!$subtype_id) {
             $subtype_id = add_subtype($type, $subtype);
         }
     } else {
         if (isset($attributes['subtype_id'])) {
             $subtype_id = $attributes['subtype_id'];
             $subtype = get_subtype_from_id($subtype_id);
         }
     }
     $attributes['guid'] = $guid;
     $attributes['type'] = $type;
     $attributes['subtype'] = $subtype_id;
     $time = $this->getCurrentTime()->getTimestamp();
     $primary_attributes = array('owner_guid' => 0, 'container_guid' => 0, 'access_id' => ACCESS_PUBLIC, 'time_created' => $time, 'time_updated' => $time, 'last_action' => $time, 'enabled' => 'yes');
     switch ($type) {
         case 'object':
             $external_attributes = ['title' => null, 'description' => null];
             break;
         case 'user':
             $external_attributes = ['name' => "John Doe {$guid}", 'username' => "john_doe_{$guid}", 'password_hash' => null, 'email' => "john_doe_{$guid}@example.com", 'language' => 'en', 'banned' => "no", 'admin' => 'no', 'prev_last_action' => null, 'last_login' => null, 'prev_last_login' => null];
             break;
         case 'group':
             $external_attributes = ['name' => null, 'description' => null];
             break;
     }
     $map = array_merge($primary_attributes, $external_attributes, $attributes);
     $attrs = (object) $map;
     $this->rows[$guid] = $attrs;
     $this->addQuerySpecs($attrs);
     $entity = $this->rowToElggStar($this->rows[$guid]);
     foreach ($attrs as $name => $value) {
         if (!isset($entity->{$name}) || $entity->{$name} != $value) {
             // not an attribute, so needs to be set again
             $entity->{$name} = $value;
         }
     }
     return $entity;
 }
开发者ID:elgg,项目名称:elgg,代码行数:57,代码来源:EntityTable.php


示例3: elasticsearch_get_view

function elasticsearch_get_view($object)
{
    if ($object->type == "annotation") {
        $subtype = $object->name;
    } else {
        $subtype = get_subtype_from_id($object->subtype);
    }
    if (elgg_view_exists('search/' . $object->type . '/' . $subtype)) {
        return 'search/' . $object->type . '/' . $subtype;
    } else {
        if (elgg_view_exists('search/' . $object->type)) {
            return 'search/' . $object->type;
        }
    }
    return 'search/entity';
}
开发者ID:pleio,项目名称:elasticsearch,代码行数:16,代码来源:functions.php


示例4: filterObject

 public function filterObject($object)
 {
     global $CONFIG;
     $dbprefix = $CONFIG->dbprefix;
     $subtype = get_subtype_from_id($object->subtype);
     // do not index specific types of content
     if (in_array($subtype, array('messages', 'plugin', 'widget', 'custom_profile_field', 'custom_profile_field_category', 'reported_content', 'custom_group_field', 'custom_profile_type', 'gruop_widget', 'multi_dashboard'))) {
         return false;
     }
     $return = array();
     foreach (self::$entity_fields as $field) {
         $return[$field] = $object->{$field};
     }
     $return['title'] = html_entity_decode($object->title);
     $return['description'] = html_entity_decode(elgg_strip_tags($object->description));
     // remove HTML
     $metastring_id = get_metastring_id('tags');
     if (!$metastring_id) {
         throw new Exception("No metastring id for tags found");
     }
     $metadata = get_data("SELECT md.access_id, v.string AS value FROM {$dbprefix}metadata md JOIN {$dbprefix}metastrings v ON md.value_id = v.id WHERE md.entity_guid = {$object->guid} AND md.name_id = {$metastring_id} AND md.enabled = 'yes'");
     if (count($metadata) > 0) {
         $return['tags'] = array();
         foreach ($metadata as $item) {
             if ($item->value) {
                 $return['tags'][] = $item->value;
             }
         }
     }
     if (in_array($subtype, array('question', 'cafe', 'news', 'blog'))) {
         if ($subtype == "question") {
             $comment_subtype = "answer";
         } else {
             $comment_subtype = "comment";
         }
         $options = array("type" => "object", "subtype" => $comment_subtype, "container_guid" => $object->guid, "site_guids" => null, "limit" => false);
         $return['comments'] = array();
         foreach (elgg_get_entities($options) as $comment) {
             $return['comments'][] = html_entity_decode(elgg_strip_tags($comment->description));
         }
     }
     return $return;
 }
开发者ID:pleio,项目名称:elasticsearch,代码行数:43,代码来源:ESFilter.php


示例5: dirname

 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Kevin Jardine <[email protected]>
 * @copyright Radagast Solutions 2008
 * @link http://radagast.biz/
 */
// Load Elgg engine
require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php";
// Load form model
require_once dirname(__FILE__) . "/models/model.php";
// Define context
set_context('form:content');
$form_id = get_input('id', 0);
$form_data_id = get_input('d', 0);
$preview = get_input('preview', 0);
$form = get_entity($form_id);
if ($form && $form->type == 'object' && get_subtype_from_id($form->subtype) == 'form:form') {
    set_page_owner($form->owner_guid);
    if ($form_data_id && ($form_data = form_get_data($form_data_id))) {
        if (get_entity($form_data_id)->canEdit()) {
            $tab_data = form_get_data_for_edit_form($form, $form_data);
        } else {
            register_error(elgg_echo('form:content_not_found'));
            forward();
        }
    } else {
        $tab_data = form_get_data_for_edit_form($form);
    }
    $title = form_form_t($form, 'title');
    $body = elgg_view('form/forms/display_form', array('form' => $form, 'tab_data' => $tab_data, 'preview' => $preview, 'form_data_id' => $form_data_id));
    $pg_owner_entity = page_owner_entity();
    $username = $pg_owner_entity->username;
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:form.php


示例6: foreach

}
$rows .= "<th>" . $site->name . "</th>";
$rows .= "</tr>";
foreach ($all_results as $row) {
    if (!elgg_is_admin_logged_in() && !is_registered_entity_type($row->type, get_subtype_from_id($row->subtype))) {
        // skip unsearchable entities for regular users
        continue;
    }
    if ($row->subtype) {
        $label = elgg_echo("item:" . $row->type . ":" . get_subtype_from_id($row->subtype));
    } else {
        $label = elgg_echo("item:" . $row->type);
    }
    if (strpos($label, "item:") === 0) {
        if ($row->subtype) {
            $label = elgg_echo(get_subtype_from_id($row->subtype));
        } else {
            $label = elgg_echo($row->type);
        }
    }
    $site_count = "&nbsp;";
    foreach ($site_results as $site_row) {
        if ($site_row->type == $row->type && $site_row->subtype == $row->subtype) {
            $site_count = $site_row->count;
            break;
        }
    }
    if (!elgg_is_admin_logged_in()) {
        $rows .= "<tr><td>" . $label . "</td><td>" . $site_count . "</td></tr>";
    } else {
        $rows .= "<tr><td>" . $label . "</td><td>" . $row->count . "</td><td>" . $site_count . "</td></tr>";
开发者ID:pleio,项目名称:subsite_manager,代码行数:31,代码来源:numentities.php


示例7: dbvalidate_get_object_type

/**
 * Get the object type or group as a string for a guid
 */
function dbvalidate_get_object_type($guid)
{
    $db_prefix = elgg_get_config('dbprefix');
    $guid = (int) $guid;
    $query = "SELECT type, subtype FROM {$db_prefix}entities WHERE guid={$guid}";
    $result = get_data_row($query);
    if ($result->type == 'group') {
        return "group";
    }
    $subtype = get_subtype_from_id($result->subtype);
    if ($subtype) {
        return $subtype;
    }
    return "unknown";
}
开发者ID:beck24,项目名称:elgg-db-cleaner,代码行数:18,代码来源:start.php


示例8: elgg_view_entity

                         $results_found[] = elgg_view_entity($entities2, $fullview);
                     }
                 }
             }
         }
     }
 }
 $rows3 = get_data("SELECT * FROM {$CONFIG->dbprefix}groups_entity WHERE  name LIKE  '%{$searchstring}%' OR description LIKE '%{$searchstring}%'");
 if (!empty($rows3)) {
     foreach ($rows3 as $row3) {
         $entity_id3 = $row3->guid;
         $entities3 = get_entity($entity_id3);
         if (in_array(get_subtype_from_id($entities3->subtype), $allowedTypes) or empty($entities3->subtype)) {
             if (!in_array($entities3->guid, $added)) {
                 if ($entities3->type != 'site') {
                     if (get_subtype_from_id($entities3->subtype) == 'event_calendar') {
                         $results_found[] = "<div class=\"search_listing\">" . elgg_view_entity($entities3, $fullview) . "</div>";
                     } else {
                         $results_found[] = elgg_view_entity($entities3, $fullview);
                     }
                 }
             }
         }
     }
 }
 $url = '?tag' . $tag . '&searchType=' . $searchType;
 $current_page = get_input('page');
 $current_page = intval($current_page);
 $current_page = $current_page ? $current_page : 1;
 $results_found = trim_array($results_found);
 // array_unique($results_found);
开发者ID:eokyere,项目名称:elgg,代码行数:31,代码来源:index.php


示例9: elgg_echo

    echo elgg_echo('dbvalidate:badowners');
    echo "<ul>";
    foreach ($bad_guids as $guid) {
        echo "<li>";
        echo elgg_echo('dbvalidate:GUID') . $guid . ", " . elgg_echo('dbvalidate:type') . ': ' . dbvalidate_get_object_type($guid);
        echo "</li>";
    }
    echo "</ul>";
} else {
    echo elgg_echo('dbvalidate:nobadowners');
}
echo "<br />";
$incomplete_entities = dbvalidate_get_incomplete_entities();
// write html for incomplete entities
if ($incomplete_entities !== false && count($incomplete_entities) > 0) {
    echo elgg_echo('dbvalidate:incompleteentities');
    echo "<ul>";
    foreach ($incomplete_entities as $entity) {
        echo "<li>";
        echo elgg_echo('dbvalidate:GUID') . $entity->guid . ", " . elgg_echo('dbvalidate:type') . ": " . $entity->type;
        if ($subtype = get_subtype_from_id($entity->subtype)) {
            echo ":{$subtype}";
        }
        echo "</li>";
    }
    echo "</ul>";
} else {
    echo elgg_echo('dbvalidate:noincompleteentities');
    echo "<br />";
}
exit;
开发者ID:beck24,项目名称:elgg-db-cleaner,代码行数:31,代码来源:validate.php


示例10: profile_usericon_hook

/**
 * This hooks into the getIcon API and provides nice user icons for users where possible.
 *
 * @param unknown_type $hook
 * @param unknown_type $entity_type
 * @param unknown_type $returnvalue
 * @param unknown_type $params
 * @return unknown
 */
function profile_usericon_hook($hook, $entity_type, $returnvalue, $params)
{
    global $CONFIG;
    if (!$returnvalue && $hook == 'entity:icon:url' && $params['entity'] instanceof ElggUser) {
        $entity = $params['entity'];
        $type = $entity->type;
        $subtype = get_subtype_from_id($entity->subtype);
        $viewtype = $params['viewtype'];
        $size = $params['size'];
        $username = $entity->username;
        if ($icontime = $entity->icontime) {
            $icontime = "{$icontime}";
        } else {
            $icontime = "default";
        }
        if ($entity->isBanned()) {
            return elgg_view('icon/user/default/' . $size);
        }
        $filehandler = new ElggFile();
        $filehandler->owner_guid = $entity->getGUID();
        $filehandler->setFilename("profile/" . $username . $size . ".jpg");
        if ($filehandler->exists()) {
            //$url = $CONFIG->url . "pg/icon/$username/$size/$icontime.jpg";
            return $CONFIG->wwwroot . 'mod/profile/icondirect.php?lastcache=' . $icontime . '&username=' . $entity->username . '&size=' . $size;
        }
    }
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:36,代码来源:start.php


示例11: site_search

/**
 * Performs a search of the elgg site
 *
 * @return array $results search result
 */
function site_search($query, $offset, $limit, $sort, $order, $search_type, $entity_type, $entity_subtype, $owner_guid, $container_guid)
{
    $params = array('query' => $query, 'offset' => $offset, 'limit' => $limit, 'sort' => $sort, 'order' => $order, 'search_type' => $search_type, 'type' => $entity_type, 'subtype' => $entity_subtype, 'owner_guid' => $owner_guid, 'container_guid' => $container_guid);
    $types = get_registered_entity_types();
    foreach ($types as $type => $subtypes) {
        $results = elgg_trigger_plugin_hook('search', $type, $params, array());
        if ($results === FALSE) {
            // someone is saying not to display these types in searches.
            continue;
        }
        if ($results['count']) {
            foreach ($results['entities'] as $single) {
                //search matched critera
                /*
                $result['search_matched_title'] = $single->getVolatileData('search_matched_title');
                $result['search_matched_description'] = $single->getVolatileData('search_matched_description');
                $result['search_matched_extra'] = $single->getVolatileData('search_matched_extra');
                */
                if ($type == 'group' || $type == 'user') {
                    $result['title'] = $single->name;
                } else {
                    $result['title'] = $single->title;
                }
                $result['guid'] = $single->guid;
                $result['type'] = $single->type;
                $result['subtype'] = get_subtype_from_id($single->subtype);
                $result['avatar_url'] = get_entity_icon_url($single, 'small');
                $return[$type] = $result;
            }
        }
    }
    return $return;
}
开发者ID:manumatrix,项目名称:elgg-web-services,代码行数:38,代码来源:core.php


示例12: pleio_api_create_push_message

function pleio_api_create_push_message($type, $object = null)
{
    $m = array();
    $m['t'] = $type;
    if ($object) {
        if ($object->container_guid == $object->guid) {
            unset($object->container_guid);
        }
        $m['id'] = $object->guid;
        if ($object->subtype) {
            $m['t'] = get_subtype_from_id($object->subtype);
        }
        if ($object->site_guid) {
            $m['s'] = $object->site_guid;
        }
        if ($object->container_guid) {
            $m['c'] = $object->container_guid;
        }
    }
    return $m;
}
开发者ID:appstaat,项目名称:pleio_api,代码行数:21,代码来源:helpers.php


示例13: tag_tools_is_notification_entity

/**
 * Check is notifications for this entity are allowed
 *
 * @param int $entity_guid the entity guid
 *
 * @return bool
 */
function tag_tools_is_notification_entity($entity_guid)
{
    $entity_guid = sanitise_int($entity_guid);
    $entity_row = get_entity_as_row($entity_guid);
    if (empty($entity_row)) {
        return false;
    }
    $type_subtypes = tag_tools_get_notification_type_subtypes();
    if (empty($type_subtypes) || !is_array($type_subtypes)) {
        return false;
    }
    $type = $entity_row->type;
    if (empty($type) || !isset($type_subtypes[$type])) {
        return false;
    }
    $subtype = get_subtype_from_id($entity_row->subtype);
    if (empty($subtype)) {
        // user, group, site
        return true;
    }
    return in_array($subtype, elgg_extract($type, $type_subtypes));
}
开发者ID:coldtrick,项目名称:tag_tools,代码行数:29,代码来源:functions.php


示例14: advanced_statistics_get_content_data

function advanced_statistics_get_content_data($chart_id)
{
    $result = array("data" => array(), "options" => array());
    $dbprefix = elgg_get_config("dbprefix");
    $current_site_guid = elgg_get_site_entity()->getGUID();
    switch ($chart_id) {
        case "totals":
            $data = array();
            $subtype_ids = array();
            $subtypes = get_registered_entity_types("object");
            foreach ($subtypes as $subtype) {
                if ($subtype_id = get_subtype_id("object", $subtype)) {
                    $subtype_ids[] = $subtype_id;
                }
            }
            $query = "SELECT e.subtype as subtype, count(*) as total";
            $query .= " FROM " . $dbprefix . "entities e";
            $query .= " WHERE e.type = 'object'";
            $query .= " AND e.subtype IN (" . implode(",", $subtype_ids) . ")";
            $query .= " AND e.site_guid = " . $current_site_guid;
            $query .= " GROUP BY e.subtype";
            $query .= " ORDER BY total DESC";
            if ($query_result = get_data($query)) {
                foreach ($query_result as $row) {
                    $subtype = get_subtype_from_id($row->subtype);
                    $subtype = elgg_echo("item:object:" . $subtype);
                    $total = (int) $row->total;
                    $data[] = array($subtype, $total);
                }
            }
            $result["data"] = array($data);
            $result["options"] = advanced_statistics_get_default_chart_options("bar");
            $result["options"]["seriesDefaults"]["rendererOptions"] = array("varyBarColor" => true);
            $result["options"]["highlighter"] = array("show" => true, "sizeAdjust" => 7.5, "tooltipAxes" => "y");
            $result["options"]["axes"]["xaxis"]["tickRenderer"] = "\$.jqplot.CanvasAxisTickRenderer";
            $result["options"]["axes"]["xaxis"]["tickOptions"] = array("angle" => "-30", "fontSize" => "8pt");
            break;
        case "distribution":
            $data = array();
            $subtype_ids = array();
            $subtypes = get_registered_entity_types("object");
            foreach ($subtypes as $subtype) {
                if ($subtype_id = get_subtype_id("object", $subtype)) {
                    $subtype_ids[] = $subtype_id;
                }
            }
            $query = "SELECT e2.type as type, count(*) as total";
            $query .= " FROM " . $dbprefix . "entities e";
            $query .= " JOIN " . $dbprefix . "entities e2 ON e.container_guid = e2.guid";
            $query .= " WHERE e.type = 'object'";
            $query .= " AND e.subtype IN (" . implode(",", $subtype_ids) . ")";
            $query .= " AND e.site_guid = " . $current_site_guid;
            $query .= " GROUP BY e2.type";
            $query .= " ORDER BY total DESC";
            if ($query_result = get_data($query)) {
                foreach ($query_result as $row) {
                    $total = (int) $row->total;
                    $data[] = array($row->type, $total);
                }
            }
            $result["data"] = array($data);
            $result["options"] = advanced_statistics_get_default_chart_options("pie");
            break;
        default:
            $params = array("chart_id" => $chart_id, "default_result" => $result);
            $result = elgg_trigger_plugin_hook("content", "advanced_statistics", $params, $result);
            break;
    }
    return json_encode($result);
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:70,代码来源:functions.php


示例15: getRequiredAttributes

 /**
  * Get all required attributes for the entity, validating any that are passed in. Returns empty array
  * if can't be loaded (Check $failure_reason).
  *
  * This function splits loading between "primary" attributes (those in {prefix}entities table) and
  * "secondary" attributes (e.g. those in {prefix}objects_entity), but can load all at once if a
  * combined loader is available.
  *
  * @param mixed $row a row loaded from DB (array or stdClass) or a GUID
  * @return array will be empty if failed to load all attributes (access control or entity doesn't exist)
  *
  * @throws InvalidArgumentException|LogicException|IncompleteEntityException
  */
 public function getRequiredAttributes($row)
 {
     if (!is_array($row) && !$row instanceof stdClass) {
         // assume row is the GUID
         $row = array('guid' => $row);
     }
     $row = (array) $row;
     if (empty($row['guid'])) {
         throw new InvalidArgumentException('$row must be or contain a GUID');
     }
     $was_missing_primaries = $this->isMissingPrimaries($row);
     $was_missing_secondaries = $this->isMissingSecondaries($row);
     // some types have a function to load all attributes at once, it should be faster
     if (($was_missing_primaries || $was_missing_secondaries) && is_callable($this->full_loader)) {
         $fetched = (array) call_user_func($this->full_loader, $row['guid']);
         if (!$fetched) {
             return array();
         }
         $row = array_merge($row, $fetched);
         $this->checkType($row);
     } else {
         if ($was_missing_primaries) {
             if (!is_callable($this->primary_loader)) {
                 throw new LogicException('Primary attribute loader must be callable');
             }
             if ($this->requires_access_control) {
                 $fetched = (array) call_user_func($this->primary_loader, $row['guid']);
             } else {
                 $ignoring_access = elgg_set_ignore_access();
                 $fetched = (array) call_user_func($this->primary_loader, $row['guid']);
                 elgg_set_ignore_access($ignoring_access);
             }
             if (!$fetched) {
                 return array();
             }
             $row = array_merge($row, $fetched);
         }
         // We must test type before trying to load the secondaries so that InvalidClassException
         // gets thrown. Otherwise the secondary loader will fail and return false.
         $this->checkType($row);
         if ($was_missing_secondaries) {
             if (!is_callable($this->secondary_loader)) {
                 throw new LogicException('Secondary attribute loader must be callable');
             }
             $fetched = (array) call_user_func($this->secondary_loader, $row['guid']);
             if (!$fetched) {
                 throw new IncompleteEntityException("Secondary loader failed to return row for {$row['guid']}");
             }
             $row = array_merge($row, $fetched);
         }
     }
     $row = $this->filterAddedColumns($row);
     // resolve subtype from int to string
     $subtype = get_subtype_from_id($row['subtype']);
     if ($subtype) {
         $row['subtype'] = $subtype;
     } else {
         $row['subtype'] = null;
     }
     // set to null when reading empty value, to match default empty value; See #5456
     foreach (self::$null_attr_names as $key) {
         if (isset($row[$key]) && !$row[$key]) {
             $row[$key] = null;
         }
     }
     // Note: If there are still missing attributes, we're running on a 1.7 or earlier schema. We let
     // this pass so the upgrades can run.
     // guid needs to be an int  http://trac.elgg.org/ticket/4111
     foreach (self::$integer_attr_names as $key) {
         if (isset($row[$key])) {
             $row[$key] = (int) $row[$key];
         }
     }
     return $row;
 }
开发者ID:tjcaverly,项目名称:Elgg,代码行数:88,代码来源:AttributeLoader.php


示例16: get_entity

<?php

$performed_by = get_entity($vars['item']->subject_guid);
// $statement->getSubject();
$object = get_entity($vars['item']->object_guid);
$url = $object->getURL();
$subtype = get_subtype_from_id($object->subtype);
$url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
$string = sprintf(elgg_echo("river:posted:generic"), $url) . " ";
$string .= elgg_echo("{$subtype}:river:annotate") . " | <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
?>

<?php 
echo $string;
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:14,代码来源:annotate.php


示例17: search

 public function search($string, $search_type, $type, $subtypes = array(), $limit = 10, $offset = 0, $sort = "", $order = "", $container_guid = 0, $profile_fields = array())
 {
     if ($search_type == 'tags') {
         $search_type = SEARCH_TAGS;
     } else {
         $search_type = SEARCH_DEFAULT;
         $string = strtolower($string);
     }
     $query = new ESQuery($this->index, $search_type);
     $query->setOffset($offset);
     $query->setLimit($limit);
     if ($type) {
         $query->filterType($type);
     }
     if ($sort && $sort !== "relevance") {
         if (!$order) {
             $order = "asc";
         }
         $query->setSort($sort, $order);
     }
     if ($subtypes) {
         $search_subtypes = array();
         if (is_array($subtypes)) {
             foreach ($subtypes as $subtype) {
                 $search_subtypes[] = get_subtype_id('object', $subtype);
             }
         } else {
             $search_subtypes[] = get_subtype_id('object', $subtypes);
         }
         $query->filterSubtypes($search_subtypes);
     }
     if ($container_guid) {
         $query->filterContainer($container_guid);
     }
     if ($profile_fields && count($profile_fields) > 0) {
         $query->filterProfileFields($profile_fields);
     }
     try {
         $results = $this->client->search($query->search($string));
     } catch (Exception $e) {
         elgg_log('Elasticsearch search exception ' . $e->getMessage(), 'ERROR');
         return array('count' => 0, 'count_per_type' => array(), 'count_per_subtype' => array(), 'hits' => array());
     }
     $hits = array();
     foreach ($results['hits']['hits'] as $hit) {
         if ($hit['_type'] == 'annotation') {
             $object = elgg_get_annotation_from_id($hit['_id']);
         } else {
             $object = get_entity($hit['_id']);
         }
         if ($object) {
             $hits[] = $object;
         }
     }
     $count_per_type = array();
     foreach ($results['facets']['type']['terms'] as $type) {
         $count_per_type[$type['term']] = $type['count'];
     }
     $count_per_subtype = array();
     foreach ($results['facets']['subtype']['terms'] as $subtype) {
         if ($subtype['term']) {
             $key = get_subtype_from_id($subtype['term']);
             $count_per_subtype[$key] = $subtype['count'];
         }
     }
     return array('count' => $results['hits']['total'], 'count_per_type' => $count_per_type, 'count_per_subtype' => $count_per_subtype, 'hits' => $hits);
 }
开发者ID:pleio,项目名称:elasticsearch,代码行数:67,代码来源:ESInterface.php


示例18: export

 /**
  * Export this class into an array of ODD Elements containing all necessary fields.
  * Override if you wish to return more information than can be found in
  * $this->attributes (shouldn't happen)
  *
  * @return array
  * @deprecated 1.9
  */
 public function export()
 {
     elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9);
     $tmp = array();
     // Generate uuid
     $uuid = guid_to_uuid($this->getGUID());
     // Create entity
     $odd = new ODDEntity($uuid, $this->attributes['type'], get_subtype_from_id($this->attributes['subtype']));
     $tmp[] = $odd;
     $exportable_values = $this->getExportableValues();
     // Now add its attributes
     foreach ($this->attributes as $k => $v) {
         $meta = null;
         if (in_array($k, $exportable_values)) {
             switch ($k) {
                 case 'guid':
                     // Dont use guid in OpenDD
                 // Dont use guid in OpenDD
                 case 'type':
                     // Type and subtype already taken care of
                 // Type and subtype already taken care of
                 case 'subtype':
                     break;
                 case 'time_created':
                     // Created = published
                     $odd->setAttribute('published', date("r", $v));
                     break;
                 case 'site_guid':
                     // Container
                     $k = 'site_uuid';
                     $v = guid_to_uuid($v);
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
                     break;
                 case 'container_guid':
                     // Container
                     $k = 'container_uuid';
                     $v = guid_to_uuid($v);
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
                     break;
                 case 'owner_guid':
                     // Convert owner guid to uuid, this will be stored in metadata
                     $k = 'owner_uuid';
                     $v = guid_to_uuid($v);
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
                     break;
                 default:
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
             }
             // set the time of any metadata created
             if ($meta) {
                 $meta->setAttribute('published', date("r", $this->time_created));
                 $tmp[] = $meta;
             }
         }
     }
     // Now we do something a bit special.
     /*
      * This provides a rendered view of the entity to foreign sites.
      */
     elgg_set_viewtype('default');
     $view = elgg_view_entity($this, array('full_view' => true));
     elgg_set_viewtype();
     $tmp[] = new ODDMetaData($uuid . "volatile/renderedentity/", $uuid, 'renderedentity', $view, 'volatile');
     return $tmp;
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:73,代码来源:ElggEntity.php


示例19: elgg_extract

<?php

$data = elgg_extract('data', $vars);
$type = $data->type;
$subtype_id = $data->subtype;
$subtype = is_numeric($subtype_id) ? get_subtype_from_id($subtype_id) : $subtype_id;
echo $subtype;
开发者ID:hypejunction,项目名称:hypedbexplorer,代码行数:7,代码来源:subtype.php


示例20: getSubtype

 /**
  * Get the entity subtype
  *
  * @return string The entity subtype
  */
 public function getSubtype()
 {
     // If this object hasn't been saved, then return the subtype string.
     if ($this->attributes['guid']) {
         return get_subtype_from_id($this->attributes['subtype']);
     }
     return $this->attributes['subtype'];
 }
开发者ID:elgg,项目名称:elgg,代码行数:13,代码来源:ElggEntity.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_subtype_id函数代码示例发布时间:2022-05-15
下一篇:
PHP get_subtype_class函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap