mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-05 15:43:53 +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
|
@ -2,28 +2,28 @@
|
|||
/**
|
||||
* Library of array functions for Cake.
|
||||
*
|
||||
* 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.Utility
|
||||
* @since CakePHP(tm) v 1.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('String', 'Utility');
|
||||
App::uses('CakeText', 'Utility');
|
||||
App::uses('Hash', 'Utility');
|
||||
|
||||
/**
|
||||
* Class used for manipulation of arrays.
|
||||
*
|
||||
* @package Cake.Utility
|
||||
* @deprecated 3.0.0 Will be removed in 3.0. Use Hash instead.
|
||||
*/
|
||||
class Set {
|
||||
|
||||
|
@ -32,7 +32,7 @@ class Set {
|
|||
* to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
|
||||
* but does not do if for keys containing strings (unlike array_merge_recursive).
|
||||
*
|
||||
* Since this method emulates `array_merge`, it will re-order numeric keys. When combined with out of
|
||||
* Since this method emulates `array_merge`, it will re-order numeric keys. When combined with out of
|
||||
* order numeric keys containing arrays, results can be lossy.
|
||||
*
|
||||
* Note: This function will work with an unlimited amount of arguments and typecasts non-array
|
||||
|
@ -97,7 +97,7 @@ class Set {
|
|||
*
|
||||
* @param string $class A class name of the type of object to map to
|
||||
* @param string $tmp A temporary class name used as $class if $class is an array
|
||||
* @return object Hierarchical object
|
||||
* @return object|null Hierarchical object
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::map
|
||||
*/
|
||||
public static function map($class = 'stdClass', $tmp = 'stdClass') {
|
||||
|
@ -120,9 +120,9 @@ class Set {
|
|||
* returned object (recursively). If $key is numeric will maintain array
|
||||
* structure
|
||||
*
|
||||
* @param array $array Array to map
|
||||
* @param array &$array Array to map
|
||||
* @param string $class Class name
|
||||
* @param boolean $primary whether to assign first array key as the _name_
|
||||
* @param bool $primary whether to assign first array key as the _name_
|
||||
* @return mixed Mapped object
|
||||
*/
|
||||
protected static function _map(&$array, $class, $primary = false) {
|
||||
|
@ -185,8 +185,8 @@ class Set {
|
|||
/**
|
||||
* Checks to see if all the values in the array are numeric
|
||||
*
|
||||
* @param array $array The array to check. If null, the value of the current Set object
|
||||
* @return boolean true if values are numeric, false otherwise
|
||||
* @param array $array The array to check. If null, the value of the current Set object
|
||||
* @return bool true if values are numeric, false otherwise
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::numeric
|
||||
*/
|
||||
public static function numeric($array = null) {
|
||||
|
@ -203,7 +203,7 @@ class Set {
|
|||
*
|
||||
* $list defaults to 0 = no 1 = yes if param is not passed
|
||||
*
|
||||
* @param array $select Key in $list to return
|
||||
* @param string $select Key in $list to return
|
||||
* @param array|string $list can be an array or a comma-separated list.
|
||||
* @return string the value of the array key or null if no match
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::enum
|
||||
|
@ -228,7 +228,7 @@ class Set {
|
|||
* @param array $data Source array from which to extract the data
|
||||
* @param string $format Format string into which values will be inserted, see sprintf()
|
||||
* @param array $keys An array containing one or more Set::extract()-style key paths
|
||||
* @return array An array of strings extracted from $keys and formatted with $format
|
||||
* @return array|null An array of strings extracted from $keys and formatted with $format, otherwise null.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::format
|
||||
*/
|
||||
public static function format($data, $format, $keys) {
|
||||
|
@ -236,7 +236,7 @@ class Set {
|
|||
$count = count($keys);
|
||||
|
||||
if (!$count) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
@ -308,7 +308,7 @@ class Set {
|
|||
* @param string $path An absolute XPath 2.0 path
|
||||
* @param array $data An array of data to extract from
|
||||
* @param array $options Currently only supports 'flatten' which can be disabled for higher XPath-ness
|
||||
* @return array An array of matched items
|
||||
* @return mixed An array of matched items or the content of a single selected item or null in any of these cases: $path or $data are null, no items found.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::extract
|
||||
*/
|
||||
public static function extract($path, $data = null, $options = array()) {
|
||||
|
@ -327,7 +327,7 @@ class Set {
|
|||
return $data;
|
||||
}
|
||||
$contexts = $data;
|
||||
$options = array_merge(array('flatten' => true), $options);
|
||||
$options += array('flatten' => true);
|
||||
if (!isset($contexts[0])) {
|
||||
$current = current($data);
|
||||
if ((is_array($current) && count($data) < 1) || !is_array($current) || !Set::numeric(array_keys($data))) {
|
||||
|
@ -349,7 +349,7 @@ class Set {
|
|||
$context = array('trace' => array(null), 'item' => $context, 'key' => $key);
|
||||
}
|
||||
if ($token === '..') {
|
||||
if (count($context['trace']) == 1) {
|
||||
if (count($context['trace']) === 1) {
|
||||
$context['trace'][] = $context['key'];
|
||||
}
|
||||
$parent = implode('/', $context['trace']) . '/.';
|
||||
|
@ -373,7 +373,7 @@ class Set {
|
|||
);
|
||||
} elseif (is_array($context['item'])
|
||||
&& array_key_exists($token, $context['item'])
|
||||
&& !(strval($key) === strval($token) && count($tokens) == 1 && $tokens[0] === '.')) {
|
||||
&& !(strval($key) === strval($token) && count($tokens) === 1 && $tokens[0] === '.')) {
|
||||
$items = $context['item'][$token];
|
||||
if (!is_array($items)) {
|
||||
$items = array($items);
|
||||
|
@ -456,10 +456,10 @@ class Set {
|
|||
* This function can be used to see if a single item or a given xpath match certain conditions.
|
||||
*
|
||||
* @param string|array $conditions An array of condition strings or an XPath expression
|
||||
* @param array $data An array of data to execute the match on
|
||||
* @param integer $i Optional: The 'nth'-number of the item being matched.
|
||||
* @param integer $length
|
||||
* @return boolean
|
||||
* @param array $data An array of data to execute the match on
|
||||
* @param int $i Optional: The 'nth'-number of the item being matched.
|
||||
* @param int $length Length.
|
||||
* @return bool
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::matches
|
||||
*/
|
||||
public static function matches($conditions, $data = array(), $i = null, $length = null) {
|
||||
|
@ -467,7 +467,7 @@ class Set {
|
|||
return true;
|
||||
}
|
||||
if (is_string($conditions)) {
|
||||
return !!Set::extract($conditions, $data);
|
||||
return (bool)Set::extract($conditions, $data);
|
||||
}
|
||||
foreach ($conditions as $condition) {
|
||||
if ($condition === ':last') {
|
||||
|
@ -533,7 +533,7 @@ class Set {
|
|||
*
|
||||
* @param array $data Array from where to extract
|
||||
* @param string|array $path As an array, or as a dot-separated string.
|
||||
* @return array|null Extracted data or null when $data or $path are empty.
|
||||
* @return mixed An array of matched items or the content of a single selected item or null in any of these cases: $path or $data are null, no items found.
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::classicExtract
|
||||
*/
|
||||
public static function classicExtract($data, $path = null) {
|
||||
|
@ -549,7 +549,7 @@ class Set {
|
|||
return null;
|
||||
}
|
||||
if (is_string($path) && strpos($path, '{') !== false) {
|
||||
$path = String::tokenize($path, '.', '{', '}');
|
||||
$path = CakeText::tokenize($path, '.', '{', '}');
|
||||
} elseif (is_string($path)) {
|
||||
$path = explode('.', $path);
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ class Set {
|
|||
}
|
||||
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && intval($key) > 0 || $key === '0') {
|
||||
if (is_numeric($key) && (int)$key > 0 || $key === '0') {
|
||||
if (isset($data[$key])) {
|
||||
$data = $data[$key];
|
||||
} else {
|
||||
|
@ -590,7 +590,7 @@ class Set {
|
|||
}
|
||||
}
|
||||
return $tmp;
|
||||
} elseif (false !== strpos($key, '{') && false !== strpos($key, '}')) {
|
||||
} elseif (strpos($key, '{') !== false && strpos($key, '}') !== false) {
|
||||
$pattern = substr($key, 1, -1);
|
||||
|
||||
foreach ($data as $j => $val) {
|
||||
|
@ -645,7 +645,7 @@ class Set {
|
|||
*
|
||||
* @param string|array $data Data to check on
|
||||
* @param string|array $path A dot-separated string.
|
||||
* @return boolean true if path is found, false otherwise
|
||||
* @return bool true if path is found, false otherwise
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::check
|
||||
*/
|
||||
public static function check($data, $path = null) {
|
||||
|
@ -657,8 +657,8 @@ class Set {
|
|||
}
|
||||
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && intval($key) > 0 || $key === '0') {
|
||||
$key = intval($key);
|
||||
if (is_numeric($key) && (int)$key > 0 || $key === '0') {
|
||||
$key = (int)$key;
|
||||
}
|
||||
if ($i === count($path) - 1) {
|
||||
return (is_array($data) && array_key_exists($key, $data));
|
||||
|
@ -705,7 +705,7 @@ class Set {
|
|||
*
|
||||
* @param array $val1 First value
|
||||
* @param array $val2 Second value
|
||||
* @return boolean true if $val1 contains $val2, false otherwise
|
||||
* @return bool true if $val1 contains $val2, false otherwise
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::contains
|
||||
*/
|
||||
public static function contains($val1, $val2 = null) {
|
||||
|
@ -730,12 +730,12 @@ class Set {
|
|||
* only consider the dimension of the first element in the array.
|
||||
*
|
||||
* @param array $array Array to count dimensions on
|
||||
* @param boolean $all Set to true to count the dimension considering all elements in array
|
||||
* @param integer $count Start the dimension count at this number
|
||||
* @return integer The number of dimensions in $array
|
||||
* @param bool $all Set to true to count the dimension considering all elements in array
|
||||
* @param int $count Start the dimension count at this number
|
||||
* @return int The number of dimensions in $array
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::countDim
|
||||
*/
|
||||
public static function countDim($array = null, $all = false, $count = 0) {
|
||||
public static function countDim($array, $all = false, $count = 0) {
|
||||
if ($all) {
|
||||
$depth = array($count);
|
||||
if (is_array($array) && reset($array) !== false) {
|
||||
|
@ -758,9 +758,9 @@ class Set {
|
|||
* Normalizes a string or array list.
|
||||
*
|
||||
* @param mixed $list List to normalize
|
||||
* @param boolean $assoc If true, $list will be converted to an associative array
|
||||
* @param bool $assoc If true, $list will be converted to an associative array
|
||||
* @param string $sep If $list is a string, it will be split into an array with $sep
|
||||
* @param boolean $trim If true, separated strings will be trimmed
|
||||
* @param bool $trim If true, separated strings will be trimmed
|
||||
* @return array
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::normalize
|
||||
*/
|
||||
|
@ -827,7 +827,7 @@ class Set {
|
|||
}
|
||||
}
|
||||
|
||||
if ($groupPath != null) {
|
||||
if ($groupPath) {
|
||||
$group = Set::extract($data, $groupPath);
|
||||
if (!empty($group)) {
|
||||
$c = count($keys);
|
||||
|
@ -851,6 +851,7 @@ class Set {
|
|||
|
||||
/**
|
||||
* Converts an object into an array.
|
||||
*
|
||||
* @param object $object Object to reverse
|
||||
* @return array Array representation of given object
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::reverse
|
||||
|
@ -909,7 +910,7 @@ class Set {
|
|||
}
|
||||
|
||||
/**
|
||||
* Expand/unflattens an string to an array
|
||||
* Expand/unflattens a string to an array
|
||||
*
|
||||
* For example, unflattens an array that was collapsed with `Set::flatten()`
|
||||
* into a multi-dimensional array. So, `array('0.Foo.Bar' => 'Far')` becomes
|
||||
|
@ -926,15 +927,15 @@ class Set {
|
|||
/**
|
||||
* Flattens an array for sorting
|
||||
*
|
||||
* @param array $results
|
||||
* @param string $key
|
||||
* @param array $results Array to flatten.
|
||||
* @param string $key Key.
|
||||
* @return array
|
||||
*/
|
||||
protected static function _flatten($results, $key = null) {
|
||||
$stack = array();
|
||||
foreach ($results as $k => $r) {
|
||||
$id = $k;
|
||||
if (!is_null($key)) {
|
||||
if ($key !== null) {
|
||||
$id = $key;
|
||||
}
|
||||
if (is_array($r) && !empty($r)) {
|
||||
|
@ -1010,7 +1011,7 @@ class Set {
|
|||
*/
|
||||
public static function apply($path, $data, $callback, $options = array()) {
|
||||
$defaults = array('type' => 'pass');
|
||||
$options = array_merge($defaults, $options);
|
||||
$options += $defaults;
|
||||
$extracted = Set::extract($path, $data);
|
||||
|
||||
if ($options['type'] === 'map') {
|
||||
|
@ -1026,7 +1027,7 @@ class Set {
|
|||
/**
|
||||
* Takes in a flat array and returns a nested array
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param mixed $data Data
|
||||
* @param array $options Options are:
|
||||
* children - the key name to use in the resultset for children
|
||||
* idPath - the path to a key that identifies each entry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue