Changeset 1119 for trunk/index.php


Ignore:
Timestamp:
Apr 3, 2006, 12:26:19 AM (18 years ago)
Author:
plg
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r1117 r1119  
    222222  }
    223223}
     224//------------------------------------------------------------------------ tags
     225if ('tags' == $page['section'])
     226{
     227  $template->assign_block_vars('tags', array());
     228 
     229  // display tags associated to currently tagged items, less current tags
     230  $query = '
     231SELECT tag_id, name, url_name, count(*) counter
     232  FROM '.IMAGE_TAG_TABLE.'
     233    INNER JOIN '.TAGS_TABLE.' ON tag_id = id
     234  WHERE image_id IN ('.implode(',', $items).')
     235    AND tag_id NOT IN ('.implode(',', $page['tag_ids']).')
     236  GROUP BY tag_id
     237  ORDER BY name ASC
     238;';
     239  $result = pwg_query($query);
     240
     241  $tags = array();
     242 
     243  while($row = mysql_fetch_array($result))
     244  {
     245    array_push($tags, $row);
     246  }
     247
     248  $tags = add_level_to_tags($tags);
     249
     250  foreach ($tags as $tag)
     251  {
     252    $template->assign_block_vars(
     253      'tags.tag',
     254      array(
     255        'URL_ADD' => make_index_URL(
     256          array(
     257            'tags' => array_merge(
     258              $page['tags'],
     259              array(
     260                array(
     261                  'id' => $tag['tag_id'],
     262                  'url_name' => $tag['url_name'],
     263                  ),
     264                )
     265              )
     266            )
     267          ),
     268
     269        'URL' => make_index_URL(
     270          array(
     271            'tags' => array(
     272              array(
     273                'id' => $tag['tag_id'],
     274                'url_name' => $tag['url_name'],
     275                ),
     276              )
     277            )
     278          ),
     279       
     280        'NAME' => $tag['name'],
     281       
     282        'TITLE' => l10n('See pictures linked to this tag only'),
     283
     284        'TITLE_ADD' => sprintf(
     285          l10n('%d pictures are also linked to current tags'),
     286          $tag['counter']
     287          ),
     288       
     289        'CLASS' => 'tagLevel'.$tag['level']
     290        )
     291      );
     292  }
     293}
    224294//---------------------------------------------------------- special categories
    225295// favorites categories
     
    333403}
    334404
     405// tags link
     406$template->assign_block_vars(
     407  'summary',
     408  array(
     409    'TITLE' => l10n('See available tags'),
     410    'NAME' => l10n('Tags'),
     411    'U_SUMMARY'=> get_root_url().'tags.php',
     412    )
     413  );
     414
    335415// search link
    336416$template->assign_block_vars(
Note: See TracChangeset for help on using the changeset viewer.