public function alter_providerResult(org_tubepress_api_provider_ProviderResult $providerResult) { $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $perPageSortOrder = $context->get(org_tubepress_api_const_options_names_Feed::PER_PAGE_SORT); $feedSortOrder = $context->get(org_tubepress_api_const_options_names_Feed::ORDER_BY); /** No sort requested? */ if ($perPageSortOrder === org_tubepress_api_const_options_values_PerPageSortValue::NONE) { org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Requested per-page sort order is "none". Not applying per-page sorting.'); return $providerResult; } /** Grab a handle to the videos. */ $videos = $providerResult->getVideoArray(); if ($feedSortOrder === org_tubepress_api_const_options_values_OrderByValue::RANDOM || $perPageSortOrder === org_tubepress_api_const_options_values_PerPageSortValue::RANDOM) { org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Shuffling videos'); shuffle($videos); } else { /** Determine the sort method name. */ $sortCallback = '_' . $perPageSortOrder . '_compare'; /** If we have a sorter, use it. */ if (method_exists($this, $sortCallback)) { org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Now sorting %s videos on page (%s)', count($videos), $perPageSortOrder); uasort($videos, array($this, $sortCallback)); } else { org_tubepress_impl_log_Log::log(self::$_logPrefix, 'No sort available for this page (%s)', $perPageSortOrder); } } $videos = array_values($videos); /** Modify the feed result. */ $providerResult->setVideoArray($videos); return $providerResult; }
public function alter_galleryTemplate(org_tubepress_api_template_Template $template, org_tubepress_api_provider_ProviderResult $providerResult, $page, $providerName) { $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $htmlGenerator = $ioc->get(org_tubepress_api_player_PlayerHtmlGenerator::_); $playerName = $context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_LOCATION); $videos = $providerResult->getVideoArray(); $galleryId = $context->get(org_tubepress_api_const_options_names_Advanced::GALLERY_ID); $playerHtml = $playerHtml = $this->_showPlayerHtmlOnPageLoad($ioc, $playerName) ? $htmlGenerator->getHtml($videos[0], $galleryId) : ''; $template->setVariable(org_tubepress_api_const_template_Variable::PLAYER_HTML, $playerHtml); $template->setVariable(org_tubepress_api_const_template_Variable::PLAYER_NAME, $playerName); return $template; }
public function alter_providerResult(org_tubepress_api_provider_ProviderResult $providerResult, $providerName) { $videos = $providerResult->getVideoArray(); $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get('org_tubepress_api_exec_ExecutionContext'); /* shuffle if we need to */ if ($context->get(org_tubepress_api_const_options_names_Display::ORDER_BY) == org_tubepress_api_const_options_values_OrderValue::RANDOM) { org_tubepress_impl_log_Log::log('Shuffler', 'Shuffling videos'); shuffle($videos); } /* modify the feed result */ $providerResult->setVideoArray($videos); return $providerResult; }
public function alter_galleryTemplate(org_tubepress_api_template_Template $template, org_tubepress_api_provider_ProviderResult $providerResult, $page, $providerName) { $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get('org_tubepress_api_exec_ExecutionContext'); $videoArray = $providerResult->getVideoArray(); $thumbWidth = $context->get(org_tubepress_api_const_options_names_Display::THUMB_WIDTH); $thumbHeight = $context->get(org_tubepress_api_const_options_names_Display::THUMB_HEIGHT); $galleryId = $context->get(org_tubepress_api_const_options_names_Advanced::GALLERY_ID); /* add some core template variables */ $template->setVariable(org_tubepress_api_const_template_Variable::VIDEO_ARRAY, $videoArray); $template->setVariable(org_tubepress_api_const_template_Variable::GALLERY_ID, $galleryId); $template->setVariable(org_tubepress_api_const_template_Variable::THUMBNAIL_WIDTH, $thumbWidth); $template->setVariable(org_tubepress_api_const_template_Variable::THUMBNAIL_HEIGHT, $thumbHeight); return $template; }
public function alter_providerResult(org_tubepress_api_provider_ProviderResult $providerResult) { $totalResults = $providerResult->getEffectiveTotalResultCount(); $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $limit = $context->get(org_tubepress_api_const_options_names_Feed::RESULT_COUNT_CAP); $firstCut = $limit == 0 ? $totalResults : min($limit, $totalResults); $secondCut = min($firstCut, self::_calculateRealMax($context, $firstCut)); $videos = $providerResult->getVideoArray(); $resultCount = count($videos); org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Effective total result count (taking into account user-defined limit) is %d video(s)', $secondCut); if ($resultCount > $secondCut) { org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Result has %d video(s), limit is %d. So we\'re chopping it down.', $resultCount, $secondCut); $providerResult->setVideoArray(array_splice($videos, 0, $secondCut - $resultCount)); } $providerResult->setEffectiveTotalResultCount($secondCut); return $providerResult; }
public function alter_providerResult(org_tubepress_api_provider_ProviderResult $providerResult) { $videos = $providerResult->getVideoArray(); $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $blacklist = $context->get(org_tubepress_api_const_options_names_Feed::VIDEO_BLACKLIST); $videosToKeep = array(); $blacklistCount = 0; foreach ($videos as $video) { $id = $video->getId(); /* keep videos without an ID or that aren't blacklisted */ if (!isset($id) || $this->_isNotBlacklisted($id, $blacklist)) { $videosToKeep[] = $video; } else { $blacklistCount++; } } /* modify the feed result */ $providerResult->setVideoArray($videosToKeep); return $providerResult; }