/** * Help in setting the class of the active link to 'active' * If another class is required, * pass a third parameter of class name * @param $path * @param string $secondPath * @param string $active * @return string */ function set_active($path, $secondPath = '', $active = 'active') { if ($path == 'admin/search' && strpos(Request::path(), 'admin/search') !== false) { return $active; } return Request::is($path) || Request::is($secondPath) ? $active : ''; }
/** * @param array $array * @param string $active * @return string */ function set_expanded($array = array(), $active = 'nav-expanded') { $path = Request::path(); if (in_array($path, $array)) { return Request::is($path) ? $active : ''; } }
/** * Determine whether this navigation item is active or not. * This implementation tries to guess it based on the request * URL and query parameters. * * @return boolean true if item is active, false otherwise */ public function isActive() { if (isset($this->active)) { return $this->active; } $url = $this->getURL(); // if URL is set, try to guess whether active or not if (isset($url)) { list($request_path, $query) = explode('?', Request::path()); list($request_url, $query) = explode('?', Request::url()); list($url, $query) = explode('?', $url); if (!preg_match('%^[a-z]+:%', $url) && $url[0] !== '/') { $url = $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'] . $url; } if ($url === $request_path || $url === $request_url) { $this->active = true; if (isset($this->params)) { foreach ($this->params as $key => $val) { if (Request::get($key) != $val) { $this->active = false; } } } if ($this->active) { return true; } } } return $this->active = (bool) $this->activeSubNavigation(); }
/** * Creates a Laravel route, returning a closure which passes the raw input to AngularPHP and returns the response */ protected function init() { $route = func_get_arg(0); $this->setErrorHandler(function (\Exception $e, Request $r) { \Log::error($e, $r->toArray()); }); $endpoint = $this; \Route::any($route, function () use($endpoint) { $path = '/' . \Request::path(); $referrer = \Request::header('referer'); $host = \Request::header('host'); if (($origin = \Request::header('Origin')) && count($this->corsHosts)) { $this->setCorsOrigin($origin); } /** * If being called remotely, add the domain name to the URI */ if (strlen($referrer) && parse_url($referrer, PHP_URL_HOST) != $host) { $uri = '//' . $host . $path; } else { $uri = $path; } $request = new Request(\Request::json()->all()); $response = $endpoint->setUri($uri)->execute($request, \Request::getMethod()); return \Response::make($response->content, $response->code, $response->headers)->header('Content-Type', $response->contentType); }); }
/** * La methode getPath() est une methode qui permet de recuperer la variable * locale $path * @return array() retourne un tableau de l'arboressance de l'url */ public static function getPath() { if (self::$path == null) { self::$path = isset($_GET['PATH']) ? explode('/', $_GET['PATH']) : array(); } return self::$path; }
/** * @param Request $request * @return RouteResult */ public function validate(Request $request) { $parameters = []; $matched = $this->method === $request->method(); $matched = $matched && preg_match($this->path, $request->path(), $parameters); return new RouteResult($matched, $parameters, $this->response_factory); }
public function execute() { $sPath = Request::path(); foreach ($this->routes as $sKey => $sMethod) { if (preg_match('~' . $sKey . '~', $sPath)) { debug(get_class($this) . " -> {$sMethod}() [{$sPath} => {$sKey}]"); if ($sMethod[0] == '#') { $sMethod = substr($sMethod, 1); if (class_exists($sMethod)) { return Service::create($sMethod)->execute(); } else { debug('Service not found: ' . $sMethod); $this->error404(); } } else { if (method_exists($this, $sMethod)) { $this->catchAll(); $bReturn = $this->{$sMethod}(); P::mark(get_class($this) . '::' . $sMethod); Response::end(); return $bReturn; } else { debug('Method not found: ' . get_class($this) . '::' . $sMethod . '()'); $this->error404(); } } } } debug(get_class($this) . " -> NO MATCH"); return false; }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $path = Request::path(); $pathid = explode('/', $path); $id = $pathid[1]; return ['username' => 'required|max:255', 'email' => 'required|email|max:255|unique:users' . ($id ? ",id,{$id}" : ''), 'image' => 'max:1000|image']; }
/** * Show the application registration form. * * @return \Illuminate\Http\Response */ public function getRegister() { if (\Request::ajax()) { return response()->json(['locale' => session()->get('locale', 'nl'), 'url' => \Request::url(), 'title' => 'Register | De Sessie', 'type' => 'pageload', 'path' => \Request::path(), 'view' => view('auth.register')->render()]); } return view('auth.register'); }
public function create() { if (\Request::ajax()) { return response()->json(['url' => \Request::url(), 'title' => 'Contact | Jonas Vanderhaegen', 'path' => \Request::path(), 'view' => view('pages.messages.create')->render()]); } return view('pages.messages.create'); }
public function getMod($slug) { $table_javascript = route('tdf_name', ['modmodpacks', '0', $slug]); $mod = Mod::where('slug', '=', $slug)->first(); if (!$mod) { $redirect = new URLRedirect(); $do_redirect = $redirect->getRedirect(Request::path()); if ($do_redirect) { return Redirect::to($do_redirect->target, 301); } App::abort(404); } $can_edit = false; if (Auth::check()) { $maintainer = $mod->maintainers()->where('user_id', Auth::id())->first(); if ($maintainer) { $can_edit = true; } } $authors = $mod->authors; $spotlights = $mod->youtubeVideos()->where('category_id', 2)->get(); $tutorials = $mod->youtubeVideos()->where('category_id', 3)->get(); $raw_links = ['website' => $mod->website, 'download_link' => $mod->download_link, 'donate_link' => $mod->donate_link, 'wiki_link' => $mod->wiki_link]; $links = []; foreach ($raw_links as $index => $link) { if ($link != '') { $links["{$index}"] = $link; } } $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($mod->description)); $mod_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html); $title = $mod->name . ' - Mod - ' . $this->site_name; $meta_description = $mod->deck; return View::make('mods.detail', ['table_javascript' => $table_javascript, 'mod' => $mod, 'mod_description' => $mod_description, 'links' => $links, 'authors' => $authors, 'title' => $title, 'meta_description' => $meta_description, 'sticky_tabs' => true, 'spotlights' => $spotlights, 'tutorials' => $tutorials, 'can_edit' => $can_edit]); }
public function getBreadcrumb() { $activeSection = ''; if (Request::path() == 'about') { $activeSection = "เกี่ยวกับสารานุกรมกว๊านพะเยา"; } elseif (Request::path() == 'general') { $activeSection = "ข้อมูลทั่วไปกว๊านพะเยา"; } elseif (Request::path() == 'ecology') { $activeSection = "นิเวศวิทยาและสิ่งแวดล้อม"; } elseif (Request::path() == 'travel') { $activeSection = "เศรษฐกิจและการท่องเที่ยว"; } elseif (Request::path() == 'water-resources') { $activeSection = "การจัดการทรัพยากรธรรมชาติ"; } elseif (Request::path() == 'history') { $activeSection = "ประวัติศาสตร์และวัฒนธรรม"; } elseif (Request::path() == 'register' || Request::path() == 'register/profile' || Request::path() == 'register/account') { $activeSection = "ลงทะเบียน"; } if ($activeSection == '') { $showBreadcrumb = false; } else { $showBreadcrumb = true; } View::share('activeSection', $activeSection); View::share('showBreadcrumb', $showBreadcrumb); }
function setActive($path, $strict = false, $active = 'active') { if ($strict) { return Request::is($path) ? $active : ''; } return strpos(Request::path(), $path) !== false ? $active : ''; }
public function handleRequest() { // TODO create "page not found" page $uri = Request::path(); // Default version of the documentation $page = 'introduction'; $versions = array("4.0", "4.1", "4.2", "4.3", "4.6", "5.0", "5.6", "5.12"); $version = end($versions); // If not the root, then split the uri to find the content $segment1 = Request::segment(1); $segment2 = Request::segment(2); if (!empty($segment1)) { $version = $segment1; if (!empty($segment2)) { $page = $segment2; } } // Show the correct markdown contents $page = __DIR__ . '/docs/' . $version . '/' . $page . '.md'; if (file_exists($page)) { $contents = file_get_contents($page); $sidebar = file_get_contents(__DIR__ . '/docs/' . $version . '/sidebar.md'); // Transform documents $contents_html = Markdown::defaultTransform($contents); $sidebar_html = Markdown::defaultTransform($sidebar); // Replace url variable $sidebar_html = preg_replace('/{url}/mi', URL::to($version), $sidebar_html); return View::make('layouts.master')->with('version', $version)->with('versions', $versions)->with('sidebar', $sidebar_html)->with('content', $contents_html); } else { \App::abort(400, "The page you were looking for could not be found."); } }
public function my_schedule() { if (Auth::check()) { $data["inside_url"] = Config::get('app.inside_url'); $data["user"] = Session::get('user'); $data["actions"] = Session::get('actions'); if (in_array('side_mi_horario', $data["actions"])) { $current_ay = AcademicYear::getCurrentAcademicYear(); if (!$current_ay) { return View::make('schedule/academic_year_error', $data); } $student = $data["user"]->student; $data["enrollment_info"] = $student->getCurrentEnrollment(); $data["level"] = $data["enrollment_info"]->level; $data["schedules_data"] = $data["level"]->schedules()->orderBy('initial_hour')->get(); return View::make('schedule/my_schedule', $data); } else { // Llamo a la función para registrar el log de auditoria $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'"; Helpers::registerLog(10, $log_description); Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.'); return Redirect::to('/dashboard'); } } else { return View::make('error/error'); } }
public function showPageBySlug() { $slug = strtolower(\Request::path()); $page = $this->page->requestPageBySlug($slug); $title = $page->title; return $this->frontend->render($page->template, ['page' => $page, 'title' => $title]); }
public function router($routes, array $data = [], $path = null) { $props = json_encode($data); if (is_null($path)) { $path = \Request::path() == '/' ? '/' : '/' . \Request::path(); } return $this->render('?type=react-router' . '&routes=' . urlencode($routes) . '&path=' . urlencode($path) . '&props=' . urlencode($props)); }
function __construct() { if (Menu::whereSlug(Request::path())->count()) { $this->banners = Menu::whereSlug(Request::path())->first()->banner; } else { $this->banners = false; } }
function isActive(array $routes, $output = "active") { foreach ($routes as $route) { if (Request::path() == $route) { return $output; } } }
/** * @return $this|\Illuminate\Database\Eloquent\Builder */ public function newQuery() { $query = parent::newQuery(); if (substr(\Request::path(), 0, 6) !== 'admin/') { return $query->where('is_active', 1); } return $query; }
protected function getNodeForCurrentRoute() { $currentUri = \Request::path(); if ($navItem = NavItem::where('uri', '=', $currentUri)->orWhere('uri', '=', '/' . $currentUri)->first()) { return $navItem; } return null; }
function set_active($path, $active = 'active') { $path_array = explode('/', Request::path()); if (count($path_array) >= 2) { return $path_array[0] == $path ? $active : ''; } else { return Request::is($path) ? $active : ''; } }
/** * @return Page */ static function findCurrentPage() { $pageService = App::make("Transp\\Service\\IPageService"); $domain = Domain::current(); $slug = \Request::path(); if (strlen($slug) > 1) { return $pageService->findPageBySlugAndDomain($slug, $domain); } return null; }
public function sitemap() { $shares = $this->posts->findById(1, 'user')->shares()->get(['url', 'website', 'icon'])->toarray(); $tags = $this->posts->orderBy('tag', 'title', 'asc')->get(['title'])->toarray(); $types = $this->posts->getAllFrom('type')->all()->toArray(); if (\Request::ajax()) { return response()->json(['url' => \Request::url(), 'title' => 'Sitemap | Jonas Vanderhaegen', 'path' => \Request::path(), 'view' => view('pages.sitemap', compact('shares', 'tags', 'types'))->render()]); } return view('pages.sitemap', compact('shares', 'tags', 'types')); }
/** * Build the HTML navigation from the given config key. * * @param string $url * @param string $type * @return string */ public function make($url = null) { $menu = $this->getNavigationConfig(); $html = ''; $url = $url ?: \Request::path(); foreach ($menu as $item) { $html .= $this->buildItem($item, $url); } return $html; }
function setActive($path, $active = 'active') { $request = Request::path(); if (is_string($path) && $path == $request) { return 'active'; } if (is_array($path) && in_array($request, $path)) { return 'active'; } }
function switchLanguageUrl($lang) { $segments = explode('/', Request::path()); if ($segments[0] == 'en' || $segments[0] == 'zh') { $segments[0] = $lang; $newPath = implode('/', $segments); } $url = 'http://' . Request::getHttpHost() . "/" . $newPath . "?" . http_build_query(Input::all()); return $url; }
public static function Ativate($url, $valor) { $ativate = ''; if (is_array($url)) { $ativate = in_array(\Request::path(), $url) ? $valor : ''; } else { $ativate = \Request::path() == $url ? $valor : ''; } return $ativate; }
public function testQueriesServerForInfo() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['HTTP_HOST'] = 'derp.com'; $_SERVER['REQUEST_URI'] = '/'; $_SERVER['HTTP_REFERER'] = 'http://google.com/'; $this->assertEquals('POST', Request::method()); $this->assertEquals('derp.com', Request::host()); $this->assertEquals('/', Request::path()); $this->assertEquals('http://google.com/', Request::referer()); }
public function update($platform_id) { if (!$this->platform->updatePlatform($platform_id, Input::all())) { $errorNum = $this->logger->createLog('platformsController', 'update', 'Failed to edit the copmany with an ID of "' . $platform_id . '"', Request::url(), Request::path(), 8); Session::put('adminDangerAlert', '<b>Error #' . $errorNum . '</b> - Something went wrong attempting to edit the game. Contact an administrator if this continues.'); return Redirect::back(); } //return successful update Session::put('adminSuccessAlert', '<b>' . Input::get('name') . '</b> has successfully been updated.'); return Redirect::to('/admin/platforms'); }