function displayCategoryTable() { global $wgOut; $catmap = Categoryhelper::getIconMap(); ksort($catmap); $queryString = WikihowCategoryViewer::getViewModeParam(); if (!empty($queryString)) { $queryString = "?" . $queryString; } $wgOut->addHTML("<div class='section_text'>"); foreach ($catmap as $cat => $image) { $title = Title::newFromText($image); if ($title) { $file = wfFindFile($title, false); $sourceWidth = $file->getWidth(); $sourceHeight = $file->getHeight(); $heightPreference = false; if (self::CAT_HEIGHT > self::CAT_WIDTH && $sourceWidth > $sourceHeight) { //desired image is portrait $heightPreference = true; } $thumb = $file->getThumbnail(self::CAT_WIDTH, self::CAT_HEIGHT, true, true, $heightPreference); $category = urldecode(str_replace("-", " ", $cat)); $catTitle = Title::newFromText("Category:" . $category); if ($catTitle) { $wgOut->addHTML("<div class='thumbnail'><a href='{$catTitle->getLocalUrl()}{$queryString}'><img src='" . wfGetPad($thumb->getUrl()) . "' /><div class='text'><p><span>{$category}</span></p></div></a></div>"); } } } $wgOut->addHTML("<div class='clearall'></div>"); $wgOut->addHTML("</div><!-- end section_text -->"); }
function getCategoryLinks($usebrowser) { global $wgOut, $wgUser, $wgContLang; if (!$usebrowser && count($wgOut->mCategoryLinks) == 0) { 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>'; $t = $embed . implode("{$pop} | {$embed}", $wgOut->mCategoryLinks) . $pop; if (!$usebrowser) { return $t; } $mainPageObj = Title::newMainPage(); $sk = $wgUser->getSkin(); $sep = self::BREADCRUMB_SEPARATOR; $queryString = WikihowCategoryViewer::getViewModeParam(); $categories = $sk->makeLinkObj(Title::newFromText('Special:Categorylisting'), wfMsg('categories'), $queryString); $s = "<li class='home'>" . $sk->makeLinkObj($mainPageObj, wfMsg('home')) . "</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; $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++) { if (strpos($tempout[$i], "/Category:WikiHow") === false && strpos($tempout[$i], "/Category:Featured") == false && strpos($tempout[$i], "/Category:Nomination") == false) { $s = $olds; $s .= $tempout[$i]; break; } } } } return $s; }