From 42abf4c57664d2596872d437f70b95193f9a5d18 Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 2 Apr 2006 22:26:19 +0000 Subject: improvement: tags replace keywords. Better data model, less limitations. Each image can be associated to as many tag as needed. Tags can contain non ASCII characters. Oriented navigation with tags by association. git-svn-id: http://piwigo.org/svn/trunk@1119 68402e56-0260-453c-a942-63ccdbb3a9ee --- index.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'index.php') diff --git a/index.php b/index.php index 3bb03d4bd..784832623 100644 --- a/index.php +++ b/index.php @@ -221,6 +221,76 @@ if (count($conf['links']) > 0) ); } } +//------------------------------------------------------------------------ tags +if ('tags' == $page['section']) +{ + $template->assign_block_vars('tags', array()); + + // display tags associated to currently tagged items, less current tags + $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).') + AND tag_id NOT IN ('.implode(',', $page['tag_ids']).') + GROUP BY tag_id + ORDER BY name ASC +;'; + $result = pwg_query($query); + + $tags = array(); + + while($row = mysql_fetch_array($result)) + { + array_push($tags, $row); + } + + $tags = add_level_to_tags($tags); + + foreach ($tags as $tag) + { + $template->assign_block_vars( + 'tags.tag', + array( + 'URL_ADD' => make_index_URL( + array( + 'tags' => array_merge( + $page['tags'], + array( + array( + 'id' => $tag['tag_id'], + 'url_name' => $tag['url_name'], + ), + ) + ) + ) + ), + + 'URL' => make_index_URL( + array( + 'tags' => array( + array( + 'id' => $tag['tag_id'], + 'url_name' => $tag['url_name'], + ), + ) + ) + ), + + 'NAME' => $tag['name'], + + 'TITLE' => l10n('See pictures linked to this tag only'), + + 'TITLE_ADD' => sprintf( + l10n('%d pictures are also linked to current tags'), + $tag['counter'] + ), + + 'CLASS' => 'tagLevel'.$tag['level'] + ) + ); + } +} //---------------------------------------------------------- special categories // favorites categories if ( !$user['is_the_guest'] ) @@ -332,6 +402,16 @@ else } } +// tags link +$template->assign_block_vars( + 'summary', + array( + 'TITLE' => l10n('See available tags'), + 'NAME' => l10n('Tags'), + 'U_SUMMARY'=> get_root_url().'tags.php', + ) + ); + // search link $template->assign_block_vars( 'summary', -- cgit v1.2.3