http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96583

Revision: 96583
Author:   maxsem
Date:     2011-09-08 16:34:59 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
TOC for hieroglyph list

Modified Paths:
--------------
    trunk/extensions/wikihiero/SpecialHieroglyphs.php
    trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css

Modified: trunk/extensions/wikihiero/SpecialHieroglyphs.php
===================================================================
--- trunk/extensions/wikihiero/SpecialHieroglyphs.php   2011-09-08 16:25:18 UTC 
(rev 96582)
+++ trunk/extensions/wikihiero/SpecialHieroglyphs.php   2011-09-08 16:34:59 UTC 
(rev 96583)
@@ -62,9 +62,12 @@
                        . Html::closeElement( 'form' )
                );
 
+               $out->addHTML( '<table><tr><td>' );
                $out->addHTML( '<div class="mw-hiero-list">' );
                $out->addHTML( $this->listHieroglyphs() );
-               $out->addHTML( '</div>' );
+               $out->addHTML( '</div></td><td>' );
+               $out->addHTML( $this->getToc() );
+               $out->addHTML( '</td></tr></table>' );
        }
 
        /**
@@ -124,6 +127,32 @@
                return $html;
        }
 
+       private function getToc() {
+               $html = '<table class="toc mw-hiero-toc"><tr>';
+               $count = 0;
+               $cats = $this->getCategories();
+               $end = array_pop( $cats );
+               foreach ( $cats as $cat ) {
+                       $html .= '<td>'
+                               . Html::element( 'a',
+                                       array( 'href' => "#cat-$cat", 'title' 
=> wfMessage( "wikihiero-category-$cat" )->text() ),
+                                       $cat
+                               )
+                               . '</td>';
+                       $count++;
+                       if ( $count % 5 == 0 ) {
+                               $html .= '</tr><tr>';
+                       }
+               }
+               $html .= '</tr><tr><td colspan="5">'
+                               . Html::element( 'a',
+                                       array( 'href' => "#cat-$end", 'title' 
=> wfMessage( "wikihiero-category-$end" )->text() ),
+                                       $end
+                               )
+                               . '</td>';
+               return $html . '</tr></table>';
+       }
+
        /**
         * Returns an array with hieroglyph categories from Gardiner's list
         */

Modified: trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css
===================================================================
--- trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css        
2011-09-08 16:25:18 UTC (rev 96582)
+++ trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css        
2011-09-08 16:34:59 UTC (rev 96583)
@@ -2,4 +2,9 @@
        overflow: auto;
        height: 400px;
        margin-top: 1em;
+       border: 1px solid silver;
 }
+
+.mw-hiero-toc {
+       text-align: center;
+}


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to