diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_html.inc.php | 4 | ||||
-rw-r--r-- | include/functions_tag.inc.php | 24 | ||||
-rw-r--r-- | include/menubar.inc.php | 14 | ||||
-rw-r--r-- | include/ws_functions.inc.php | 32 |
4 files changed, 27 insertions, 47 deletions
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 490def9ed..3aba87d61 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -558,10 +558,10 @@ function get_html_tag_selection( '<li>' .'<label>' .'<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"'; } diff --git a/include/functions_tag.inc.php b/include/functions_tag.inc.php index 42704d238..c9f239ef7 100644 --- a/include/functions_tag.inc.php +++ b/include/functions_tag.inc.php @@ -2,14 +2,13 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | 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 : $RCSfile$ -// | last update : $Date: 2006-03-16 23:58:16 +0100 (jeu, 16 mar 2006) $ -// | last modifier : $Author: rub $ -// | revision : $Revision: 1085 $ -// | revision : $Revision: 1085 $ +// | file : $Id$ +// | last update : $Date$ +// | last modifier : $Author$ +// | revision : $Revision$ +// | revision : $Revision$ // +-----------------------------------------------------------------------+ // | 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 | @@ -41,7 +40,7 @@ function get_available_tags() { // we can find top fatter tags among reachable images $tags_query = ' -SELECT tag_id, name, url_name, count(*) counter +SELECT id, name, url_name, count(*) counter FROM '.IMAGE_TAG_TABLE.' INNER JOIN '.TAGS_TABLE.' ON tag_id = id'; @@ -57,7 +56,7 @@ SELECT tag_id, name, url_name, count(*) counter 'WHERE' ); - if (!is_null($where_tag_img)) + if (!empty($where_tag_img)) { // first we need all reachable image ids $images_query = ' @@ -101,7 +100,7 @@ SELECT DISTINCT image_id function get_all_tags() { $query = ' -SELECT id AS tag_id, +SELECT id, name, url_name FROM '.TAGS_TABLE.' @@ -245,7 +244,7 @@ function get_common_tags($items, $max_tags, $excluded_tag_ids=null) return array(); } $query = ' -SELECT tag_id, name, url_name, count(*) counter +SELECT id, name, url_name, count(*) counter FROM '.IMAGE_TAG_TABLE.' INNER JOIN '.TAGS_TABLE.' ON tag_id = id 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).')'; } $query .=' - GROUP BY tag_id - ORDER BY counter DESC'; + GROUP BY tag_id'; if ($max_tags>0) { $query .= ' diff --git a/include/menubar.inc.php b/include/menubar.inc.php index 030c46cbd..d38290704 100644 --- a/include/menubar.inc.php +++ b/include/menubar.inc.php @@ -130,12 +130,7 @@ if ('tags' == $page['section']) array( 'URL' => make_index_url( array( - 'tags' => array( - array( - 'id' => $tag['tag_id'], - 'url_name' => $tag['url_name'], - ), - ) + 'tags' => array($tag) ) ), @@ -154,12 +149,7 @@ if ('tags' == $page['section']) array( 'tags' => array_merge( $page['tags'], - array( - array( - 'id' => $tag['tag_id'], - 'url_name' => $tag['url_name'], - ), - ) + array($tag) ) ) ), diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 61b17dc78..5c0221e7e 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -537,29 +537,23 @@ SELECT c.id,c.name,c.uppercats,c.global_rank } //-------------------------------------------------------------- related tags - $query = ' -SELECT id, name, url_name - 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)) + $related_tags = get_common_tags( array($image_row['id']), -1 ); + foreach( $related_tags as $i=>$tag) { - $row['url'] = make_index_url( + $tag['url'] = make_index_url( array( - 'tags' => array($row) + 'tags' => array($tag) ) ); - $row['page_url'] = make_picture_url( + $tag['page_url'] = make_picture_url( array( 'image_id' => $image_row['id'], '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 $query = ' @@ -674,9 +668,8 @@ function ws_tags_getList($params, &$service) } 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']; - unset($tags[$i]['tag_id']); $tags[$i]['url'] = make_index_url( array( 'section'=>'tags', @@ -702,19 +695,18 @@ function ws_tags_getImages($params, &$service) $tags_by_id = array(); for( $i=0; $i<count($tags); $i++ ) { - $tags[$i]['tag_id']=(int)$tags[$i]['tag_id']; - $tags[$i]['id']=(int)$tags[$i]['tag_id']; //required by make_xxx_url + $tags[$i]['id']=(int)$tags[$i]['id']; } foreach( $tags as $tag ) { - $tags_by_id[ $tag['tag_id'] ] = $tag; + $tags_by_id[ $tag['id'] ] = $tag; if ( in_array($tag['name'], $params['tag_name']) or in_array($tag['url_name'], $params['tag_url_name']) ) { - $tag_ids[] = $tag['tag_id']; + $tag_ids[] = $tag['id']; } } unset($tags); |