Skip to content

Commit

Permalink
Merge branch '1.3' into 1.3-bake
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 25, 2009
2 parents 737740d + cfb4602 commit e9afb63
Show file tree
Hide file tree
Showing 471 changed files with 33,848 additions and 12,466 deletions.
2 changes: 1 addition & 1 deletion app/webroot/test.php
Expand Up @@ -86,7 +86,7 @@
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}

$corePath = Configure::corePaths('cake');
$corePath = App::core('cake');
if (isset($corePath[0])) {
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
} else {
Expand Down
64 changes: 51 additions & 13 deletions cake/basics.php
@@ -1,5 +1,6 @@
<?php
/* SVN FILE: $Id$ */

/**
* Basic Cake functionality.
*
Expand All @@ -24,6 +25,7 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

/**
* Basic defines for timing functions.
*/
Expand All @@ -34,6 +36,7 @@
define('WEEK', 7 * DAY);
define('MONTH', 30 * DAY);
define('YEAR', 365 * DAY);

/**
* Patch for PHP < 5.0
*/
Expand All @@ -46,6 +49,7 @@ function clone($object)
}');
}
}

/**
* Loads configuration files. Receives a set of configuration files
* to load.
Expand Down Expand Up @@ -75,6 +79,7 @@ function config() {
}
return true;
}

/**
* Loads component/components from LIBS. Takes optional number of parameters.
*
Expand All @@ -91,6 +96,7 @@ function uses() {
require_once(LIBS . strtolower($file) . '.php');
}
}

/**
* Prints out debug information about given variable.
*
Expand Down Expand Up @@ -118,6 +124,7 @@ function debug($var = false, $showHtml = false, $showFrom = true) {
}
}
if (!function_exists('getMicrotime')) {

/**
* Returns microtime for execution time checking
*
Expand All @@ -129,6 +136,7 @@ function getMicrotime() {
}
}
if (!function_exists('sortByKey')) {

/**
* Sorts given $array by key $sortby.
*
Expand Down Expand Up @@ -160,6 +168,7 @@ function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
}
}
if (!function_exists('array_combine')) {

/**
* Combines given identical arrays by using the first array's values as keys,
* and the second one's values as values. (Implemented for backwards compatibility with PHP4)
Expand Down Expand Up @@ -188,6 +197,7 @@ function array_combine($a1, $a2) {
return $output;
}
}

/**
* Convenience method for htmlspecialchars.
*
Expand All @@ -208,6 +218,7 @@ function h($text, $charset = null) {
}
return htmlspecialchars($text, ENT_QUOTES, $charset);
}

/**
* Returns an array of all the given parameters.
*
Expand All @@ -228,6 +239,7 @@ function a() {
$args = func_get_args();
return $args;
}

/**
* Constructs associative array from pairs of arguments.
*
Expand Down Expand Up @@ -257,6 +269,7 @@ function aa() {
}
return $a;
}

/**
* Convenience method for echo().
*
Expand All @@ -266,6 +279,7 @@ function aa() {
function e($text) {
echo $text;
}

/**
* Convenience method for strtolower().
*
Expand All @@ -276,6 +290,7 @@ function e($text) {
function low($str) {
return strtolower($str);
}

/**
* Convenience method for strtoupper().
*
Expand All @@ -286,6 +301,7 @@ function low($str) {
function up($str) {
return strtoupper($str);
}

/**
* Convenience method for str_replace().
*
Expand All @@ -298,6 +314,7 @@ function up($str) {
function r($search, $replace, $subject) {
return str_replace($search, $replace, $subject);
}

/**
* Print_r convenience function, which prints out <PRE> tags around
* the output of given array. Similar to debug().
Expand All @@ -314,6 +331,7 @@ function pr($var) {
echo '</pre>';
}
}

/**
* Display parameters.
*
Expand All @@ -329,6 +347,7 @@ function params($p) {
}
return $p;
}

/**
* Merge a group of arrays
*
Expand All @@ -350,6 +369,7 @@ function am() {
}
return $r;
}

/**
* Gets an environment variable from available sources, and provides emulation
* for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on
Expand All @@ -362,8 +382,8 @@ function am() {
*/
function env($key) {
if ($key == 'HTTPS') {
if (isset($_SERVER) && !empty($_SERVER)) {
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on');
if (isset($_SERVER['HTTPS'])) {
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
}
return (strpos(env('SCRIPT_URI'), 'https://') === 0);
}
Expand Down Expand Up @@ -426,6 +446,7 @@ function env($key) {
return null;
}
if (!function_exists('file_put_contents')) {

/**
* Writes data into file.
*
Expand Down Expand Up @@ -453,6 +474,7 @@ function file_put_contents($fileName, $data) {
return false;
}
}

/**
* Reads/writes temporary data to cache files or session.
*
Expand Down Expand Up @@ -504,6 +526,7 @@ function cache($path, $data = null, $expires = '+1 day', $target = 'cache') {
}
return $data;
}

/**
* Used to delete files in the cache directories, or clear contents of cache directories
*
Expand Down Expand Up @@ -566,6 +589,7 @@ function clearCache($params = null, $type = 'views', $ext = '.php') {
}
return false;
}

/**
* Recursively strips slashes from all values in an array
*
Expand All @@ -583,6 +607,7 @@ function stripslashes_deep($values) {
}
return $values;
}

/**
* Returns a translated string if one is found; Otherwise, the submitted message.
*
Expand All @@ -605,6 +630,7 @@ function __($singular, $return = false) {
return I18n::translate($singular);
}
}

/**
* Returns correct plural form of message identified by $singular and $plural for count $count.
* Some languages have more than one form for plural messages dependent on the count.
Expand All @@ -624,11 +650,12 @@ function __n($singular, $plural, $count, $return = false) {
}

if ($return === false) {
echo I18n::translate($singular, $plural, null, 5, $count);
echo I18n::translate($singular, $plural, null, 6, $count);
} else {
return I18n::translate($singular, $plural, null, 5, $count);
return I18n::translate($singular, $plural, null, 6, $count);
}
}

/**
* Allows you to override the current domain for a single message lookup.
*
Expand All @@ -651,6 +678,7 @@ function __d($domain, $msg, $return = false) {
return I18n::translate($msg, null, $domain);
}
}

/**
* Allows you to override the current domain for a single plural message lookup.
* Returns correct plural form of message identified by $singular and $plural for count $count
Expand All @@ -672,11 +700,12 @@ function __dn($domain, $singular, $plural, $count, $return = false) {
}

if ($return === false) {
echo I18n::translate($singular, $plural, $domain, 5, $count);
echo I18n::translate($singular, $plural, $domain, 6, $count);
} else {
return I18n::translate($singular, $plural, $domain, 5, $count);
return I18n::translate($singular, $plural, $domain, 6, $count);
}
}

/**
* Allows you to override the current domain for a single message lookup.
* It also allows you to specify a category.
Expand Down Expand Up @@ -713,6 +742,7 @@ function __dc($domain, $msg, $category, $return = false) {
return I18n::translate($msg, null, $domain, $category);
}
}

/**
* Allows you to override the current domain for a single plural message lookup.
* It also allows you to specify a category.
Expand All @@ -723,13 +753,13 @@ function __dc($domain, $msg, $category, $return = false) {
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
*
* Note that the category must be specified with a numeric value, instead of the constant name. The values are:
* LC_CTYPE 0
* LC_NUMERIC 1
* LC_TIME 2
* LC_COLLATE 3
* LC_MONETARY 4
* LC_MESSAGES 5
* LC_ALL 6
* LC_ALL 0
* LC_COLLATE 1
* LC_CTYPE 2
* LC_MONETARY 3
* LC_NUMERIC 4
* LC_TIME 5
* LC_MESSAGES 6
*
* @param string $domain Domain
* @param string $singular Singular string to translate
Expand All @@ -753,6 +783,7 @@ function __dcn($domain, $singular, $plural, $count, $category, $return = false)
return I18n::translate($singular, $plural, $domain, $category, $count);
}
}

/**
* The category argument allows a specific category of the locale settings to be used for fetching a message.
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
Expand Down Expand Up @@ -785,6 +816,7 @@ function __c($msg, $category, $return = false) {
return I18n::translate($msg, null, null, $category);
}
}

/**
* Computes the difference of arrays using keys for comparison.
*
Expand Down Expand Up @@ -819,6 +851,7 @@ function array_diff_key() {
return $valuesDiff;
}
}

/**
* Computes the intersection of arrays using keys for comparison
*
Expand All @@ -837,6 +870,7 @@ function array_intersect_key($arr1, $arr2) {
return $res;
}
}

/**
* Shortcut to Log::write.
*
Expand All @@ -850,6 +884,7 @@ function LogError($message) {
$good = ' ';
CakeLog::write('error', str_replace($bad, $good, $message));
}

/**
* Searches include path for files.
*
Expand All @@ -870,6 +905,7 @@ function fileExistsInPath($file) {
}
return false;
}

/**
* Convert forward slashes to underscores and removes first and last underscores in a string
*
Expand All @@ -883,6 +919,7 @@ function convertSlash($string) {
$string = str_replace('/', '_', $string);
return $string;
}

/**
* Implements http_build_query for PHP4.
*
Expand Down Expand Up @@ -922,6 +959,7 @@ function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null
return implode($argSep, $out);
}
}

/**
* Wraps ternary operations. If $condition is a non-empty value, $val1 is returned, otherwise $val2.
* Don't use for isset() conditions, or wrap your variable with @ operator:
Expand Down

0 comments on commit e9afb63

Please sign in to comment.