mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 22:53:58 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -1,16 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Utility
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -21,6 +22,40 @@
|
|||
*/
|
||||
class Folder {
|
||||
|
||||
/**
|
||||
* Default scheme for Folder::copy
|
||||
* Recursively merges subfolders with the same name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const MERGE = 'merge';
|
||||
|
||||
/**
|
||||
* Overwrite scheme for Folder::copy
|
||||
* subfolders with the same name will be replaced
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const OVERWRITE = 'overwrite';
|
||||
|
||||
/**
|
||||
* Skip scheme for Folder::copy
|
||||
* if a subfolder with the same name exists it will be skipped
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SKIP = 'skip';
|
||||
|
||||
/**
|
||||
* Sort mode by name
|
||||
*/
|
||||
const SORT_NAME = 'name';
|
||||
|
||||
/**
|
||||
* Sort mode by time
|
||||
*/
|
||||
const SORT_TIME = 'time';
|
||||
|
||||
/**
|
||||
* Path to Folder.
|
||||
*
|
||||
|
@ -33,19 +68,27 @@ class Folder {
|
|||
* Sortedness. Whether or not list results
|
||||
* should be sorted by name.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$sort
|
||||
*/
|
||||
public $sort = false;
|
||||
|
||||
/**
|
||||
* Mode to be used on create. Does nothing on windows platforms.
|
||||
* Mode to be used on create. Does nothing on Windows platforms.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
* http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$mode
|
||||
*/
|
||||
public $mode = 0755;
|
||||
|
||||
/**
|
||||
* Functions array to be called depending on the sort type chosen.
|
||||
*/
|
||||
protected $_fsorts = array(
|
||||
self::SORT_NAME => 'getPathname',
|
||||
self::SORT_TIME => 'getCTime'
|
||||
);
|
||||
|
||||
/**
|
||||
* Holds messages from last method.
|
||||
*
|
||||
|
@ -78,8 +121,8 @@ class Folder {
|
|||
* Constructor.
|
||||
*
|
||||
* @param string $path Path to folder
|
||||
* @param boolean $create Create folder if not found
|
||||
* @param string|boolean $mode Mode (CHMOD) to apply to created folder, false to ignore
|
||||
* @param bool $create Create folder if not found
|
||||
* @param string|bool $mode Mode (CHMOD) to apply to created folder, false to ignore
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder
|
||||
*/
|
||||
public function __construct($path = false, $create = false, $mode = false) {
|
||||
|
@ -130,14 +173,14 @@ class Folder {
|
|||
* Returns an array of the contents of the current directory.
|
||||
* The returned array holds two arrays: One of directories and one of files.
|
||||
*
|
||||
* @param boolean $sort Whether you want the results sorted, set this and the sort property
|
||||
* @param string|bool $sort Whether you want the results sorted, set this and the sort property
|
||||
* to false to get unsorted results.
|
||||
* @param array|boolean $exceptions Either an array or boolean true will not grab dot files
|
||||
* @param boolean $fullPath True returns the full path
|
||||
* @param array|bool $exceptions Either an array or boolean true will not grab dot files
|
||||
* @param bool $fullPath True returns the full path
|
||||
* @return mixed Contents of current directory as an array, an empty array on failure
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::read
|
||||
*/
|
||||
public function read($sort = true, $exceptions = false, $fullPath = false) {
|
||||
public function read($sort = self::SORT_NAME, $exceptions = false, $fullPath = false) {
|
||||
$dirs = $files = array();
|
||||
|
||||
if (!$this->pwd()) {
|
||||
|
@ -153,6 +196,11 @@ class Folder {
|
|||
} catch (Exception $e) {
|
||||
return array($dirs, $files);
|
||||
}
|
||||
if (!is_bool($sort) && isset($this->_fsorts[$sort])) {
|
||||
$methodName = $this->_fsorts[$sort];
|
||||
} else {
|
||||
$methodName = $this->_fsorts[self::SORT_NAME];
|
||||
}
|
||||
|
||||
foreach ($iterator as $item) {
|
||||
if ($item->isDot()) {
|
||||
|
@ -166,14 +214,22 @@ class Folder {
|
|||
$name = $item->getPathName();
|
||||
}
|
||||
if ($item->isDir()) {
|
||||
$dirs[] = $name;
|
||||
$dirs[$item->{$methodName}()][] = $name;
|
||||
} else {
|
||||
$files[] = $name;
|
||||
$files[$item->{$methodName}()][] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sort || $this->sort) {
|
||||
sort($dirs);
|
||||
sort($files);
|
||||
ksort($dirs);
|
||||
ksort($files);
|
||||
}
|
||||
|
||||
if ($dirs) {
|
||||
$dirs = call_user_func_array('array_merge', $dirs);
|
||||
}
|
||||
if ($files) {
|
||||
$files = call_user_func_array('array_merge', $files);
|
||||
}
|
||||
return array($dirs, $files);
|
||||
}
|
||||
|
@ -182,12 +238,12 @@ class Folder {
|
|||
* Returns an array of all matching files in current directory.
|
||||
*
|
||||
* @param string $regexpPattern Preg_match pattern (Defaults to: .*)
|
||||
* @param boolean $sort Whether results should be sorted.
|
||||
* @param bool $sort Whether results should be sorted.
|
||||
* @return array Files that match given pattern
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::find
|
||||
*/
|
||||
public function find($regexpPattern = '.*', $sort = false) {
|
||||
list($dirs, $files) = $this->read($sort);
|
||||
list(, $files) = $this->read($sort);
|
||||
return array_values(preg_grep('/^' . $regexpPattern . '$/i', $files));
|
||||
}
|
||||
|
||||
|
@ -195,7 +251,7 @@ class Folder {
|
|||
* Returns an array of all matching files in and below current directory.
|
||||
*
|
||||
* @param string $pattern Preg_match pattern (Defaults to: .*)
|
||||
* @param boolean $sort Whether results should be sorted.
|
||||
* @param bool $sort Whether results should be sorted.
|
||||
* @return array Files matching $pattern
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::findRecursive
|
||||
*/
|
||||
|
@ -213,7 +269,7 @@ class Folder {
|
|||
* Private helper function for findRecursive.
|
||||
*
|
||||
* @param string $pattern Pattern to match against
|
||||
* @param boolean $sort Whether results should be sorted.
|
||||
* @param bool $sort Whether results should be sorted.
|
||||
* @return array Files matching pattern
|
||||
*/
|
||||
protected function _findRecursive($pattern, $sort = false) {
|
||||
|
@ -238,22 +294,44 @@ class Folder {
|
|||
* Returns true if given $path is a Windows path.
|
||||
*
|
||||
* @param string $path Path to check
|
||||
* @return boolean true if windows path, false otherwise
|
||||
* @return bool true if Windows path, false otherwise
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isWindowsPath
|
||||
*/
|
||||
public static function isWindowsPath($path) {
|
||||
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) === '\\\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given $path is an absolute path.
|
||||
*
|
||||
* @param string $path Path to check
|
||||
* @return boolean true if path is absolute.
|
||||
* @return bool true if path is absolute.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isAbsolute
|
||||
*/
|
||||
public static function isAbsolute($path) {
|
||||
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||
if (empty($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $path[0] === '/' ||
|
||||
preg_match('/^[A-Z]:\\\\/i', $path) ||
|
||||
substr($path, 0, 2) === '\\\\' ||
|
||||
static::isRegisteredStreamWrapper($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given $path is a registered stream wrapper.
|
||||
*
|
||||
* @param string $path Path to check
|
||||
* @return boo true If path is registered stream wrapper.
|
||||
*/
|
||||
public static function isRegisteredStreamWrapper($path) {
|
||||
if (preg_match('/^[A-Z]+(?=:\/\/)/i', $path, $matches) &&
|
||||
in_array($matches[0], stream_get_wrappers())
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,19 +374,21 @@ class Folder {
|
|||
* Returns $path with $element added, with correct slash in-between.
|
||||
*
|
||||
* @param string $path Path
|
||||
* @param string $element Element to and at end of path
|
||||
* @param string|array $element Element to add at end of path
|
||||
* @return string Combined path
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::addPathElement
|
||||
*/
|
||||
public static function addPathElement($path, $element) {
|
||||
return rtrim($path, DS) . DS . $element;
|
||||
$element = (array)$element;
|
||||
array_unshift($element, rtrim($path, DS));
|
||||
return implode(DS, $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the File is in a given CakePath.
|
||||
* Returns true if the Folder is in the given Cake path.
|
||||
*
|
||||
* @param string $path The path to check.
|
||||
* @return boolean
|
||||
* @return bool
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inCakePath
|
||||
*/
|
||||
public function inCakePath($path = '') {
|
||||
|
@ -319,21 +399,26 @@ class Folder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if the File is in given path.
|
||||
* Returns true if the Folder is in the given path.
|
||||
*
|
||||
* @param string $path The path to check that the current pwd() resides with in.
|
||||
* @param boolean $reverse Reverse the search, check that pwd() resides within $path.
|
||||
* @return boolean
|
||||
* @param string $path The absolute path to check that the current `pwd()` resides within.
|
||||
* @param bool $reverse Reverse the search, check if the given `$path` resides within the current `pwd()`.
|
||||
* @return bool
|
||||
* @throws \InvalidArgumentException When the given `$path` argument is not an absolute path.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inPath
|
||||
*/
|
||||
public function inPath($path = '', $reverse = false) {
|
||||
if (!Folder::isAbsolute($path)) {
|
||||
throw new InvalidArgumentException(__d('cake_dev', 'The $path argument is expected to be an absolute path.'));
|
||||
}
|
||||
|
||||
$dir = Folder::slashTerm($path);
|
||||
$current = Folder::slashTerm($this->pwd());
|
||||
|
||||
if (!$reverse) {
|
||||
$return = preg_match('/^(.*)' . preg_quote($dir, '/') . '(.*)/', $current);
|
||||
$return = preg_match('/^' . preg_quote($dir, '/') . '(.*)/', $current);
|
||||
} else {
|
||||
$return = preg_match('/^(.*)' . preg_quote($current, '/') . '(.*)/', $dir);
|
||||
$return = preg_match('/^' . preg_quote($current, '/') . '(.*)/', $dir);
|
||||
}
|
||||
return (bool)$return;
|
||||
}
|
||||
|
@ -341,11 +426,11 @@ class Folder {
|
|||
/**
|
||||
* Change the mode on a directory structure recursively. This includes changing the mode on files as well.
|
||||
*
|
||||
* @param string $path The path to chmod
|
||||
* @param integer $mode octal value 0755
|
||||
* @param boolean $recursive chmod recursively, set to false to only change the current directory.
|
||||
* @param array $exceptions array of files, directories to skip
|
||||
* @return boolean Returns TRUE on success, FALSE on failure
|
||||
* @param string $path The path to chmod.
|
||||
* @param int $mode Octal value, e.g. 0755.
|
||||
* @param bool $recursive Chmod recursively, set to false to only change the current directory.
|
||||
* @param array $exceptions Array of files, directories to skip.
|
||||
* @return bool Success.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod
|
||||
*/
|
||||
public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
||||
|
@ -398,14 +483,14 @@ class Folder {
|
|||
* Returns an array of nested directories and files in each directory
|
||||
*
|
||||
* @param string $path the directory path to build the tree from
|
||||
* @param array|boolean $exceptions Either an array of files/folder to exclude
|
||||
* @param array|bool $exceptions Either an array of files/folder to exclude
|
||||
* or boolean true to not grab dot files/folders
|
||||
* @param string $type either 'file' or 'dir'. null returns both files and directories
|
||||
* @return mixed array of nested directories and files in each directory
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
|
||||
*/
|
||||
public function tree($path = null, $exceptions = false, $type = null) {
|
||||
if ($path == null) {
|
||||
if (!$path) {
|
||||
$path = $this->path;
|
||||
}
|
||||
$files = array();
|
||||
|
@ -435,7 +520,7 @@ class Folder {
|
|||
foreach ($iterator as $itemPath => $fsIterator) {
|
||||
if ($skipHidden) {
|
||||
$subPathName = $fsIterator->getSubPathname();
|
||||
if ($subPathName{0} == '.' || strpos($subPathName, DS . '.') !== false) {
|
||||
if ($subPathName{0} === '.' || strpos($subPathName, DS . '.') !== false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -460,12 +545,15 @@ class Folder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a directory structure recursively. Can be used to create
|
||||
* deep path structures like `/foo/bar/baz/shoe/horn`
|
||||
* Create a directory structure recursively.
|
||||
*
|
||||
* @param string $pathname The directory structure to create
|
||||
* @param integer $mode octal value 0755
|
||||
* @return boolean Returns TRUE on success, FALSE on failure
|
||||
* Can be used to create deep path structures like `/foo/bar/baz/shoe/horn`
|
||||
*
|
||||
* @param string $pathname The directory structure to create. Either an absolute or relative
|
||||
* path. If the path is relative and exists in the process' cwd it will not be created.
|
||||
* Otherwise relative paths will be prefixed with the current pwd().
|
||||
* @param int $mode octal value 0755
|
||||
* @return bool Returns TRUE on success, FALSE on failure
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::create
|
||||
*/
|
||||
public function create($pathname, $mode = false) {
|
||||
|
@ -473,6 +561,10 @@ class Folder {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!static::isAbsolute($pathname)) {
|
||||
$pathname = static::addPathElement($this->pwd(), $pathname);
|
||||
}
|
||||
|
||||
if (!$mode) {
|
||||
$mode = $this->mode;
|
||||
}
|
||||
|
@ -491,11 +583,10 @@ class Folder {
|
|||
umask($old);
|
||||
$this->_messages[] = __d('cake_dev', '%s created', $pathname);
|
||||
return true;
|
||||
} else {
|
||||
umask($old);
|
||||
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
|
||||
return false;
|
||||
}
|
||||
umask($old);
|
||||
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -504,7 +595,7 @@ class Folder {
|
|||
/**
|
||||
* Returns the size in bytes of this Folder and its contents.
|
||||
*
|
||||
* @return integer size in bytes of current folder
|
||||
* @return int size in bytes of current folder
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::dirsize
|
||||
*/
|
||||
public function dirsize() {
|
||||
|
@ -541,7 +632,7 @@ class Folder {
|
|||
* Recursively Remove directories if the system allows.
|
||||
*
|
||||
* @param string $path Path of directory to delete
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::delete
|
||||
*/
|
||||
public function delete($path = null) {
|
||||
|
@ -549,7 +640,7 @@ class Folder {
|
|||
$path = $this->pwd();
|
||||
}
|
||||
if (!$path) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
$path = Folder::slashTerm($path);
|
||||
if (is_dir($path)) {
|
||||
|
@ -602,14 +693,15 @@ class Folder {
|
|||
*
|
||||
* - `to` The directory to copy to.
|
||||
* - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd().
|
||||
* - `mode` The mode to copy the files/directories with.
|
||||
* - `mode` The mode to copy the files/directories with as integer, e.g. 0775.
|
||||
* - `skip` Files/directories to skip.
|
||||
* - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP
|
||||
*
|
||||
* @param array|string $options Either an array of options (see above) or a string of the destination directory.
|
||||
* @return boolean Success
|
||||
* @return bool Success.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
|
||||
*/
|
||||
public function copy($options = array()) {
|
||||
public function copy($options) {
|
||||
if (!$this->pwd()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -618,7 +710,13 @@ class Folder {
|
|||
$to = $options;
|
||||
$options = array();
|
||||
}
|
||||
$options = array_merge(array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array()), $options);
|
||||
$options += array(
|
||||
'to' => $to,
|
||||
'from' => $this->path,
|
||||
'mode' => $this->mode,
|
||||
'skip' => array(),
|
||||
'scheme' => Folder::MERGE
|
||||
);
|
||||
|
||||
$fromDir = $options['from'];
|
||||
$toDir = $options['to'];
|
||||
|
@ -642,11 +740,11 @@ class Folder {
|
|||
//@codingStandardsIgnoreStart
|
||||
if ($handle = @opendir($fromDir)) {
|
||||
//@codingStandardsIgnoreEnd
|
||||
while (false !== ($item = readdir($handle))) {
|
||||
if (!in_array($item, $exceptions)) {
|
||||
while (($item = readdir($handle)) !== false) {
|
||||
$to = Folder::addPathElement($toDir, $item);
|
||||
if (($options['scheme'] != Folder::SKIP || !is_dir($to)) && !in_array($item, $exceptions)) {
|
||||
$from = Folder::addPathElement($fromDir, $item);
|
||||
$to = Folder::addPathElement($toDir, $item);
|
||||
if (is_file($from)) {
|
||||
if (is_file($from) && (!is_file($to) || $options['scheme'] != Folder::SKIP)) {
|
||||
if (copy($from, $to)) {
|
||||
chmod($to, intval($mode, 8));
|
||||
touch($to, filemtime($from));
|
||||
|
@ -656,6 +754,10 @@ class Folder {
|
|||
}
|
||||
}
|
||||
|
||||
if (is_dir($from) && file_exists($to) && $options['scheme'] === Folder::OVERWRITE) {
|
||||
$this->delete($to);
|
||||
}
|
||||
|
||||
if (is_dir($from) && !file_exists($to)) {
|
||||
$old = umask(0);
|
||||
if (mkdir($to, $mode)) {
|
||||
|
@ -664,11 +766,14 @@ class Folder {
|
|||
chmod($to, $mode);
|
||||
umask($old);
|
||||
$this->_messages[] = __d('cake_dev', '%s created', $to);
|
||||
$options = array_merge($options, array('to' => $to, 'from' => $from));
|
||||
$options = array('to' => $to, 'from' => $from) + $options;
|
||||
$this->copy($options);
|
||||
} else {
|
||||
$this->_errors[] = __d('cake_dev', '%s not created', $to);
|
||||
}
|
||||
} elseif (is_dir($from) && $options['scheme'] === Folder::MERGE) {
|
||||
$options = array('to' => $to, 'from' => $from) + $options;
|
||||
$this->copy($options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -692,9 +797,10 @@ class Folder {
|
|||
* - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd().
|
||||
* - `chmod` The mode to copy the files/directories with.
|
||||
* - `skip` Files/directories to skip.
|
||||
* - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP
|
||||
*
|
||||
* @param array $options (to, from, chmod, skip)
|
||||
* @return boolean Success
|
||||
* @param array $options (to, from, chmod, skip, scheme)
|
||||
* @return bool Success
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::move
|
||||
*/
|
||||
public function move($options) {
|
||||
|
@ -703,10 +809,7 @@ class Folder {
|
|||
$to = $options;
|
||||
$options = (array)$options;
|
||||
}
|
||||
$options = array_merge(
|
||||
array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array()),
|
||||
$options
|
||||
);
|
||||
$options += array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array());
|
||||
|
||||
if ($this->copy($options)) {
|
||||
if ($this->delete($options['from'])) {
|
||||
|
@ -719,21 +822,31 @@ class Folder {
|
|||
/**
|
||||
* get messages from latest method
|
||||
*
|
||||
* @param bool $reset Reset message stack after reading
|
||||
* @return array
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::messages
|
||||
*/
|
||||
public function messages() {
|
||||
return $this->_messages;
|
||||
public function messages($reset = true) {
|
||||
$messages = $this->_messages;
|
||||
if ($reset) {
|
||||
$this->_messages = array();
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* get error from latest method
|
||||
*
|
||||
* @param bool $reset Reset error stack after reading
|
||||
* @return array
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::errors
|
||||
*/
|
||||
public function errors() {
|
||||
return $this->_errors;
|
||||
public function errors($reset = true) {
|
||||
$errors = $this->_errors;
|
||||
if ($reset) {
|
||||
$this->_errors = array();
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -744,13 +857,13 @@ class Folder {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::realpath
|
||||
*/
|
||||
public function realpath($path) {
|
||||
$path = str_replace('/', DS, trim($path));
|
||||
if (strpos($path, '..') === false) {
|
||||
if (!Folder::isAbsolute($path)) {
|
||||
$path = Folder::addPathElement($this->path, $path);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
$path = str_replace('/', DS, trim($path));
|
||||
$parts = explode(DS, $path);
|
||||
$newparts = array();
|
||||
$newpath = '';
|
||||
|
@ -766,9 +879,8 @@ class Folder {
|
|||
if (!empty($newparts)) {
|
||||
array_pop($newparts);
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$newparts[] = $part;
|
||||
}
|
||||
|
@ -781,7 +893,7 @@ class Folder {
|
|||
* Returns true if given $path ends in a slash (i.e. is slash-terminated).
|
||||
*
|
||||
* @param string $path Path to check
|
||||
* @return boolean true if path ends with slash, false otherwise
|
||||
* @return bool true if path ends with slash, false otherwise
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isSlashTerm
|
||||
*/
|
||||
public static function isSlashTerm($path) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue