mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-09 21:12:41 +00:00
Merge branch 'master' into 2.3
Conflicts: lib/Cake/View/Helper.php
This commit is contained in:
commit
739982addb
4 changed files with 50 additions and 32 deletions
|
@ -295,37 +295,53 @@ class Helper extends Object {
|
|||
if (is_array($path)) {
|
||||
return $this->url($path, !empty($options['fullBase']));
|
||||
}
|
||||
if (strpos($path, '://') === false) {
|
||||
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
|
||||
list($plugin, $path) = $this->_View->pluginSplit($path, false);
|
||||
}
|
||||
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
|
||||
$path = $options['pathPrefix'] . $path;
|
||||
}
|
||||
if (
|
||||
!empty($options['ext']) &&
|
||||
strpos($path, '?') === false &&
|
||||
substr($path, -strlen($options['ext'])) !== $options['ext']
|
||||
) {
|
||||
$path .= $options['ext'];
|
||||
}
|
||||
if (isset($plugin)) {
|
||||
$path = Inflector::underscore($plugin) . '/' . $path;
|
||||
}
|
||||
$path = h($this->assetTimestamp($this->webroot($path)));
|
||||
if (strpos($path, '://') !== false) {
|
||||
return $path;
|
||||
}
|
||||
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
|
||||
list($plugin, $path) = $this->_View->pluginSplit($path, false);
|
||||
}
|
||||
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
|
||||
$path = $options['pathPrefix'] . $path;
|
||||
}
|
||||
if (
|
||||
!empty($options['ext']) &&
|
||||
strpos($path, '?') === false &&
|
||||
substr($path, -strlen($options['ext'])) !== $options['ext']
|
||||
) {
|
||||
$path .= $options['ext'];
|
||||
}
|
||||
if (isset($plugin)) {
|
||||
$path = Inflector::underscore($plugin) . '/' . $path;
|
||||
}
|
||||
$path = $this->_encodeUrl($this->assetTimestamp($this->webroot($path)));
|
||||
|
||||
if (!empty($options['fullBase'])) {
|
||||
$base = $this->url('/', true);
|
||||
$len = strlen($this->request->webroot);
|
||||
if ($len) {
|
||||
$base = substr($base, 0, -$len);
|
||||
}
|
||||
$path = $base . $path;
|
||||
if (!empty($options['fullBase'])) {
|
||||
$base = $this->url('/', true);
|
||||
$len = strlen($this->request->webroot);
|
||||
if ($len) {
|
||||
$base = substr($base, 0, -$len);
|
||||
}
|
||||
$path = $base . $path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a URL for use in HTML attributes.
|
||||
*
|
||||
* @param string $url The url to encode.
|
||||
* @return string The url encoded for both URL & HTML contexts.
|
||||
*/
|
||||
protected function _encodeUrl($url) {
|
||||
$path = parse_url($url, PHP_URL_PATH);
|
||||
$encoded = implode('/', array_map(
|
||||
'rawurlencode',
|
||||
explode('/', $path)
|
||||
));
|
||||
return h(str_replace($path, $encoded, $url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a timestamp to a file based resource based on the value of `Asset.timestamp` in
|
||||
* Configure. If Asset.timestamp is true and debug > 0, or Asset.timestamp == 'force'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue