mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
[1183]
Author: phpnut Date: 10:42:06 PM, Sunday, October 23, 2005 Message: Fixed errors created with change I have been making. Controller::generateFields(); was not setting the tagName properly. [1182] Author: phpnut Date: 10:13:33 PM, Sunday, October 23, 2005 Message: Removing the need to set hasMany and hasAndBelongsToMany to plural. All associations should be created as CamelCase associations now. [1181] Author: phpnut Date: 9:38:50 PM, Sunday, October 23, 2005 Message: Forgot dispatcher.php in last commit [1180] Author: phpnut Date: 9:37:06 PM, Sunday, October 23, 2005 Message: refactoring and removing unneeded calls to Inflector git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1184 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
68b194965e
commit
38076557aa
5 changed files with 20 additions and 34 deletions
|
@ -98,13 +98,13 @@ function loadControllers ()
|
|||
*/
|
||||
function loadController ($name)
|
||||
{
|
||||
if(file_exists(CONTROLLERS.Inflector::underscore($name).'_controller.php'))
|
||||
if(file_exists(CONTROLLERS.$name.'_controller.php'))
|
||||
{
|
||||
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
|
||||
$controller_fn = CONTROLLERS.$name.'_controller.php';
|
||||
}
|
||||
elseif(file_exists(LIBS.'controller'.DS.Inflector::underscore($name).'_controller.php'))
|
||||
elseif(file_exists(LIBS.'controller'.DS.$name.'_controller.php'))
|
||||
{
|
||||
$controller_fn = LIBS.'controller'.DS.Inflector::underscore($name).'_controller.php';
|
||||
$controller_fn = LIBS.'controller'.DS.$name.'_controller.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ class Dispatcher extends Object
|
|||
$ctrlName = Inflector::camelize($params['controller']);
|
||||
$ctrlClass = $ctrlName.'Controller';
|
||||
|
||||
if (!loadController($ctrlName) || !class_exists($ctrlClass))
|
||||
if (!loadController($params['controller']) || !class_exists($ctrlClass))
|
||||
{
|
||||
if(preg_match('/([\\.]+)/',$ctrlName))
|
||||
{
|
||||
|
@ -148,7 +148,6 @@ class Dispatcher extends Object
|
|||
$controller->action = $params['action'];
|
||||
$controller->data = empty($params['data'])? null: $params['data'];
|
||||
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
||||
$controller->viewpath = Inflector::underscore($ctrlName);
|
||||
$controller->autoLayout = !$params['bare'];
|
||||
$controller->autoRender = !$params['render'];
|
||||
|
||||
|
|
|
@ -200,6 +200,8 @@ class Controller extends Object
|
|||
}
|
||||
|
||||
$this->viewPath = Inflector::underscore($this->name);
|
||||
$this->modelClass = Inflector::singularize($this->name);
|
||||
$this->modelKey = Inflector::underscore($this->modelClass);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
@ -247,13 +249,10 @@ class Controller extends Object
|
|||
$dboFactory = DboFactory::getInstance($this->useDbConfig);
|
||||
$this->db =& $dboFactory;
|
||||
|
||||
$modelClass = Inflector::singularize($this->name);
|
||||
$modelKey = strtolower(Inflector::underscore($modelClass));
|
||||
|
||||
if (class_exists($modelClass) && ($this->uses === false))
|
||||
if (class_exists($this->modelClass) && ($this->uses === false))
|
||||
{
|
||||
$this->{$modelClass} =& new $modelClass($id);
|
||||
$this->modelNames[] = $modelClass;
|
||||
$this->{$this->modelClass} =& new $this->modelClass($id);
|
||||
$this->modelNames[] = $this->modelClass;
|
||||
}
|
||||
elseif ($this->uses)
|
||||
{
|
||||
|
@ -264,10 +263,9 @@ class Controller extends Object
|
|||
|
||||
$uses = is_array($this->uses)? $this->uses: array($this->uses);
|
||||
|
||||
foreach ($uses as $modelName)
|
||||
foreach ($uses as $modelClass)
|
||||
{
|
||||
$modelClass = ucfirst(strtolower($modelName));
|
||||
$modelKey = strtolower(Inflector::underscore($modelClass));
|
||||
$modelKey = Inflector::underscore($modelClass);
|
||||
|
||||
if (class_exists($modelClass))
|
||||
{
|
||||
|
@ -367,10 +365,9 @@ class Controller extends Object
|
|||
{
|
||||
foreach ($this->modelNames as $model)
|
||||
{
|
||||
$key = Inflector::underscore($model);
|
||||
if(!empty($this->{$model}->validationErrors))
|
||||
{
|
||||
$view->validationErrors[$key] =& $this->{$model}->validationErrors;
|
||||
$view->validationErrors[$this->modelKey] =& $this->{$model}->validationErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,20 +579,15 @@ class Controller extends Object
|
|||
*/
|
||||
function generateFieldNames( $data = null, $doCreateOptions = true )
|
||||
{
|
||||
// Initialize the list array
|
||||
$fieldNames = array();
|
||||
|
||||
// figure out what model and table we are working with
|
||||
$model = Inflector::singularize($this->name);
|
||||
$modelKey = Inflector::underscore($model);
|
||||
$model = $this->modelClass;
|
||||
$modelKey = $this->modelKey;
|
||||
$table = $this->{$model}->table;
|
||||
|
||||
|
||||
// get all of the column names.
|
||||
$classRegistry =& ClassRegistry::getInstance();
|
||||
$objRegistryModel = $classRegistry->getObject($modelKey);
|
||||
|
||||
|
||||
foreach ($objRegistryModel->_tableInfo as $tables)
|
||||
{
|
||||
foreach ($tables as $tabl)
|
||||
|
@ -799,7 +791,7 @@ class Controller extends Object
|
|||
{
|
||||
list($tableName) = $relation;
|
||||
|
||||
$otherModelName = Inflector::singularize($tableName);
|
||||
$otherModelName = Inflector::underscore($tableName);
|
||||
$otherModel = new $otherModelName();
|
||||
|
||||
if( $doCreateOptions )
|
||||
|
@ -808,7 +800,7 @@ class Controller extends Object
|
|||
$fieldNames[$tableName]['model'] = $tableName;
|
||||
$fieldNames[$tableName]['prompt'] = "Related ".Inflector::humanize($tableName);
|
||||
$fieldNames[$tableName]['type'] = "selectMultiple";
|
||||
$fieldNames[$tableName]['tagName'] = $otherModelName.'/'.$tableName;
|
||||
$fieldNames[$tableName]['tagName'] = $otherModelName.'/'.Inflector::underscore($tableName);
|
||||
|
||||
foreach( $otherModel->findAll() as $pass )
|
||||
{
|
||||
|
|
|
@ -276,7 +276,6 @@ class Model extends Object
|
|||
$association = explode(',', $this->belongsTo);
|
||||
foreach ($association as $className)
|
||||
{
|
||||
$className = Inflector::singularize($className);
|
||||
$this->_constructAssociatedModels($className , 'Belongs');
|
||||
$this->linkAssociation('Belongs', $className, $this->id);
|
||||
}
|
||||
|
@ -303,7 +302,6 @@ class Model extends Object
|
|||
$association = explode(',', $this->hasOne);
|
||||
foreach ($association as $className)
|
||||
{
|
||||
$className = Inflector::singularize($className);
|
||||
$this->_constructAssociatedModels($className , 'One');
|
||||
$this->linkAssociation('One', $className, $this->id);
|
||||
}
|
||||
|
@ -330,7 +328,6 @@ class Model extends Object
|
|||
$association = explode(',', $this->hasMany);
|
||||
foreach ($association as $className)
|
||||
{
|
||||
$className = Inflector::singularize($className);
|
||||
$this->_constructAssociatedModels($className , 'Many');
|
||||
$this->linkAssociation('Many', $className, $this->id);
|
||||
}
|
||||
|
@ -357,7 +354,6 @@ class Model extends Object
|
|||
$association = explode(',', $this->hasAndBelongsToMany);
|
||||
foreach ($association as $className)
|
||||
{
|
||||
$className = Inflector::singularize($className);
|
||||
$this->_constructAssociatedModels($className , 'ManyTo');
|
||||
$this->linkAssociation('ManyTo', $className, $this->id);
|
||||
}
|
||||
|
@ -385,7 +381,6 @@ class Model extends Object
|
|||
|
||||
if ($classCreated === false)
|
||||
{
|
||||
$className = Inflector::singularize($className);
|
||||
$this->_constructAssociatedModels($className , $type);
|
||||
$classCreated = true;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class Inflector
|
|||
{
|
||||
$inflec =& Inflector::getInstance();
|
||||
|
||||
require_once('config/nouns.php');
|
||||
require_once(CAKE.'config'.DS.'nouns.php');
|
||||
|
||||
$regexPluralUninflected = $inflec->_enclose(join( '|', array_values(array_merge($pluralUninflected,$pluralUninflecteds))));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue