21 $ar = array_map(
'trim', $ar);
22 $ar = array_filter($ar,
'is_not_null');
23 $ar = array_map(
'strip_tags', $ar);
76 'tag_names' => array(),
85 'site_guids' => $CONFIG->site_guid,
99 $singulars = array(
'type',
'subtype',
'owner_guid',
'container_guid',
'site_guid',
'tag_name');
104 if (!is_array(
$options[
'tag_names'])) {
109 if (count(
$options[
'tag_names']) == 0) {
110 $options[
'tag_names'] = $registered_tags;
113 $diff = array_diff(
$options[
'tag_names'], $registered_tags);
114 if (count($diff) > 0) {
115 elgg_deprecated_notice(
'Tag metadata names must be registered by elgg_register_tag_metadata_name()', 1.7);
123 $wheres[] =
"msv.string != ''";
125 $sanitised_tags = array();
126 foreach (
$options[
'tag_names'] as $tag) {
129 $tags_in = implode(
',', $sanitised_tags);
130 $wheres[] =
"(msn.string IN ($tags_in))";
142 foreach ($wheres as $i => $where) {
143 if ($where ===
false) {
145 } elseif (empty($where)) {
151 $wheres = array_unique($wheres);
155 $joins[] =
"JOIN {$CONFIG->dbprefix}metadata md on md.entity_guid = e.guid";
156 $joins[] =
"JOIN {$CONFIG->dbprefix}metastrings msv on msv.id = md.value_id";
157 $joins[] =
"JOIN {$CONFIG->dbprefix}metastrings msn on md.name_id = msn.id";
160 $joins = array_unique($joins);
162 foreach ($joins as $i => $join) {
163 if ($join ===
false) {
165 } elseif (empty($join)) {
171 $query =
"SELECT msv.string as tag, count(msv.id) as total ";
172 $query .=
"FROM {$CONFIG->dbprefix}entities e ";
175 foreach ($joins as $j) {
182 foreach ($wheres as $w) {
183 $query .=
" $w AND ";
190 $query .=
" GROUP BY msv.string HAVING total >= {$threshold} ";
191 $query .=
" ORDER BY total DESC ";
194 $query .=
" LIMIT {$limit} ";
212 if (!isset($CONFIG->registered_tag_metadata_names)) {
213 $CONFIG->registered_tag_metadata_names = array();
216 if (!in_array(
$name, $CONFIG->registered_tag_metadata_names)) {
217 $CONFIG->registered_tag_metadata_names[] =
$name;
232 $names = (isset($CONFIG->registered_tag_metadata_names)) ? $CONFIG->registered_tag_metadata_names : array();
251 'tag_name' =>
'tags',
if($guid==elgg_get_logged_in_user_guid()) $name
elgg_view_tagcloud(array $options=array())
Create a tagcloud for viewing.
_elgg_get_guid_based_where_sql($column, $guids)
Returns SQL where clause for owner and containers.
_elgg_get_entity_time_where_sql($table, $time_created_upper=null, $time_created_lower=null, $time_updated_upper=null, $time_updated_lower=null)
Returns SQL where clause for entity time limits.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
sanitise_string($string)
Wrapper function for alternate English spelling (.
const ELGG_ENTITIES_ANY_VALUE
elgg echo
Translates a string.
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
elgg_view_layout($layout_name, $vars=array())
Displays a layout with optional parameters.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
get_data($query, $callback="")
Retrieve rows from the database.
$content
Set robots.txt action.
_elgg_get_entity_type_subtype_where_sql($table, $types, $subtypes, $pairs)
Returns SQL where clause for type and subtype on main entity table.
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
sanitise_int($int, $signed=true)
Sanitizes an integer for database use.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
_elgg_get_access_where_sql(array $options=array())
Returns the SQL where clause for enforcing read access to data.