Renaming directory for 1.x.x.x code base

git-svn-id: https://svn.cakephp.org/repo/branches/1.x.x.x@2771 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-05-07 03:35:58 +00:00
parent e41214da87
commit f5a4a58758
10 changed files with 123 additions and 63 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ // // +---------------------------------------------------------------------------------------------------+ //
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
1.0.1.2708 1.0.1.2767

View file

@ -207,5 +207,16 @@ class SessionComponent extends Object
return $this->CakeSession->isValid(); return $this->CakeSession->isValid();
} }
/**
* Enter description here...
*
* Use like this. $this->Session->destroy();
* Used to destroy Sessions
*
*/
function destroy()
{
$this->CakeSession->destroyInvalid();
}
} }
?> ?>

View file

@ -842,7 +842,7 @@ class Controller extends Object
break; break;
case "date": case "date":
case "datetime": case "datetime":
if(0 != strncmp( "created", $tabl['name'], 6 ) && 0 != strncmp("modified",$tabl['name'], 8)) if(0 != strncmp( "created", $tabl['name'], 7 ) && 0 != strncmp("modified",$tabl['name'], 8))
{ {
$fieldNames[ $tabl['name']]['type'] = $type; $fieldNames[ $tabl['name']]['type'] = $type;
} }

View file

