/** * Test for static_base route. * * @dataProvider provider_static_base * @test * @covers LogReader_URL::static_base * @covers LogReader_URL::set_configuration * @param mixed $expected Expected result. * @param string $static_route Static route. */ public function test_static_base($expected, $static_route) { $config = $this->getMockBuilder('LogReader_Config')->setConstructorArgs(array(array()))->getMock(); $config->expects($this->any())->method('get_static_route')->will($this->returnValue($static_route)); LogReader_URL::set_configuration($config); $this->assertSame($expected, LogReader_URL::static_base()); }
public function action_index() { $current_page = (int) $this->request->query('page'); $message = $this->request->query('message'); $levels = $this->request->query('levels'); $date_from = $this->request->query('date-from'); $date_to = $this->request->query('date-to'); $limit = $this->request->query('limit'); if ($current_page < 1) { $current_page = 1; } if (!is_array($levels)) { $levels = array(); } $filters = $this->logreader->create_filters($message, $levels, $date_from, $date_to, $limit); $filters_for_autorefresh = $this->logreader->create_filters($message, $levels, $date_from, NULL, $limit); $view = View::factory('logreader/index'); $view->stylesheets = array(LogReader_URL::static_base() . 'css/messages.css'); $view->javascripts = array(LogReader_URL::static_base() . 'js/messages.js'); $view->user = $this->user; $view->is_tester_available = $this->logreader_config->is_tester_available(); $view->content = View::factory('logreader/messages'); $view->content->name = 'messages'; $view->content->levels = $this->logreader->get_levels(); $view->content->filters = $filters; $view->content->auto_refresh_time = $this->logreader_config->get_auto_refresh_interval(); $offset = ($current_page - 1) * $filters['limit']; $view->content->messages = $this->logreader->get_messages($filters['date-from'], $filters['date-to'], $filters['limit'], $offset, $filters['message']['text'] && $filters['message']['valid'] ? $filters['message']['text'] : NULL, $filters['levels'], array(), NULL); $view->content->all_matches = $view->content->messages['all_matches']; $view->content->all_matches_before_id = $view->content->all_matches - $offset; $view->content->messages = $view->content->messages['messages']; $view->content->current_page = $current_page; $view->content->auto_refresh_url = LogReader_URL::api_base() . 'messages/?' . $filters_for_autorefresh['query_string']; $uri = LogReader_URL::base() . "?" . $filters['query_string']; $view->content->pages = LogReader_URL::pager($current_page, ceil($view->content->all_matches / $filters['limit']), $uri . "&page=%(page)s", $uri); $this->response->body($view); }
?> js/underscore-min.js"></script> <script src="<?php print LogReader_URL::static_base(); ?> js/jquery-1.11.1.min.js"></script> <script src="<?php print LogReader_URL::static_base(); ?> js/moment.min.js"></script> <script src="<?php print LogReader_URL::static_base(); ?> bootstrap/js/bootstrap.min.js"></script> <script src="<?php print LogReader_URL::static_base(); ?> bootstrap/js/bootstrap-datetimepicker.min.js"></script> <?php if (isset($javascripts) && $javascripts) { foreach ($javascripts as $javascript) { ?> <script src="<?php print $javascript; ?> "></script> <?php } } ?> </body>