本文整理汇总了PHP中Request::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::path方法的具体用法?PHP Request::path怎么用?PHP Request::path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_active
/**
* 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 : '';
}
示例2: set_expanded
/**
* @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 : '';
}
}
示例3: isActive
/**
* 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();
}
示例4: init
/**
* 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);
});
}
示例5: getPath
/**
* 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;
}
示例6: validate
/**
* @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);
}
示例7: execute
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;
}
示例8: rules
/**
* 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'];
}
示例9: getRegister
/**
* 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');
}
示例10: create
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');
}
示例11: getMod
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]);
}
示例12: getBreadcrumb
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);
}
示例13: setActive
function setActive($path, $strict = false, $active = 'active')
{
if ($strict) {
return Request::is($path) ? $active : '';
}
return strpos(Request::path(), $path) !== false ? $active : '';
}
示例14: handleRequest
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.");
}
}
示例15: my_schedule
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');
}
}