/**
  * Registers all the styles and scripts for the front end.
  *
  * @param array $opts The options.
  *
  * @return void
  */
 public final function printWidgetHtml($opts)
 {
     extract($opts);
     $context = tubepress_impl_patterns_sl_ServiceLocator::getExecutionContext();
     $parser = tubepress_impl_patterns_sl_ServiceLocator::getShortcodeParser();
     $gallery = tubepress_impl_patterns_sl_ServiceLocator::getShortcodeHtmlGenerator();
     /* default widget options */
     $defaultWidgetOptions = array(tubepress_api_const_options_names_Thumbs::RESULTS_PER_PAGE => 3, tubepress_api_const_options_names_Meta::VIEWS => false, tubepress_api_const_options_names_Meta::DESCRIPTION => true, tubepress_api_const_options_names_Meta::DESC_LIMIT => 50, tubepress_api_const_options_names_Embedded::PLAYER_LOCATION => 'popup', tubepress_api_const_options_names_Thumbs::THUMB_HEIGHT => 105, tubepress_api_const_options_names_Thumbs::THUMB_WIDTH => 135, tubepress_api_const_options_names_Thumbs::PAGINATE_ABOVE => false, tubepress_api_const_options_names_Thumbs::PAGINATE_BELOW => false, tubepress_api_const_options_names_Thumbs::THEME => 'sidebar', tubepress_api_const_options_names_Thumbs::FLUID_THUMBS => false);
     /* now apply the user's options */
     $rawTag = $context->get(tubepress_addons_wordpress_api_const_options_names_WordPress::WIDGET_SHORTCODE);
     $widgetTag = tubepress_impl_util_StringUtils::removeNewLines($rawTag);
     $parser->parse($widgetTag);
     /* calculate the final options */
     $finalOptions = array_merge($defaultWidgetOptions, $context->getCustomOptions());
     $context->setCustomOptions($finalOptions);
     if ($context->get(tubepress_api_const_options_names_Thumbs::THEME) === '') {
         $context->set(tubepress_api_const_options_names_Thumbs::THEME, 'sidebar');
     }
     try {
         $out = $gallery->getHtmlForShortcode('');
     } catch (Exception $e) {
         $out = $this->_dispatchErrorAndGetMessage($e);
     }
     /* do the standard WordPress widget dance */
     /** @noinspection PhpUndefinedVariableInspection */
     echo $before_widget . $before_title . $context->get(tubepress_addons_wordpress_api_const_options_names_WordPress::WIDGET_TITLE) . $after_title . $out . $after_widget;
     /* reset the context for the next shortcode */
     $context->reset();
 }
 private function _stripLeadingHash($value)
 {
     if (!tubepress_impl_util_StringUtils::startsWith($value, '#')) {
         return $value;
     }
     return ltrim($value, '#');
 }
 private function _canHandle(ehough_shortstop_api_HttpRequest $request, ehough_shortstop_api_HttpResponse $response)
 {
     $url = $request->getUrl();
     $host = $url->getHost();
     if (!tubepress_impl_util_StringUtils::endsWith($host, 'youtube.com')) {
         return false;
     }
     $contentType = $response->getHeaderValue('Content-Type');
     $entity = $response->getEntity();
     return $entity && $contentType === 'application/vnd.google.gdata.error+xml';
 }
Exemplo n.º 4
0
 /**
  * Converts gdata timestamps to unix time
  * 
  * @param string $rfcTime The RFC 3339 format of time
  * 
  * @return int Unix time for the given RFC 3339 time
  */
 public static function rfc3339toUnixTime($rfcTime)
 {
     $tmp = str_replace('T', ' ', $rfcTime);
     $tmp = preg_replace('/(\\.[0-9]{1,})?/', '', $tmp);
     $datetime = substr($tmp, 0, 19);
     if (tubepress_impl_util_StringUtils::endsWith($tmp, 'Z')) {
         $reset = date_default_timezone_get();
         date_default_timezone_set('UTC');
         $toReturn = strtotime($datetime);
         date_default_timezone_set($reset);
         return $toReturn;
     }
     $timezone = str_replace(':', '', substr($tmp, 19, 6));
     return strtotime($datetime . ' ' . $timezone);
 }
 private function _maybeGetListValueFromUrl($originalValue)
 {
     $url = null;
     try {
         $url = new ehough_curly_Url($originalValue);
     } catch (Exception $e) {
         return $originalValue;
     }
     $host = $url->getHost();
     if (!tubepress_impl_util_StringUtils::endsWith($host, 'youtube.com')) {
         return $originalValue;
     }
     $params = $url->getQueryVariables();
     if (!array_key_exists('list', $params)) {
         return $originalValue;
     }
     return $params['list'];
 }
 private function _getHtml($content, $trigger, tubepress_spi_shortcode_ShortcodeParser $parser)
 {
     $context = tubepress_impl_patterns_sl_ServiceLocator::getExecutionContext();
     $gallery = tubepress_impl_patterns_sl_ServiceLocator::getShortcodeHtmlGenerator();
     /* Parse each shortcode one at a time */
     while ($parser->somethingToParse($content, $trigger)) {
         /* Get the HTML for this particular shortcode. Could be a single video or a gallery. */
         try {
             $generatedHtml = $gallery->getHtmlForShortcode($content);
         } catch (Exception $e) {
             $generatedHtml = $this->_dispatchErrorAndGetMessage($e);
         }
         /* remove any leading/trailing <p> tags from the content */
         $pattern = '/(<[P|p]>\\s*)(' . preg_quote($context->getActualShortcodeUsed(), '/') . ')(\\s*<\\/[P|p]>)/';
         $content = preg_replace($pattern, '${2}', $content);
         /* replace the shortcode with our new content */
         $currentShortcode = $context->getActualShortcodeUsed();
         $content = tubepress_impl_util_StringUtils::replaceFirst($currentShortcode, $generatedHtml, $content);
         $content = tubepress_impl_util_StringUtils::removeEmptyLines($content);
         /* reset the context for the next shortcode */
         $context->reset();
     }
     return $content;
 }
 public function magic(tubepress_api_event_EventInterface $event)
 {
     $value = $event->getSubject();
     /** If it's an array, send each element through the filter. */
     if (is_array($value)) {
         foreach ($value as $key => $subValue) {
             $subEvent = new tubepress_spi_event_EventBase($subValue);
             $subEvent->setArgument('optionName', $key);
             $this->magic($subEvent);
             $value[$key] = $subEvent->getSubject();
         }
         $event->setSubject($value);
         return;
     }
     /** We're only interested in strings. */
     if (!is_string($value)) {
         return;
     }
     $toReturn = trim($value);
     $toReturn = htmlspecialchars($toReturn, ENT_NOQUOTES);
     $toReturn = tubepress_impl_util_StringUtils::stripslashes_deep($toReturn);
     $toReturn = $this->_booleanMagic($toReturn);
     $event->setSubject($toReturn);
 }
 private function _canHandle(ehough_shortstop_api_HttpRequest $request, ehough_shortstop_api_HttpResponse $response)
 {
     $url = $request->getUrl();
     $host = $url->getHost();
     return tubepress_impl_util_StringUtils::endsWith($host, 'vimeo.com');
 }