Index: CHANGELOG
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/glossary/CHANGELOG,v
retrieving revision 1.22
diff -r1.22 CHANGELOG
0a1,5
> 19 Nov 2004
> [Frodo Looijaard]
> - Reimplement alphabar in glossary page [issue 13083; also fixes issues 12936, 
>   10645 and 9457].
> 
Index: glossary.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/glossary/glossary.module,v
retrieving revision 1.77
diff -r1.77 glossary.module
2c2
< // $Id: glossary.module,v 1.77 2004/11/14 19:47:46 frodo Exp $
---
> // $Id: glossary.module,v 1.71 2004/11/07 17:32:41 frodo Exp $
245,253c245,246
< function _glossary_alphabar($vid) {
<   $output = "\n<div class=\"glossary-links\">";
<   foreach (range('a', 'z') as $letter) {
<     $letters[] = l($letter, 'glossary/'.$vid, NULL, NULL, 'letter' . $letter);
<   }
<   $output .= theme_links($letters);
<   $output .= "</div>\n";
<   return $output;
< }
---
> function _glossary_alphabar($vid, &$tree) {
>   $blocks = array(range('0', '9'), range('a', 'z'));
254a248,275
>   $found_letters = array();
>   foreach ($tree as $key=>$term) {
>     if ($term->depth == 0) {
>       $firstletter = strtolower($term->name[0]);
>       if (! array_key_exists($firstletter, $found_letters)) {
>         $found_letters[$firstletter] = 1;
>         $tree[$key]->firstletter = $firstletter;
>       }
>     }
>   }
>   
>   foreach ($blocks as $block) {
>     $found = False;
>     foreach ($block as $entry) {
>       if (array_key_exists($entry, $found_letters)) {
>         $found = True;
>         break;
>       }
>     }
>     if ($found) {
>       foreach ($block as $entry) {
>         if (! array_key_exists($entry, $found_letters)) {
>           $found_letters[$entry] = 0;
>         }
>       }
>     }
>   }
>    
256,258c277,286
< function _glossary_anchor($lower, $upper) {
<   foreach (range($lower, $upper) as $letter) {
<     $output .= "<a id=\"letter$letter\"></a>\n";
---
>   $output = "\n<div class=\"glossary-links\">";   
>   $letters = array_keys($found_letters);
>   sort($letters);
>   foreach ($letters as $letter) {
>     if ($found_letters[$letter]) {
>       $links[] = l($letter, 'glossary/'.$vid, NULL, NULL, 'letter' . $letter);
>     } 
>     else {
>       $links[] = $letter;
>     }
259a288,289
>   $output .= theme_links($links);
>   $output .= "</div>\n";
263,264d292
< function glossary_overview($vid) {
<   global $tree;
266c294
<   $output = _glossary_alphabar($vid);
---
> function glossary_overview($vid) {
267a296
>   $output = _glossary_alphabar($vid, $tree);
269d297
<     $output .= _glossary_anchor('a', strtolower($tree[0]->name[0]));
271,274c299,300
<       // skip this on first iteration since was already outputted above
<       if (isset($lastletter)) {
<         $firstletter = strtolower($term->name[0]);
<         $output .= _glossary_anchor(chr(ord($lastletter) + 1) , $firstletter);
---
>       if (isset($term->firstletter)) {
>           $output .= "<a id=\"letter". $term->firstletter ."\"></a>\n";
289c315
<           $items[] .= l($related->name, 'glossary/'.$vid, NULL, NULL, "term".$related->tid);
---
>           $items[] .= l($related->name, 'glossary/'. $vid, NULL, NULL, "term". $related->tid);
295d320
<       $lastletter = strtolower($term->name[0]);
297d321
<     $output .= _glossary_anchor(chr(ord($lastletter) + 1), 'z');
