本文整理汇总了PHP中url::isAbsolute方法的典型用法代码示例。如果您正苦于以下问题:PHP url::isAbsolute方法的具体用法?PHP url::isAbsolute怎么用?PHP url::isAbsolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url
的用法示例。
在下文中一共展示了url::isAbsolute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($path)
{
$this->kirby = kirby::instance();
if (is_a($path, 'Media')) {
parent::__construct($path->root(), $path->url());
} else {
parent::__construct(url::isAbsolute($path) ? null : $this->kirby->roots()->index() . DS . ltrim($path, DS), url::makeAbsolute($path));
}
}
示例2: configure
public function configure()
{
// load all available config files
$root = $this->roots()->config();
$configs = array('main' => 'config.php', 'host' => 'config.' . server::get('SERVER_NAME') . '.php', 'addr' => 'config.' . server::get('SERVER_ADDR') . '.php');
$allowed = array_filter(dir::read($root), function ($file) {
return substr($file, 0, 7) === 'config.' and substr($file, -4) === '.php';
});
foreach ($configs as $config) {
$file = $root . DS . $config;
if (in_array($config, $allowed, true) and file_exists($file)) {
include_once $file;
}
}
// apply the options
$this->options = array_merge($this->options, c::$data);
// overwrite the autodetected url
if ($this->options['url']) {
$this->urls->index = $this->options['url'];
}
// connect the url class with its handlers
url::$home = $this->urls()->index();
url::$to = $this->option('url.to', function ($url = '') {
if (url::isAbsolute($url)) {
return $url;
}
$start = substr($url, 0, 1);
switch ($start) {
case '#':
return $url;
break;
case '.':
return page()->url() . '/' . $url;
break;
default:
// don't convert absolute urls
return url::makeAbsolute($url);
break;
}
});
// setup the thumbnail generator
thumb::$defaults['root'] = $this->roots->thumbs();
thumb::$defaults['url'] = $this->urls->thumbs();
thumb::$defaults['driver'] = $this->option('thumbs.driver');
thumb::$defaults['filename'] = $this->option('thumbs.filename');
// simple error handling
if ($this->options['debug'] === true) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
if ($this->options['debug'] === false) {
error_reporting(0);
ini_set('display_errors', 0);
}
}
}
示例3: configure
public function configure()
{
// load all available config files
$root = $this->roots()->config();
$configs = array('main' => $root . DS . 'config.php', 'host' => $root . DS . 'config.' . server::get('HTTP_HOST') . '.php', 'addr' => $root . DS . 'config.' . server::get('SERVER_ADDR') . '.php');
foreach ($configs as $config) {
if (file_exists($config)) {
include_once $config;
}
}
// apply the options
$this->options = array_merge($this->options, c::$data);
// connect the url class with its handlers
url::$home = $this->urls()->index();
url::$to = $this->option('url.to', function ($url = '') {
if (url::isAbsolute($url)) {
return $url;
}
$start = substr($url, 0, 1);
switch ($start) {
case '#':
return $url;
break;
case '.':
return page()->url() . '/' . $url;
break;
default:
// don't convert absolute urls
return url::makeAbsolute($url);
break;
}
});
// setup the thumbnail generator
thumb::$defaults['root'] = $this->roots->thumbs();
thumb::$defaults['url'] = $this->urls->thumbs();
thumb::$defaults['driver'] = $this->option('thumbs.driver');
thumb::$defaults['filename'] = $this->option('thumbs.filename');
// simple error handling
if ($this->option('debug')) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
error_reporting(0);
ini_set('display_errors', 0);
}
}
示例4: configure
public function configure()
{
// load all available config files
$root = $this->roots()->config();
$configs = array('main' => 'config.php', 'host' => 'config.' . server::get('SERVER_NAME') . '.php', 'addr' => 'config.' . server::get('SERVER_ADDR') . '.php');
$allowed = array_filter(dir::read($root), function ($file) {
return substr($file, 0, 7) === 'config.' and substr($file, -4) === '.php';
});
foreach ($configs as $config) {
$file = $root . DS . $config;
if (in_array($config, $allowed, true) and file_exists($file)) {
include_once $file;
}
}
// apply the options
$this->options = array_merge($this->options, c::$data);
// overwrite the autodetected url
if ($this->options['url']) {
$this->urls->index = $this->options['url'];
}
// connect the url class with its handlers
url::$home = $this->urls()->index();
url::$to = $this->option('url.to', function ($url = '', $lang = null) {
if (url::isAbsolute($url)) {
return $url;
}
$start = substr($url, 0, 1);
switch ($start) {
case '#':
return $url;
break;
case '.':
return page()->url() . '/' . $url;
break;
default:
if ($page = page($url)) {
// use the "official" page url
return $page->url($lang);
} else {
// don't convert absolute urls
return url::makeAbsolute($url);
}
break;
}
});
// setup the pagination redirect to the error page
pagination::$defaults['redirect'] = $this->option('error');
// setting up the email class
email::$defaults['service'] = $this->option('email.service');
email::$defaults['from'] = $this->option('email.from');
email::$defaults['to'] = $this->option('email.to');
email::$defaults['replyTo'] = $this->option('email.replyTo');
email::$defaults['subject'] = $this->option('email.subject');
email::$defaults['body'] = $this->option('email.body');
email::$defaults['options'] = $this->option('email.options');
// simple error handling
if ($this->options['debug'] === true) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
if ($this->options['debug'] === false) {
error_reporting(0);
ini_set('display_errors', 0);
}
}
}
示例5: rtrim
$url = rtrim($url, '/');
return $length ? str::short($url, $length, $rep) : $url;
}
/**
* Returns the URL for document root no
* matter what the path is.
*
* @return string
*/
public static function index()
{
if (r::cli()) {
return '/';
} else {
return static::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
}
}
}
// basic home url setup
url::$home = url::base();
// basic url generator setup
url::$to = function ($path = '/') {
if (url::isAbsolute($path)) {
return $path;
}
$path = ltrim($path, '/');
if (empty($path)) {
return url::home();
}
return url::home() . '/' . $path;
};
示例6: url
<div class="dashboard-box">
<a class="dashboard-item" target="_blank" href="<?php
echo url();
?>
">
<figure>
<span class="dashboard-item-icon dashboard-item-icon-with-border"><i class="fa fa-chain"></i></span>
<figcaption class="dashboard-item-text"><?php
e(url::isAbsolute(url()), url::short(url()), url());
?>
</figcaption>
</figure>
</a>
</div>
示例7: normalizeUrl
/**
* Normalizes given URL in context of current application.
*
* Provided URL may be relative, absolute but local or external. It may
* contain query parameters and fragment.
*
* @note This method does not support multiple normalization in case of
* relative URLs, thus you shouldn't call it more than once per URL.
*
* @param string $url URL to be normalized
* @return string normalized URL
*/
public function normalizeUrl($url)
{
if (url::isRelative($url)) {
return $this->relativePrefix($url);
}
if (url::isAbsolute($url)) {
$parameters = url::parseQuery($url);
$action = parse_url($url, PHP_URL_PATH);
$fragment = parse_url($url, PHP_URL_FRAGMENT);
$url = $this->scriptURL($action, $parameters);
if ($fragment) {
$url .= '#' . $fragment;
}
return $url;
}
return $url;
}
示例8: configure
/**
* Sets all defaults and loads the user configuration
*
* @param array $config
*/
protected static function configure($config = array())
{
// start with a fresh configuration
c::$data = array();
// set some defaults
c::$data['root'] = dirname(__DIR__);
c::$data['root.kirby'] = __DIR__;
c::$data['root.content'] = c::$data['root'] . DS . 'content';
c::$data['root.site'] = c::$data['root'] . DS . 'site';
// the default timezone
c::$data['timezone'] = 'UTC';
// tinyurl handling
c::$data['tinyurl.enabled'] = true;
c::$data['tinyurl.folder'] = 'x';
// disable the cache by default
c::$data['cache'] = false;
c::$data['cache.driver'] = 'file';
c::$data['cache.options'] = array();
// set the default license code
c::$data['license'] = null;
// url rewriting
c::$data['rewrite'] = true;
// markdown defaults
c::$data['markdown'] = true;
c::$data['markdown.extra'] = false;
c::$data['markdown.breaks'] = true;
// pass the config vars from the constructor
// to be able to set all roots
c::$data = array_merge(c::$data, $config);
// set the subroots for site
c::$data['root.cache'] = c::$data['root.site'] . DS . 'cache';
c::$data['root.plugins'] = c::$data['root.site'] . DS . 'plugins';
c::$data['root.templates'] = c::$data['root.site'] . DS . 'templates';
c::$data['root.snippets'] = c::$data['root.site'] . DS . 'snippets';
c::$data['root.controllers'] = c::$data['root.site'] . DS . 'controllers';
c::$data['root.config'] = c::$data['root.site'] . DS . 'config';
c::$data['root.tags'] = c::$data['root.site'] . DS . 'tags';
c::$data['root.accounts'] = c::$data['root.site'] . DS . 'accounts';
// auto css and js setup
c::$data['auto.css.url'] = 'assets/css/templates';
c::$data['auto.css.root'] = c::$data['root'] . DS . 'assets' . DS . 'css' . DS . 'templates';
c::$data['auto.js.url'] = 'assets/js/templates';
c::$data['auto.js.root'] = c::$data['root'] . DS . 'assets' . DS . 'js' . DS . 'templates';
// load all available config files
$configs = array('main' => c::$data['root.config'] . DS . 'config.php', 'host' => c::$data['root.config'] . DS . 'config.' . server::get('HTTP_HOST') . '.php', 'addr' => c::$data['root.config'] . DS . 'config.' . server::get('SERVER_ADDR') . '.php');
foreach ($configs as $confile) {
if (file_exists($confile)) {
include_once $confile;
}
}
// pass the config vars from the constructor again to overwrite
// stuff from the user config
c::$data = array_merge(c::$data, $config);
// detect and store the url
static::url();
// default url handler
if (empty(c::$data['url.to'])) {
c::$data['url.to'] = function ($url = '') {
if (url::isAbsolute($url)) {
return $url;
}
$start = substr($url, 0, 1);
switch ($start) {
case '#':
return $url;
break;
case '.':
return page()->url() . '/' . $url;
break;
default:
// don't convert absolute urls
return url::makeAbsolute($url);
break;
}
};
}
// connect the url class with its handlers
url::$home = c::$data['url'];
url::$to = c::$data['url.to'];
// setup the thumbnail generator
thumb::$defaults['root'] = isset(c::$data['thumb.root']) ? c::$data['thumb.root'] : c::$data['root'] . DS . 'thumbs';
thumb::$defaults['url'] = isset(c::$data['thumb.url']) ? c::$data['thumb.url'] : 'thumbs';
thumb::$defaults['driver'] = isset(c::$data['thumb.driver']) ? c::$data['thumb.driver'] : 'gd';
thumb::$defaults['filename'] = isset(c::$data['thumb.filename']) ? c::$data['thumb.filename'] : '{safeName}-{hash}.{extension}';
// build absolute urls
c::$data['auto.css.url'] = url::makeAbsolute(c::$data['auto.css.url'], url::$home);
c::$data['auto.js.url'] = url::makeAbsolute(c::$data['auto.js.url'], url::$home);
thumb::$defaults['url'] = url::makeAbsolute(thumb::$defaults['url'], url::$home);
// cache setup
if (c::$data['cache']) {
if (c::$data['cache.driver'] == 'file' and empty(c::$data['cache.options'])) {
c::$data['cache.options'] = array('root' => c::get('root.cache'));
}
cache::setup(c::$data['cache.driver'], c::$data['cache.options']);
} else {
//.........这里部分代码省略.........
示例9: url
<div class="dashboard-box">
<a class="dashboard-item" target="_blank" href="<?php
echo url();
?>
">
<figure>
<span class="dashboard-item-icon dashboard-item-icon-with-border"><i class="fa fa-chain"></i></span>
<figcaption class="dashboard-item-text"><?php
e(url::isAbsolute(url()), url::idn(url()), url());
?>
</figcaption>
</figure>
</a>
</div>