2006-10-18 17:51:29 +00:00
< ? php
2005-08-21 06:49:02 +00:00
/* SVN FILE: $Id$ */
2005-06-23 08:32:04 +00:00
/**
2005-08-25 16:40:50 +00:00
* Basic Cake functionality .
2005-12-27 03:33:44 +00:00
*
2005-08-25 16:40:50 +00:00
* Core functions for including other source files , loading models and so forth .
2005-08-21 06:49:02 +00:00
*
* PHP versions 4 and 5
*
2007-02-02 10:39:45 +00:00
* CakePHP ( tm ) : Rapid Development Framework < http :// www . cakephp . org />
2008-01-01 22:18:17 +00:00
* Copyright 2005 - 2008 , Cake Software Foundation , Inc .
2006-05-26 05:29:17 +00:00
* 1785 E . Sahara Avenue , Suite 490 - 204
* Las Vegas , Nevada 89104
2005-08-21 06:49:02 +00:00
*
2005-12-23 21:57:26 +00:00
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice .
2005-08-21 06:49:02 +00:00
*
2005-12-27 03:33:44 +00:00
* @ filesource
2008-01-01 22:18:17 +00:00
* @ copyright Copyright 2005 - 2008 , Cake Software Foundation , Inc .
2007-02-02 10:39:45 +00:00
* @ link http :// www . cakefoundation . org / projects / info / cakephp CakePHP ( tm ) Project
2006-05-26 05:29:17 +00:00
* @ package cake
* @ subpackage cake . cake
2007-02-02 10:39:45 +00:00
* @ since CakePHP ( tm ) v 0.2 . 9
2006-05-26 05:29:17 +00:00
* @ version $Revision $
* @ modifiedby $LastChangedBy $
* @ lastmodified $Date $
* @ license http :// www . opensource . org / licenses / mit - license . php The MIT License
2005-06-23 08:32:04 +00:00
*/
/**
2005-09-17 02:22:07 +00:00
* Basic defines for timing functions .
2005-06-23 08:32:04 +00:00
*/
2006-05-26 05:29:17 +00:00
define ( 'SECOND' , 1 );
define ( 'MINUTE' , 60 * SECOND );
define ( 'HOUR' , 60 * MINUTE );
define ( 'DAY' , 24 * HOUR );
define ( 'WEEK' , 7 * DAY );
define ( 'MONTH' , 30 * DAY );
define ( 'YEAR' , 365 * DAY );
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
/**
2006-10-19 00:37:29 +00:00
* Patch for PHP < 5.0
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
*/
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
if ( ! function_exists ( 'clone' )) {
2006-10-19 00:37:29 +00:00
if ( version_compare ( phpversion (), '5.0' ) < 0 ) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
eval ( '
2006-10-19 00:37:29 +00:00
function clone ( $object )
{
return $object ;
} ' );
2006-05-26 05:29:17 +00:00
}
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
}
2007-06-19 13:20:34 +00:00
/**
* Get CakePHP basic paths as an indexed array .
* Resulting array will contain array of paths
* indexed by : Models , Behaviors , Controllers ,
* Components , and Helpers .
*
* @ return array Array of paths indexed by type
2008-05-19 07:09:53 +00:00
* @ deprecated See Configure :: corePaths
2007-06-19 13:20:34 +00:00
*/
2007-06-20 07:51:52 +00:00
function paths () {
2007-01-13 21:08:52 +00:00
$directories = Configure :: getInstance ();
$paths = array ();
2007-06-20 06:15:35 +00:00
foreach ( $directories -> modelPaths as $path ) {
2007-01-13 21:08:52 +00:00
$paths [ 'Models' ][] = $path ;
}
2007-06-20 06:15:35 +00:00
foreach ( $directories -> behaviorPaths as $path ) {
2007-01-13 21:08:52 +00:00
$paths [ 'Behaviors' ][] = $path ;
}
2007-06-20 06:15:35 +00:00
foreach ( $directories -> controllerPaths as $path ) {
2007-01-13 21:08:52 +00:00
$paths [ 'Controllers' ][] = $path ;
}
2007-06-20 06:15:35 +00:00
foreach ( $directories -> componentPaths as $path ) {
2007-01-13 21:08:52 +00:00
$paths [ 'Components' ][] = $path ;
}
2007-06-20 06:15:35 +00:00
foreach ( $directories -> helperPaths as $path ) {
2007-01-13 21:08:52 +00:00
$paths [ 'Helpers' ][] = $path ;
}
2007-06-20 07:51:52 +00:00
if ( ! class_exists ( 'Folder' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'Folder' );
2007-01-13 21:08:52 +00:00
}
$folder =& new Folder ( APP . 'plugins' . DS );
$plugins = $folder -> ls ();
$classPaths = array ( 'models' , 'models' . DS . 'behaviors' , 'controllers' , 'controllers' . DS . 'components' , 'views' . DS . 'helpers' );
2007-06-20 07:51:52 +00:00
foreach ( $plugins [ 0 ] as $plugin ) {
foreach ( $classPaths as $path ) {
if ( strpos ( $path , DS ) !== false ) {
2007-01-13 21:08:52 +00:00
$key = explode ( DS , $path );
$key = $key [ 1 ];
} else {
$key = $path ;
}
$folder -> path = APP . 'plugins' . DS . $plugin . DS . $path ;
$paths [ Inflector :: camelize ( $plugin )][ Inflector :: camelize ( $key )][] = $folder -> path ;
}
}
return $paths ;
}
2005-06-23 08:32:04 +00:00
/**
2007-06-19 13:20:34 +00:00
* Loads configuration files . Receives a set of configuration files
* to load .
* Example :
* < code >
* config ( 'config1' , 'config2' );
* </ code >
2006-01-12 02:10:47 +00:00
*
2007-10-22 16:09:35 +00:00
* @ return boolean Success
2006-01-12 02:10:47 +00:00
*/
2006-05-26 05:29:17 +00:00
function config () {
$args = func_get_args ();
2007-06-20 06:15:35 +00:00
foreach ( $args as $arg ) {
2006-05-26 05:29:17 +00:00
if (( 'database' == $arg ) && file_exists ( CONFIGS . $arg . '.php' )) {
include_once ( CONFIGS . $arg . '.php' );
} elseif ( file_exists ( CONFIGS . $arg . '.php' )) {
include_once ( CONFIGS . $arg . '.php' );
if ( count ( $args ) == 1 ) {
return true ;
}
} else {
if ( count ( $args ) == 1 ) {
return false ;
}
}
}
return true ;
}
2005-06-23 08:32:04 +00:00
/**
2007-10-22 06:17:16 +00:00
* Loads component / components from LIBS . Takes optional number of parameters .
2005-06-23 08:32:04 +00:00
*
* Example :
* < code >
* uses ( 'flay' , 'time' );
* </ code >
*
2007-10-22 06:17:16 +00:00
* @ param string $name Filename without the . php part
2005-06-23 08:32:04 +00:00
*/
2006-05-26 05:29:17 +00:00
function uses () {
2006-09-03 06:46:43 +00:00
$args = func_get_args ();
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
foreach ( $args as $file ) {
require_once ( LIBS . strtolower ( $file ) . '.php' );
2006-05-26 05:29:17 +00:00
}
}
2005-08-25 16:40:50 +00:00
/**
2008-03-01 05:23:32 +00:00
* @ deprecated
2005-08-25 16:40:50 +00:00
*/
2007-10-21 17:54:15 +00:00
function vendor () {
2008-03-01 05:23:32 +00:00
trigger_error ( '(vendor) Deprecated, see App::import(\'Vendor\', \'...\');' , E_USER_WARNING );
2006-09-03 06:46:43 +00:00
$args = func_get_args ();
2006-08-08 21:17:20 +00:00
$c = func_num_args ();
2007-05-26 09:50:17 +00:00
2006-08-08 21:17:20 +00:00
for ( $i = 0 ; $i < $c ; $i ++ ) {
$arg = $args [ $i ];
2007-05-26 09:50:17 +00:00
2007-06-20 07:51:52 +00:00
if ( strpos ( $arg , '.' ) !== false ) {
2007-05-27 04:10:33 +00:00
$file = explode ( '.' , $arg );
$plugin = Inflector :: underscore ( $file [ 0 ]);
unset ( $file [ 0 ]);
$file = implode ( '.' , $file );
if ( file_exists ( APP . 'plugins' . DS . $plugin . DS . 'vendors' . DS . $file . '.php' )) {
require_once ( APP . 'plugins' . DS . $plugin . DS . 'vendors' . DS . $file . '.php' );
continue ;
}
2007-05-26 09:50:17 +00:00
}
2006-05-26 05:29:17 +00:00
if ( file_exists ( APP . 'vendors' . DS . $arg . '.php' )) {
require_once ( APP . 'vendors' . DS . $arg . '.php' );
2007-02-04 02:08:17 +00:00
} elseif ( file_exists ( VENDORS . $arg . '.php' )) {
2006-05-26 05:29:17 +00:00
require_once ( VENDORS . $arg . '.php' );
2007-02-04 02:08:17 +00:00
} else {
return false ;
2006-05-26 05:29:17 +00:00
}
}
2007-02-04 02:08:17 +00:00
return true ;
2006-05-26 05:29:17 +00:00
}
2005-06-23 08:32:04 +00:00
/**
2006-01-12 02:10:47 +00:00
* Prints out debug information about given variable .
2005-09-17 02:22:07 +00:00
*
2007-08-16 05:44:06 +00:00
* Only runs if debug level is non - zero .
2005-06-23 08:32:04 +00:00
*
2007-10-22 16:54:36 +00:00
* @ param boolean $var Variable to show debug information for .
* @ param boolean $showHtml If set to true , the method prints the debug data in a screen - friendly way .
* @ param boolean $showFrom If set to true , the method prints from where the function was called .
2005-06-23 08:32:04 +00:00
*/
2007-09-16 01:36:30 +00:00
function debug ( $var = false , $showHtml = false , $showFrom = true ) {
2006-12-05 09:49:59 +00:00
if ( Configure :: read () > 0 ) {
2007-09-16 01:36:30 +00:00
if ( $showFrom ) {
$calledFrom = debug_backtrace ();
print " <strong> " . substr ( r ( ROOT , " " , $calledFrom [ 0 ][ 'file' ]), 1 ) . " </strong> (line <strong> " . $calledFrom [ 0 ][ 'line' ] . " </strong>) " ;
}
2007-10-21 17:54:15 +00:00
print " \n <pre class= \" cake-debug \" > \n " ;
2007-11-17 23:13:52 +00:00
$var = print_r ( $var , true );
2006-01-12 02:10:47 +00:00
2006-05-26 05:29:17 +00:00
if ( $showHtml ) {
$var = str_replace ( '<' , '<' , str_replace ( '>' , '>' , $var ));
}
print " { $var } \n </pre> \n " ;
}
}
2007-10-22 06:17:16 +00:00
if ( ! function_exists ( 'getMicrotime' )) {
2005-10-03 04:41:33 +00:00
/**
2006-05-26 05:29:17 +00:00
* Returns microtime for execution time checking
2005-10-03 04:41:33 +00:00
*
2007-06-19 13:20:34 +00:00
* @ return float Microtime
2005-10-03 04:41:33 +00:00
*/
2006-05-26 05:29:17 +00:00
function getMicrotime () {
2006-06-14 18:02:37 +00:00
list ( $usec , $sec ) = explode ( " " , microtime ());
2006-05-26 05:29:17 +00:00
return (( float ) $usec + ( float ) $sec );
}
}
2007-10-22 06:17:16 +00:00
if ( ! function_exists ( 'sortByKey' )) {
2005-10-03 04:41:33 +00:00
/**
* Sorts given $array by key $sortby .
*
2007-06-19 13:20:34 +00:00
* @ param array $array Array to sort
* @ param string $sortby Sort by this key
* @ param string $order Sort order asc / desc ( ascending or descending ) .
2007-10-22 16:11:12 +00:00
* @ param integer $type Type of sorting to perform
2007-06-19 13:20:34 +00:00
* @ return mixed Sorted array
2005-10-03 04:41:33 +00:00
*/
2006-05-26 05:29:17 +00:00
function sortByKey ( & $array , $sortby , $order = 'asc' , $type = SORT_NUMERIC ) {
if ( ! is_array ( $array )) {
return null ;
}
2007-06-20 06:15:35 +00:00
foreach ( $array as $key => $val ) {
2006-05-26 05:29:17 +00:00
$sa [ $key ] = $val [ $sortby ];
}
if ( $order == 'asc' ) {
asort ( $sa , $type );
} else {
arsort ( $sa , $type );
}
2007-06-20 06:15:35 +00:00
foreach ( $sa as $key => $val ) {
2006-05-26 05:29:17 +00:00
$out [] = $array [ $key ];
}
return $out ;
}
}
2007-10-22 06:17:16 +00:00
if ( ! function_exists ( 'array_combine' )) {
2005-10-03 04:41:33 +00:00
/**
* Combines given identical arrays by using the first array ' s values as keys ,
2006-05-26 05:29:17 +00:00
* and the second one ' s values as values . ( Implemented for back - compatibility with PHP4 )
2005-10-03 04:41:33 +00:00
*
2007-10-22 06:17:16 +00:00
* @ param array $a1 Array to use for keys
* @ param array $a2 Array to use for values
2005-10-03 04:41:33 +00:00
* @ return mixed Outputs either combined array or false .
*/
2006-05-26 05:29:17 +00:00
function array_combine ( $a1 , $a2 ) {
$a1 = array_values ( $a1 );
$a2 = array_values ( $a2 );
$c1 = count ( $a1 );
$c2 = count ( $a2 );
if ( $c1 != $c2 ) {
return false ;
}
if ( $c1 <= 0 ) {
return false ;
}
$output = array ();
2007-06-20 06:15:35 +00:00
for ( $i = 0 ; $i < $c1 ; $i ++ ) {
2006-05-26 05:29:17 +00:00
$output [ $a1 [ $i ]] = $a2 [ $i ];
}
return $output ;
}
}
2005-10-09 01:56:21 +00:00
/**
2005-10-18 22:27:39 +00:00
* Convenience method for htmlspecialchars .
2005-10-09 01:56:21 +00:00
*
2007-06-19 13:20:34 +00:00
* @ param string $text Text to wrap through htmlspecialchars
2008-03-09 21:41:13 +00:00
* @ param string $charset Character set to use when escaping . Defaults to config value in 'App.encoding' or 'UTF-8'
2007-06-19 13:20:34 +00:00
* @ return string Wrapped text
2005-10-09 01:56:21 +00:00
*/
2008-03-09 21:41:13 +00:00
function h ( $text , $charset = null ) {
2006-06-15 14:44:16 +00:00
if ( is_array ( $text )) {
2006-12-01 17:10:53 +00:00
return array_map ( 'h' , $text );
2006-06-15 14:44:16 +00:00
}
2008-03-09 21:41:13 +00:00
if ( empty ( $charset )) {
$charset = Configure :: read ( 'App.encoding' );
}
if ( empty ( $charset )) {
$charset = 'UTF-8' ;
}
return htmlspecialchars ( $text , ENT_QUOTES , $charset );
2006-05-26 05:29:17 +00:00
}
2005-10-09 01:56:21 +00:00
/**
2006-01-12 02:10:47 +00:00
* Returns an array of all the given parameters .
*
* Example :
* < code >
* a ( 'a' , 'b' )
* </ code >
*
* Would return :
* < code >
* array ( 'a' , 'b' )
* </ code >
2005-10-09 01:56:21 +00:00
*
2007-06-19 13:20:34 +00:00
* @ return array Array of given parameters
2005-10-09 01:56:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function a () {
$args = func_get_args ();
return $args ;
}
2005-10-09 01:56:21 +00:00
/**
2006-01-12 02:10:47 +00:00
* Constructs associative array from pairs of arguments .
*
* Example :
* < code >
* aa ( 'a' , 'b' )
* </ code >
*
* Would return :
* < code >
* array ( 'a' => 'b' )
* </ code >
2005-10-09 01:56:21 +00:00
*
2007-06-19 13:20:34 +00:00
* @ return array Associative array
2005-10-09 01:56:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function aa () {
$args = func_get_args ();
2007-06-20 06:15:35 +00:00
for ( $l = 0 , $c = count ( $args ); $l < $c ; $l ++ ) {
2006-05-26 05:29:17 +00:00
if ( $l + 1 < count ( $args )) {
$a [ $args [ $l ]] = $args [ $l + 1 ];
} else {
$a [ $args [ $l ]] = null ;
}
$l ++ ;
}
return $a ;
}
2005-10-09 01:56:21 +00:00
/**
2005-10-18 22:27:39 +00:00
* Convenience method for echo () .
2005-10-09 01:56:21 +00:00
*
2005-10-18 22:27:39 +00:00
* @ param string $text String to echo
2005-10-09 01:56:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function e ( $text ) {
echo $text ;
}
2006-01-12 02:10:47 +00:00
/**
* Convenience method for strtolower () .
*
* @ param string $str String to lowercase
2007-06-19 13:20:34 +00:00
* @ return string Lowercased string
2006-01-12 02:10:47 +00:00
*/
2006-05-26 05:29:17 +00:00
function low ( $str ) {
return strtolower ( $str );
}
2006-01-12 02:10:47 +00:00
/**
* Convenience method for strtoupper () .
*
* @ param string $str String to uppercase
2007-06-19 13:20:34 +00:00
* @ return string Uppercased string
2006-01-12 02:10:47 +00:00
*/
2006-05-26 05:29:17 +00:00
function up ( $str ) {
return strtoupper ( $str );
}
2006-01-12 02:10:47 +00:00
/**
* Convenience method for str_replace () .
*
* @ param string $search String to be replaced
* @ param string $replace String to insert
* @ param string $subject String to search
2007-06-19 13:20:34 +00:00
* @ return string Replaced string
2006-01-12 02:10:47 +00:00
*/
2006-05-26 05:29:17 +00:00
function r ( $search , $replace , $subject ) {
return str_replace ( $search , $replace , $subject );
}
2005-10-09 01:56:21 +00:00
/**
2005-12-27 03:33:44 +00:00
* Print_r convenience function , which prints out < PRE > tags around
2005-10-18 22:27:39 +00:00
* the output of given array . Similar to debug () .
2005-12-27 03:33:44 +00:00
*
2006-05-26 05:29:17 +00:00
* @ see debug ()
2007-09-16 01:36:30 +00:00
* @ param array $var Variable to print out
2007-10-22 16:54:36 +00:00
* @ param boolean $showFrom If set to true , the method prints from where the function was called
2005-10-09 01:56:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function pr ( $var ) {
2006-12-05 09:49:59 +00:00
if ( Configure :: read () > 0 ) {
2006-05-26 05:29:17 +00:00
echo " <pre> " ;
print_r ( $var );
echo " </pre> " ;
}
}
2005-10-09 01:56:21 +00:00
/**
2005-10-18 22:27:39 +00:00
* Display parameter
2005-10-09 01:56:21 +00:00
*
2007-10-22 06:17:16 +00:00
* @ param mixed $p Parameter as string or array
2005-10-18 22:27:39 +00:00
* @ return string
2005-10-09 01:56:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function params ( $p ) {
if ( ! is_array ( $p ) || count ( $p ) == 0 ) {
return null ;
} else {
if ( is_array ( $p [ 0 ]) && count ( $p ) == 1 ) {
return $p [ 0 ];
} else {
return $p ;
}
}
}
2006-03-12 00:11:40 +00:00
/**
* Merge a group of arrays
*
* @ param array First array
* @ param array Second array
* @ param array Third array
* @ param array Etc ...
* @ return array All array parameters merged into one
*/
2006-05-26 05:29:17 +00:00
function am () {
$r = array ();
2007-06-20 06:15:35 +00:00
foreach ( func_get_args () as $a ) {
2006-05-26 05:29:17 +00:00
if ( ! is_array ( $a )) {
$a = array ( $a );
}
$r = array_merge ( $r , $a );
}
return $r ;
}
2005-10-09 01:56:21 +00:00
/**
2007-08-05 02:03:18 +00:00
* see Dispatcher :: uri ();
2005-10-09 01:56:21 +00:00
*
2007-08-05 02:03:18 +00:00
* @ deprecated
2005-10-09 01:56:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function setUri () {
2007-08-05 02:03:18 +00:00
return null ;
2007-07-25 04:38:28 +00:00
}
/**
2007-08-05 02:03:18 +00:00
* see Dispatcher :: getUrl ();
2007-07-25 04:38:28 +00:00
*
2007-08-05 02:03:18 +00:00
* @ deprecated
2007-07-25 04:38:28 +00:00
*/
2007-08-05 02:03:18 +00:00
function setUrl () {
return null ;
2006-05-26 05:29:17 +00:00
}
2006-01-12 02:10:47 +00:00
/**
2006-09-05 18:10:59 +00:00
* Gets an environment variable from available sources , and provides emulation
* for unsupported or inconsisten environment variables ( i . e . DOCUMENT_ROOT on
* IIS , or SCRIPT_NAME in CGI mode ) . Also exposes some additional custom
* environment information .
2006-01-12 02:10:47 +00:00
*
* @ param string $key Environment variable name .
* @ return string Environment variable setting .
*/
2006-05-26 05:29:17 +00:00
function env ( $key ) {
2006-09-20 19:13:57 +00:00
if ( $key == 'HTTPS' ) {
if ( isset ( $_SERVER ) && ! empty ( $_SERVER )) {
return ( isset ( $_SERVER [ 'HTTPS' ]) && $_SERVER [ 'HTTPS' ] == 'on' );
} else {
return ( strpos ( env ( 'SCRIPT_URI' ), 'https://' ) === 0 );
}
}
2006-09-05 18:10:59 +00:00
if ( $key == 'SCRIPT_NAME' ) {
2007-11-22 17:38:19 +00:00
if ( env ( 'CGI_MODE' ) && isset ( $_ENV [ 'SCRIPT_URL' ])) {
2006-09-05 18:10:59 +00:00
$key = 'SCRIPT_URL' ;
}
}
$val = null ;
2006-05-26 05:29:17 +00:00
if ( isset ( $_SERVER [ $key ])) {
2006-09-05 18:10:59 +00:00
$val = $_SERVER [ $key ];
2006-05-26 05:29:17 +00:00
} elseif ( isset ( $_ENV [ $key ])) {
2006-09-05 18:10:59 +00:00
$val = $_ENV [ $key ];
2006-05-26 05:29:17 +00:00
} elseif ( getenv ( $key ) !== false ) {
2006-09-05 18:10:59 +00:00
$val = getenv ( $key );
2006-05-26 05:29:17 +00:00
}
2006-09-05 18:10:59 +00:00
if ( $key == 'REMOTE_ADDR' && $val == env ( 'SERVER_ADDR' )) {
$addr = env ( 'HTTP_PC_REMOTE_ADDR' );
if ( $addr != null ) {
$val = $addr ;
2006-05-26 05:29:17 +00:00
}
}
2006-09-05 18:10:59 +00:00
if ( $val !== null ) {
return $val ;
}
switch ( $key ) {
2007-07-08 17:41:33 +00:00
case 'SCRIPT_FILENAME' :
if ( defined ( 'SERVER_IIS' ) && SERVER_IIS === true ){
return str_replace ( '\\\\' , '\\' , env ( 'PATH_TRANSLATED' ) );
}
break ;
2006-09-05 18:10:59 +00:00
case 'DOCUMENT_ROOT' :
$offset = 0 ;
if ( ! strpos ( env ( 'SCRIPT_NAME' ), '.php' )) {
$offset = 4 ;
}
return substr ( env ( 'SCRIPT_FILENAME' ), 0 , strlen ( env ( 'SCRIPT_FILENAME' )) - ( strlen ( env ( 'SCRIPT_NAME' )) + $offset ));
break ;
case 'PHP_SELF' :
return r ( env ( 'DOCUMENT_ROOT' ), '' , env ( 'SCRIPT_FILENAME' ));
break ;
case 'CGI_MODE' :
return ( substr ( php_sapi_name (), 0 , 3 ) == 'cgi' );
break ;
2007-03-16 14:59:40 +00:00
case 'HTTP_BASE' :
return preg_replace ( '/^([^.])*/i' , null , env ( 'HTTP_HOST' ));
break ;
2006-05-26 05:29:17 +00:00
}
return null ;
}
2007-10-22 06:17:16 +00:00
if ( ! function_exists ( 'file_put_contents' )) {
2006-02-18 23:42:21 +00:00
/**
* Writes data into file .
*
2006-05-26 05:29:17 +00:00
* If file exists , it will be overwritten . If data is an array , it will be join () ed with an empty string .
2006-02-18 23:42:21 +00:00
*
* @ param string $fileName File name .
2006-05-26 05:29:17 +00:00
* @ param mixed $data String or array .
2007-10-22 16:09:35 +00:00
* @ return boolean Success
2006-05-26 05:29:17 +00:00
*/
function file_put_contents ( $fileName , $data ) {
if ( is_array ( $data )) {
$data = join ( '' , $data );
}
$res = @ fopen ( $fileName , 'w+b' );
if ( $res ) {
2006-10-19 18:14:09 +00:00
$write = @ fwrite ( $res , $data );
2007-06-20 06:15:35 +00:00
if ( $write === false ) {
2006-10-19 18:14:09 +00:00
return false ;
} else {
2007-12-22 22:17:42 +00:00
@ fclose ( $res );
2006-10-19 18:14:09 +00:00
return $write ;
}
2006-05-26 05:29:17 +00:00
}
2006-10-19 18:14:09 +00:00
return false ;
2006-05-26 05:29:17 +00:00
}
}
2006-01-12 02:10:47 +00:00
/**
* Reads / writes temporary data to cache files or session .
*
2006-05-26 05:29:17 +00:00
* @ param string $path File path within / tmp to save the file .
* @ param mixed $data The data to save to the temporary file .
2006-01-12 02:10:47 +00:00
* @ param mixed $expires A valid strtotime string when the data expires .
* @ param string $target The target of the cached data ; either 'cache' or 'public' .
* @ return mixed The contents of the temporary file .
2008-05-17 21:44:17 +00:00
* @ deprecated Please use Cache :: write () instead
2006-01-12 02:10:47 +00:00
*/
2006-05-26 05:29:17 +00:00
function cache ( $path , $data = null , $expires = '+1 day' , $target = 'cache' ) {
2007-09-30 07:45:34 +00:00
if ( Configure :: read ( 'Cache.disable' )) {
2006-07-04 01:29:48 +00:00
return null ;
}
2006-11-28 22:34:28 +00:00
$now = time ();
2006-07-04 01:29:48 +00:00
2006-05-26 05:29:17 +00:00
if ( ! is_numeric ( $expires )) {
2006-11-28 22:34:28 +00:00
$expires = strtotime ( $expires , $now );
2006-05-26 05:29:17 +00:00
}
2007-10-22 06:17:16 +00:00
switch ( low ( $target )) {
2006-05-26 05:29:17 +00:00
case 'cache' :
$filename = CACHE . $path ;
break ;
case 'public' :
$filename = WWW_ROOT . $path ;
break ;
2007-01-17 02:41:02 +00:00
case 'tmp' :
$filename = TMP . $path ;
break ;
2006-05-26 05:29:17 +00:00
}
2006-11-28 22:34:28 +00:00
$timediff = $expires - $now ;
2007-02-01 06:39:25 +00:00
$filetime = false ;
2007-12-22 22:17:42 +00:00
2007-06-20 06:15:35 +00:00
if ( file_exists ( $filename )) {
2007-02-01 06:39:25 +00:00
$filetime = @ filemtime ( $filename );
}
2007-01-13 21:08:52 +00:00
2007-02-01 03:34:32 +00:00
if ( $data === null ) {
2006-05-26 05:29:17 +00:00
if ( file_exists ( $filename ) && $filetime !== false ) {
if ( $filetime + $timediff < $now ) {
@ unlink ( $filename );
} else {
2007-12-22 22:17:42 +00:00
$data = @ file_get_contents ( $filename );
2006-05-26 05:29:17 +00:00
}
}
2007-06-20 06:15:35 +00:00
} elseif ( is_writable ( dirname ( $filename ))) {
2007-12-22 22:17:42 +00:00
@ file_put_contents ( $filename , $data );
2006-05-26 05:29:17 +00:00
}
return $data ;
}
2006-03-12 05:56:07 +00:00
/**
* Used to delete files in the cache directories , or clear contents of cache directories
*
* @ param mixed $params As String name to be searched for deletion , if name is a directory all files in directory will be deleted .
2006-05-26 05:29:17 +00:00
* If array , names to be searched for deletion .
* If clearCache () without params , all files in app / tmp / cache / views will be deleted
2006-03-12 05:56:07 +00:00
*
* @ param string $type Directory in tmp / cache defaults to view directory
* @ param string $ext The file extension you are deleting
* @ return true if files found and deleted false otherwise
*/
2006-05-26 05:29:17 +00:00
function clearCache ( $params = null , $type = 'views' , $ext = '.php' ) {
if ( is_string ( $params ) || $params === null ) {
$params = preg_replace ( '/\/\//' , '/' , $params );
$cache = CACHE . $type . DS . $params ;
if ( is_file ( $cache . $ext )) {
@ unlink ( $cache . $ext );
return true ;
2007-06-20 06:15:35 +00:00
} elseif ( is_dir ( $cache )) {
2006-05-26 05:29:17 +00:00
$files = glob ( " $cache * " );
if ( $files === false ) {
return false ;
}
2007-06-20 06:15:35 +00:00
foreach ( $files as $file ) {
2006-05-26 05:29:17 +00:00
if ( is_file ( $file )) {
@ unlink ( $file );
}
}
return true ;
} else {
2008-03-08 04:30:55 +00:00
$cache = CACHE . $type . DS . '*' . $params . $ext ;
2006-05-26 05:29:17 +00:00
$files = glob ( $cache );
2008-03-08 04:30:55 +00:00
$cache = CACHE . $type . DS . '*' . $params . '_*' . $ext ;
$files = array_merge ( $files , glob ( $cache ));
2006-05-26 05:29:17 +00:00
if ( $files === false ) {
return false ;
}
2008-03-08 04:30:55 +00:00
2007-06-20 06:15:35 +00:00
foreach ( $files as $file ) {
2006-05-26 05:29:17 +00:00
if ( is_file ( $file )) {
@ unlink ( $file );
}
}
return true ;
}
} elseif ( is_array ( $params )) {
2007-06-20 06:15:35 +00:00
foreach ( $params as $key => $file ) {
2008-03-08 04:30:55 +00:00
clearCache ( $file , $type , $ext );
2006-05-26 05:29:17 +00:00
}
2008-03-08 04:30:55 +00:00
return true ;
2006-05-26 05:29:17 +00:00
}
2008-03-08 04:30:55 +00:00
return false ;
2006-05-26 05:29:17 +00:00
}
2006-03-12 05:56:07 +00:00
/**
2006-03-13 03:48:39 +00:00
* Recursively strips slashes from all values in an array
2006-03-12 05:56:07 +00:00
*
2007-06-19 13:20:34 +00:00
* @ param array $value Array of values to strip slashes
* @ return mixed What is returned from calling stripslashes
2006-03-12 05:56:07 +00:00
*/
2006-05-26 05:29:17 +00:00
function stripslashes_deep ( $value ) {
if ( is_array ( $value )) {
$return = array_map ( 'stripslashes_deep' , $value );
return $return ;
} else {
$return = stripslashes ( $value );
return $return ;
}
}
2006-01-12 02:10:47 +00:00
/**
2006-12-22 20:04:15 +00:00
* Returns a translated string if one is found , or the submitted message if not found .
2006-01-12 02:10:47 +00:00
*
2007-06-19 13:20:34 +00:00
* @ param string $singular Text to translate
2007-10-22 16:54:36 +00:00
* @ param boolean $return Set to true to return translated string , or false to echo
2007-06-19 13:20:34 +00:00
* @ return mixed translated string if $return is false string will be echoed
2006-01-12 02:10:47 +00:00
*/
2006-12-25 04:42:47 +00:00
function __ ( $singular , $return = false ) {
2007-10-24 01:25:21 +00:00
if ( ! $singular ) {
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-06-14 19:06:14 +00:00
}
2006-10-18 17:17:29 +00:00
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2007-11-23 08:16:23 +00:00
echo I18n :: translate ( $singular );
2006-06-14 19:06:14 +00:00
} else {
2007-11-23 08:16:23 +00:00
return I18n :: translate ( $singular );
2006-06-14 19:06:14 +00:00
}
}
/**
2006-12-25 04:42:47 +00:00
* Returns correct plural form of message identified by $singular and $plural for count $count .
2006-06-14 19:06:14 +00:00
* Some languages have more than one form for plural messages dependent on the count .
*
2007-06-19 13:20:34 +00:00
* @ param string $singular Singular text to translate
* @ param string $plural Plural text
2007-10-22 16:11:12 +00:00
* @ param integer $count Count
2007-10-22 16:54:36 +00:00
* @ param boolean $return true to return , false to echo
2007-06-19 13:20:34 +00:00
* @ return mixed plural form of translated string if $return is false string will be echoed
2006-06-14 19:06:14 +00:00
*/
2006-12-25 04:42:47 +00:00
function __n ( $singular , $plural , $count , $return = false ) {
2007-10-28 04:18:18 +00:00
if ( ! $singular ) {
2007-10-24 01:25:21 +00:00
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-06-14 19:06:14 +00:00
}
2006-10-18 17:17:29 +00:00
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2007-11-23 08:16:23 +00:00
echo I18n :: translate ( $singular , $plural , null , 5 , $count );
2006-06-14 19:06:14 +00:00
} else {
2007-11-23 08:16:23 +00:00
return I18n :: translate ( $singular , $plural , null , 5 , $count );
2006-06-14 19:06:14 +00:00
}
}
2006-12-25 19:38:28 +00:00
/**
* Allows you to override the current domain for a single message lookup .
*
2007-06-19 13:20:34 +00:00
* @ param string $domain Domain
* @ param string $msg String to translate
* @ param string $return true to return , false to echo
2006-12-25 19:38:28 +00:00
* @ return translated string if $return is false string will be echoed
*/
function __d ( $domain , $msg , $return = false ) {
2007-10-24 01:25:21 +00:00
if ( ! $msg ) {
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-12-25 19:38:28 +00:00
}
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2006-12-25 19:38:28 +00:00
echo I18n :: translate ( $msg , null , $domain );
} else {
return I18n :: translate ( $msg , null , $domain );
}
}
2006-06-14 19:06:14 +00:00
/**
* Allows you to override the current domain for a single plural message lookup
2006-12-25 04:42:47 +00:00
* Returns correct plural form of message identified by $singular and $plural for count $count
2006-06-14 19:06:14 +00:00
* from domain $domain
*
2007-06-19 13:20:34 +00:00
* @ param string $domain Domain
* @ param string $singular Singular string to translate
* @ param string $plural Plural
2007-10-22 16:11:12 +00:00
* @ param integer $count Count
2007-10-22 16:54:36 +00:00
* @ param boolean $return true to return , false to echo
2006-12-22 20:04:15 +00:00
* @ return plural form of translated string if $return is false string will be echoed
2006-06-14 19:06:14 +00:00
*/
2006-12-25 04:42:47 +00:00
function __dn ( $domain , $singular , $plural , $count , $return = false ) {
2007-10-24 01:25:21 +00:00
if ( ! $singular ) {
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-06-14 19:06:14 +00:00
}
2006-10-18 17:17:29 +00:00
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2006-12-25 19:38:28 +00:00
echo I18n :: translate ( $singular , $plural , $domain , 5 , $count );
2006-06-14 19:06:14 +00:00
} else {
2006-12-25 19:38:28 +00:00
return I18n :: translate ( $singular , $plural , $domain , 5 , $count );
2006-06-14 19:06:14 +00:00
}
}
/**
2006-12-25 19:38:28 +00:00
* Allows you to override the current domain for a single message lookup .
2006-06-14 19:06:14 +00:00
* It also allows you to specify a category .
*
* 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 .
*
* 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
*
2007-06-19 13:20:34 +00:00
* @ param string $domain Domain
* @ param string $msg Message to translate
2007-10-22 16:11:12 +00:00
* @ param integer $category Category
2007-10-22 16:54:36 +00:00
* @ param boolean $return true to return , false to echo
2006-12-25 19:38:28 +00:00
* @ return translated string if $return is false string will be echoed
2006-06-14 19:06:14 +00:00
*/
2006-12-25 19:38:28 +00:00
function __dc ( $domain , $msg , $category , $return = false ) {
2007-10-24 01:25:21 +00:00
if ( ! $msg ) {
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-06-14 19:06:14 +00:00
}
2006-10-18 17:17:29 +00:00
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2006-12-25 19:38:28 +00:00
echo I18n :: translate ( $msg , null , $domain , $category );
2006-05-26 05:29:17 +00:00
} else {
2006-12-25 19:38:28 +00:00
return I18n :: translate ( $msg , null , $domain , $category );
2006-05-26 05:29:17 +00:00
}
}
2006-06-14 19:06:14 +00:00
/**
2006-12-25 19:38:28 +00:00
* Allows you to override the current domain for a single plural message lookup .
2006-06-14 19:06:14 +00:00
* It also allows you to specify a category .
2006-12-25 19:38:28 +00:00
* Returns correct plural form of message identified by $singular and $plural for count $count
* from domain $domain
2006-06-14 19:06:14 +00:00
*
* 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 .
*
* 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
*
2007-06-19 13:20:34 +00:00
* @ param string $domain Domain
* @ param string $singular Singular string to translate
* @ param string $plural Plural
2007-10-22 16:11:12 +00:00
* @ param integer $count Count
* @ param integer $category Category
2007-10-22 16:54:36 +00:00
* @ param boolean $return true to return , false to echo
2006-12-25 19:38:28 +00:00
* @ return plural form of translated string if $return is false string will be echoed
2006-06-14 19:06:14 +00:00
*/
2006-12-25 19:38:28 +00:00
function __dcn ( $domain , $singular , $plural , $count , $category , $return = false ) {
2007-10-24 01:25:21 +00:00
if ( ! $singular ) {
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-06-14 19:06:14 +00:00
}
2006-10-18 17:17:29 +00:00
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2006-12-25 19:38:28 +00:00
echo I18n :: translate ( $singular , $plural , $domain , $category , $count );
2006-06-14 19:06:14 +00:00
} else {
2006-12-25 19:38:28 +00:00
return I18n :: translate ( $singular , $plural , $domain , $category , $count );
2006-06-14 19:06:14 +00:00
}
}
2006-12-25 04:42:47 +00:00
/**
* 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 .
*
* 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
*
2007-06-19 13:20:34 +00:00
* @ param string $msg String to translate
2007-10-22 16:11:12 +00:00
* @ param integer $category Category
2007-06-19 13:20:34 +00:00
* @ param string $return true to return , false to echo
2006-12-25 04:42:47 +00:00
* @ return translated string if $return is false string will be echoed
2006-06-14 19:06:14 +00:00
*/
2006-12-30 01:02:19 +00:00
function __c ( $msg , $category , $return = false ) {
2007-10-24 01:25:21 +00:00
if ( ! $msg ) {
return ;
}
2007-06-20 06:15:35 +00:00
if ( ! class_exists ( 'I18n' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'i18n' );
2006-06-14 19:06:14 +00:00
}
2006-10-18 17:17:29 +00:00
2007-06-20 06:15:35 +00:00
if ( $return === false ) {
2007-11-23 08:16:23 +00:00
echo I18n :: translate ( $msg , null , null , $category );
2006-06-14 19:06:14 +00:00
} else {
2007-11-23 08:16:23 +00:00
return I18n :: translate ( $msg , null , null , $category );
2006-06-14 19:06:14 +00:00
}
}
2006-12-08 08:59:35 +00:00
/**
* Computes the difference of arrays using keys for comparison
*
2007-06-19 13:20:34 +00:00
* @ param array First array
* @ param array Second array
* @ return array Array with different keys
2006-12-08 08:59:35 +00:00
*/
if ( ! function_exists ( 'array_diff_key' )) {
function array_diff_key () {
$valuesDiff = array ();
2006-12-13 04:39:26 +00:00
2006-12-08 08:59:35 +00:00
if ( func_num_args () < 2 ) {
return false ;
}
2006-12-13 04:39:26 +00:00
2006-12-08 08:59:35 +00:00
foreach ( func_get_args () as $param ) {
if ( ! is_array ( $param )) {
return false ;
}
}
$args = func_get_args ();
foreach ( $args [ 0 ] as $valueKey => $valueData ) {
for ( $i = 1 ; $i < func_num_args (); $i ++ ) {
2007-04-05 16:09:51 +00:00
if ( isset ( $args [ $i ][ $valueKey ])) {
2006-12-08 08:59:35 +00:00
continue 2 ;
}
}
$valuesDiff [ $valueKey ] = $valueData ;
}
return $valuesDiff ;
}
}
/**
* Computes the intersection of arrays using keys for comparison
*
2007-06-19 13:20:34 +00:00
* @ param array First array
* @ param array Second array
* @ return array Array with interesected keys
2006-12-08 08:59:35 +00:00
*/
if ( ! function_exists ( 'array_intersect_key' )) {
function array_intersect_key ( $arr1 , $arr2 ) {
$res = array ();
2007-06-20 06:15:35 +00:00
foreach ( $arr1 as $key => $value ) {
if ( array_key_exists ( $key , $arr2 )) {
2006-12-08 08:59:35 +00:00
$res [ $key ] = $arr1 [ $key ];
}
}
return $res ;
}
}
2006-02-08 15:25:34 +00:00
/**
2006-02-18 23:42:21 +00:00
* Shortcut to Log :: write .
2007-06-19 13:20:34 +00:00
*
* @ param string $message Message to write to log
2006-02-18 23:42:21 +00:00
*/
2006-05-26 05:29:17 +00:00
function LogError ( $message ) {
if ( ! class_exists ( 'CakeLog' )) {
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
App :: import ( 'Core' , 'CakeLog' );
2006-05-26 05:29:17 +00:00
}
$bad = array ( " \n " , " \r " , " \t " );
$good = ' ' ;
CakeLog :: write ( 'error' , str_replace ( $bad , $good , $message ));
}
2006-03-12 05:56:07 +00:00
/**
* Searches include path for files
*
2007-06-19 13:20:34 +00:00
* @ param string $file File to look for
2006-03-12 05:56:07 +00:00
* @ return Full path to file if exists , otherwise false
*/
2006-05-26 05:29:17 +00:00
function fileExistsInPath ( $file ) {
$paths = explode ( PATH_SEPARATOR , ini_get ( 'include_path' ));
2007-06-20 06:15:35 +00:00
foreach ( $paths as $path ) {
2006-05-26 05:29:17 +00:00
$fullPath = $path . DIRECTORY_SEPARATOR . $file ;
2006-02-16 09:29:28 +00:00
2006-05-26 05:29:17 +00:00
if ( file_exists ( $fullPath )) {
return $fullPath ;
} elseif ( file_exists ( $file )) {
return $file ;
}
}
return false ;
}
2006-03-14 11:54:03 +00:00
/**
* Convert forward slashes to underscores and removes first and last underscores in a string
*
2007-06-19 13:20:34 +00:00
* @ param string String to convert
2006-03-14 11:54:03 +00:00
* @ return string with underscore remove from start and end of string
*/
2006-05-26 05:29:17 +00:00
function convertSlash ( $string ) {
2006-12-28 05:15:21 +00:00
$string = trim ( $string , " / " );
2006-05-26 05:29:17 +00:00
$string = preg_replace ( '/\/\//' , '/' , $string );
$string = str_replace ( '/' , '_' , $string );
return $string ;
}
2007-08-16 05:44:06 +00:00
/**
* Implements http_build_query for PHP4 .
*
* @ param string $data Data to set in query string
* @ param string $prefix If numeric indices , prepend this to index for elements in base array .
* @ param string $argSep String used to separate arguments
* @ param string $baseKey Base key
* @ return string URL encoded query string
* @ see http :// php . net / http_build_query
*/
if ( ! function_exists ( 'http_build_query' )) {
function http_build_query ( $data , $prefix = null , $argSep = null , $baseKey = null ) {
if ( empty ( $argSep )) {
$argSep = ini_get ( 'arg_separator.output' );
}
if ( is_object ( $data )) {
$data = get_object_vars ( $data );
}
$out = array ();
foreach (( array ) $data as $key => $v ) {
if ( is_numeric ( $key ) && ! empty ( $prefix )) {
$key = $prefix . $key ;
}
$key = urlencode ( $key );
if ( ! empty ( $baseKey )) {
$key = $baseKey . '[' . $key . ']' ;
}
if ( is_array ( $v ) || is_object ( $v )) {
$out [] = http_build_query ( $v , $prefix , $argSep , $key );
} else {
$out [] = $key . '=' . urlencode ( $v );
}
}
return implode ( $argSep , $out );
}
}
2007-01-30 16:34:22 +00:00
/**
2007-10-22 06:17:16 +00:00
* Wraps ternary operations . If $condition is a non - empty value , $val1 is returned , otherwise $val2 .
2007-06-19 13:20:34 +00:00
* Don ' t use for isset () conditions , or wrap your variable with @ operator :
* Example :
* < code >
* ife ( isset ( $variable ), @ $variable , 'default' );
* </ code >
2007-01-30 16:34:22 +00:00
*
* @ param mixed $condition Conditional expression
2007-06-19 13:20:34 +00:00
* @ param mixed $val1 Value to return in case condition matches
* @ param mixed $val2 Value to return if condition doesn ' t match
2007-01-30 16:34:22 +00:00
* @ return mixed $val1 or $val2 , depending on whether $condition evaluates to a non - empty expression .
*/
function ife ( $condition , $val1 = null , $val2 = null ) {
if ( ! empty ( $condition )) {
return $val1 ;
}
return $val2 ;
}
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
/**
* @ deprecated
2007-11-23 08:16:23 +00:00
* @ see App :: import ( 'View' , 'ViewName' );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
*/
2007-11-19 16:39:14 +00:00
function loadView ( $name ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadView is deprecated see App::import(\'View\', \'ViewName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'View' , $name );
}
/**
* @ deprecated
* @ see App :: import ( 'Model' , 'ModelName' );
*/
function loadModel ( $name = null ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadModel is deprecated see App::import(\'Model\', \'ModelName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Model' , $name );
}
/**
* @ deprecated
* @ see App :: import ( 'Controller' , 'ControllerName' );
*/
function loadController ( $name ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadController is deprecated see App::import(\'Controller\', \'ControllerName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Controller' , $name );
}
/**
* @ deprecated
* @ see App :: import ( 'Helper' , 'HelperName' );
*/
function loadHelper ( $name ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadHelper is deprecated see App::import(\'Helper\', \'PluginName.HelperName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Helper' , $name );
}
/**
* @ deprecated
* @ see App :: import ( 'Helper' , 'PluginName.HelperName' );
*/
function loadPluginHelper ( $plugin , $helper ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadPluginHelper is deprecated see App::import(\'Helper\', \'PluginName.HelperName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Helper' , $plugin . '.' . $helper );
}
/**
* @ deprecated
2007-11-23 08:16:23 +00:00
* @ see App :: import ( 'Component' , 'ComponentName' );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
*/
function loadComponent ( $name ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadComponent is deprecated see App::import(\'Component\', \'ComponentName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Component' , $name );
}
/**
* @ deprecated
* @ see App :: import ( 'Component' , 'PluginName.ComponentName' );
*/
function loadPluginComponent ( $plugin , $component ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadPluginComponent is deprecated see App::import(\'Component\', \'PluginName.ComponentName\');' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Component' , $plugin . '.' . $component );
}
/**
* @ deprecated
* @ see App :: import ( 'Behavior' , 'BehaviorrName' );
*/
function loadBehavior ( $name ) {
2007-11-23 08:16:23 +00:00
trigger_error ( 'loadBehavior is deprecated see App::import(\'Behavior\', $name);' , E_USER_WARNING );
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
return App :: import ( 'Behavior' , $name );
}
2007-11-23 08:16:23 +00:00
/**
* @ deprecated
* @ see $model = Configure :: listObjects ( 'model' ); and App :: import ( 'Model' , $models );
* or App :: import ( 'Model' , array ( List of Models ));
*/
function loadModels () {
$loadModels = array ();
if ( func_num_args () > 0 ) {
$args = func_get_args ();
foreach ( $args as $arg ) {
if ( is_array ( $arg )) {
$loadModels = am ( $loadModels , $arg );
} else {
$loadModels [] = $arg ;
}
}
}
if ( empty ( $loadModels )) {
$loadModels = Configure :: listObjects ( 'model' );
}
App :: import ( 'Model' , $loadModels );
trigger_error ( 'loadModels is deprecated see $model = Configure::listObjects(\'model\'); and App::import(\'Model\', $models);' , E_USER_WARNING );
return $loadModels ;
}
/**
* @ deprecated
* @ see App :: import ( 'Model' , 'PluginName.PluginModel' );
*/
function loadPluginModels ( $plugin ) {
if ( ! class_exists ( 'AppModel' )) {
loadModel ();
}
$plugin = Inflector :: underscore ( $plugin );
$pluginAppModel = Inflector :: camelize ( $plugin . '_app_model' );
$pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php' ;
if ( ! class_exists ( $pluginAppModel )) {
if ( file_exists ( $pluginAppModelFile )) {
require ( $pluginAppModelFile );
Overloadable :: overload ( $pluginAppModel );
}
}
$pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS ;
if ( is_dir ( $pluginModelDir )) {
foreach ( listClasses ( $pluginModelDir ) as $modelFileName ) {
list ( $name ) = explode ( '.' , $modelFileName );
$className = Inflector :: camelize ( $name );
if ( ! class_exists ( $className )) {
require ( $pluginModelDir . $modelFileName );
Overloadable :: overload ( $className );
}
}
}
trigger_error ( 'loadPluginModels is deprecated see App::import(\'Model\', \'PluginName.PluginModel\');' , E_USER_WARNING );
}
/**
* @ deprecated
* @ see $controllers = Configure :: listObjects ( 'controller' ); and App :: import ( 'Controller' , $controllers );
* or App :: import ( 'Controller' , array ( List of Controllers );
*/
function loadControllers () {
$loadControllers = array ();
if ( func_num_args () > 0 ) {
$args = func_get_args ();
foreach ( $args as $arg ) {
if ( is_array ( $arg )) {
$loadControllers = am ( $loadControllers , $arg );
} else {
$loadControllers [] = $arg ;
}
}
}
if ( empty ( $loadControllers )) {
$loadControllers = Configure :: listObjects ( 'controller' );
}
App :: import ( 'Controller' , $loadControllers );
trigger_error ( 'loadControllers is deprecated see $controllers = Configure::listObjects(\'controller\'); and App::import(\'Controller\', $controllers);' , E_USER_WARNING );
return $loadControllers ;
}
/**
* @ deprecated
* @ see Configure :: listObjects ( 'file' , $path );
*/
function listClasses ( $path ) {
trigger_error ( 'listClasses is deprecated see Configure::listObjects(\'file\', $path);' , E_USER_WARNING );
return Configure :: listObjects ( 'file' , $path );
}
2007-10-28 04:18:18 +00:00
?>