mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
e41214da87
commit
f5a4a58758
10 changed files with 123 additions and 63 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1.0.1.2708
|
||||
1.0.1.2767
|
|
@ -207,5 +207,16 @@ class SessionComponent extends Object
|
|||
return $this->CakeSession->isValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* Use like this. $this->Session->destroy();
|
||||
* Used to destroy Sessions
|
||||
*
|
||||
*/
|
||||
function destroy()
|
||||
{
|
||||
$this->CakeSession->destroyInvalid();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -842,7 +842,7 @@ class Controller extends Object
|
|||
break;
|
||||
case "date":
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -568,23 +568,26 @@ class DboSource extends DataSource
|
|||
{
|
||||
foreach($model->{$type} as $assoc => $assocData)
|
||||
{
|
||||
$linkModel =& $model->{$assocData['className']};
|
||||
if($model->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany')
|
||||
if ($model->recursive > -1)
|
||||
{
|
||||
if (true === $this->generateSelfAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, false, $null))
|
||||
$linkModel =& $model->{$assocData['className']};
|
||||
if($model->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany')
|
||||
{
|
||||
$linkedModels[] = $type.'/'.$assoc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($model->useDbConfig == $linkModel->useDbConfig)
|
||||
{
|
||||
if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, false, $null))
|
||||
if (true === $this->generateSelfAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, false, $null))
|
||||
{
|
||||
$linkedModels[] = $type.'/'.$assoc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($model->useDbConfig == $linkModel->useDbConfig)
|
||||
{
|
||||
if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, false, $null))
|
||||
{
|
||||
$linkedModels[] = $type.'/'.$assoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1578,7 +1581,7 @@ class DboSource extends DataSource
|
|||
{
|
||||
if(is_numeric($key))
|
||||
{
|
||||
$value = r('ORDER BY ', '', $this->order($value));
|
||||
$value = ltrim(r('ORDER BY ', '', $this->order($value)));
|
||||
$key = $value;
|
||||
|
||||
if (!preg_match('/\\x20ASC|\\x20DESC/i', $key))
|
||||
|
|
|
@ -784,13 +784,28 @@ class Model extends Object
|
|||
}
|
||||
if ($data = $this->find($conditions, $name, $order, 0))
|
||||
{
|
||||
if (isset($data[$this->name][$name]))
|
||||
if (strpos($name, '.') === false)
|
||||
{
|
||||
return $data[$this->name][$name];
|
||||
if (isset($data[$this->name][$name]))
|
||||
{
|
||||
return $data[$this->name][$name];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
$name = explode('.', $name);
|
||||
if (isset($data[$name[0]][$name[1]]))
|
||||
{
|
||||
return $data[$name[0]][$name[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -839,11 +854,6 @@ class Model extends Object
|
|||
$whitelist = !(empty($fieldList) || count($fieldList) == 0);
|
||||
$this->validationErrors = array();
|
||||
|
||||
if(!$this->beforeValidate())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($validate && !$this->validates())
|
||||
{
|
||||
return false;
|
||||
|
@ -1058,9 +1068,9 @@ class Model extends Object
|
|||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
if ($this->id && $db->delete($this))
|
||||
{
|
||||
$this->__deleteMulti($id);
|
||||
$this->__deleteHasMany($id, $cascade);
|
||||
$this->__deleteHasOne($id, $cascade);
|
||||
$this->_deleteMulti($id);
|
||||
$this->_deleteHasMany($id, $cascade);
|
||||
$this->_deleteHasOne($id, $cascade);
|
||||
$this->afterDelete();
|
||||
$this->_clearCache();
|
||||
$this->id = false;
|
||||
|
@ -1087,9 +1097,9 @@ class Model extends Object
|
|||
*
|
||||
* @param string $id
|
||||
* @return null
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __deleteHasMany ($id, $cascade)
|
||||
function _deleteHasMany ($id, $cascade)
|
||||
{
|
||||
foreach ($this->hasMany as $assoc => $data)
|
||||
{
|
||||
|
@ -1113,9 +1123,9 @@ class Model extends Object
|
|||
*
|
||||
* @param string $id
|
||||
* @return null
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __deleteHasOne ($id, $cascade)
|
||||
function _deleteHasOne ($id, $cascade)
|
||||
{
|
||||
foreach ($this->hasOne as $assoc => $data)
|
||||
{
|
||||
|
@ -1139,9 +1149,9 @@ class Model extends Object
|
|||
*
|
||||
* @param string $id
|
||||
* @return null
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __deleteMulti ($id)
|
||||
function _deleteMulti ($id)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
foreach ($this->hasAndBelongsToMany as $assoc => $data)
|
||||
|
@ -1442,6 +1452,11 @@ class Model extends Object
|
|||
*/
|
||||
function invalidFields ($data = array())
|
||||
{
|
||||
if(!$this->beforeValidate())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($this->validate))
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -780,13 +780,28 @@ class Model extends Object
|
|||
}
|
||||
if ($data = $this->find($conditions, $name, $order, 0))
|
||||
{
|
||||
if (isset($data[$this->name][$name]))
|
||||
if (strpos($name, '.') === false)
|
||||
{
|
||||
return $data[$this->name][$name];
|
||||
if (isset($data[$this->name][$name]))
|
||||
{
|
||||
return $data[$this->name][$name];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
$name = explode('.', $name);
|
||||
if (isset($data[$name[0]][$name[1]]))
|
||||
{
|
||||
return $data[$name[0]][$name[1]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -835,11 +850,6 @@ class Model extends Object
|
|||
$whitelist = !(empty($fieldList) || count($fieldList) == 0);
|
||||
$this->validationErrors = array();
|
||||
|
||||
if(!$this->beforeValidate())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($validate && !$this->validates())
|
||||
{
|
||||
return false;
|
||||
|
@ -1054,9 +1064,9 @@ class Model extends Object
|
|||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
if ($this->id && $db->delete($this))
|
||||
{
|
||||
$this->__deleteMulti($id);
|
||||
$this->__deleteHasMany($id, $cascade);
|
||||
$this->__deleteHasOne($id, $cascade);
|
||||
$this->_deleteMulti($id);
|
||||
$this->_deleteHasMany($id, $cascade);
|
||||
$this->_deleteHasOne($id, $cascade);
|
||||
$this->afterDelete();
|
||||
$this->_clearCache();
|
||||
$this->id = false;
|
||||
|
@ -1083,9 +1093,9 @@ class Model extends Object
|
|||
*
|
||||
* @param string $id
|
||||
* @return null
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __deleteHasMany ($id, $cascade)
|
||||
function _deleteHasMany ($id, $cascade)
|
||||
{
|
||||
foreach ($this->hasMany as $assoc => $data)
|
||||
{
|
||||
|
@ -1109,9 +1119,9 @@ class Model extends Object
|
|||
*
|
||||
* @param string $id
|
||||
* @return null
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __deleteHasOne ($id, $cascade)
|
||||
function _deleteHasOne ($id, $cascade)
|
||||
{
|
||||
foreach ($this->hasOne as $assoc => $data)
|
||||
{
|
||||
|
@ -1135,9 +1145,9 @@ class Model extends Object
|
|||
*
|
||||
* @param string $id
|
||||
* @return null
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __deleteMulti ($id)
|
||||
function _deleteMulti ($id)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
foreach ($this->hasAndBelongsToMany as $assoc => $data)
|
||||
|
@ -1438,6 +1448,11 @@ class Model extends Object
|
|||
*/
|
||||
function invalidFields ($data = array())
|
||||
{
|
||||
if(!$this->beforeValidate())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($this->validate))
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -308,7 +308,7 @@ class CakeSession extends Object
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __destroyInvalid()
|
||||
function destroyInvalid()
|
||||
{
|
||||
$sessionpath = session_save_path();
|
||||
if (empty($sessionpath))
|
||||
|
@ -468,7 +468,7 @@ class CakeSession extends Object
|
|||
{
|
||||
$this->valid = false;
|
||||
$this->__setError(1, "Session Highjacking Attempted !!!");
|
||||
$this->__destroyInvalid();
|
||||
$this->destroyInvalid();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -415,7 +415,7 @@ class AjaxHelper extends Helper
|
|||
{
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -309,6 +309,7 @@ function url($url = null, $return = false)
|
|||
if(!empty($htmlAttributes['value']) && !$value)
|
||||
{
|
||||
$value = $htmlAttributes['value'];
|
||||
unset($htmlAttributes['value']);
|
||||
}
|
||||
|
||||
if ($this->tagIsInvalid($this->model, $this->field))
|
||||
|
|
|
@ -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');
|
||||
$uses = array();
|
||||
|
||||
|
@ -983,23 +985,26 @@ class Bake {
|
|||
if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes')
|
||||
{
|
||||
$controllerModel = $inflect->singularize($controllerClassName);
|
||||
loadModels();
|
||||
$tempModel = new $controllerModel();
|
||||
|
||||
$actions .= "\n";
|
||||
$actions .= "\tfunction index()\n";
|
||||
$actions .= "\t{\n";
|
||||
$actions .= "\t\t\$this->{$controllerModel}->recursive = 0;\n";
|
||||
$actions .= "\t\t\$this->set('data', \$this->{$controllerModel}->findAll());\n";
|
||||
$actions .= "\t}\n";
|
||||
|
||||
$actions .= "\n";
|
||||
$actions .= "\tfunction add()\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\t\$this->render();\n";
|
||||
$actions .= "\t\t}\n";
|
||||
$actions .= "\t\telse\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\t\$this->flash('{$controllerModel} saved.', '/{$controllerName}/index');\n";
|
||||
$actions .= "\t\t\t}\n";
|
||||
|
@ -1013,19 +1018,19 @@ class Bake {
|
|||
$actions .= "\n";
|
||||
$actions .= "\tfunction edit(\$id)\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\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\telse\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\t\$this->flash('{$controllerModel} saved.', '/{$controllerName}/index');\n";
|
||||
$actions .= "\t\t\t}\n";
|
||||
$actions .= "\t\t\telse\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->render();\n";
|
||||
$actions .= "\t\t\t}\n";
|
||||
|
@ -1035,7 +1040,7 @@ class Bake {
|
|||
$actions .= "\n";
|
||||
$actions .= "\tfunction view(\$id)\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 .= "\n";
|
||||
|
@ -1047,13 +1052,19 @@ class Bake {
|
|||
$actions .= "\n";
|
||||
|
||||
$lowerCaseModel = strtolower(substr($controllerModel, 0, 1)) . substr($controllerModel, 1);
|
||||
if($tempModel->displayField === null)
|
||||
{
|
||||
$tempModel->displayField = 'name';
|
||||
}
|
||||
|
||||
|
||||
$actions .= "\tfunction {$lowerCaseModel}List()\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\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 .= "\n";
|
||||
$actions .= "\t\treturn \$list;\n";
|
||||
|
@ -1761,7 +1772,7 @@ class Bake {
|
|||
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));
|
||||
$tagNameArray = explode('/', $tagName);
|
||||
|
@ -1842,7 +1853,11 @@ function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $s
|
|||
else
|
||||
{
|
||||
$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->tagErrorMsg('{$tagName}', 'Error message for {$tagNameArray[1]} goes here.') ?>\n";
|
||||
}
|
||||
|
@ -1948,4 +1963,4 @@ Make options array in selectTag dynamic (create a listModels function in the con
|
|||
|
||||
*/
|
||||
|
||||
?>
|
||||
?>
|
Loading…
Reference in a new issue