/** * Creates a Widget view object for the BlueSpice Skin. * @param array &$aViews List of Widget view objects from the BlueSpice Skin. */ private function addWidgetView(&$aViews) { $iCount = BsConfig::get('MW::PagesVisited::WidgetLimit'); $aNamespaces = BsConfig::get('MW::PagesVisited::WidgetNS'); $sSortOrder = BsConfig::get('MW::PagesVisited::WidgetSortOdr'); //Validation $oValidationICount = BsValidator::isValid('IntegerRange', $iCount, array('fullResponse' => true, 'lowerBoundary' => 1, 'upperBoundary' => 30)); if ($oValidationICount->getErrorCode()) { $iCount = 10; } $iCurrentNamespaceId = $this->getTitle()->getNamespace(); // TODO RBV (04.07.11 15:02): Rework method -> implode() is a workaround for legacy code. $oListView = $this->makePagesVisitedWikiList($iCount, implode(',', $aNamespaces), $iCurrentNamespaceId, 30, $sSortOrder); $sOut = $oListView->execute(); if (!$oListView instanceof ViewTagError) { $sOut = $this->mCore->parseWikiText($sOut, $this->getTitle()); } $oWidgetView = new ViewWidget(); $oWidgetView->setTitle(wfMessage('bs-pagesvisited-widget-title')->plain())->setBody($sOut)->setAdditionalBodyClasses(array('bs-nav-links')); //For correct margin and fontsize $aViews[] = $oWidgetView; }
/** * Creates a Widget and returns it * @return ViewWidget */ public function onWidgetListKeyword() { $oCurrentUser = $this->getUser(); if ($oCurrentUser->isAnon()) { return null; } $iCount = BsConfig::get('MW::WatchList::WidgetLimit'); $sOrder = BsConfig::get('MW::WatchList::WidgetSortOdr'); //Validation $oValidationICount = BsValidator::isValid('IntegerRange', $iCount, array('fullResponse' => true, 'lowerBoundary' => 1, 'upperBoundary' => 30)); if ($oValidationICount->getErrorCode()) { $iCount = 10; } if (!in_array($sOrder, array('pagename', 'time'))) { $sOrder = 'pagename'; } $oUserSidebarView = new ViewWidget(); $oUserSidebarView->setTitle(wfMessage('bs-watchlist-title-sidebar')->plain())->setAdditionalBodyClasses(array('bs-nav-links')); //For correct margin and fontsize $oWatchList = $this->fetchWatchlist($oCurrentUser, $iCount, 30, $sOrder); $sWatchListWikiText = $oWatchList->execute(); if (empty($sWatchListWikiText)) { return $oUserSidebarView; } $oUserSidebarView->setBody($this->mCore->parseWikiText($sWatchListWikiText, $this->getTitle(), true), $this->getTitle()); return $oUserSidebarView; }
/** * Creates a Widget and returns it * @return ViewWidget */ public function onWidgetListKeyword() { $sTitle = wfMessage('bs-wantedarticle-tag-default-title')->plain(); $aWishList = $this->getTitleListFromTitle($this->getDataSourceTemplateArticle()->getTitle()); $sSort = BsConfig::get('MW::WantedArticle::Sort'); switch ($sSort) { case 'title': $aTitleList = $this->sortWishListByTitle($aWishList); break; case 'time': default: $aTitleList = $this->getDefaultTitleList($aWishList); } if (BsConfig::get('MW::WantedArticle::Order') == 'DESC') { $aTitleList = array_reverse($aTitleList); } $iIncludeLimit = BsConfig::get('MW::WantedArticle::IncludeLimit'); $iCount = count($aTitleList); $iCount = $iCount > $iIncludeLimit ? $iIncludeLimit : $iCount; $aWikiCodeList = array(); $oTitle = null; $sWishTitle = ''; for ($i = 0; $i < $iCount; $i++) { $oTitle = $aTitleList[$i]; $sWishTitle = BsStringHelper::shorten($oTitle->getPrefixedText(), array('max-length' => 30, 'position' => 'middle')); $aWikiCodeList[] = '*' . BsLinkProvider::makeEscapedWikiLinkForTitle($oTitle, $sWishTitle); } $sBody = $this->mCore->parseWikiText(implode("\n", $aWikiCodeList), $this->getTitle()); $oWidgetView = new ViewWidget(); $oWidgetView->setTitle($sTitle)->setBody($sBody)->setTooltip($sTitle)->setAdditionalBodyClasses(array('bs-nav-links')); //For correct margin and fontsize return $oWidgetView; }