mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 17:23:04 +02:00
feature 519: quick search (first version)
git-svn-id: http://piwigo.org/svn/trunk@1537 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -221,4 +221,47 @@ SELECT DISTINCT image_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return a list of tags corresponding to given items.
|
||||
*
|
||||
* @param array items
|
||||
* @param array max_tags
|
||||
* @param array excluded_tag_ids
|
||||
* @return array
|
||||
*/
|
||||
function get_common_tags($items, $max_tags, $excluded_tag_ids=null)
|
||||
{
|
||||
if (empty($items))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
$query = '
|
||||
SELECT tag_id, name, url_name, count(*) counter
|
||||
FROM '.IMAGE_TAG_TABLE.'
|
||||
INNER JOIN '.TAGS_TABLE.' ON tag_id = id
|
||||
WHERE image_id IN ('.implode(',', $items).')';
|
||||
if (!empty($excluded_tag_ids))
|
||||
{
|
||||
$query.='
|
||||
AND tag_id NOT IN ('.implode(',', $excluded_tag_ids).')';
|
||||
}
|
||||
$query .='
|
||||
GROUP BY tag_id
|
||||
ORDER BY counter DESC';
|
||||
if ($max_tags>0)
|
||||
{
|
||||
$query .= '
|
||||
LIMIT 0,'.$max_tags;
|
||||
}
|
||||
|
||||
$result = pwg_query($query);
|
||||
$tags = array();
|
||||
while($row = mysql_fetch_array($result))
|
||||
{
|
||||
array_push($tags, $row);
|
||||
}
|
||||
usort($tags, 'name_compare');
|
||||
return $tags;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user