function execute()
 {
     global $wgOut, $wgUser, $wgRequest, $wgTitle;
     $gVar = $wgRequest->getText('var');
     $gVal = $wgRequest->getVal('val', 'true');
     $gLikeVal = $wgRequest->getVal('likeValue', 'true');
     $gTypeVal = $wgRequest->getVal('searchType', 'bool');
     $wgOut->SetPageTitle(wfMsg('whereisextension'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     if (!$wgUser->isAllowed('WhereIsExtension')) {
         $this->displayRestrictionError();
         return;
     }
     $this->values = array(0 => array('true', true, '='), 1 => array('false', false, '='), 2 => array('not empty', '', '!='));
     $tagName = $wgRequest->getVal('wikiSelectTagName', null);
     $tagWikis = $wgRequest->getArray('wikiSelected');
     $tagResultInfo = '';
     if ($wgRequest->wasPosted() && !empty($tagName) && count($tagWikis)) {
         $tagResultInfo = $this->tagSelectedWikis($tagName, $tagWikis);
     }
     $formData['vars'] = $this->getListOfVars($gVar == '');
     $formData['vals'] = $this->values;
     $formData['selectedVal'] = $gVal;
     $formData['likeValue'] = $gLikeVal;
     $formData['searchType'] = $gTypeVal;
     $formData['selectedGroup'] = $gVar == '' ? 27 : '';
     //default group: extensions (or all groups when looking for variable, rt#16953)
     $formData['groups'] = WikiFactory::getGroups();
     $formData['actionURL'] = $wgTitle->getFullURL();
     // by default, we don't need a paginator
     $sPaginator = '';
     if (!empty($gVar)) {
         $formData['selectedVar'] = $gVar;
         // assume an empty result
         $formData['count'] = 0;
         $formData['wikis'] = array();
         if (isset($this->values[$gVal][1]) && isset($this->values[$gVal][2])) {
             // check how many wikis meet the conditions
             $formData['count'] = WikiFactory::getCountOfWikisWithVar($gVar, $gTypeVal, $this->values[$gVal][2], $this->values[$gVal][1], $gLikeVal);
             // if there are any, get the list and create a Paginator
             if (0 < $formData['count']) {
                 // determine the offset (from the requested page)
                 $iPage = $wgRequest->getVal('page', 1);
                 $iOffset = ($iPage - 1) * self::ITEMS_PER_PAGE;
                 // the list
                 $formData['wikis'] = WikiFactory::getListOfWikisWithVar($gVar, $gTypeVal, $this->values[$gVal][2], $this->values[$gVal][1], $gLikeVal, $iOffset, self::ITEMS_PER_PAGE);
                 // the Paginator, if we need more than one page
                 if (self::ITEMS_PER_PAGE < $formData['count']) {
                     $oPaginator = Paginator::newFromArray(array_fill(0, $formData['count'], ''), self::ITEMS_PER_PAGE, 5);
                     $oPaginator->setActivePage($iPage - 1);
                     $sPager = $oPaginator->getBarHTML(sprintf('%s?var=%s&val=%s&likeValue=%s&searchType=%s&page=%%s', $wgTitle->getFullURL(), $gVar, $gVal, $gLikeVal, $gTypeVal));
                 }
             }
         }
     }
     $oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $oTmpl->set_vars(array('formData' => $formData, 'tagResultInfo' => $tagResultInfo, 'sPager' => $sPager));
     $wgOut->addHTML($oTmpl->render('list'));
 }
 protected function getPaginatedRSSData()
 {
     if (empty($this->getPaginatedData)) {
         $crRSS = $this->getRSSData();
         $this->title = $crRSS->getTitle();
         $pages = Paginator::newFromArray($crRSS->getItems(), self::CRUNCHYROLL_COLLUMNS * $this->getRowsNumber());
         $this->getPaginatedData = $pages;
     }
     return $this->getPaginatedData;
 }
 /**
  * Videos page
  * @requestParam string sort [ recent/popular/trend/premium ]
  * @requestParam integer page - page number
  * @responseParam integer addVideo [0/1]
  * @responseParam string pagination
  * @responseParam string sortMsg - selected option (sorting)
  * @responseParam array sortingOptions - sorting options
  * @responseParam array videos - list of videos
  */
 public function index()
 {
     $this->wg->SupressPageSubtitle = true;
     $this->getContext()->getOutput()->setPageTitle($this->wf->Msg('specialvideos-page-title'));
     $this->getContext()->getOutput()->setHTMLTitle($this->wf->Msg('specialvideos-html-title'));
     $this->getContext()->getOutput()->setRobotPolicy("index,follow");
     $sort = $this->request->getVal('sort', 'trend');
     $page = $this->request->getVal('page', 1);
     if (!is_numeric($page)) {
         $page = 1;
     }
     $addVideo = 1;
     $specialVideos = F::build('SpecialVideosHelper');
     $videos = $specialVideos->getVideos($sort, $page);
     $mediaService = F::build('MediaQueryService');
     if ($sort == 'premium') {
         $totalVideos = $mediaService->getTotalPremiumVideos();
     } else {
         $totalVideos = $mediaService->getTotalVideos();
     }
     $totalVideos = $totalVideos + 1;
     // adding 'add video' placeholder to video array count
     $sortingOptions = array_merge($specialVideos->getSortingOptions(), $specialVideos->getFilterOptions());
     if (!array_key_exists($sort, $sortingOptions)) {
         $sort = 'recent';
     }
     // Set up pagination
     $pagination = '';
     $linkToSpecialPage = SpecialPage::getTitleFor("Videos")->escapeLocalUrl();
     if ($totalVideos > SpecialVideosHelper::VIDEOS_PER_PAGE) {
         $pages = Paginator::newFromArray(array_fill(0, $totalVideos, ''), SpecialVideosHelper::VIDEOS_PER_PAGE);
         $pages->setActivePage($page - 1);
         $pagination = $pages->getBarHTML($linkToSpecialPage . '?page=%s&sort=' . $sort);
         // check if we're on the last page
         if ($page < $pages->getPagesCount()) {
             // we're not so don't show the add video placeholder
             $addVideo = 0;
         }
     }
     foreach ($videos as &$video) {
         $video['byUserMsg'] = $specialVideos->getByUserMsg($video['userName'], $video['userUrl']);
         $video['postedInMsg'] = $specialVideos->getPostedInMsg($video['truncatedList'], $video['isTruncated']);
         $video['videoOverlay'] = F::build('WikiaFileHelper', array(SpecialVideosHelper::THUMBNAIL_WIDTH, $video['fileTitle']), 'videoInfoOverlay');
         $video['videoPlayButton'] = F::build('WikiaFileHelper', array(SpecialVideosHelper::THUMBNAIL_WIDTH, SpecialVideosHelper::THUMBNAIL_HEIGHT), 'videoPlayButtonOverlay');
     }
     $this->thumbHeight = SpecialVideosHelper::THUMBNAIL_HEIGHT;
     $this->thumbWidth = SpecialVideosHelper::THUMBNAIL_WIDTH;
     $this->addVideo = $addVideo;
     $this->pagination = $pagination;
     $this->sortMsg = $sortingOptions[$sort];
     // selected sorting option to display in drop down
     $this->sortingOptions = $sortingOptions;
     // populate the drop down
     $this->videos = $videos;
 }
 public function index()
 {
     $this->response->addAsset('/skins/oasis/css/modules/CorporateDatepicker.scss');
     $this->collectRequestParameters();
     $faqPageName = $this->model->getWAMFAQPageName();
     $title = $this->wg->Title;
     if ($title instanceof Title) {
         $this->redirectIfMisspelledWamMainPage($title);
     }
     $this->faqPage = !empty($faqPageName) ? $faqPageName : '#';
     $this->visualizationWikis = $this->model->getVisualizationWikis($this->selectedVerticalId);
     $this->indexWikis = $this->model->getIndexWikis($this->getIndexParams());
     $total = empty($this->indexWikis['wam_results_total']) ? 0 : $this->indexWikis['wam_results_total'];
     $itemsPerPage = $this->model->getItemsPerPage();
     if ($total > $itemsPerPage) {
         $paginator = Paginator::newFromArray(array_fill(0, $total, ''), $itemsPerPage);
         $paginator->setActivePage($this->page - 1);
         $this->paginatorBar = $paginator->getBarHTML($this->getUrlWithAllParams());
     }
 }
 public function index()
 {
     $this->setGlobalDisplayVars();
     $this->accessReview = $this->wg->User->isAllowed('wdacreview');
     if (!$this->specialPage->userCanExecute($this->wg->User)) {
         $this->specialPage->displayRestrictionError();
         return false;
     }
     $this->response->addAsset('extensions/wikia/WDACReview/js/WDACReview.js');
     $this->response->addAsset('extensions/wikia/WDACReview/css/WDACReview.scss');
     $helper = $this->getHelper();
     $this->baseUrl = $this->specialPage->getTitle()->getFullUrl();
     $this->paginatorUrl = urldecode($this->specialPage->getTitle()->getFullUrl(array('page' => "%s")));
     $this->toolName = $this->getToolName();
     $this->submitUrl = $this->baseUrl;
     if ($this->wg->request->wasPosted()) {
         $data = $this->wg->request->getValues();
         if (!empty($data)) {
             $cities = $this->parseData($data);
             if (count($cities) > 0) {
                 $helper->updateWDACFlags($cities);
                 BannerNotificationsController::addConfirmation(wfMessage('wdacreview-confirm-update')->escaped());
             }
         }
     }
     $iPage = $this->wg->request->getVal('page', 1);
     $iCount = $helper->getCountWikisForReview();
     $this->aCities = $helper->getCitiesForReviewList(self::WIKIS_PER_PAGE_LIMIT, $iPage - 1);
     $this->paginator = '';
     if (self::WIKIS_PER_PAGE_LIMIT < $iCount) {
         $oPaginator = Paginator::newFromArray(array_fill(0, $iCount, ''), self::WIKIS_PER_PAGE_LIMIT);
         $oPaginator->setActivePage($iPage - 1);
         // And here we go! The %s will be replaced with the page number.
         $this->paginator = $oPaginator->getBarHTML($this->paginatorUrl);
     }
 }
 /**
  * main function returning filled template ready to print.
  * @param $itemsPerPage int number of articles per page
  * @param $namespace mixed: int namespace or array of int for category query
  * @return EasyTemplate object
  */
 protected function getTemplateForNameSpace($namespace, $itemsPerPage = 16, $negative = false)
 {
     $cachedContent = $this->getFromCache();
     $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     if (empty($cachedContent)) {
         $aTmpData = $this->fetchSectionItems($namespace, $negative);
         $pages = Paginator::newFromArray($aTmpData, $itemsPerPage);
         if (is_array($aTmpData) && count($aTmpData) > 0) {
             $aTmpData = $pages->getPage($this->paginatorPosition, true);
             $aData = $this->getArticles($aTmpData);
             $oTmpl->set_vars(array('data' => $aData, 'category' => $this->categoryTitle->getText(), 'paginator' => $pages->getBarHTML($this->sUrl)));
             $this->saveToCache($oTmpl->mVars);
             return $oTmpl;
         } else {
             return null;
         }
     } else {
         $oTmpl->set_vars($cachedContent);
         return $oTmpl;
     }
 }
 /**
  * Get pagination
  * @param integer $totalVideos
  * @param integer $currentPage
  * @param string $selectedSort
  * @return string $pagination
  */
 public function getPagination($totalVideos, $currentPage, $selectedSort)
 {
     $pagination = '';
     if ($totalVideos > self::VIDEOS_PER_PAGE) {
         $pages = Paginator::newFromArray(array_fill(0, $totalVideos, ''), self::VIDEOS_PER_PAGE);
         $pages->setActivePage($currentPage - 1);
         $linkToSpecialPage = SpecialPage::getTitleFor("LicensedVideoSwap")->escapeLocalUrl();
         $pagination = $pages->getBarHTML($linkToSpecialPage . '?currentPage=%s&sort=' . $selectedSort);
     }
     return $pagination;
 }
 /**
  * @desc Renders a table with wikis in visualization on corporate page plus pagination if needed
  *
  * @requestParam string $visualizationLang language code of wikis
  * @requestParam integer $page page number
  * @requestParam string $wikiHeadline a string filtering the list
  *
  * @return false if user does not have permissions
  */
 public function renderWikiListPage()
 {
     wfProfileIn(__METHOD__);
     if (!$this->checkAccess()) {
         wfProfileOut(__METHOD__);
         return false;
     }
     //todo: move to __construct() the same in index()
     if (empty($this->visualizationLang)) {
         $visualizationLang = $this->request->getVal('visualizationLang', $this->wg->contLang->getCode());
     } else {
         $visualizationLang = $this->visualizationLang;
     }
     $filterOptions = $this->request->getVal('filterOptions', []);
     //todo: new class for options
     $currentPage = $this->request->getVal('page', 1);
     $options = $this->prepareFilterOptions($visualizationLang, $filterOptions, $currentPage);
     $count = $this->helper->getWikisCountForStaffTool($options);
     $options->limit = self::WHST_WIKIS_PER_PAGE;
     $options->offset = ($currentPage - 1) * self::WHST_WIKIS_PER_PAGE;
     $this->list = $this->helper->getWikisForStaffTool($options);
     $this->collections = $this->getWikiaCollectionsModel()->getList($visualizationLang);
     $this->verticals = $this->helper->getWikiVerticals();
     if ($count > self::WHST_WIKIS_PER_PAGE) {
         /** @var $paginator Paginator */
         $paginator = Paginator::newFromArray(array_fill(0, $count, ''), self::WHST_WIKIS_PER_PAGE);
         $paginator->setActivePage($currentPage - 1);
         $url = $this->getUrlWithAllParams($visualizationLang, $filterOptions);
         $this->setVal('pagination', $paginator->getBarHTML($url));
     }
     wfProfileOut(__METHOD__);
 }
Esempio n. 9
0
<!-- s:<?php 
echo __FILE__;
?>
 -->
<?php 
if ($iPageCount > 1) {
    $pages = Paginator::newFromArray($iTotal, $iCount, 3, false, '', 50);
    $pages->setActivePage($iPage);
    echo $pages->getBarHTML('', 'BlogPaginator');
    ?>
<script type="text/javascript" src="<?php 
    echo $wgExtensionsPath;
    ?>
/wikia/Blogs/js/BlogsPager.js"></script>
<?php 
}
?>
<!-- e:<?php 
echo __FILE__;
?>
 -->
 /**
  * Get pagination (HTML)
  * @param array $videoParams
  *   [ array( 'sort' => string, 'page' => int, 'category' => string, 'provider' => string ) ]
  * @param int $addVideo
  * @return string $pagination
  */
 public function getPagination($videoParams, &$addVideo)
 {
     wfProfileIn(__METHOD__);
     $pagination = '';
     $linkToSpecialPage = SpecialPage::getTitleFor("Videos")->escapeLocalUrl();
     $totalVideos = $this->getTotalVideos($videoParams);
     if ($totalVideos > self::VIDEOS_PER_PAGE) {
         // Paginator::newFromArray allows array and integer param
         $pages = Paginator::newFromArray($totalVideos, self::VIDEOS_PER_PAGE);
         $pages->setActivePage($videoParams['page'] - 1);
         $queryString = '';
         foreach (['sort', 'category', 'provider'] as $key) {
             if (!empty($videoParams[$key])) {
                 $queryString .= "&{$key}=" . urlencode($videoParams[$key]);
             }
         }
         $pagination = $pages->getBarHTML($linkToSpecialPage . '?page=%s' . $queryString);
         // check if we're on the last page
         if ($videoParams['page'] < $pages->getPagesCount()) {
             // we're not so don't show the add video placeholder
             $addVideo = 0;
         }
     }
     wfProfileOut(__METHOD__);
     return $pagination;
 }
 public function getHTML()
 {
     global $wgCategoryExhibitionMediaSectionRows;
     $cachedContent = $this->getFromCache();
     if (empty($cachedContent)) {
         // grabs data for videos and images
         $aTmpData = $this->fetchSectionItems(array(NS_FILE));
         // we wan't old videos
         if (is_array($aTmpData) && count($aTmpData) > 0) {
             $pages = Paginator::newFromArray($aTmpData, $wgCategoryExhibitionMediaSectionRows * 4);
             $pageData = $pages->getPage($this->paginatorPosition, true);
             $aData = array();
             foreach ($pageData as $item) {
                 $itemTitle = Title::newFromID($item['page_id']);
                 $forceHeight = '';
                 $forceWidth = '';
                 $isVideo = WikiaFileHelper::isFileTypeVideo($itemTitle);
                 // item is image
                 $image = wfFindFile($itemTitle);
                 $elementClass = 'lightbox';
                 if (!is_object($image) || $image->height == 0 || $image->width == 0) {
                     $imageSrc = '';
                 } else {
                     $proportions = $image->width / $image->height;
                     if ($proportions < 1) {
                         $calculatedWidth = floor($proportions * $this->thumbWidth);
                     } else {
                         $calculatedWidth = $this->thumbMedia;
                     }
                     $forceWidth = floor($calculatedWidth);
                     $forceHeight = floor($calculatedWidth / $proportions);
                     $imageServing = new ImageServing(array($item['page_id']), $calculatedWidth, array("w" => $image->width, "h" => $image->height));
                     $imageSrc = wfReplaceImageServer($image->getThumbUrl($imageServing->getCut($image->width, $image->height) . "-" . $image->getName()));
                     if ($isVideo) {
                         $videoSizeClass = ThumbnailHelper::getThumbnailSize($forceWidth);
                         $elementClass .= ' video video-thumbnail ' . $videoSizeClass;
                     }
                 }
                 $linkedFiles = $this->getLinkedFiles($itemTitle);
                 if (!empty($linkedFiles)) {
                     $linkText = $linkedFiles->getText();
                     $linkFullUrl = $linkedFiles->getFullURL();
                 } else {
                     $linkText = '';
                     $linkFullUrl = '';
                 }
                 // types casting for proper caching;
                 $aData[] = array('id' => $item['page_id'], 'title' => $itemTitle->getText(), 'key' => $itemTitle->getDBKey(), 'img' => (string) $imageSrc, 'url' => $itemTitle->getFullURL(), 'dimensions' => array('w' => (int) $forceWidth, 'h' => (int) $forceHeight), 'class' => $elementClass, 'data-ref' => $itemTitle->getPrefixedURL(), 'targetUrl' => $linkFullUrl, 'targetText' => $linkText, 'isVideo' => $isVideo);
             }
             $aContent = array('data' => $aData, 'category' => $this->categoryTitle->getText(), 'paginator' => $pages->getBarHTML($this->sUrl));
             $this->saveToCache($aContent);
         } else {
             return false;
         }
     } else {
         $aContent = $cachedContent;
     }
     if (!empty($aContent) && is_array($aContent)) {
         $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
         $oTmpl->set_vars($aContent);
         $oTmpl->set_vars(array('fromAjax' => $this->isFromAjax));
         if ($this->isFromAjax) {
             return array('page' => $oTmpl->render($this->templateName), 'paginator' => $oTmpl->mVars['paginator']);
         } else {
             return $oTmpl->render($this->templateName);
         }
     }
 }
 /**
  * Prepare pagination
  */
 private function preparePagination()
 {
     $total = $this->model->getTotalResultsNum();
     $itemsPerPage = $this->model->getLimitResultsNum();
     $params['page'] = '%s';
     $sorting = $this->request->getVal('sort', null);
     if ($sorting) {
         $params['sort'] = $sorting;
     }
     if ($total > $itemsPerPage) {
         $paginator = Paginator::newFromArray(array_fill(0, $total, ''), $itemsPerPage);
         $paginator->setActivePage($this->model->getPage());
         $url = urldecode($this->getSpecialInsightsUrl($this->subpage, $params));
         $this->paginatorBar = $paginator->getBarHTML($url);
     }
 }