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(); }
public function onAjax(tubepress_api_event_EventInterface $ajaxEvent) { $isDebugEnabled = $this->_logger->isEnabled(); if ($isDebugEnabled) { $this->_logger->debug('Handling incoming request. First parsing shortcode.'); } $nvpMap = $this->_requestParams->getParamValue('tubepress_options'); $itemId = $this->_requestParams->getParamValue('tubepress_item'); if ($isDebugEnabled) { $this->_logger->debug('Requested item ID is ' . $itemId); } $this->_context->setEphemeralOptions($nvpMap); if ($this->_context->get(tubepress_api_options_Names::EMBEDDED_LAZYPLAY)) { $this->_context->setEphemeralOption(tubepress_api_options_Names::EMBEDDED_AUTOPLAY, true); } if ($isDebugEnabled) { $this->_logger->debug('Now asking collector for item with ID ' . $itemId); } /* grab the item! */ $mediaItem = $this->_collector->collectSingle($itemId); if ($mediaItem === null) { $this->_responseCode->setResponseCode(404); $ajaxEvent->setArgument('handled', true); return; } if ($isDebugEnabled) { $this->_logger->debug('Collector found item with ID ' . $itemId . '. Sending it to browser'); } $playerHtml = $this->_templating->renderTemplate('gallery/player/ajax', array(tubepress_api_template_VariableNames::MEDIA_ITEM => $mediaItem)); $toReturn = array('mediaItem' => $mediaItem->toHtmlSafeArray(), 'html' => $playerHtml); $this->_responseCode->setResponseCode(200); echo json_encode($toReturn); $ajaxEvent->setArgument('handled', true); }
public function onOptionSet(tubepress_api_event_EventInterface $event) { if (!$this->_logger->isEnabled()) { return; } $errors = $event->getSubject(); $optionName = $event->getArgument('optionName'); $optionValue = $event->getArgument('optionValue'); if (count($errors) === 0) { $this->_logger->debug(sprintf('(Option Logger) Accepted valid value: <code>%s</code> = <code>%s</code>', $optionName, $this->_stringUtils->redactSecrets($optionValue))); } else { $this->_logger->error(sprintf('(Option Logger) Rejecting invalid value: <code>%s</code> = <code>%s</code> (%s)', $optionName, $this->_stringUtils->redactSecrets($optionValue), $errors[0])); } }
private function _handle(tubepress_api_event_EventInterface $event) { $itemId = $this->_requestParams->getParamValue('tubepress_item'); $shouldLog = $this->_logger->isEnabled(); if ($shouldLog) { $this->_logger->debug(sprintf('Building single video with ID %s', $itemId)); } $result = $this->_context->setEphemeralOption(tubepress_api_options_Names::SINGLE_MEDIA_ITEM_ID, $itemId); if ($result !== null) { if ($shouldLog) { $this->_logger->debug('Could not verify video ID.'); } } }
public function onException(tubepress_api_event_EventInterface $event) { if (!$this->_logger->isEnabled()) { return; } /* * @var Exception */ $exception = $event->getSubject(); $traceData = $exception->getTraceAsString(); $traceData = explode("\n", $traceData); foreach ($traceData as $line) { $line = htmlspecialchars($line); $this->_logger->error("<code>{$line}</code><br />"); } }
public function __construct(tubepress_api_options_ContextInterface $context, tubepress_api_boot_BootSettingsInterface $bootSettings, tubepress_api_log_LoggerInterface $logger) { $this->_context = $context; $this->_bootSettings = $bootSettings; $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); }
private function _feedToMediaItemArray(tubepress_spi_media_HttpFeedHandlerInterface $feedHandler) { $toReturn = array(); $total = $feedHandler->getCurrentResultCount(); if ($this->_shouldLog) { $this->_logDebug(sprintf('Now attempting to build %d item(s) from raw feed', $total)); } for ($index = 0; $index < $total; ++$index) { $failureMessage = $feedHandler->getReasonUnableToUseItemAtIndex($index); if ($failureMessage !== null) { if ($this->_shouldLog) { $this->_logDebug(sprintf('Skipping item at index %d: %s', $index, $failureMessage)); } continue; } $mediaItemId = $feedHandler->getIdForItemAtIndex($index); if (!$mediaItemId) { if ($this->_logger->isEnabled()) { $this->_logger->error(sprintf('Unable to determine ID for item at index %d. Skipping it.', $index)); } continue; } $mediaItem = new tubepress_api_media_MediaItem($mediaItemId); $initialEventArgs = $feedHandler->getNewItemEventArguments($mediaItem, $index); $finalItem = $this->_dispatchAndReturnSubject($feedHandler, tubepress_api_event_Events::MEDIA_ITEM_HTTP_NEW, $mediaItem, $initialEventArgs); array_push($toReturn, $finalItem); } $feedHandler->onAnalysisComplete(); if ($this->_shouldLog) { $this->_logDebug(sprintf('Built %d items(s) from raw feed', sizeof($toReturn))); } return $toReturn; }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_ContextInterface $context, tubepress_api_http_RequestParametersInterface $requestParams, tubepress_api_media_CollectorInterface $collector) { $this->_logger = $logger; $this->_context = $context; $this->_requestParams = $requestParams; $this->_collector = $collector; $this->_shouldLog = $logger->isEnabled(); }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_ContextInterface $context, tubepress_api_contrib_RegistryInterface $themeRegistry, tubepress_theme_impl_CurrentThemeService $currentThemeService) { $this->_themeRegistry = $themeRegistry; $this->_context = $context; $this->_currentThemeService = $currentThemeService; $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_ContextInterface $context, tubepress_api_event_EventDispatcherInterface $eventDispatcher, tubepress_api_util_StringUtilsInterface $stringUtils) { $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); $this->_context = $context; $this->_eventDispatcher = $eventDispatcher; $this->_stringUtils = $stringUtils; }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_ContextInterface $context, tubepress_api_event_EventDispatcherInterface $eventDispatcher, tubepress_api_environment_EnvironmentInterface $environment) { $this->_context = $context; $this->_eventDispatcher = $eventDispatcher; $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); $this->_environment = $environment; }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_PersistenceInterface $persistence, tubepress_http_oauth2_impl_util_PersistenceHelper $persistenceHelper, tubepress_http_oauth2_impl_util_AccessTokenFetcher $accessTokenFetcher) { $this->_persistenceHelper = $persistenceHelper; $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); $this->_accessTokenFetcher = $accessTokenFetcher; $this->_persistence = $persistence; }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_ContextInterface $context, tubepress_api_url_UrlFactoryInterface $urlFactory, tubepress_api_array_ArrayReaderInterface $arrayReader, tubepress_dailymotion_impl_dmapi_ApiUtility $apiUtility) { $this->_logger = $logger; $this->_context = $context; $this->_urlFactory = $urlFactory; $this->_arrayReader = $arrayReader; $this->_apiUtility = $apiUtility; $this->_shouldLog = $logger->isEnabled(); }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_options_ContextInterface $context, tubepress_api_http_HttpClientInterface $httpClient, tubepress_api_array_ArrayReaderInterface $arrayReader) { $this->_logger = $logger; $this->_context = $context; $this->_httpClient = $httpClient; $this->_arrayReader = $arrayReader; $this->_memoryCache = array(); $this->_shouldLog = $logger->isEnabled(); }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_http_RequestParametersInterface $requestParams, tubepress_api_http_ResponseCodeInterface $responseCode, tubepress_api_event_EventDispatcherInterface $eventDispatcher, tubepress_api_template_TemplatingInterface $templating) { $this->_logger = $logger; $this->_isDebugEnabled = $logger->isEnabled(); $this->_requestParameters = $requestParams; $this->_responseCode = $responseCode; $this->_eventDispatcher = $eventDispatcher; $this->_templating = $templating; }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_internal_boot_helper_uncached_contrib_ManifestFinder $manifestFinder, tubepress_internal_boot_helper_uncached_contrib_AddonFactory $addonFactory, tubepress_internal_boot_helper_uncached_Compiler $ici, tubepress_api_boot_BootSettingsInterface $sfri) { $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); $this->_iocCompiler = $ici; $this->_bootSettings = $sfri; $this->_manifestFinder = $manifestFinder; $this->_addonFactory = $addonFactory; }
public function __construct(tubepress_api_event_EventDispatcherInterface $eventDispatcher, tubepress_api_options_ContextInterface $context, tubepress_api_html_HtmlGeneratorInterface $htmlGenerator, tubepress_api_options_ReferenceInterface $optionsReference, tubepress_api_log_LoggerInterface $logger) { $this->_eventDispatcher = $eventDispatcher; $this->_context = $context; $this->_htmlGenerator = $htmlGenerator; $this->_optionsReference = $optionsReference; $this->_logger = $logger; $this->_loggingEnabled = $logger->isEnabled(); }
public function __construct($systemStartingPoint, $userStartingPoint, $manifestName, tubepress_api_log_LoggerInterface $logger, tubepress_api_boot_BootSettingsInterface $bootSettings, tubepress_internal_finder_FinderFactory $finderFactory) { $this->_shouldLog = $logger->isEnabled(); $this->_logger = $logger; $this->_bootSettings = $bootSettings; $this->_finderFactory = $finderFactory; $this->_systemStartingPoint = $systemStartingPoint; $this->_userStartingPoint = $userStartingPoint; $this->_manifestName = $manifestName; }
/** * @param string $manifestPath * @param array $manifestData * * @return tubepress_internal_contrib_AbstractContributable */ public function fromManifestData($manifestPath, array $manifestData) { $errors = $this->_normalizeAndReturnErrors($manifestPath, $manifestData); if (count($errors) !== 0) { if ($this->_logger->isEnabled()) { $this->_logger->error(sprintf('The following errors were detected when processing %s', $manifestPath)); foreach ($errors as $error) { $this->_logger->error($error); } } return $errors; } $contributable = $this->buildWithValidNormalizedData($manifestPath, $manifestData); $this->_setDescription($manifestData, $contributable); $this->_setKeywords($manifestData, $contributable); $this->_setScreenshots($manifestData, $contributable); $this->_setSupport($manifestData, $contributable); return $contributable; }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_template_TemplatingInterface $templating, tubepress_api_options_PersistenceInterface $persistence, tubepress_api_util_StringUtilsInterface $stringUtils, tubepress_html_impl_CssAndJsGenerationHelper $cssAndJsGenerationHelper, tubepress_api_http_RequestParametersInterface $httpRequestParams) { $this->_logger = $logger; $this->_templating = $templating; $this->_persistence = $persistence; $this->_stringUtils = $stringUtils; $this->_cssAndJsGenerationHelper = $cssAndJsGenerationHelper; $this->_httpRequestParams = $httpRequestParams; $this->_shouldLog = $logger->isEnabled(); }
public function onHtmlGeneration(tubepress_api_event_EventInterface $event) { $mediaItemId = $this->_context->get(tubepress_api_options_Names::SINGLE_MEDIA_ITEM_ID); if ($mediaItemId == '') { return; } /* grab the media item from the provider */ if ($this->_logger->isEnabled()) { $this->_logger->debug(sprintf('Asking provider for video with ID %s', $mediaItemId)); } $mediaItem = $this->_collector->collectSingle($mediaItemId); $eventArgs = array('itemId' => $mediaItemId); if ($mediaItem !== null) { $eventArgs['mediaItem'] = $mediaItem; } $singleHtml = $this->_templating->renderTemplate('single/main', $eventArgs); $event->setSubject($singleHtml); $event->stopPropagation(); }
public function __construct(tubepress_wordpress_impl_wp_WpFunctions $wpFunctions, tubepress_api_options_PersistenceInterface $persistence, tubepress_api_log_LoggerInterface $logger, tubepress_api_event_EventDispatcherInterface $eventDispatcher, array $actions, array $filters) { $this->_baseName = basename(TUBEPRESS_ROOT); $this->_wpFunctions = $wpFunctions; $this->_persistence = $persistence; $this->_actions = $actions; $this->_filters = $filters; $this->_logger = $logger; $this->_eventDispatcher = $eventDispatcher; $this->_loggingEnabled = $logger->isEnabled(); }
public function onPreValidationSet(tubepress_api_event_EventInterface $event) { $themeValue = $event->getArgument('optionValue'); $shouldLog = $this->_logger->isEnabled(); if (in_array($themeValue, self::$_LEGACY_THEME_VALUES)) { if ($shouldLog) { $this->_logger->debug(sprintf('Renaming theme value from %s to tubepress/legacy-%s', $themeValue, $themeValue)); } $event->setArgument('optionValue', "tubepress/legacy-{$themeValue}"); return; } $allThemes = $this->_themeRegistry->getAll(); foreach ($allThemes as $theme) { if ($theme->getName() !== "unknown/legacy-{$themeValue}") { continue; } if ($shouldLog) { $this->_logger->debug(sprintf('Renaming theme value from %s to unknown/legacy-%s', $themeValue, $themeValue)); } $event->setArgument('optionValue', "unknown/legacy-{$themeValue}"); } }
/** * @param tubepress_api_url_UrlInterface $url * * @return \Stash\Interfaces\ItemInterface */ private function _getCachedItem(tubepress_api_url_UrlInterface $url) { $isDebugEnabled = $this->_logger->isEnabled(); if ($isDebugEnabled) { $this->_logDebug(sprintf('Asking cache for <code>%s</code>', $url)); } /* * @var \Stash\Interfaces\ItemInterface */ $result = $this->_getItem($url); if ($isDebugEnabled) { if ($result->isMiss()) { $this->_logDebug(sprintf('Cache miss for <code>%s</code>.', $url)); } else { $this->_logDebug(sprintf('Cache hit for <code>%s</code>.', $url)); } } return $result; }
private function _handleSearchOutput(tubepress_api_event_EventInterface $event) { $rawSearchTerms = $this->_requestParams->getParamValue('tubepress_search'); $hasSearchTerms = $rawSearchTerms != ''; $shouldLog = $this->_logger->isEnabled(); /* if the user isn't searching, don't display anything */ if (!$hasSearchTerms) { if ($shouldLog) { $this->_logDebug('User doesn\'t appear to be searching. Will not display anything.'); } $event->setSubject(''); $event->stopPropagation(); return; } if ($shouldLog) { $this->_logDebug('User is searching. We\'ll handle this.'); } $provider = $this->_findMediaProvider(); $modeName = $provider->getSearchModeName(); $valueName = $provider->getSearchQueryOptionName(); $this->_context->setEphemeralOption(tubepress_api_options_Names::GALLERY_SOURCE, $modeName); $this->_context->setEphemeralOption($valueName, $rawSearchTerms); }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_boot_BootSettingsInterface $bootSettings) { $this->_logger = $logger; $this->_bootSettings = $bootSettings; $this->_logEnabled = $logger->isEnabled(); }
public function __construct(tubepress_api_log_LoggerInterface $logger, tubepress_api_url_UrlFactoryInterface $urlFactory) { $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); $this->_urlFactory = $urlFactory; }
public function __construct(tubepress_api_log_LoggerInterface $logger) { $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); }
public function __construct(array $engines = array(), tubepress_api_log_LoggerInterface $logger) { parent::__construct($engines); $this->_logger = $logger; $this->_shouldLog = $this->_logger->isEnabled(); }
public function __construct(tubepress_api_event_EventDispatcherInterface $eventDispatcher, tubepress_api_log_LoggerInterface $logger) { $this->_eventDispatcher = $eventDispatcher; $this->_logger = $logger; $this->_shouldLog = $logger->isEnabled(); }