Changeset 12761

Show
Ignore:
Timestamp:
12/17/11 23:52:19 (17 months ago)
Author:
plg
Message:

merge r12760 from branch 2.3 to trunk

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:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_html.inc.php

    r12479 r12761  
    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 
  • trunk/tags.php

    r10824 r12761  
    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