Пример #1
0
 /**
  * Prints the output of the TubePress widget.
  *
  * @param array $opts The array of widget options.
  *
  * @return void
  */
 public static function printWidget($opts)
 {
     extract($opts);
     $iocContainer = org_tubepress_impl_ioc_IocContainer::getInstance();
     $context = $iocContainer->get('org_tubepress_api_exec_ExecutionContext');
     $parser = $iocContainer->get('org_tubepress_api_shortcode_ShortcodeParser');
     $gallery = $iocContainer->get('org_tubepress_api_shortcode_ShortcodeHtmlGenerator');
     $ms = $iocContainer->get('org_tubepress_api_message_MessageService');
     /* Turn on logging if we need to */
     org_tubepress_impl_log_Log::setEnabled($context->get(org_tubepress_api_const_options_names_Advanced::DEBUG_ON), $_GET);
     /* default widget options */
     $defaultWidgetOptions = array(org_tubepress_api_const_options_names_Display::RESULTS_PER_PAGE => 3, org_tubepress_api_const_options_names_Meta::VIEWS => false, org_tubepress_api_const_options_names_Meta::DESCRIPTION => true, org_tubepress_api_const_options_names_Display::DESC_LIMIT => 50, org_tubepress_api_const_options_names_Display::CURRENT_PLAYER_NAME => org_tubepress_api_const_options_values_PlayerValue::POPUP, org_tubepress_api_const_options_names_Display::THUMB_HEIGHT => 105, org_tubepress_api_const_options_names_Display::THUMB_WIDTH => 135, org_tubepress_api_const_options_names_Display::PAGINATE_ABOVE => false, org_tubepress_api_const_options_names_Display::PAGINATE_BELOW => false, org_tubepress_api_const_options_names_Display::THEME => 'sidebar', org_tubepress_api_const_options_names_Display::FLUID_THUMBS => false);
     /* now apply the user's options */
     $rawTag = $context->get(org_tubepress_api_const_options_names_Widget::TAGSTRING);
     $widgetTag = org_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(org_tubepress_api_const_options_names_Display::THEME) === '') {
         $context->set(org_tubepress_api_const_options_names_Display::THEME, 'sidebar');
     }
     try {
         $out = $gallery->getHtmlForShortcode('');
     } catch (Exception $e) {
         $out = $ms->_('no-videos-found');
     }
     /* do the standard WordPress widget dance */
     echo $before_widget . $before_title . $context->get(org_tubepress_api_const_options_names_Widget::TITLE) . $after_title . $out . $after_widget;
     /* reset the context for the next shortcode */
     $context->reset();
 }
Пример #2
0
 function testRemoveNewLines()
 {
     $string = "this\r\n\r\n\n\n\nis\r\r\r\na\r\ntest\r\n\r\n";
     $this->assertEquals('thisisatest', org_tubepress_impl_util_StringUtils::removeNewLines($string));
 }