Beispiel #1
0
 function getCategoryLinks($usebrowser)
 {
     global $wgOut, $wgContLang;
     if (!$usebrowser && empty($wgOut->mCategoryLinks["normal"])) {
         return '';
     }
     // Use Unicode bidi embedding override characters,
     // to make sure links don't smash each other up in ugly ways.
     $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
     $embed = "<span dir='{$dir}'>";
     $pop = '</span>';
     if (empty($wgOut->mCategoryLinks["normal"])) {
         $t = $embed . "" . $pop;
     } else {
         $t = $embed . implode("{$pop} | {$embed}", $wgOut->mCategoryLinks["normal"]) . $pop;
     }
     if (!$usebrowser) {
         return $t;
     }
     $mainPageObj = Title::newMainPage();
     $sk = $this->getSkin();
     $sep = self::BREADCRUMB_SEPARATOR;
     $viewMode = WikihowCategoryViewer::getViewModeArray($this->getContext());
     $categories = Linker::link(Title::newFromText('Special:Categorylisting'), wfMessage('categories')->text(), array(), $viewMode);
     $s = "<li class='home'>" . Linker::link($mainPageObj, wfMessage('home')->text()) . "</li> <li>{$sep} {$categories}</li>";
     # optional 'dmoz-like' category browser. Will be shown under the list
     # of categories an article belong to
     if ($usebrowser) {
         $s .= ' ';
         # get a big array of the parents tree
         $parenttree = Categoryhelper::getCurrentParentCategoryTree();
         if (is_array($parenttree)) {
             $parenttree = array_reverse($parenttree);
         } else {
             return $s;
         }
         # Skin object passed by reference cause it can not be
         # accessed under the method subfunction drawCategoryBrowser
         $tempout = explode("\n", $this->drawCategoryBrowser($parenttree, $this));
         $newarray = array();
         foreach ($tempout as $t) {
             if (trim($t) != "") {
                 $newarray[] = $t;
             }
         }
         $tempout = $newarray;
         asort($tempout);
         $olds = $s;
         if ($tempout) {
             $s .= $tempout[0];
         }
         // this usually works
         if (strpos($s, "/Category:WikiHow") !== false || strpos($s, "/Category:Featured") !== false || strpos($s, "/Category:Nomination") !== false) {
             for ($i = 1; $i <= sizeof($tempout); $i++) {
                 // Reuben: changed to add this isset($tempout[$i]) stuff so that
                 // functionality remains identical but without variable not defined
                 // notice, even though I don't understand the functionality
                 if (strpos(@$tempout[$i], "/Category:WikiHow") === false && strpos(@$tempout[$i], "/Category:Featured") == false && strpos(@$tempout[$i], "/Category:Nomination") == false) {
                     $s = $olds;
                     $s .= isset($tempout[$i]) ? $tempout[$i] : '';
                     break;
                 }
             }
         }
     }
     return $s;
 }