当前位置: 首页>>代码示例>>PHP>>正文


PHP Url::current方法代码示例

本文整理汇总了PHP中Url::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::current方法的具体用法?PHP Url::current怎么用?PHP Url::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Url的用法示例。


在下文中一共展示了Url::current方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: url

/**
 * Return current URL with get query.
 *
 * @param  null|string $slug
 * @param array $query
 * @return string
 */
function url($slug = null, array $query = [])
{
    static $url = null;
    if ($url === null) {
        $url = strval(Url::current('/'));
    }
    return $url . ltrim($slug, '/') . (($q = http_build_query($query, '', '&', PHP_QUERY_RFC3986)) ? '?' . $q : '');
}
开发者ID:sphido,项目名称:url,代码行数:15,代码来源:url.php

示例2: init

 static function init()
 {
     self::$protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https' : 'http';
     self::$host = self::$protocol . '://' . $_SERVER['HTTP_HOST'];
     self::$current = urldecode(self::$host . $_SERVER['REQUEST_URI']);
     self::$application = self::$host . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']);
     define('URL_PROTOCOL', self::$protocol);
     define('URL_HOST', self::$host);
     define('URL_CURRENT', self::$current);
     define('URL_APPLICATION', self::$application);
 }
开发者ID:xtiurti,项目名称:web-service-lavanderia-encoder,代码行数:11,代码来源:url.php

示例3: boot

 protected static function boot()
 {
     parent::boot();
     self::saving(function ($channel) {
         if ($channel->code == null) {
             $channel->code = \Str::slug($channel->name);
         }
     });
     if (strstr(\Url::current(), \Backend::baseUrl())) {
         self::backendBoot();
     }
 }
开发者ID:janusnic,项目名称:octobercms-feedback,代码行数:12,代码来源:Channel.php

示例4: get

 /**
  * Creates an HTML anchor tag. If the given url matches the first part of current url, a class of "active" will automatically
  * be added to the attributes.
  *
  * Basic Example:
  * Html::a('My Text', 'some/path'); // Short hand
  * Html::a()->get('My Text', 'some/path');
  *
  * Attributes Example:
  * Html::a()->get('My Text', 'some/path', array('title' => 'My Text', 'class' => 'active'));
  *
  * @param string $title The text to go between the tags
  * @param string $url The relative or full url
  * @param array $attributes An optional array of attributes where the key is the attribute name
  * @return string An HTML anchor tag
  */
 public function get($title, $url, $attributes = array())
 {
     $attr = '';
     if ($url != '/' && strstr(Url::current(true), $url)) {
         if (isset($attributes['class'])) {
             $attributes['class'] = 'active ' . $attributes['class'];
         } else {
             $attributes['class'] = 'active';
         }
     } elseif ($url == '/' && !strlen(Url::current(true))) {
         $attributes['class'] = 'active';
     }
     if ($attributes) {
         foreach ($attributes as $k => $v) {
             $attr .= sprintf(' %s="%s"', $k, $v);
         }
     }
     $url = is_null($url) ? 'javascript:null' : Url::to($url);
     return sprintf('<a href="%s"%s>%s</a>', $url, $attr, $title);
 }
开发者ID:simudream,项目名称:caffeine,代码行数:36,代码来源:html_a.php

示例5: sorter

 /**
  * Create the column sorter.
  *
  * @return string|void
  */
 public function sorter()
 {
     if (!$this->sortable) {
         return;
     }
     $icon = 'fa-sort';
     $type = 'desc';
     if ($this->isSorted()) {
         $type = $this->sort['type'] == 'desc' ? 'asc' : 'desc';
         $icon .= "-amount-{$this->sort['type']}";
     }
     $query = app('request')->all();
     $query = array_merge($query, ['_sort' => ['column' => $this->name, 'type' => $type]]);
     $url = Url::current() . '?' . http_build_query($query);
     return "<a class=\"fa fa-fw {$icon}\" href=\"{$url}\"></a>";
 }
开发者ID:z-song,项目名称:laravel-admin,代码行数:21,代码来源:Column.php

示例6: __

<h1><?php 
echo __('users.log_in', 'Log in');
?>
</h1>

<?php 
echo Notifications::read();
?>

<section class="content">

	<form method="post" action="<?php 
echo Url::current();
?>
">

		<input name="token" type="hidden" value="<?php 
echo Csrf::token();
?>
">
		
		<fieldset>
			
			<p>
			    <label for="user"><?php 
echo __('users.username', 'Username');
?>
:</label>
			    <input autocapitalize="off" name="user" id="user" value="<?php 
echo filter_var(Input::post('user'), FILTER_SANITIZE_STRING);
?>
开发者ID:nathggns,项目名称:anchor-cms,代码行数:31,代码来源:login.php

示例7:

<?php

$canonical_url = Url::current();
switch (PAGE_ACTION) {
    case 'index':
        $title = 'Encuestas | ' . SITE_NAME;
        $description = '';
        break;
    case 'view':
        $title = $poll->question . ' | ' . SITE_NAME;
        $description = $poll->description;
        break;
    case 'vote':
        $title = 'Vota: &quot;' . $poll->question . '&quot; | ' . SITE_NAME;
        $description = 'Vota a la encuesta número ' . $poll->id . ' en ' . SITE_NAME;
        break;
}
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">

	<title><?php 
echo $title;
?>
</title>
	<meta name="description" content="<?php 
echo $description;
?>
">
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:31,代码来源:header.php

示例8: theme_url

				<img src="<?php 
echo theme_url('assets/img/logo.png');
?>
" alt="Anchor CMS">
			</a>

			<?php 
if (($user = Users::authed()) !== false) {
    ?>
			<nav>
				<ul>
					<?php 
    foreach (admin_menu() as $title => $url) {
        ?>
					<li <?php 
        if (strpos(Url::current(), $url) !== false) {
            echo 'class="active"';
        }
        ?>
>
						<a href="<?php 
        echo Url::make($url);
        ?>
"><?php 
        echo __('common.' . $title, $title);
        ?>
</a>
					</li>
					<?php 
    }
    ?>
开发者ID:nathggns,项目名称:anchor-cms,代码行数:31,代码来源:header.php

示例9: translate

 public static function translate(&$route_vars = array())
 {
     $route_vars = array('extension' => '', 'controller' => '', 'action' => '');
     $route_comps = parse_url(str_replace(Url::root(), '', Url::current()));
     if (empty($route_comps['path']) and empty($route_comps['query'])) {
         //show the home page
         $route_vars = self::page();
         return;
     }
     $path = !empty($route_comps['path']) ? $route_comps['path'] : '';
     $path_chunks = array_filter(explode('/', $path));
     //remove indeix.php from the path
     if (!empty($path_chunks) and strtolower($path_chunks[0]) == 'index.php') {
         array_shift($path_chunks);
     }
     //if there is no path, show the home page (index.php)
     if (empty($path_chunks)) {
         //no path provided, try to find the extension data
         $route_vars = array('extension' => Request::data('ext', ''), 'controller' => Request::data('cont', ''), 'action' => Request::data('act', ''));
         if (empty($route_vars['extension'])) {
             if (empty($route_vars['controller'])) {
                 //no ext/cont provided, load default home page
                 $route_vars = self::page();
             } elseif ($route_vars['controller'] == 'pages') {
                 $route_vars = self::page(Request::get('_Route.index', null));
             }
         }
         return;
     }
     if ((bool) Base::getConfig('sef_urls', 0) === false) {
         //SEF disabled, no matching path found, will display 404 error
         return;
     }
     //we have a path, it may be a page alias OR an extension name
     $branches = $path_chunks;
     $alias = array_shift($path_chunks);
     //check a page with a matching alias
     if (!empty($alias)) {
         //check pages aliases
         $tests = array();
         while (!empty($branches)) {
             $tests[] = implode('/', $branches);
             array_pop($branches);
         }
         $route_vars = self::page($tests);
         $path_chunks = array_diff($path_chunks, explode('/', Request::data('_Route.page.alias', '')));
         if (!empty($route_vars)) {
             //matching page alias found
             //check if the page belongs to an extension and if the extension has a router ?
             if (!empty($route_vars['extension'])) {
                 $route_vars = array_merge($route_vars, self::set_params($route_vars['extension'], $path_chunks));
             } elseif (empty($route_vars['extension']) and !empty($route_vars['controller'])) {
                 $route_vars = array_merge($route_vars, self::set_params($route_vars['controller'], $path_chunks, 'controller'));
             }
             return;
         }
     }
     //check if this is a valid extension name
     if (class_exists('\\GCore\\Extensions\\' . Str::camilize($alias) . '\\' . Str::camilize($alias))) {
         $route_vars['extension'] = $alias;
         Request::set('_Route.index', $alias);
         $route_vars['controller'] = Request::data('cont', '');
         $route_vars['action'] = Request::data('act', '');
         //check if the extension has a router ?
         $route_vars = array_merge($route_vars, self::set_params($alias, $path_chunks));
         return;
     }
     //check if this is a valid core controller name
     if (class_exists('\\GCore\\Controllers\\' . Str::camilize($alias))) {
         $route_vars['controller'] = $alias;
         Request::set('_Route.index', $alias);
         $route_vars['action'] = Request::data('act', '');
         //check if the extension has a router ?
         $route_vars = array_merge($route_vars, self::set_params($alias, $path_chunks, 'controller'));
         return;
     }
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:77,代码来源:route.php

示例10: url

 /**
  * 生成outh URL
  *
  * @param string $to
  * @param string $scope
  * @param string $state
  *
  * @return string
  */
 public function url($to = null, $scope = 'snsapi_base', $state = 'STATE')
 {
     $to !== null || ($to = Url::current());
     $params = array('appid' => $this->appId, 'redirect_uri' => $to, 'response_type' => 'code', 'scope' => $scope, 'state' => $state);
     return self::API_URL . '?' . http_build_query($params) . '#wechat_redirect';
 }
开发者ID:shoaly,项目名称:wechat-biz,代码行数:15,代码来源:AuthBiz.php

示例11: getRouteData

 /**
  * Returns the route data associated with the current route. 
  *
  * The route data is set in a modules setup.php file. If no data is
  * found for the current route, boolean false is returned.
  *
  * @return mixed Array of data if route exists, boolean false otherwise
  *
  * TODO Check for invalid characters in URL
  */
 public static function getRouteData()
 {
     $data = false;
     /*
     $defaultRoute = Config::get('router.default_route');
     $currentRoute = $defaultRoute;
     
     if(isset($_GET['r']) && strlen($_GET['r']))
         $currentRoute = $_GET['r'];
     
     $currentRoute = rtrim($currentRoute, '/');
     
     // Look for language code, and modify route if need be
     if(Multilanguage::routeHasLangCode($currentRoute))
     {
         $currentRoute = ltrim(substr($currentRoute, 3), '/');
     
         // If current route is empty now (due to being at base url with language code (ex: /<code>), set to default
         if(!strlen($currentRoute))
             $currentRoute = $defaultRoute;
     }
     */
     $currentRoute = Url::current();
     if ($currentRoute == '/') {
         $currentRoute = Config::get('router.default_route');
     } else {
         $currentRoute = ltrim($currentRoute, '/');
     }
     // We dont want leading slash of the current url for routes
     while (true) {
         // First search routes with exact match
         if (isset(self::$_routes[$currentRoute])) {
             $data = self::$_routes[$currentRoute];
         }
         // If no exact match, check matches with regex
         foreach (self::$_routes as $route => $routeData) {
             $regexRoute = String::regify($route);
             if (preg_match('@^' . $regexRoute . '$@', $currentRoute, $matches)) {
                 self::$_params = array_slice($matches, 1);
                 $data = $routeData;
             }
         }
         // If no route data was found, must be 404
         if (!$data) {
             break;
         } elseif (isset($data['redirect'])) {
             $currentRoute = $data['redirect'];
         } elseif ($data) {
             // First check permissions, if any, for current user
             self::$_currentRoute = array('route' => $currentRoute, 'data' => $data);
             break;
         }
     }
     if ($data && !isset($data['permissions'])) {
         $data['permissions'] = array();
     }
     // Let other areas of the application make use of route data
     Event::trigger('router.data', array($currentRoute, $data));
     return array($currentRoute, $data);
 }
开发者ID:simudream,项目名称:caffeine,代码行数:70,代码来源:router.php

示例12: action_edit

 public static function action_edit($id = null)
 {
     if (!IS_ADMIN) {
         Redirect::to(Url::get('admin@login', null, 'redirect-to=' . urlencode(Url::current())));
     }
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         if ($id === 'delete-answer') {
             if (($answer_id = Param::post('answer_id')) && is_numeric($answer_id)) {
                 $answer = Answer::get((int) $answer_id);
                 Answer::find((int) $answer_id)->delete();
                 $votes = Vote::where('answer_id', '=', $answer_id)->count();
                 if ($votes) {
                     Poll::find($answer->poll_id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
                 }
                 return Response::json(array('status' => 200, 'deleted' => true));
             } else {
                 return Response::json(array('status' => 0, 'deleted' => false));
             }
         } elseif ($id) {
             return Response::error(404);
         } else {
             $id = Param::post('id');
             if ($answer_id = Param::post('remove_answer')) {
                 Answer::find((int) $answer_id)->and_where('poll_id', '=', $id)->delete();
                 $votes = Vote::where('answer_id', '=', $answer_id)->count();
                 if ($votes) {
                     Poll::find($id)->set(array('nofilter:total_votes' => "`total_votes` - {$votes}"));
                 }
                 Redirect::to(Url::get('admin@edit', $id, 'answer_deleted=true'));
             }
             if (Param::post('remove_poll')) {
                 Poll::find($id)->delete();
                 Redirect::to(Url::get('admin', null, 'poll_deleted=true'));
             }
             if (is_numeric($id) && ($poll = Poll::get((int) $id))) {
                 foreach ($_POST as $key => $value) {
                     if (isset($poll->{$key}) && (!empty($_POST[$key]) || $_POST[$key] === "0")) {
                         $poll->{$key} = is_numeric($_POST[$key]) ? intval($_POST[$key], 10) : $_POST[$key];
                     } elseif (false !== strpos($key, 'answer-')) {
                         $answer_id = explode('-', $key);
                         $answer_id = $answer_id[1];
                         if (is_numeric($answer_id)) {
                             Answer::find((int) $answer_id)->set(array('text' => $value));
                         }
                     } elseif ($key === 'new_answers') {
                         foreach ($value as $new_answer) {
                             if (!empty($new_answer)) {
                                 Answer::create(array('poll_id' => (int) $poll->id, 'text' => $new_answer));
                             }
                         }
                     }
                 }
                 Poll::save($poll);
                 Redirect::to(Url::get('admin', null, 'success=' . $_POST['id'] . '&updated=true'));
             } else {
                 return Response::error(500);
             }
         }
     }
     if (!$id || !is_numeric($id) || !($poll = Poll::get((int) $id))) {
         return Response::error(404);
     } else {
         $answers = Answer::where('poll_id', '=', $poll->id)->get();
         return View::make('admin.edit')->add_var('answers', $answers)->add_var('poll', $poll);
     }
 }
开发者ID:jruizdes,项目名称:encuestamanki,代码行数:66,代码来源:admin.php

示例13: current

 public static function current()
 {
     return Url::current()->uri();
 }
开发者ID:nerdsrescueme,项目名称:Core,代码行数:4,代码来源:uri.php

示例14: dispatch

 function dispatch($content_only = false, $check_perm = true)
 {
     Event::trigger('on_before_dispatch', $this);
     $session = Base::getSession();
     reset:
     //if no action set, set it to index
     if (strlen(trim($this->action)) == 0) {
         $this->action = 'index';
     }
     //set admin path
     $site = '';
     if ($this->site == 'admin') {
         $site = '\\Admin';
     }
     //load the extension class
     $controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
     $extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
     $classname = '\\GCore' . $site . $extension . $controller;
     $this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
     //set referer
     if (!$content_only) {
         if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
             $session->set('_referer', Url::current());
         } else {
             //$session->set('_referer', 'index.php');
         }
     }
     //check permissions
     if ($check_perm and !Authorize::authorized($classname, $this->action)) {
         if ($content_only) {
             return;
         }
         $this->redirect(r_('index.php?cont=users&act=login'));
     }
     //if the extension class not found or the action function not found then load an error
     if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
         $this->controller = 'errors';
         $this->action = 'e404';
         //reset the controller
         $classname = '\\GCore\\Controllers\\Errors';
         \GCore\Libs\Env::e404();
         //we need the rendered content only
         if ($content_only) {
             return;
         }
     }
     //load language file
     if (!empty($extension)) {
         Lang::load($site . $extension);
     }
     //set theme
     $doc = Document::getInstance($this->site, $this->thread);
     $doc->theme = 'bootstrap3';
     //'gcoreui';//'semantic1';
     $theme = \GCore\Helpers\Theme::getInstance();
     // in gcore app, bootstrap should be always loaded first with jquery
     //load class and run the action
     ${$classname} = new $classname($this->site, $this->thread);
     ob_start();
     $continue = ${$classname}->_initialize();
     //check and read cache
     if (!empty(${$classname}->cache)) {
         if (!is_array(${$classname}->cache)) {
             ${$classname}->cache = array();
         }
         if (empty(${$classname}->cache['time'])) {
             ${$classname}->cache['time'] = Base::getConfig('app_cache_expiry', 900);
         }
         if (empty(${$classname}->cache['title'])) {
             ${$classname}->cache['title'] = File::makeSafe($classname . '_' . $this->action);
         } else {
             ${$classname}->cache['title'] = File::makeSafe(${$classname}->cache['title']);
         }
         if (empty(${$classname}->cache['key'])) {
             ${$classname}->cache['key'] = 'cached_view';
         } else {
             ${$classname}->cache['key'] = 'cached_view_' . ${$classname}->cache['key'];
         }
         $cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
         $cached_view = $cache->get(${$classname}->cache['key']);
         $cached = false;
         if (!empty($cached_view)) {
             $cached = true;
             $continue = false;
             echo $cached_view;
         }
     }
     if ($continue !== false) {
         ${$classname}->{$this->action}();
         if ($this->reset === true) {
             $this->reset = false;
             goto reset;
         }
         //initialize and render view
         $view = new View();
         $view->initialize(${$classname});
         $view->renderView($this->action);
     }
     //get the action output buffer
     $this->buffer = ob_get_clean();
//.........这里部分代码省略.........
开发者ID:ejailesb,项目名称:repo_empr,代码行数:101,代码来源:app.php


注:本文中的Url::current方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。