Changeset 12760


Ignore:
Timestamp:
Dec 17, 2011, 11:51:20 PM (9 years ago)
Author:
plg
Message:

bug 2502 fixed: better handling of non-latin tags and multilanguage tags on
tags.php with mode letter.

We can't rely on url_name because it always start with "_" when the tag looks
like "[lang...". Instead we compute a str2url on the name, but once it has been
rendered by Extended Description. To avoid useless computations, I have added a
cache on the tag_alpha_compare function. Tested on a 175 tags set, speed is
good.

Location:
branches/2.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/include/functions_html.inc.php

    r12480 r12760  
    295295function tag_alpha_compare($a, $b)
    296296{
    297   return strcmp(strtolower($a['url_name']), strtolower($b['url_name']));
     297  global $page;
     298 
     299  foreach (array($a, $b) as $tag)
     300  {
     301    if (!isset($page[__FUNCTION__.'_cache'][ $tag['name'] ]))
     302    {
     303      $page[__FUNCTION__.'_cache'][ $tag['name'] ] = strtolower(str2url($tag['name']));
     304    }
     305  }
     306
     307  return strcmp($page[__FUNCTION__.'_cache'][ $a['name'] ], $page[__FUNCTION__.'_cache'][ $b['name'] ]);
    298308}
    299309
  • branches/2.3/tags.php

    r10824 r12760  
    100100  foreach ($tags as $tag)
    101101  {
    102     $tag_letter = strtoupper(substr($tag['url_name'], 0, 1));
     102    $tag_letter = strtoupper(mb_substr(str2url($tag['name']), 0, 1, 'utf-8'));
    103103
    104104    if ($current_tag_idx==0) {
     
    172172
    173173// we want tags diplayed in alphabetic order
    174 usort($tags, 'tag_alpha_compare');
     174if ('letters' != $page['display_mode'])
     175{
     176  usort($tags, 'tag_alpha_compare');
     177}
    175178
    176179// display sorted tags
Note: See TracChangeset for help on using the changeset viewer.