24 $ar = array_map(
'trim', $ar);
25 $ar = array_filter($ar,
'is_not_null');
26 $ar = array_map(
'strip_tags', $ar);
27 $ar = array_unique($ar);
83 'tag_names' => array(),
92 'site_guids' => $CONFIG->site_guid,
106 $singulars = array(
'type',
'subtype',
'owner_guid',
'container_guid',
'site_guid',
'tag_name');
111 if (!is_array(
$options[
'tag_names'])) {
116 if (count(
$options[
'tag_names']) == 0) {
117 $options[
'tag_names'] = $registered_tags;
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} ";
211 $GLOBALS[
'_ELGG']->registered_tag_metadata_names = array();
215 $GLOBALS[
'_ELGG']->registered_tag_metadata_names[] =
$name;
242 $events->registerHandler(
'init',
'system',
'_elgg_tags_init');
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
if($guid==elgg_get_logged_in_user_guid()) $name
_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.
sanitise_string($string)
Alias of sanitize_string.
const ELGG_ENTITIES_ANY_VALUE
elgg global
Pointer to the global context.
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
$_ELGG registered_tag_metadata_names
An array of metadata names to be used as tags.
sanitise_int($int, $signed=true)
Alias of sanitize_int.
_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.