/** * Processing Request * * @todo: add this to App::run(); * @return boolean */ public static function process_request() { $uri = static::$uri !== false ? static::$uri : URI::current(); $match = false; foreach (static::$routes as $route) { if ($route->match($uri)) { $match = true; } } return $match; }
private function eval_route() { $route = URI::current(); $formula = $this->get_formula($route, $action_count); $m = new EvalMath(); $result = $m->e($formula); if ($action_count <= 10 && $result !== false) { return round($result, 0, PHP_ROUND_HALF_UP); } else { return 'Incorrect arithmetic route'; } }
public function call() { $cacheEnabled = array_get($this->action, "cacheEnabled") && Config::item("application", "cache", true); if ($cacheEnabled && ($data = Cache::get(URI::current()))) { $headersEnd = strpos($data, "\n\n"); if ($headersEnd > 0) { $headers = explode("\n", substr($data, 0, $headersEnd)); foreach ($headers as $header) { header($header); } } $data = substr($data, $headersEnd + 2); return $data; } $response = $this->response(); if ($cacheEnabled) { $headersList = implode("\n", headers_list()); Cache::save(URI::current(), $headersList . "\n\n" . $response, array_get($this->action, "cacheExpirationTime")); } else { Cache::remove(URI::current()); } return $response; }
<span class="icon-bar"></span> </a> <a class="brand" href="#"><span style="color:#777">Laravel</span><span style="color:#ddd">Squi</span></a> <div class="nav-collapse"> <ul class="nav"> <li <?php if (URI::current() == 'squi/docs/form') { echo 'class="active"'; } ?> ><a href="<?php echo URL::to('squi/docs/form'); ?> ">Form</a></li> <li <?php if (URI::current() == 'squi/docs/table') { echo 'class="active"'; } ?> ><a href="<?php echo URL::to('squi/docs/table'); ?> ">Table</a></li> </ul> </div> </div> </div> </div> <div class="container"> <?php
/** * Output heading * * Generate <h1>, <h2> etc * @param array $args */ function page_title($args = array()) { $args = array_merge(array('echo' => TRUE, 'a' => FALSE, 'tag' => 'h1', 'caption' => Xysti::page('caption'), 'href' => URI::current(), 'title' => Xysti::page('title')), $args); $output = ''; $output .= '<' . $args['tag'] . '>'; if ($args['a']) { $output .= '<a href="' . $args['href'] . '">'; } $output .= $args['title']; if ($args['caption']) { $output .= ' <span class="caption">' . $args['caption'] . '</span>'; } if ($args['a']) { $output .= '</a>'; } $output .= '</' . $args['tag'] . '>' . PHP_EOL; if ($args['echo']) { echo $output; } else { return $output; } }
/** * Return the compiled output for a given container. * * @return string */ public static function compiled() { $hash = md5('basset::' . URI::current()); // Cache is the first priority, if a cached copy exists then Basset will return // it before anything else. if (Cache::has($hash)) { return Cache::get($hash); } elseif (File::exists($path = static::$routes[URI::current()]->config->get('compiling.directory') . DS . $hash)) { return File::get($path); } // If nothing could be found we'll let them know by simply returning a not found // error to the browser. return '/* Basset could not load [' . URI::current() . '] */'; }
|-------------------------------------------------------------------------- | Filters |-------------------------------------------------------------------------- */ Route::filter('before', function () { }); Route::filter('after', function ($response) { }); Route::filter('csrf', function () { if (Request::forged()) { return Response::error('500'); } }); Route::filter('auth', function () { if (Auth::guest()) { Session::put('return', URI::current()); return Redirect::to('login'); } }); Route::filter('ajax', function () { if (!Request::ajax()) { return Response::error('404'); } }); Route::filter('project', function () { // find project id from issue object if (Request::route()->parameters[0] == 0) { return; } Project::load_project(Request::route()->parameters[0]); if (!Project::current()) {
public function is_active($menuitem) { if ($menuitem['url'] == URI::current()) { return true; } return false; }
/** * Determine the appropriate action parameter to use for a form. * * If no action is specified, the current request URI will be used. * * @param string $action * @param bool $https * @return string */ protected static function action($action, $https) { $uri = is_null($action) ? URI::current() : $action; return HTML::entities(URL::to($uri, $https)); }
/** * Get the URI for the current request. * * @return string */ public static function uri() { return URI::current(); }
* This is what makes it possible for Basset routes to be adjusted prior to them being displayed. */ $handler = Bundle::handles(URI::current()); Route::filter("{$handler}::before", function () { Config::set('session.driver', ''); return Basset::compiled(); }); /** * After the Basset route is run we'll adjust the response object setting the appropriate content * type for the assets. */ Route::filter("{$handler}::after", function ($response) { $types = array('less' => 'text/css', 'sass' => 'text/css', 'scss' => 'text/css', 'css' => 'text/css', 'js' => 'text/javascript'); $extension = File::extension(Request::uri()); if (array_key_exists($extension, $types)) { $response->header('Content-Type', $types[$extension]); } // To prevent any further output being added to any Basset routes we'll clear any events listening // for the laravel.done event. Event::clear('laravel.done'); }); } /** * If the current URI is not being handled by Basset then all registered Basset routes will be * compiled once Laravel has finished doing its thing. */ if (!starts_with(URI::current(), Bundle::option('basset', 'handles'))) { Event::listen('laravel.done', function () { Basset::compile(); }); }
</div> </div> <div class="content-wrap"> <div> <div class="page_id"> <div class="page"> <?php $cur = URI::segment(1); $cur = htmlspecialchars($cur); ?> @if(!empty($cur)) <?php $url = explode('/', URI::current()); $str = ''; for ($i = 1; $i < count($url); $i++) { $str .= ' / ' . htmlspecialchars(ucfirst($url[$i])); } ?> <a href="/{{URI::segment(1)}}">{{ htmlspecialchars(ucfirst(URI::segment(1))) }}</a> <span style="font-size:75%">{{ htmlspecialchars($str) }}</span> @else <a href="/">Home</a> @endif </div> </div> <div class="page_id_border"></div> </div> <div class='content'>
$allowed = true; break; } } if (!$allowed || count($pieces) == 0) { return Response::code(403); } $path = implode(DS, $pieces); if (!File::exists(J_PATH . $path) || is_dir(J_PATH . $path)) { return Response::code(404); } $im = new Image(J_PATH . $path); $im->resize((int) Request::get("width"), (int) Request::get("height"), Request::get("method", "fit"), Request::get("background", 0xffffff)); $im->header(); }); Router::register("*", "(:all)", function () { Response::code(404); if (Request::isLocal()) { echo "URI: " . URI::full() . "<br>\n"; echo "Path Info: " . Request::pathInfo() . "\n"; } return; }); if (URI::isManager()) { Structure::routes(); } Request::$route = Router::route(Request::method(), URI::current()); Event::fire(J_EVENT_RESPONSE_START); echo Request::$route->call(); Event::fire(J_EVENT_RESPONSE_END); //echo "<br><br>" . round(elapsed_time() * 1000000) / 1000 . "ms";
return Response::error('500'); } }); Route::filter('auth', function () { if (Auth::guest()) { return Redirect::to('/'); } }); Route::filter('Sentry_auth', function () { if (Sentry::guest()) { return Redirect::to('/'); } }); Route::filter('ip', function () { // Create the Eloquent object Visit $visit = new Track(); $browser = new Browser(); $visit->location = Locate::get('city') . ', ' . Locate::get('state') . ', ' . Locate::get('country'); $visit->ip_address = Request::ip(); $visit->request = URI::current(); if (Auth::check()) { $visit->user_id = Auth::user()->id; } // Browser stats $visit->browser = $browser->getBrowser(); $visit->browser_version = $browser->getVersion(); $visit->platform = $browser->getPlatform(); $visit->mobile = $browser->isMobile(); $visit->robot = $browser->isRobot(); $visit->save(); });
</div> </form> </td> </tr> </tfoot> </table> <h5>Sharing</h5> <p> <?php echo e(__("r.projects.admin.sharing")); ?> <form action="<?php echo e(route('project_toggle_public', array($project->id))); ?> ?redirect=<?php echo e(URI::current()); ?> " method="POST"> <div class="well"> <?php if ($project->public) { ?> <span class="public-status">Status: Public</span> <button class="btn btn-danger">Set to Private</button> <?php } else { ?> <span class="public-status">Status: Private</span> <button class="btn btn-success">Set to Public (Recommended!)</button> <?php }
/** * Test the URI::current method. * * @group laravel * @dataProvider requestUriProvider */ public function testCorrectURIIsReturnedByCurrentMethod($uri, $expectation) { $this->setRequestUri($uri); $this->assertEquals($expectation, URI::current()); }
foreach ($partials as $partial) { if ($path = $config['partials'][$partial]) { $view->{$partial} = View::make($path, $view->data)->render(); } else { $view->{$partial} = ''; } } }); // Main Nav View::composer($config['partials']['main_nav'], function ($view) use($config) { // Recursivity ftw! $render_item = function ($item, $text) { !isset($item['attr']['class']) and $item['attr']['class'] = ''; $url = isset($item['url']) ? $item['url'] : ''; if (isset($item['uri'])) { if ($item['uri'] == URI::current()) { $item['attr']['class'] += ' active'; } $url = URL::to($item['uri']); } echo '<li ' . HTML::attributes($item['attr']) . '><a href="' . $url . '">' . $text . '</a>'; if (isset($item['submenu'])) { echo '<ul class="submenu">'; array_walk($item['submenu'], $render_item); echo '</ul>'; } echo '</li>'; }; $view->render_item = $render_item; }); // Search
/** * Create a HTML page link. * * @param int $page * @param string $text * @param string $class * @return string */ protected function link($page, $text, $class) { $query = '?page=' . $page . $this->appendage($this->appends); return '<li' . HTML::attributes(array('class' => $class)) . '>' . HTML::link(URI::current() . $query, $text, array(), Request::secure()) . '</li>'; }
public function get_register() { $fields = RKFieldSet::from_model(self::register_model); return View::make(self::register_view, array('fields' => $fields->get(), 'action' => URI::current(), 'title' => 'New user', 'labels' => 'form-register')); }
/** * Create a HTML page link. * * @param int $page * @param string $text * @param string $class * @return string */ protected function link($page, $text, $class) { $query = '?page=' . $page . $this->appendage($this->appends); return HTML::link(URI::current() . $query, $text, compact('class'), Request::secure()); }
*/ unset($input[Request::spoofer]); Input::$input = $input; //Compatibility hack set_log4php_env('ls_log_file', \Config::get('env.log_path') . '/content.log'); \Logger::configure(\Config::get('log4php')); /** * Route the request to the proper route in the application. If a * route is found, the route will be called with the current request * instance. If no route is found, the 404 response will be returned * to the browser. */ Routing\Filter::register(require APP_PATH . 'filters' . EXT); $loader = new Routing\Loader(APP_PATH, ROUTE_PATH); $router = new Routing\Router($loader, CONTROLLER_PATH); IoC::instance('laravel.routing.router', $router); Request::$route = $router->route(Request::method(), URI::current()); if (!is_null(Request::$route)) { $new_relic->name_transaction(Request::$route->key); try { $response = Request::$route->call(); } catch (\Exception $e) { $handler($e); } } else { $new_relic->name_transaction('404'); \Laravel\Routing\Filter::run(array('before'), array(), true); $response = \Response::json(['msg' => 'Not found'], 404); \Laravel\Routing\Filter::run(array('after'), array($response), true); } $response->send();
// add styles to layout Asset::container('header')->add('bootstrap_style', 'bundles/gotin/css/bootstrap.css'); Asset::container('header')->add('bootstrap_res', 'bundles/gotin/css/bootstrap-responsive.css'); Asset::container('header')->add('docs_style', 'bundles/gotin/css/gotin.css'); Asset::container('header')->add('gotin_style', 'bundles/gotin/css/docs.css'); // add scripts to layout Asset::container('header')->add('jquery', 'bundles/gotin/js/jquery.js'); Asset::container('header')->add('bootstrap', 'bundles/gotin/js/bootstrap.min.js'); if (Config::get('gotin::gotin.login_mode') == "ajax") { Asset::container('header')->add('gotin', 'bundles/gotin/js/gotin.js'); } }); /** * Filter admin access */ Route::filter('auth', function () { if (!Auth::gotin_check()) { Auth::logout(); return Redirect::to_action('login'); } // Admin role protected routes $admin_protected = array('users', 'roles'); $gotin_route = Bundle::get('gotin')['handles']; foreach ($admin_protected as $ap) { $r = $gotin_route . "\\/" . $ap; $match = preg_match("/" . $r . "/", URI::current()); if ($match && !Auth::is("Admin")) { return Redirect::to_action('gotin::dashboard'); } } });
public function render() { $query_params = Input::query(); $query = $this->_get_query(); $active_sort_by = isset($query_params['sort_by']) ? $query_params['sort_by'] : $this->config['default_sort']; if (!empty($active_sort_by) && $this->config['attributes'][$active_sort_by]['sortable']) { $active_sort_dir = Input::query('sort_dir'); if (empty($active_sort_dir)) { $active_sort_dir = $active_sort_by == $this->config['default_sort'] && !empty($this->config['default_sort_dir']) ? $this->config['default_sort_dir'] : 'ASC'; } if (!is_null($this->config['attributes'][$active_sort_by]['decoder_for_sql'])) { $decoder_for_sql = $this->config['attributes'][$active_sort_by]['decoder_for_sql']; $sort_column = is_callable($decoder_for_sql) ? $decoder_for_sql($active_sort_by) : $decoder_for_sql; $sort_column = DB::raw($sort_column); } else { $sort_column = $active_sort_by; } $query = $query->order_by($sort_column, strtolower($active_sort_dir)); } else { $active_sort_by = false; $active_sort_dir = false; } $paginate = isset($this->config['pager_enabled']) ? $this->config['pager_enabled'] : Config::get('autolist::autolist.pager_enabled', true); $per_page = isset($this->config['page_size']) ? $this->config['page_size'] : Config::get('autolist::autolist.page_size', 10); $page_links = FALSE; if ($paginate) { $pager = $query->paginate($per_page); $extra_query_params = $query_params; unset($extra_query_params['page']); $pager->appends($extra_query_params); $page_links = $pager->links(); $items = $pager->results; } else { $items = $query->get(); } $permission_check = isset($this->config['permission_check']) && is_callable($this->config['permission_check']) ? $this->config['permission_check'] : Config::get('autolist::autolist.permission_check'); list($detail_view_action, $detail_view_permission_check) = $this->_get_detail_view_action_details($this->config); $permitted_items = array(); $has_item_actions = false; foreach ($items as $item) { if (!is_null($detail_view_permission_check) && !$detail_view_permission_check($item, $item->{$this->model_key})) { continue; } else { if ($permission_check && is_callable($permission_check) && !$permission_check($detail_view_action, $item, $item->{$this->model_key})) { continue; } } $action_links = array(); foreach ($this->config['item_actions'] as $action => $action_options) { $action_details = $this->_get_action_details($action, $action_options); $action_permitted = true; if (is_callable($action_details['permission_check'])) { $action_permission_check = $action_details['permission_check']; $action_permitted = $action_permission_check($item, $item->{$this->model_key}); } else { if (is_callable($permission_check)) { $action_permitted = $permission_check($action_details['action'], $item, $item->{$this->model_key}); } } if ($action_permitted) { $action_details['id'] = $item->{$this->model_key}; $action_links[$action_details['action']] = render(Config::get('autolist::autolist.views.action_link'), $action_details); $has_item_actions = true; } } $item_data = array(); foreach ($this->config['attributes'] as $attribute => $attribute_details) { $item_data[$attribute] = $this->_get_attribute_value($item, $attribute_details, $detail_view_action); } $item_data['action_links'] = $action_links; $permitted_items[] = $item_data; } $global_action_links = array(); foreach ($this->config['global_actions'] as $action => $action_options) { $action_details = $this->_get_action_details($action, $action_options); $action_permitted = true; if (is_callable($action_details['permission_check'])) { $action_permission_check = $action_details['permission_check']; $action_permitted = $action_permission_check($item); } else { if (is_callable($permission_check)) { $action_permitted = $permission_check($action_details['action'], $item); } } if ($action_permitted) { $action_details['id'] = NULL; $global_action_links[$action_details['action']] = render(Config::get('autolist::autolist.views.action_link'), $action_details); } } $header_columns = array(); foreach ($this->config['attributes'] as $attribute => $attribute_details) { if ($attribute_details['sortable']) { $attribute_details['active_sort_by'] = $active_sort_by; $attribute_details['active_sort_dir'] = $active_sort_dir; $current_link_params = $query_params; $current_link_params['sort_by'] = $attribute; $current_link_params['sort_dir'] = 'ASC'; $attribute_details['sort_url_asc'] = URL::to(URI::current() . "?" . http_build_query($current_link_params), Request::secure()); $current_link_params['sort_dir'] = 'DESC'; $attribute_details['sort_url_desc'] = URL::to(URI::current() . "?" . http_build_query($current_link_params), Request::secure()); } $header_columns[$attribute] = render(Config::get('autolist::autolist.views.header_item'), $attribute_details); } $list_data = array('title' => $this->config['title'], 'header_columns' => $header_columns, 'has_item_actions' => $has_item_actions, 'items' => $permitted_items, 'global_action_links' => $global_action_links, 'page_links' => $page_links); return render(Config::get('autolist::autolist.views.list'), $list_data); }
| */ Routing\Router::register('*', '(:all)', function () { return Event::first('404'); }); /* |-------------------------------------------------------------------------- | Route The Incoming Request |-------------------------------------------------------------------------- | | Phew! We can finally route the request to the appropriate route and | execute the route to get the response. This will give an instance | of the Response object that we can send back to the browser | */ $uri = URI::current(); Request::$route = Routing\Router::route(Request::method(), $uri); $response = Request::$route->call(); /* |-------------------------------------------------------------------------- | Persist The Session To Storage |-------------------------------------------------------------------------- | | If a session driver has been configured, we will save the session to | storage so it is avaiable for the next request. This will also set | the session cookie in the cookie jar to be sent to the user. | */ if (Config::get('session.driver') !== '') { Session::save(); }
/** * Count URI segments * @var string $uri * @return int */ public static function uri_count($uri = NULL) { if (is_null($uri)) { $uri = URI::current(); } return count(Xysti::uri_array($uri)); }