本文整理汇总了PHP中get_subtype_from_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_subtype_from_id函数的具体用法?PHP get_subtype_from_id怎么用?PHP get_subtype_from_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_subtype_from_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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';
}
示例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;
}
示例5: dirname
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Kevin Jardine <kevin@radagast.biz>
* @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;
示例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 = " ";
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>";
示例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";
}
示例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);
示例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;
示例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;
}
}
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
示例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;
}