/** * Get the uri. * * @return mixed */ public function uri() { if (!is_null($this->route)) { return $this->route->uri(); } return null; }
/** * Table sort order uri */ public function sort(Jelly_Field $column, $foreign = null) { //Current page $page = $this->_target->request()->query($this->_config['current_page']['key']); //Request params $params = $this->_target->request()->query(); //Set sort params $params[$this->_config['current_sort']['key']] = $column->name; if (!is_null($foreign) && $column instanceof Jelly_Field_Supports_With) { $model = Jelly::factory($column->foreign['model'])->meta(); if ($model->field($foreign) !== NULL) { //Set sort params $params[$this->_config['current_sort']['key']] = ':' . $column->foreign['model'] . '.' . $foreign; } } //Set sort params $params[$this->_config['current_order']['key']] = $this->_direct; $class = ''; $arrow = '<i class="fa fa-sort pull-right"></i>'; if ($this->_sort_column == $column->name) { $arrow = $this->_direct == 'DESC' ? '<i class="fa fa-sort-desc pull-right"></i>' : '<i class="fa fa-sort-asc pull-right"></i>'; $class = 'text-success'; } return HTML::anchor($this->_route->uri($this->_target->route_params()) . URL::query($params), $column->label . $arrow, array('class' => $class)); }
/** * The after() method is called after controller action * * @uses Route::uri */ public function after() { if ($this->auto_render) { // Add styles $this->template->styles = array($this->_media->uri(array('file' => 'css/bootstrap.css')) => 'screen', $this->_media->uri(array('file' => 'css/install.css')) => 'screen'); $this->template->logo = $this->_media->uri(array('file' => 'logo.png')); $this->template->link = $this->_media->uri(array('file' => 'favicon.ico')); // Do some CSS magic to page class $classes = array(); $classes[] = I18n::$lang; $classes[] = $this->request->controller(); $classes[] = $this->request->action(); $page_class = implode(' ', array_unique(array_map('trim', $classes))); // Bind the generic page variables $this->template->set('lang', I18n::$lang)->set('page_class', $page_class); } parent::after(); }
private static function getURI() { $uri = $_SERVER['REQUEST_URI']; $uri = trim($uri, '/'); $u = explode('/', $uri); if ($u[0] == 'index.php') { array_shift($u); } $uri = implode('/', $u); if ($uri == '') { $uri = '/'; } self::$uri = $uri; }
/** * Generates the full URL for a certain page. * * @param integer int page number * * @uses Url::site * @return string page URL */ public function url($page = 1) { // Clean the page number $page = max(1, (int) $page); // No page number in URLs to first page if ($page === 1 and !$this->_config->first_page_in_url) { $page = null; } switch ($this->_config->source) { case 'query': return URL::site($this->_route->uri($this->_route_params) . $this->query(array($this->_config->key => $page))); case 'route': return URL::site($this->_route->uri(array_merge($this->_route_params, array($this->_config->key => $page))) . $this->query()); } return '#'; }
/** * Generates the full URL for a certain page * * @param integer $page Page number [Optional * * @return string * * @uses URL::site */ public function url($page = 1) { // Clean the page number $page = max(1, (int) $page); // gleez cms pagination $pager = '/p' . $page; // No page number in URLs to first page if ($page === 1 and !$this->config['first_page_in_url']) { $page = NULL; $pager = NULL; } switch ($this->config['current_page']['source']) { case 'query_string': return URL::site($this->_route->uri($this->_route_params) . $this->query(array($this->config['current_page']['key'] => $page))); case 'route': return URL::site($this->_route->uri(array_merge($this->_route_params, array($this->config['current_page']['key'] => $page))) . $this->query()); case 'cms': return URL::site($this->_uri . $pager . $this->query()); } return '#'; }
/** * The logic for replacing required segments is separate (but similar) to that for * replacing optional segments. * * This test asserts that Route::uri will replace required segments with provided * params * * @dataProvider provider_uri_fills_required_uri_segments_from_params * * @test * @covers Route::uri */ public function test_uri_fills_required_uri_segments_from_params($uri, $regex, $uri_string1, $uri_array1, $uri_string2, $uri_array2) { $route = new Route($uri, $regex); $this->assertSame($uri_string1, $route->uri($uri_array1)); $this->assertSame($uri_string2, $route->uri($uri_array2)); }
/** * The logic for replacing required segments is separate (but similar) to that for * replacing optional segments. * * This test asserts that Route::uri will replace required segments with provided * params * * @test * @covers Route::uri */ public function test_uri_fills_required_uri_segments_from_params() { $route = new Route('<controller>/<action>(/<id>)'); $this->assertSame('users/edit', $route->uri(array('controller' => 'users', 'action' => 'edit'))); $this->assertSame('users/edit/god', $route->uri(array('controller' => 'users', 'action' => 'edit', 'id' => 'god'))); }
/** * This tests the reverse routing returns the uri specified in the route * if it's a static route * * A static route is a route without any parameters * * @test * @covers Route::uri */ function testReverseRoutingReturnsRoutesURIIfRouteIsStatic() { $route = new Route('info/about_us'); $this->assertSame('info/about_us', $route->uri(array('some' => 'random', 'params' => 'to confuse'))); }
/** * Execute a compiled route, and store the output to a file. * * @param Route $route The compiled route * @param mixed $compile Bool, or an iteratable dataset to compile * @param array|Closure $vars An array of vars, or a callback which * provides vars to be injected into the * route placeholders */ public function compile($route, $data, $vars) { if ($data === true) { $data = [$data]; } if (!(is_array($data) || $data instanceof Traversable)) { return; } // Loop through the provided data foreach ($data as $key => $value) { $params = $vars; if ($vars instanceof Closure) { // Run the compile callback to get the vars to include in the URI $params = $vars($value, $key); } // Pass the vars to the route, and spoof the returned URI $uri = $route->uri($params); $_SERVER['REQUEST_URI'] = $uri; $this->request->uri = $uri; // Execute the route, which now matches, and capture the results $result = $route->execute(); $this->store($uri, $result); } }