Esempio n. 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();
 }
 function setup()
 {
     parent::setUp();
     $this->_sut = new org_tubepress_impl_provider_SimpleProvider();
     $this->_fakeVideo = \Mockery::mock('org_tubepress_api_video_Video');
     org_tubepress_impl_log_Log::setEnabled(false, array());
 }
 function setUp()
 {
     parent::setUp();
     $this->_sut = $this->_getSutInstance();
     org_tubepress_impl_log_Log::setEnabled(true, array('tubepress_debug' => 'true'));
     $this->_server = 'http://tubepress.org/http_tests';
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $mp = $ioc->get(org_tubepress_spi_http_HttpMessageParser::_);
     $mp->shouldReceive('getHeadersStringFromRawHttpMessage')->andReturnUsing(function ($data) {
         $x = new org_tubepress_impl_http_DefaultHttpMessageParser();
         return $x->getHeadersStringFromRawHttpMessage($data);
     });
     $mp->shouldReceive('getBodyStringFromRawHttpMessage')->andReturnUsing(function ($data) {
         $x = new org_tubepress_impl_http_DefaultHttpMessageParser();
         return $x->getBodyStringFromRawHttpMessage($data);
     });
     $mp->shouldReceive('getArrayOfHeadersFromRawHeaderString')->andReturnUsing(function ($data) {
         $x = new org_tubepress_impl_http_DefaultHttpMessageParser();
         return $x->getArrayOfHeadersFromRawHeaderString($data);
     });
     $mp->shouldReceive('getHeaderArrayAsString')->andReturnUsing(function ($data) {
         $x = new org_tubepress_impl_http_DefaultHttpMessageParser();
         return $x->getHeaderArrayAsString($data);
     });
 }
 function testCompress()
 {
     org_tubepress_impl_log_Log::setEnabled(true, array('tubepress_debug' => true));
     for ($x = 1; $x < 10; $x++) {
         $this->_testCompress($x);
     }
     org_tubepress_impl_log_Log::setEnabled(false, array());
 }
 function setUp()
 {
     parent::setUp();
     $this->_sut = new org_tubepress_impl_player_DefaultPlayerHtmlGenerator();
     org_tubepress_impl_log_Log::setEnabled(false, array());
     $this->_video = \Mockery::mock('org_tubepress_api_video_Video');
     $this->_video->shouldReceive('getId')->once()->andReturn('video-id');
 }
 private function _doBoot()
 {
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $context = $ioc->get('org_tubepress_api_exec_ExecutionContext');
     $envDetector = $ioc->get('org_tubepress_api_environment_Detector');
     $pm = $ioc->get('org_tubepress_api_plugin_PluginManager');
     /* WordPress likes to keep control of the output */
     if ($envDetector->isWordPress()) {
         ob_start();
     }
     /* 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);
     org_tubepress_impl_log_Log::log(self::LOG_PREFIX, 'Booting!');
     /* load plugins */
     $this->loadSystemPlugins($ioc);
     $this->_loadUserPlugins($ioc);
     /* tell everyone we're booting */
     $pm->notifyListeners(org_tubepress_api_const_plugin_EventName::BOOT);
     /* remember that we booted. */
     self::$_alreadyBooted = true;
 }
Esempio n. 7
0
 function testRegularGet()
 {
     org_tubepress_impl_log_Log::setEnabled(true, array('tubepress_debug' => 'true'));
     $ioc = org_tubepress_impl_ioc_IocContainer::getInstance();
     $this->_hmp = $ioc->get(org_tubepress_spi_http_HttpMessageParser::_);
     $this->_hmp->shouldReceive('getHeadersStringFromRawHttpMessage')->with($this->_sut->responseBody)->andReturn($this->_sut->headersString);
     $this->_hmp->shouldReceive('getBodyStringFromRawHttpMessage')->with($this->_sut->responseBody)->andReturn('body string');
     $this->_hmp->shouldReceive('getArrayOfHeadersFromRawHeaderString')->with($this->_sut->headersString)->andReturn($this->_sut->headers);
     $result = $this->_sut->execute($this->_context);
     $this->assertTrue($result);
     $response = $this->_context->response;
     $this->assertTrue($response instanceof org_tubepress_api_http_HttpResponse, 'Result is not a response');
     $this->assertTrue($response->getStatusCode() === 200);
     $this->assertTrue($response->getAllHeaders() === array('Content-Type' => 'text/html', 'Content-Encoding' => 'gzip'));
     $entity = $response->getEntity();
     $this->assertTrue($entity instanceof org_tubepress_api_http_HttpEntity);
     $this->assertTrue($entity->getContent() === 'body string', 'wrong response body');
     $this->assertTrue($entity->getContentLength() === 11, 'wrong content length');
     $this->assertTrue($entity->getContentType() === 'text/html', 'wrong content type');
     org_tubepress_impl_log_Log::setEnabled(false, array());
 }
 function setUp()
 {
     parent::setUp();
     $this->_sut = new org_tubepress_impl_feed_CacheAwareFeedFetcher();
     org_tubepress_impl_log_Log::setEnabled(false, array());
 }
Esempio n. 9
0
 function setUp()
 {
     parent::setUp();
     $this->_sut = new org_tubepress_impl_patterns_cor_ChainGang();
     org_tubepress_impl_log_Log::setEnabled(false, array());
 }
Esempio n. 10
0
 public function setup()
 {
     org_tubepress_impl_log_Log::setEnabled(true, array('tubepress_debug' => 'true'));
 }