mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
tags returned by get_all_tags, get_available_tags contain id key instead of tag_id
(as expected by make_index_url, as $page['tags'] was and as the database model is) git-svn-id: http://piwigo.org/svn/trunk@1815 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -2,10 +2,9 @@
|
|||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | PhpWebGallery - a PHP based picture gallery |
|
// | PhpWebGallery - a PHP based picture gallery |
|
||||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | branch : BSF (Best So Far)
|
// | file : $Id$
|
||||||
// | file : $RCSfile$
|
|
||||||
// | last update : $Date$
|
// | last update : $Date$
|
||||||
// | last modifier : $Author$
|
// | last modifier : $Author$
|
||||||
// | revision : $Revision$
|
// | revision : $Revision$
|
||||||
@@ -289,7 +288,7 @@ if (count($all_tags) == 0)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$add_tag_selection = get_html_tag_selection(
|
$add_tag_selection = get_html_tag_selection(
|
||||||
get_all_tags(),
|
$all_tags,
|
||||||
'add_tags'
|
'add_tags'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -304,21 +303,7 @@ $template->assign_vars(
|
|||||||
if (count($page['cat_elements_id']) > 0)
|
if (count($page['cat_elements_id']) > 0)
|
||||||
{
|
{
|
||||||
// remove tags
|
// remove tags
|
||||||
$query = '
|
$tags = get_common_tags($page['cat_elements_id'], -1);
|
||||||
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(',', $page['cat_elements_id']).')
|
|
||||||
GROUP BY tag_id
|
|
||||||
;';
|
|
||||||
$result = pwg_query($query);
|
|
||||||
|
|
||||||
$tags = array();
|
|
||||||
while($row = mysql_fetch_array($result))
|
|
||||||
{
|
|
||||||
array_push($tags, $row);
|
|
||||||
}
|
|
||||||
|
|
||||||
usort($tags, 'name_compare');
|
usort($tags, 'name_compare');
|
||||||
|
|
||||||
$template->assign_vars(
|
$template->assign_vars(
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | PhpWebGallery - a PHP based picture gallery |
|
// | PhpWebGallery - a PHP based picture gallery |
|
||||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | branch : BSF (Best So Far)
|
// | file : $Id$
|
||||||
// | file : $RCSfile$
|
|
||||||
// | last update : $Date$
|
// | last update : $Date$
|
||||||
// | last modifier : $Author$
|
// | last modifier : $Author$
|
||||||
// | revision : $Revision$
|
// | revision : $Revision$
|
||||||
@@ -211,7 +210,7 @@ $all_tags = get_all_tags();
|
|||||||
if (count($all_tags) > 0)
|
if (count($all_tags) > 0)
|
||||||
{
|
{
|
||||||
$tag_selection = get_html_tag_selection(
|
$tag_selection = get_html_tag_selection(
|
||||||
get_all_tags(),
|
$all_tags,
|
||||||
'tags',
|
'tags',
|
||||||
$selected_tags
|
$selected_tags
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -558,10 +558,10 @@ function get_html_tag_selection(
|
|||||||
'<li>'
|
'<li>'
|
||||||
.'<label>'
|
.'<label>'
|
||||||
.'<input type="checkbox" name="'.$fieldname.'[]"'
|
.'<input type="checkbox" name="'.$fieldname.'[]"'
|
||||||
.' value="'.$tag['tag_id'].'"'
|
.' value="'.$tag['id'].'"'
|
||||||
;
|
;
|
||||||
|
|
||||||
if (in_array($tag['tag_id'], $selecteds))
|
if (in_array($tag['id'], $selecteds))
|
||||||
{
|
{
|
||||||
$output.= ' checked="checked"';
|
$output.= ' checked="checked"';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | PhpWebGallery - a PHP based picture gallery |
|
// | PhpWebGallery - a PHP based picture gallery |
|
||||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | branch : BSF (Best So Far)
|
// | file : $Id$
|
||||||
// | file : $RCSfile$
|
// | last update : $Date$
|
||||||
// | last update : $Date: 2006-03-16 23:58:16 +0100 (jeu, 16 mar 2006) $
|
// | last modifier : $Author$
|
||||||
// | last modifier : $Author: rub $
|
// | revision : $Revision$
|
||||||
// | revision : $Revision: 1085 $
|
// | revision : $Revision$
|
||||||
// | revision : $Revision: 1085 $
|
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | This program is free software; you can redistribute it and/or modify |
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
// | it under the terms of the GNU General Public License as published by |
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
@@ -41,7 +40,7 @@ function get_available_tags()
|
|||||||
{
|
{
|
||||||
// we can find top fatter tags among reachable images
|
// we can find top fatter tags among reachable images
|
||||||
$tags_query = '
|
$tags_query = '
|
||||||
SELECT tag_id, name, url_name, count(*) counter
|
SELECT id, name, url_name, count(*) counter
|
||||||
FROM '.IMAGE_TAG_TABLE.'
|
FROM '.IMAGE_TAG_TABLE.'
|
||||||
INNER JOIN '.TAGS_TABLE.' ON tag_id = id';
|
INNER JOIN '.TAGS_TABLE.' ON tag_id = id';
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ SELECT tag_id, name, url_name, count(*) counter
|
|||||||
'WHERE'
|
'WHERE'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_null($where_tag_img))
|
if (!empty($where_tag_img))
|
||||||
{
|
{
|
||||||
// first we need all reachable image ids
|
// first we need all reachable image ids
|
||||||
$images_query = '
|
$images_query = '
|
||||||
@@ -101,7 +100,7 @@ SELECT DISTINCT image_id
|
|||||||
function get_all_tags()
|
function get_all_tags()
|
||||||
{
|
{
|
||||||
$query = '
|
$query = '
|
||||||
SELECT id AS tag_id,
|
SELECT id,
|
||||||
name,
|
name,
|
||||||
url_name
|
url_name
|
||||||
FROM '.TAGS_TABLE.'
|
FROM '.TAGS_TABLE.'
|
||||||
@@ -245,7 +244,7 @@ function get_common_tags($items, $max_tags, $excluded_tag_ids=null)
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$query = '
|
$query = '
|
||||||
SELECT tag_id, name, url_name, count(*) counter
|
SELECT id, name, url_name, count(*) counter
|
||||||
FROM '.IMAGE_TAG_TABLE.'
|
FROM '.IMAGE_TAG_TABLE.'
|
||||||
INNER JOIN '.TAGS_TABLE.' ON tag_id = id
|
INNER JOIN '.TAGS_TABLE.' ON tag_id = id
|
||||||
WHERE image_id IN ('.implode(',', $items).')';
|
WHERE image_id IN ('.implode(',', $items).')';
|
||||||
@@ -255,8 +254,7 @@ SELECT tag_id, name, url_name, count(*) counter
|
|||||||
AND tag_id NOT IN ('.implode(',', $excluded_tag_ids).')';
|
AND tag_id NOT IN ('.implode(',', $excluded_tag_ids).')';
|
||||||
}
|
}
|
||||||
$query .='
|
$query .='
|
||||||
GROUP BY tag_id
|
GROUP BY tag_id';
|
||||||
ORDER BY counter DESC';
|
|
||||||
if ($max_tags>0)
|
if ($max_tags>0)
|
||||||
{
|
{
|
||||||
$query .= '
|
$query .= '
|
||||||
|
|||||||
+2
-12
@@ -130,12 +130,7 @@ if ('tags' == $page['section'])
|
|||||||
array(
|
array(
|
||||||
'URL' => make_index_url(
|
'URL' => make_index_url(
|
||||||
array(
|
array(
|
||||||
'tags' => array(
|
'tags' => array($tag)
|
||||||
array(
|
|
||||||
'id' => $tag['tag_id'],
|
|
||||||
'url_name' => $tag['url_name'],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -154,12 +149,7 @@ if ('tags' == $page['section'])
|
|||||||
array(
|
array(
|
||||||
'tags' => array_merge(
|
'tags' => array_merge(
|
||||||
$page['tags'],
|
$page['tags'],
|
||||||
array(
|
array($tag)
|
||||||
array(
|
|
||||||
'id' => $tag['tag_id'],
|
|
||||||
'url_name' => $tag['url_name'],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -537,29 +537,23 @@ SELECT c.id,c.name,c.uppercats,c.global_rank
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- related tags
|
//-------------------------------------------------------------- related tags
|
||||||
$query = '
|
$related_tags = get_common_tags( array($image_row['id']), -1 );
|
||||||
SELECT id, name, url_name
|
foreach( $related_tags as $i=>$tag)
|
||||||
FROM '.IMAGE_TAG_TABLE.'
|
|
||||||
INNER JOIN '.TAGS_TABLE.' ON tag_id = id
|
|
||||||
WHERE image_id = '.$image_row['id'].'
|
|
||||||
;';
|
|
||||||
$result = pwg_query($query);
|
|
||||||
$related_tags = array();
|
|
||||||
while ($row = mysql_fetch_assoc($result))
|
|
||||||
{
|
{
|
||||||
$row['url'] = make_index_url(
|
$tag['url'] = make_index_url(
|
||||||
array(
|
array(
|
||||||
'tags' => array($row)
|
'tags' => array($tag)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$row['page_url'] = make_picture_url(
|
$tag['page_url'] = make_picture_url(
|
||||||
array(
|
array(
|
||||||
'image_id' => $image_row['id'],
|
'image_id' => $image_row['id'],
|
||||||
'image_file' => $image_row['file'],
|
'image_file' => $image_row['file'],
|
||||||
'tags' => array($row),
|
'tags' => array($tag),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
array_push($related_tags, $row);
|
unset($tag['counter']);
|
||||||
|
$related_tags[$i]=$tag;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------- related comments
|
//---------------------------------------------------------- related comments
|
||||||
$query = '
|
$query = '
|
||||||
@@ -674,9 +668,8 @@ function ws_tags_getList($params, &$service)
|
|||||||
}
|
}
|
||||||
for ($i=0; $i<count($tags); $i++)
|
for ($i=0; $i<count($tags); $i++)
|
||||||
{
|
{
|
||||||
$tags[$i]['id'] = (int)$tags[$i]['tag_id'];
|
$tags[$i]['id'] = (int)$tags[$i]['id'];
|
||||||
$tags[$i]['counter'] = (int)$tags[$i]['counter'];
|
$tags[$i]['counter'] = (int)$tags[$i]['counter'];
|
||||||
unset($tags[$i]['tag_id']);
|
|
||||||
$tags[$i]['url'] = make_index_url(
|
$tags[$i]['url'] = make_index_url(
|
||||||
array(
|
array(
|
||||||
'section'=>'tags',
|
'section'=>'tags',
|
||||||
@@ -702,19 +695,18 @@ function ws_tags_getImages($params, &$service)
|
|||||||
$tags_by_id = array();
|
$tags_by_id = array();
|
||||||
for( $i=0; $i<count($tags); $i++ )
|
for( $i=0; $i<count($tags); $i++ )
|
||||||
{
|
{
|
||||||
$tags[$i]['tag_id']=(int)$tags[$i]['tag_id'];
|
$tags[$i]['id']=(int)$tags[$i]['id'];
|
||||||
$tags[$i]['id']=(int)$tags[$i]['tag_id']; //required by make_xxx_url
|
|
||||||
}
|
}
|
||||||
foreach( $tags as $tag )
|
foreach( $tags as $tag )
|
||||||
{
|
{
|
||||||
$tags_by_id[ $tag['tag_id'] ] = $tag;
|
$tags_by_id[ $tag['id'] ] = $tag;
|
||||||
if (
|
if (
|
||||||
in_array($tag['name'], $params['tag_name'])
|
in_array($tag['name'], $params['tag_name'])
|
||||||
or
|
or
|
||||||
in_array($tag['url_name'], $params['tag_url_name'])
|
in_array($tag['url_name'], $params['tag_url_name'])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$tag_ids[] = $tag['tag_id'];
|
$tag_ids[] = $tag['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($tags);
|
unset($tags);
|
||||||
|
|||||||
@@ -225,12 +225,7 @@ if ( $page['section']=='search' and $page['start']==0 )
|
|||||||
'related_tags.tag', array(
|
'related_tags.tag', array(
|
||||||
'URL' => make_index_url(
|
'URL' => make_index_url(
|
||||||
array(
|
array(
|
||||||
'tags' => array(
|
'tags' => array($tag)
|
||||||
array(
|
|
||||||
'id' => $tag['tag_id'],
|
|
||||||
'url_name' => $tag['url_name'],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'NAME' => $tag['name'],
|
'NAME' => $tag['name'],
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | PhpWebGallery - a PHP based picture gallery |
|
// | PhpWebGallery - a PHP based picture gallery |
|
||||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | branch : BSF (Best So Far)
|
// | branch : BSF (Best So Far)
|
||||||
// | file : $RCSfile$
|
// | file : $Id$
|
||||||
// | last update : $Date: 2006-03-22 02:01:47 +0100 (mer, 22 mar 2006) $
|
// | last update : $Date: 2006-03-22 02:01:47 +0100 (mer, 22 mar 2006) $
|
||||||
// | last modifier : $Author: rvelices $
|
// | last modifier : $Author: rvelices $
|
||||||
// | revision : $Revision: 1092 $
|
// | revision : $Revision: 1092 $
|
||||||
@@ -33,15 +33,15 @@ function counter_compare($a, $b)
|
|||||||
{
|
{
|
||||||
if ($a['counter'] == $b['counter'])
|
if ($a['counter'] == $b['counter'])
|
||||||
{
|
{
|
||||||
return tag_id_compare($a, $b);
|
return id_compare($a, $b);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($a['counter'] < $b['counter']) ? +1 : -1;
|
return ($a['counter'] < $b['counter']) ? +1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tag_id_compare($a, $b)
|
function id_compare($a, $b)
|
||||||
{
|
{
|
||||||
return ($a['tag_id'] < $b['tag_id']) ? -1 : 1;
|
return ($a['id'] < $b['id']) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
@@ -94,12 +94,7 @@ foreach ($tags as $tag)
|
|||||||
array(
|
array(
|
||||||
'URL' => make_index_url(
|
'URL' => make_index_url(
|
||||||
array(
|
array(
|
||||||
'tags' => array(
|
'tags' => array($tag),
|
||||||
array(
|
|
||||||
'id' => $tag['tag_id'],
|
|
||||||
'url_name' => $tag['url_name'],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user