/**
  * Load system-defined plugins.
  *
  * @param org_tubepress_api_ioc_IocService $ioc The IOC container.
  *
  * @return void
  */
 protected function loadSystemPlugins(org_tubepress_api_ioc_IocService $ioc)
 {
     $pm = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
     /* pre validation option setting */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::OPTION_SET_PRE_VALIDATION, $ioc->get('org_tubepress_impl_plugin_filters_prevalidationoptionset_StringMagic'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::OPTION_SET_PRE_VALIDATION, $ioc->get('org_tubepress_impl_plugin_filters_prevalidationoptionset_YouTubePlaylistPlPrefixRemover'));
     /* embedded template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED, $ioc->get('org_tubepress_impl_plugin_filters_embeddedtemplate_CoreVariables'));
     /* embedded HTML filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::HTML_EMBEDDED, $ioc->get('org_tubepress_impl_plugin_filters_embeddedhtml_PlayerJavaScriptApi'));
     /* gallery HTML filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::HTML_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_galleryhtml_GalleryJs'));
     /* gallery init js */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::JAVASCRIPT_GALLERYINIT, $ioc->get('org_tubepress_impl_plugin_filters_galleryinitjs_GalleryInitJsBaseParams'));
     /* gallery template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_CoreVariables'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_EmbeddedPlayerName'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_Pagination'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_Player'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_VideoMeta'));
     /* player template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_PLAYER, $ioc->get('org_tubepress_impl_plugin_filters_playertemplate_CoreVariables'));
     /* provider result filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_ResultCountCapper'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_VideoBlacklist'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_PerPageSorter'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_VideoPrepender'));
     /* search input template filter */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SEARCHINPUT, $ioc->get('org_tubepress_impl_plugin_filters_searchinputtemplate_CoreVariables'));
     /* single video template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, $ioc->get('org_tubepress_impl_plugin_filters_singlevideotemplate_CoreVariables'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, $ioc->get('org_tubepress_impl_plugin_filters_singlevideotemplate_VideoMeta'));
     /* external input filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::VARIABLE_READ_FROM_EXTERNAL_INPUT, $ioc->get('org_tubepress_impl_plugin_filters_variablereadfromexternalinput_StringMagic'));
     $pm->registerListener(org_tubepress_api_const_plugin_EventName::BOOT, $ioc->get('org_tubepress_impl_plugin_listeners_WordPressBoot'));
     $pm->registerListener(org_tubepress_api_const_plugin_EventName::BOOT, $ioc->get('org_tubepress_impl_plugin_listeners_SkeletonExistsListener'));
 }
 /**
  * Handles the detection of a custom options
  *
  * @param array                            $customOptions The custom options array
  * @param array                            $match         The array shortcode matches
  * @param org_tubepress_api_ioc_IocService $ioc           The IOC service
  *
  * @return void
  */
 private static function _parseCustomOption($customOptions, $match, org_tubepress_api_ioc_IocService $ioc)
 {
     $inputValidationService = $ioc->get('org_tubepress_api_options_OptionValidator');
     foreach ($match as $m) {
         if (!empty($m[1])) {
             $name = $m[1];
             $value = self::_normalizeValue($m[2]);
         } elseif (!empty($m[3])) {
             $name = $m[3];
             $value = self::_normalizeValue($m[4]);
         } elseif (!empty($m[5])) {
             $name = $m[5];
             $value = self::_normalizeValue($m[6]);
         }
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Valid shortcode option detected: %s = %s', $name, (string) $value);
         try {
             $inputValidationService->validate($name, $value);
             $customOptions[$name] = $value;
         } catch (Exception $e) {
             org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Ignoring invalid value for "%s" option: %s', $name, $e->getMessage());
         }
     }
     return $customOptions;
 }
 /**
  * Load system-defined plugins.
  *
  * @param org_tubepress_api_ioc_IocService $ioc The IOC container.
  *
  * @return void
  */
 protected function loadSystemPlugins(org_tubepress_api_ioc_IocService $ioc)
 {
     $pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
     /* embedded template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_EMBEDDED, $ioc->get('org_tubepress_impl_plugin_filters_embeddedtemplate_CoreVariables'));
     /* gallery HTML filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::HTML_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_galleryhtml_GalleryJs'));
     /* gallery template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_CoreVariables'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_EmbeddedPlayerName'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_Pagination'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_Player'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $ioc->get('org_tubepress_impl_plugin_filters_gallerytemplate_VideoMeta'));
     /* player template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_PLAYER, $ioc->get('org_tubepress_impl_plugin_filters_playertemplate_CoreVariables'));
     /* provider result filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_ResultCountCapper'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_VideoBlacklist'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_Shuffler'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::PROVIDER_RESULT, $ioc->get('org_tubepress_impl_plugin_filters_providerresult_VideoPrepender'));
     /* search input template filter */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SEARCHINPUT, $ioc->get('org_tubepress_impl_plugin_filters_searchinputtemplate_CoreVariables'));
     /* single video template filters */
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, $ioc->get('org_tubepress_impl_plugin_filters_singlevideotemplate_CoreVariables'));
     $pm->registerFilter(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_SINGLEVIDEO, $ioc->get('org_tubepress_impl_plugin_filters_singlevideotemplate_VideoMeta'));
     $pm->registerListener(org_tubepress_api_const_plugin_EventName::BOOT, $ioc->get('org_tubepress_impl_plugin_listeners_WordPressBoot'));
     $pm->registerListener(org_tubepress_api_const_plugin_EventName::BOOT, $ioc->get('org_tubepress_impl_plugin_listeners_SkeletonExistsListener'));
 }
 /**
  * Handles the detection of a custom options
  *
  * @param array                            $customOptions The custom options array
  * @param array                            $match         The array shortcode matches
  * @param org_tubepress_api_ioc_IocService $ioc           The IOC service
  *
  * @return void
  */
 private static function _buildNameValuePairArray($match, org_tubepress_api_ioc_IocService $ioc)
 {
     $toReturn = array();
     $pluginManager = $ioc->get(org_tubepress_api_plugin_PluginManager::_);
     foreach ($match as $m) {
         if (!empty($m[1])) {
             $name = $m[1];
             $value = $m[2];
         } elseif (!empty($m[3])) {
             $name = $m[3];
             $value = $m[4];
         } elseif (!empty($m[5])) {
             $name = $m[5];
             $value = $m[6];
         }
         org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Name-value pair detected: %s = "%s" (unfiltered)', $name, $value);
         $filtered = $pluginManager->runFilters(org_tubepress_api_const_plugin_FilterPoint::VARIABLE_READ_FROM_EXTERNAL_INPUT, $value, $name);
         org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Name-value pair detected: %s = "%s" (filtered)', $name, $filtered);
         $toReturn[$name] = $filtered;
     }
     return $toReturn;
 }
 private static function _getTransportCommands(org_tubepress_api_ioc_IocService $ioc)
 {
     $result = array();
     $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_);
     $map = array(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_EXTHTTP => 'org_tubepress_impl_http_transports_ExtHttpTransport', org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_CURL => 'org_tubepress_impl_http_transports_CurlTransport', org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_STREAMS => 'org_tubepress_impl_http_transports_StreamsTransport', org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_FSOCKOPEN => 'org_tubepress_impl_http_transports_FsockOpenTransport', org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_FOPEN => 'org_tubepress_impl_http_transports_FopenTransport');
     foreach ($map as $optionName => $transport) {
         /* use the transport if it's not disabled */
         if (!$context->get($optionName)) {
             $result[] = $transport;
         } else {
             org_tubepress_impl_log_Log::log(self::$_logPrefix, '%s has been selected', $optionName);
         }
     }
     return $result;
 }
 private static function _getTransportCommands(org_tubepress_api_ioc_IocService $ioc)
 {
     $result = array();
     $context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
     if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_EXTHTTP)) {
         $result[] = 'org_tubepress_impl_http_clientimpl_commands_ExtHttpCommand';
     } else {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'ExtHttp transport disabled by request');
     }
     if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_CURL)) {
         $result[] = 'org_tubepress_impl_http_clientimpl_commands_CurlCommand';
     } else {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Curl transport disabled by request');
     }
     if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_STREAMS)) {
         $result[] = 'org_tubepress_impl_http_clientimpl_commands_StreamsCommand';
     } else {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Streams transport disabled by request');
     }
     if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_FOPEN)) {
         $result[] = 'org_tubepress_impl_http_clientimpl_commands_FopenCommand';
     } else {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'fopen transport disabled by request');
     }
     if (!$context->get(org_tubepress_api_const_options_names_Advanced::DISABLE_HTTP_FSOCKOPEN)) {
         $result[] = 'org_tubepress_impl_http_clientimpl_commands_FsockOpenCommand';
     } else {
         org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'fsockopen transport disabled by request');
     }
     if (sizeof($result) === 0) {
         throw new Exception("Must enable at least one HTTP transport");
     }
     return $result;
 }