@ -567,6 +567,8 @@ class DboSource extends DataSource
foreach($model->__associations as $type) foreach($model->__associations as $type)
{ {
foreach($model->{$type} as $assoc => $assocData) foreach($model->{$type} as $assoc => $assocData)
{
if ($model->recursive > -1)
{ {
$linkModel =& $model->{$assocData['className']}; $linkModel =& $model->{$assocData['className']};
if($model->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany') if($model->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany')
@ -588,6 +590,7 @@ class DboSource extends DataSource
} }
} }
} }
}
// Build final query SQL // Build final query SQL
$query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null); $query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null);
@ -1578,7 +1581,7 @@ class DboSource extends DataSource
{ {
if(is_numeric($key)) if(is_numeric($key))
{ {
$value = r('ORDER BY ', '', $this->order($value)); $value = ltrim(r('ORDER BY ', '', $this->order($value)));
$key = $value; $key = $value;
if (!preg_match('/\\x20ASC|\\x20DESC/i', $key)) if (!preg_match('/\\x20ASC|\\x20DESC/i', $key))

View file

@ -783,6 +783,8 @@ class Model extends Object
$conditions = array($this->name.'.'.$this->primaryKey => $this->id); $conditions = array($this->name.'.'.$this->primaryKey => $this->id);
} }
if ($data = $this->find($conditions, $name, $order, 0)) if ($data = $this->find($conditions, $name, $order, 0))
{
if (strpos($name, '.') === false)
{ {
if (isset($data[$this->name][$name])) if (isset($data[$this->name][$name]))
{ {
@ -794,6 +796,19 @@ class Model extends Object
} }
} }
else else
{
$name = explode('.', $name);
if (isset($data[$name[0]][$name[1]]))
{
return $data[$name[0]][$name[1]];
}
else
{
return false;
}
}
}
else
{ {
return false; return false;
} }
@ -839,11 +854,6 @@ class Model extends Object
$whitelist = !(empty($fieldList) || count($fieldList) == 0); $whitelist = !(empty($fieldList) || count($fieldList) == 0);
$this->validationErrors = array(); $this->validationErrors = array();
if(!$this->beforeValidate())
{
return false;
}
if ($validate && !$this->validates()) if ($validate && !$this->validates())
{ {
return false; return false;
@ -1058,9 +1068,9 @@ class Model extends Object
$db =& ConnectionManager::getDataSource($this->useDbConfig); $db =& ConnectionManager::getDataSource($this->useDbConfig);
if ($this->id && $db->delete($this)) if ($this->id && $db->delete($this))
{ {
$this->__deleteMulti($id); $this->_deleteMulti($id);
$this->__deleteHasMany($id, $cascade); $this->_deleteHasMany($id, $cascade);
$this->__deleteHasOne($id, $cascade); $this->_deleteHasOne($id, $cascade);
$this->afterDelete(); $this->afterDelete();
$this->_clearCache(); $this->_clearCache();
$this->id = false; $this->id = false;
@ -1087,9 +1097,9 @@ class Model extends Object
* *
* @param string $id * @param string $id
* @return null * @return null
* @access private * @access protected
*/ */
function __deleteHasMany ($id, $cascade) function _deleteHasMany ($id, $cascade)
{ {
foreach ($this->hasMany as $assoc => $data) foreach ($this->hasMany as $assoc => $data)
{ {
@ -1113,9 +1123,9 @@ class Model extends Object
* *
* @param string $id * @param string $id
* @return null * @return null
* @access private * @access protected
*/ */
function __deleteHasOne ($id, $cascade) function _deleteHasOne ($id, $cascade)
{ {
foreach ($this->hasOne as $assoc => $data) foreach ($this->hasOne as $assoc => $data)
{ {
@ -1139,9 +1149,9 @@ class Model extends Object
* *
* @param string $id * @param string $id
* @return null * @return null
* @access private * @access protected
*/ */
function __deleteMulti ($id) function _deleteMulti ($id)
{ {
$db =& ConnectionManager::getDataSource($this->useDbConfig); $db =& ConnectionManager::getDataSource($this->useDbConfig);
foreach ($this->hasAndBelongsToMany as $assoc => $data) foreach ($this->hasAndBelongsToMany as $assoc => $data)
@ -1442,6 +1452,11 @@ class Model extends Object
*/ */
function invalidFields ($data = array()) function invalidFields ($data = array())
{ {
if(!$this->beforeValidate())
{
return false;
}
if (!isset($this->validate)) if (!isset($this->validate))
{ {
return true; return true;

View file

@ -779,6 +779,8 @@ class Model extends Object
$conditions = array($this->name.'.'.$this->primaryKey => $this->id); $conditions = array($this->name.'.'.$this->primaryKey => $this->id);
} }
if ($data = $this->find($conditions, $name, $order, 0)) if ($data = $this->find($conditions, $name, $order, 0))
{
if (strpos($name, '.') === false)
{ {
if (isset($data[$this->name][$name])) if (isset($data[$this->name][$name]))
{ {
@ -790,6 +792,19 @@ class Model extends Object
} }
} }
else else
{
$name = explode('.', $name);
if (isset($data[$name[0]][$name[1]]))
{
return $data[$name[0]][$name[1]];
}
else
{
return false;
}
}
}
else
{ {
return false; return false;
} }
@ -835,11 +850,6 @@ class Model extends Object
$whitelist = !(empty($fieldList) || count($fieldList) == 0); $whitelist = !(empty($fieldList) || count($fieldList) == 0);
$this->validationErrors = array(); $this->validationErrors = array();
if(!$this->beforeValidate())
{
return false;
}
if ($validate && !$this->validates()) if ($validate && !$this->validates())
{ {
return false; return false;
@ -1054,9 +1064,9 @@ class Model extends Object
$db =& ConnectionManager::getDataSource($this->useDbConfig); $db =& ConnectionManager::getDataSource($this->useDbConfig);
if ($this->id && $db->delete($this)) if ($this->id && $db->delete($this))
{ {
$this->__deleteMulti($id); $this->_deleteMulti($id);
$this->__deleteHasMany($id, $cascade); $this->_deleteHasMany($id, $cascade);
$this->__deleteHasOne($id, $cascade); $this->_deleteHasOne($id, $cascade);
$this->afterDelete(); $this->afterDelete();
$this->_clearCache(); $this->_clearCache();
$this->id = false; $this->id = false;
@ -1083,9 +1093,9 @@ class Model extends Object
* *
* @param string $id * @param string $id
* @return null * @return null
* @access private * @access protected
*/ */
function __deleteHasMany ($id, $cascade) function _deleteHasMany ($id, $cascade)
{ {
foreach ($this->hasMany as $assoc => $data) foreach ($this->hasMany as $assoc => $data)
{ {
@ -1109,9 +1119,9 @@ class Model extends Object
* *
* @param string $id * @param string $id
* @return null * @return null
* @access private * @access protected
*/ */
function __deleteHasOne ($id, $cascade) function _deleteHasOne ($id, $cascade)
{ {
foreach ($this->hasOne as $assoc => $data) foreach ($this->hasOne as $assoc => $data)
{ {
@ -1135,9 +1145,9 @@ class Model extends Object
* *
* @param string $id * @param string $id
* @return null * @return null
* @access private * @access protected
*/ */
function __deleteMulti ($id) function _deleteMulti ($id)
{ {
$db =& ConnectionManager::getDataSource($this->useDbConfig); $db =& ConnectionManager::getDataSource($this->useDbConfig);
foreach ($this->hasAndBelongsToMany as $assoc => $data) foreach ($this->hasAndBelongsToMany as $assoc => $data)
@ -1438,6 +1448,11 @@ class Model extends Object
*/ */
function invalidFields ($data = array()) function invalidFields ($data = array())
{ {
if(!$this->beforeValidate())
{
return false;
}
if (!isset($this->validate)) if (!isset($this->validate))
{ {
return true; return true;

View file

@ -308,7 +308,7 @@ class CakeSession extends Object
* *
* @access private * @access private
*/ */
function __destroyInvalid() function destroyInvalid()
{ {
$sessionpath = session_save_path(); $sessionpath = session_save_path();
if (empty($sessionpath)) if (empty($sessionpath))
@ -468,7 +468,7 @@ class CakeSession extends Object
{ {
$this->valid = false; $this->valid = false;
$this->__setError(1, "Session Highjacking Attempted !!!"); $this->__setError(1, "Session Highjacking Attempted !!!");
$this->__destroyInvalid(); $this->destroyInvalid();
} }
} }
else else

View file

@ -415,7 +415,7 @@ class AjaxHelper extends Helper
{ {
if (!isset($options['with'])) if (!isset($options['with']))
{ {
$options['with'] = 'Form.serialize(this.form)'; $options['with'] = 'Form.serialize("'.$field_id.'")';
} }
return $this->Javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options)); return $this->Javascript->codeBlock($this->_buildObserver('Form.Observer', $field_id, $options));
} }

View file

@ -309,6 +309,7 @@ function url($url = null, $return = false)
if(!empty($htmlAttributes['value']) && !$value) if(!empty($htmlAttributes['value']) && !$value)
{ {
$value = $htmlAttributes['value']; $value = $htmlAttributes['value'];
unset($htmlAttributes['value']);
} }
if ($this->tagIsInvalid($this->model, $this->field)) if ($this->tagIsInvalid($this->model, $this->field))

View file

@ -588,6 +588,8 @@ class Bake {
} }
} }
$controllerName = $inflect->underscore($controllerName);
$wannaDoScaffold = $this->getInput("Would you like to create some scaffolded views (index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller and model classes (including associated models).", array('y','n'), 'n'); $wannaDoScaffold = $this->getInput("Would you like to create some scaffolded views (index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller and model classes (including associated models).", array('y','n'), 'n');
$uses = array(); $uses = array();
@ -983,23 +985,26 @@ class Bake {
if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes')
{ {
$controllerModel = $inflect->singularize($controllerClassName); $controllerModel = $inflect->singularize($controllerClassName);
loadModels();
$tempModel = new $controllerModel();
$actions .= "\n"; $actions .= "\n";
$actions .= "\tfunction index()\n"; $actions .= "\tfunction index()\n";
$actions .= "\t{\n"; $actions .= "\t{\n";
$actions .= "\t\t\$this->{$controllerModel}->recursive = 0;\n";
$actions .= "\t\t\$this->set('data', \$this->{$controllerModel}->findAll());\n"; $actions .= "\t\t\$this->set('data', \$this->{$controllerModel}->findAll());\n";
$actions .= "\t}\n"; $actions .= "\t}\n";
$actions .= "\n"; $actions .= "\n";
$actions .= "\tfunction add()\n"; $actions .= "\tfunction add()\n";
$actions .= "\t{\n"; $actions .= "\t{\n";
$actions .= "\t\tif(empty(\$this->params['data']))\n"; $actions .= "\t\tif(empty(\$this->data))\n";
$actions .= "\t\t{\n"; $actions .= "\t\t{\n";
$actions .= "\t\t\t\$this->render();\n"; $actions .= "\t\t\t\$this->render();\n";
$actions .= "\t\t}\n"; $actions .= "\t\t}\n";
$actions .= "\t\telse\n"; $actions .= "\t\telse\n";
$actions .= "\t\t{\n"; $actions .= "\t\t{\n";
$actions .= "\t\t\tif(\$this->{$controllerModel}->save(\$this->params['data']))\n"; $actions .= "\t\t\tif(\$this->{$controllerModel}->save(\$this->data))\n";
$actions .= "\t\t\t{\n"; $actions .= "\t\t\t{\n";
$actions .= "\t\t\t\t\$this->flash('{$controllerModel} saved.', '/{$controllerName}/index');\n"; $actions .= "\t\t\t\t\$this->flash('{$controllerModel} saved.', '/{$controllerName}/index');\n";
$actions .= "\t\t\t}\n"; $actions .= "\t\t\t}\n";
@ -1013,19 +1018,19 @@ class Bake {
$actions .= "\n"; $actions .= "\n";
$actions .= "\tfunction edit(\$id)\n"; $actions .= "\tfunction edit(\$id)\n";
$actions .= "\t{\n"; $actions .= "\t{\n";
$actions .= "\t\tif(empty(\$this->params['data']))\n"; $actions .= "\t\tif(empty(\$this->data))\n";
$actions .= "\t\t{\n"; $actions .= "\t\t{\n";
$actions .= "\t\t\t\$this->set('data', \$this->{$controllerModel}->find('{$controllerModel}.id = ' . \$id));\n"; $actions .= "\t\t\t\$this->set('data', \$this->{$controllerModel}->find('{$controllerModel}.{$tempModel->primaryKey} = ' . \$id));\n";
$actions .= "\t\t}\n"; $actions .= "\t\t}\n";
$actions .= "\t\telse\n"; $actions .= "\t\telse\n";
$actions .= "\t\t{\n"; $actions .= "\t\t{\n";
$actions .= "\t\t\tif(\$this->{$controllerModel}->save(\$this->params['data']))\n"; $actions .= "\t\t\tif(\$this->{$controllerModel}->save(\$this->data))\n";
$actions .= "\t\t\t{\n"; $actions .= "\t\t\t{\n";
$actions .= "\t\t\t\t\$this->flash('{$controllerModel} saved.', '/{$controllerName}/index');\n"; $actions .= "\t\t\t\t\$this->flash('{$controllerModel} saved.', '/{$controllerName}/index');\n";
$actions .= "\t\t\t}\n"; $actions .= "\t\t\t}\n";
$actions .= "\t\t\telse\n"; $actions .= "\t\t\telse\n";
$actions .= "\t\t\t{\n"; $actions .= "\t\t\t{\n";
$actions .= "\t\t\t\t\$this->set('data', \$this->params['data']);\n"; $actions .= "\t\t\t\t\$this->set('data', \$this->data);\n";
$actions .= "\t\t\t\t\$this->validateErrors(\$this->{$controllerModel});\n"; $actions .= "\t\t\t\t\$this->validateErrors(\$this->{$controllerModel});\n";
$actions .= "\t\t\t\t\$this->render();\n"; $actions .= "\t\t\t\t\$this->render();\n";
$actions .= "\t\t\t}\n"; $actions .= "\t\t\t}\n";
@ -1035,7 +1040,7 @@ class Bake {
$actions .= "\n"; $actions .= "\n";
$actions .= "\tfunction view(\$id)\n"; $actions .= "\tfunction view(\$id)\n";
$actions .= "\t{\n"; $actions .= "\t{\n";
$actions .= "\t\t\$this->set('data', \$this->{$controllerModel}->find('{$controllerModel}.id = ' . \$id));\n"; $actions .= "\t\t\$this->set('data', \$this->{$controllerModel}->find('{$controllerModel}.{$tempModel->primaryKey} = ' . \$id));\n";
$actions .= "\t}\n"; $actions .= "\t}\n";
$actions .= "\n"; $actions .= "\n";
@ -1047,13 +1052,19 @@ class Bake {
$actions .= "\n"; $actions .= "\n";
$lowerCaseModel = strtolower(substr($controllerModel, 0, 1)) . substr($controllerModel, 1); $lowerCaseModel = strtolower(substr($controllerModel, 0, 1)) . substr($controllerModel, 1);
if($tempModel->displayField === null)
{
$tempModel->displayField = 'name';
}
$actions .= "\tfunction {$lowerCaseModel}List()\n"; $actions .= "\tfunction {$lowerCaseModel}List()\n";
$actions .= "\t{\n"; $actions .= "\t{\n";
$actions .= "\t\t\$vars = \$this->{$controllerModel}->findAll();\n"; $actions .= "\t\t\$this->{$controllerModel}->recursive = 0;\n";
$actions .= "\t\t\$vars = \$this->{$controllerModel}->findAll(null,'{$tempModel->name}.{$tempModel->primaryKey}, {$tempModel->name}.{$tempModel->displayField}');\n";
$actions .= "\t\tforeach(\$vars as \$var)\n"; $actions .= "\t\tforeach(\$vars as \$var)\n";
$actions .= "\t\t{\n"; $actions .= "\t\t{\n";
$actions .= "\t\t\t\$list[\$var['{$controllerModel}']['id']] = \$var['{$controllerModel}']['name'];\n"; $actions .= "\t\t\t\$list[\$var['{$controllerModel}']['{$tempModel->primaryKey}']] = \$var['{$controllerModel}']['{$tempModel->displayField}'];\n";
$actions .= "\t\t}\n"; $actions .= "\t\t}\n";
$actions .= "\n"; $actions .= "\n";
$actions .= "\t\treturn \$list;\n"; $actions .= "\t\treturn \$list;\n";
@ -1761,7 +1772,7 @@ class Bake {
return $this->divTag("date", $requiredDiv); return $this->divTag("date", $requiredDiv);
} }
function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null ) function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null )
{ {
$htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName)); $htmlOptions['id'] = strtolower(str_replace('/', '_',$tagName));
$tagNameArray = explode('/', $tagName); $tagNameArray = explode('/', $tagName);
@ -1842,7 +1853,11 @@ function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $s
else else
{ {
$lowerName = strtolower($tagNameArray[0]); $lowerName = strtolower($tagNameArray[0]);
$str = "\t<?php foreach (\$data['{$tagNameArray[0]}'] as \$var): \${$lowerName}Options[\$var['id']] = \$var['id']; endforeach; ?>\n"; $str = "\t<?php if(isset(\$data['{$tagNameArray[0]}'])): ?>\n";
$str .= "\t<?php foreach (\$data['{$tagNameArray[0]}'] as \$var): \${$lowerName}Options[\$var['id']] = \$var['id']; endforeach; ?>\n";
$str .= "\t<?php else: ?>\n";
$str .= "\t<?php \${$lowerName}Options = null;?>\n";
$str .= "\t<?php endif ?>\n";
$str .= "\t<?php echo \$html->selectTag('{$tagName}', " . "\$this->requestAction('{$path}'), \${$lowerName}Options, " . $this->attributesToArray($selectAttr) . ") ?>\n"; $str .= "\t<?php echo \$html->selectTag('{$tagName}', " . "\$this->requestAction('{$path}'), \${$lowerName}Options, " . $this->attributesToArray($selectAttr) . ") ?>\n";
$str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Error message for {$tagNameArray[1]} goes here.') ?>\n"; $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Error message for {$tagNameArray[1]} goes here.') ?>\n";
} }