aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_tag.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/functions_tag.inc.php')
-rw-r--r--include/functions_tag.inc.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/functions_tag.inc.php b/include/functions_tag.inc.php
index 4f8c95563..c6dc01db6 100644
--- a/include/functions_tag.inc.php
+++ b/include/functions_tag.inc.php
@@ -271,4 +271,65 @@ SELECT id, name, url_name, count(*) counter
usort($tags, 'name_compare');
return $tags;
}
+
+/**
+ * return a list of tags corresponding to any of ids, url_names, names
+ *
+ * @param array ids
+ * @param array url_names
+ * @param array names
+ * @return array
+ */
+function find_tags($ids, $url_names=array(), $names=array() )
+{
+ $where_clauses = array();
+ if ( !empty($ids) )
+ {
+ $where_clauses[] = 'id IN ('.implode(',', $ids).')';
+ }
+ if ( !empty($url_names) )
+ {
+ $where_clauses[] =
+ 'url_name IN ('.
+ implode(
+ ',',
+ array_map(
+ create_function('$s', 'return "\'".$s."\'";'),
+ $url_names
+ )
+ )
+ .')';
+ }
+ if ( !empty($names) )
+ {
+ $where_clauses[] =
+ 'name IN ('.
+ implode(
+ ',',
+ array_map(
+ create_function('$s', 'return "\'".$s."\'";'),
+ $names
+ )
+ )
+ .')';
+ }
+ if (empty($where_clauses))
+ {
+ return array();
+ }
+
+ $query = '
+SELECT id, url_name, name
+ FROM '.TAGS_TABLE.'
+ WHERE '. implode( '
+ OR ', $where_clauses);
+
+ $result = pwg_query($query);
+ $tags = array();
+ while ($row = mysql_fetch_assoc($result))
+ {
+ array_push($tags, $row);
+ }
+ return $tags;
+}
?> \ No newline at end of file