mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-02 17:42:41 +00:00
Added HtmlHelper::video() for html5 video element generation. Extracted asset url generation code to new function Helper::assetUrl().
This commit is contained in:
parent
12bf1348f5
commit
22220074f2
3 changed files with 158 additions and 22 deletions
|
@ -259,6 +259,34 @@ class Helper extends Object {
|
|||
return $webPath . $asset[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate url for given asset file. Depending on options passed provides full url with domain name.
|
||||
* Also calls Helper::assetTimestamp() to add timestamp to local files
|
||||
*
|
||||
* @param string|array Path string or url array
|
||||
* @param array $options Options array. Possible keys:
|
||||
* `fullBase` Return full url with domain name
|
||||
* `pathPrefix` Path prefix for relative urls
|
||||
* @return string Generated url
|
||||
*/
|
||||
public function assetUrl($path, array $options) {
|
||||
if (is_array($path)) {
|
||||
$path = $this->url($path);
|
||||
} elseif (strpos($path, '://') === false) {
|
||||
if (!empty($options['pathPrefix']) && $path[0] !== '/') {
|
||||
$path = $options['pathPrefix'] . $path;
|
||||
}
|
||||
$path = $this->assetTimestamp($this->webroot($path));
|
||||
}
|
||||
|
||||
if (!empty($options['fullBase'])) {
|
||||
$path = $this->url('/', true) . $path;
|
||||
unset($options['fullBase']);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'
|
||||
|
@ -446,10 +474,10 @@ class Helper extends Object {
|
|||
|
||||
// 0.name, 0.created.month style inputs. Excludes inputs with the modelScope in them.
|
||||
if (
|
||||
$count >= 2 &&
|
||||
is_numeric($parts[0]) &&
|
||||
!is_numeric($parts[1]) &&
|
||||
$this->_modelScope &&
|
||||
$count >= 2 &&
|
||||
is_numeric($parts[0]) &&
|
||||
!is_numeric($parts[1]) &&
|
||||
$this->_modelScope &&
|
||||
strpos($entity, $this->_modelScope) === false
|
||||
) {
|
||||
$entity = $this->_modelScope . '.' . $entity;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue