mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-02 14:23:34 +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.Core
|
||||
* @since CakePHP(tm) v 1.0.0.2363
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -25,9 +26,18 @@ interface ConfigReaderInterface {
|
|||
* These sources can either be static resources like files, or dynamic ones like
|
||||
* a database, or other datasource.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $key Key to read.
|
||||
* @return array An array of data to merge into the runtime configuration
|
||||
*/
|
||||
public function read($key);
|
||||
|
||||
/**
|
||||
* Dumps the configure data into source.
|
||||
*
|
||||
* @param string $key The identifier to write to.
|
||||
* @param array $data The data to dump.
|
||||
* @return bool True on success or false on failure.
|
||||
*/
|
||||
public function dump($key, $data);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,21 +2,22 @@
|
|||
/**
|
||||
* IniReader
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* 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.Configure
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Hash', 'Utility');
|
||||
App::uses('CakePlugin', 'Core');
|
||||
|
||||
/**
|
||||
* Ini file configuration engine.
|
||||
|
@ -25,7 +26,7 @@ App::uses('Hash', 'Utility');
|
|||
* class shares the same behavior, especially with regards to boolean and null values.
|
||||
*
|
||||
* In addition to the native `parse_ini_file` features, IniReader also allows you
|
||||
* to create nested array structures through usage of `.` delimited names. This allows
|
||||
* to create nested array structures through usage of `.` delimited names. This allows
|
||||
* you to create nested arrays structures in an ini config file. For example:
|
||||
*
|
||||
* `db.password = secret` would turn into `array('db' => array('password' => 'secret'))`
|
||||
|
@ -33,10 +34,10 @@ App::uses('Hash', 'Utility');
|
|||
* You can nest properties as deeply as needed using `.`'s. In addition to using `.` you
|
||||
* can use standard ini section notation to create nested structures:
|
||||
*
|
||||
* {{{
|
||||
* ```
|
||||
* [section]
|
||||
* key = value
|
||||
* }}}
|
||||
* ```
|
||||
*
|
||||
* Once loaded into Configure, the above would be accessed using:
|
||||
*
|
||||
|
@ -94,30 +95,14 @@ class IniReader implements ConfigReaderInterface {
|
|||
* @return array Parsed configuration values.
|
||||
* @throws ConfigureException when files don't exist.
|
||||
* Or when files contain '..' as this could lead to abusive reads.
|
||||
* @throws ConfigureException
|
||||
*/
|
||||
public function read($key) {
|
||||
if (strpos($key, '..') !== false) {
|
||||
throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
|
||||
}
|
||||
if (substr($key, -8) === '.ini.php') {
|
||||
$key = substr($key, 0, -8);
|
||||
list($plugin, $key) = pluginSplit($key);
|
||||
$key .= '.ini.php';
|
||||
} else {
|
||||
if (substr($key, -4) === '.ini') {
|
||||
$key = substr($key, 0, -4);
|
||||
}
|
||||
list($plugin, $key) = pluginSplit($key);
|
||||
$key .= '.ini';
|
||||
}
|
||||
|
||||
if ($plugin) {
|
||||
$file = App::pluginPath($plugin) . 'Config' . DS . $key;
|
||||
} else {
|
||||
$file = $this->_path . $key;
|
||||
}
|
||||
if (!is_file($file)) {
|
||||
$file = $this->_getFilePath($key);
|
||||
if (!is_file(realpath($file))) {
|
||||
throw new ConfigureException(__d('cake_dev', 'Could not load configuration file: %s', $file));
|
||||
}
|
||||
|
||||
|
@ -165,36 +150,39 @@ class IniReader implements ConfigReaderInterface {
|
|||
/**
|
||||
* Dumps the state of Configure data into an ini formatted string.
|
||||
*
|
||||
* @param string $filename The filename on $this->_path to save into.
|
||||
* Extension ".ini" will be automatically appended if not included in filename.
|
||||
* @param string $key The identifier to write to. If the key has a . it will be treated
|
||||
* as a plugin prefix.
|
||||
* @param array $data The data to convert to ini file.
|
||||
* @return int Bytes saved.
|
||||
*/
|
||||
public function dump($filename, $data) {
|
||||
public function dump($key, $data) {
|
||||
$result = array();
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key[0] != '[') {
|
||||
$result[] = "[$key]";
|
||||
foreach ($data as $k => $value) {
|
||||
$isSection = false;
|
||||
if ($k[0] !== '[') {
|
||||
$result[] = "[$k]";
|
||||
$isSection = true;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$keyValues = Hash::flatten($value, '.');
|
||||
foreach ($keyValues as $k => $v) {
|
||||
$result[] = "$k = " . $this->_value($v);
|
||||
$kValues = Hash::flatten($value, '.');
|
||||
foreach ($kValues as $k2 => $v) {
|
||||
$result[] = "$k2 = " . $this->_value($v);
|
||||
}
|
||||
}
|
||||
if ($isSection) {
|
||||
$result[] = '';
|
||||
}
|
||||
}
|
||||
$contents = join("\n", $result);
|
||||
$contents = trim(implode("\n", $result));
|
||||
|
||||
if (substr($filename, -4) !== '.ini') {
|
||||
$filename .= '.ini';
|
||||
}
|
||||
return file_put_contents($this->_path . $filename, $contents);
|
||||
$filename = $this->_getFilePath($key);
|
||||
return file_put_contents($filename, $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a value into the ini equivalent
|
||||
*
|
||||
* @param mixed $value to export.
|
||||
* @param mixed $val Value to export.
|
||||
* @return string String value for ini file.
|
||||
*/
|
||||
protected function _value($val) {
|
||||
|
@ -210,4 +198,33 @@ class IniReader implements ConfigReaderInterface {
|
|||
return (string)$val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file path
|
||||
*
|
||||
* @param string $key The identifier to write to. If the key has a . it will be treated
|
||||
* as a plugin prefix.
|
||||
* @return string Full file path
|
||||
*/
|
||||
protected function _getFilePath($key) {
|
||||
if (substr($key, -8) === '.ini.php') {
|
||||
$key = substr($key, 0, -8);
|
||||
list($plugin, $key) = pluginSplit($key);
|
||||
$key .= '.ini.php';
|
||||
} else {
|
||||
if (substr($key, -4) === '.ini') {
|
||||
$key = substr($key, 0, -4);
|
||||
}
|
||||
list($plugin, $key) = pluginSplit($key);
|
||||
$key .= '.ini';
|
||||
}
|
||||
|
||||
if ($plugin) {
|
||||
$file = CakePlugin::path($plugin) . 'Config' . DS . $key;
|
||||
} else {
|
||||
$file = $this->_path . $key;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,20 +2,21 @@
|
|||
/**
|
||||
* PhpReader file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* 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://book.cakephp.org/2.0/en/development/configuration.html#loading-configuration-files CakePHP(tm) Configuration
|
||||
* @package Cake.Configure
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakePlugin', 'Core');
|
||||
|
||||
/**
|
||||
* PHP Reader allows Configure to load configuration values from
|
||||
* files containing simple PHP arrays.
|
||||
|
@ -37,7 +38,7 @@ class PhpReader implements ConfigReaderInterface {
|
|||
/**
|
||||
* Constructor for PHP Config file reading.
|
||||
*
|
||||
* @param string $path The path to read config files from. Defaults to APP . 'Config' . DS
|
||||
* @param string $path The path to read config files from. Defaults to APP . 'Config' . DS
|
||||
*/
|
||||
public function __construct($path = null) {
|
||||
if (!$path) {
|
||||
|
@ -49,10 +50,10 @@ class PhpReader implements ConfigReaderInterface {
|
|||
/**
|
||||
* Read a config file and return its contents.
|
||||
*
|
||||
* Files with `.` in the name will be treated as values in plugins. Instead of reading from
|
||||
* the initialized path, plugin keys will be located using App::pluginPath().
|
||||
* Files with `.` in the name will be treated as values in plugins. Instead of reading from
|
||||
* the initialized path, plugin keys will be located using CakePlugin::path().
|
||||
*
|
||||
* @param string $key The identifier to read from. If the key has a . it will be treated
|
||||
* @param string $key The identifier to read from. If the key has a . it will be treated
|
||||
* as a plugin prefix.
|
||||
* @return array Parsed configuration values.
|
||||
* @throws ConfigureException when files don't exist or they don't contain `$config`.
|
||||
|
@ -62,26 +63,15 @@ class PhpReader implements ConfigReaderInterface {
|
|||
if (strpos($key, '..') !== false) {
|
||||
throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
|
||||
}
|
||||
if (substr($key, -4) === '.php') {
|
||||
$key = substr($key, 0, -4);
|
||||
}
|
||||
list($plugin, $key) = pluginSplit($key);
|
||||
$key .= '.php';
|
||||
|
||||
if ($plugin) {
|
||||
$file = App::pluginPath($plugin) . 'Config' . DS . $key;
|
||||
} else {
|
||||
$file = $this->_path . $key;
|
||||
}
|
||||
if (!is_file($file)) {
|
||||
$file = $this->_getFilePath($key);
|
||||
if (!is_file(realpath($file))) {
|
||||
throw new ConfigureException(__d('cake_dev', 'Could not load configuration file: %s', $file));
|
||||
}
|
||||
|
||||
include $file;
|
||||
if (!isset($config)) {
|
||||
throw new ConfigureException(
|
||||
sprintf(__d('cake_dev', 'No variable $config found in %s'), $file)
|
||||
);
|
||||
throw new ConfigureException(__d('cake_dev', 'No variable %s found in %s', '$config', $file));
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
@ -90,18 +80,39 @@ class PhpReader implements ConfigReaderInterface {
|
|||
* Converts the provided $data into a string of PHP code that can
|
||||
* be used saved into a file and loaded later.
|
||||
*
|
||||
* @param string $filename The filename to create on $this->_path.
|
||||
* Extension ".php" will be automatically appended if not included in filename.
|
||||
* @param string $key The identifier to write to. If the key has a . it will be treated
|
||||
* as a plugin prefix.
|
||||
* @param array $data Data to dump.
|
||||
* @return int Bytes saved.
|
||||
*/
|
||||
public function dump($filename, $data) {
|
||||
public function dump($key, $data) {
|
||||
$contents = '<?php' . "\n" . '$config = ' . var_export($data, true) . ';';
|
||||
|
||||
if (substr($filename, -4) !== '.php') {
|
||||
$filename .= '.php';
|
||||
$filename = $this->_getFilePath($key);
|
||||
return file_put_contents($filename, $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file path
|
||||
*
|
||||
* @param string $key The identifier to write to. If the key has a . it will be treated
|
||||
* as a plugin prefix.
|
||||
* @return string Full file path
|
||||
*/
|
||||
protected function _getFilePath($key) {
|
||||
if (substr($key, -4) === '.php') {
|
||||
$key = substr($key, 0, -4);
|
||||
}
|
||||
return file_put_contents($this->_path . $filename, $contents);
|
||||
list($plugin, $key) = pluginSplit($key);
|
||||
$key .= '.php';
|
||||
|
||||
if ($plugin) {
|
||||
$file = CakePlugin::path($plugin) . 'Config' . DS . $key;
|
||||
} else {
|
||||
$file = $this->_path . $key;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue