Esempio n. 1
0
 public function onHtmlGeneration(tubepress_api_event_EventInterface $event)
 {
     $galleryId = $this->_context->get(tubepress_api_options_Names::HTML_GALLERY_ID);
     $shouldLog = $this->_logger->isEnabled();
     if ($galleryId == '') {
         $galleryId = mt_rand();
         $this->_context->setEphemeralOption(tubepress_api_options_Names::HTML_GALLERY_ID, $galleryId);
     }
     if ($shouldLog) {
         $this->_logDebug(sprintf('Starting to build thumbnail gallery <code>%s</code>', $galleryId));
     }
     $pageNumber = $this->_requestParameters->getParamValueAsInt('tubepress_page', 1);
     /* first grab the items */
     if ($shouldLog) {
         $this->_logDebug('Asking collector for a page.');
     }
     $mediaPage = $this->_collector->collectPage($pageNumber);
     $itemCount = sizeof($mediaPage->getItems());
     if ($shouldLog) {
         $this->_logDebug(sprintf('Collector has delivered <code>%d</code> item(s)', $itemCount));
     }
     $templateVars = array('mediaPage' => $mediaPage, 'pageNumber' => $pageNumber);
     $html = $this->_templating->renderTemplate('gallery/main', $templateVars);
     /* we're done. tie up */
     if ($shouldLog) {
         $this->_logDebug(sprintf('Done assembling gallery <code>%d</code>', $galleryId));
     }
     $event->setSubject($html);
     $event->stopPropagation();
 }
Esempio n. 2
0
 private function _getHtml($vidCount)
 {
     $currentPage = $this->_requestParams->getParamValueAsInt('tubepress_page', 1);
     $vidsPerPage = $this->_context->get(tubepress_api_options_Names::FEED_ADJUSTED_RESULTS_PER_PAGE);
     if (!$vidsPerPage) {
         $vidsPerPage = $this->_context->get(tubepress_api_options_Names::FEED_RESULTS_PER_PAGE);
     }
     $newurl = $this->_urlFactory->fromCurrent();
     if (!$this->_isLegacyTheme()) {
         return $this->_paginationFromTemplate($vidCount, $currentPage, $vidsPerPage, $newurl);
     }
     return $this->_legacyPagination($vidCount, $currentPage, $vidsPerPage, 1, $newurl, 'tubepress_page');
 }
Esempio n. 3
0
 public function onPostStylesTemplateRender(tubepress_api_event_EventInterface $event)
 {
     $html = $event->getSubject();
     $page = $this->_requestParameters->getParamValueAsInt('tubepress_page', 1);
     if ($page > 1) {
         $html .= "\n" . '<meta name="robots" content="noindex, nofollow" />';
     }
     $event->setSubject($html);
 }