/** * 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(); }
/** * Filter the content (which may be empty). */ public final function filterContent($content = '') { /* do as little work as possible here 'cause we might not even run */ $wpsm = tubepress_impl_patterns_sl_ServiceLocator::getOptionStorageManager(); $trigger = $wpsm->fetch(tubepress_api_const_options_names_Advanced::KEYWORD); $parser = tubepress_impl_patterns_sl_ServiceLocator::getShortcodeParser(); /* no shortcode? get out */ if (!$parser->somethingToParse($content, $trigger)) { return $content; } return $this->_getHtml($content, $trigger, $parser); }
/** * Generates the HTML for TubePress. Could be a gallery or single video. * * @param string $shortCodeContent The shortcode content. * * @throws RuntimeException If no handlers could generate the proper HTML. * * @return string The HTML for the given shortcode, or the error message if there was a problem. */ public function getHtmlForShortcode($shortCodeContent) { /* parse the shortcode if we need to */ if ($shortCodeContent != '') { $shortcodeParser = tubepress_impl_patterns_sl_ServiceLocator::getShortcodeParser(); $shortcodeParser->parse($shortCodeContent); } usort($this->_shortcodeHandlers, array($this, 'sortShortcodeHandlers')); $html = null; /** * @var $handler tubepress_spi_shortcode_PluggableShortcodeHandlerService */ foreach ($this->_shortcodeHandlers as $handler) { if ($handler->shouldExecute()) { $html = $handler->getHtml(); break; } } if ($html === null) { throw new RuntimeException('No shortcode handlers could generate HTML'); } return $html; }