mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch 'master' into 1.3
This commit is contained in:
commit
fdd63d4e8e
29 changed files with 617 additions and 115 deletions
|
@ -336,7 +336,12 @@ class AclShell extends Shell {
|
||||||
}
|
}
|
||||||
$last = $n[$class]['rght'];
|
$last = $n[$class]['rght'];
|
||||||
$count = count($stack);
|
$count = count($stack);
|
||||||
$this->out(str_repeat(' ', $count) . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
|
$indent = str_repeat(' ', $count);
|
||||||
|
if ($n[$class]['alias']) {
|
||||||
|
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
|
||||||
|
} else {
|
||||||
|
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['model'] . '.' . $n[$class]['foreign_key'] . "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->hr();
|
$this->hr();
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ class DbConfigTask extends Shell {
|
||||||
if ($info['persistent'] === false) {
|
if ($info['persistent'] === false) {
|
||||||
$info['persistent'] = 'false';
|
$info['persistent'] = 'false';
|
||||||
} else {
|
} else {
|
||||||
$info['persistent'] = 'false';
|
$info['persistent'] = ($info['persistent'] == true) ? 'true' : 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldConfigs[] = array(
|
$oldConfigs[] = array(
|
||||||
|
|
|
@ -50,16 +50,16 @@
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<?php if ($action != 'add'):?>
|
<?php if ($action != 'add'):?>
|
||||||
<li><?php echo "<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \$form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
|
<li><?php echo "<?php echo \$html->link(__('Delete', true), array('action' => 'delete', \$form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<li><?php echo "<?php echo \$html->link(__('List {$pluralHumanName}', true), array('action'=>'index'));?>";?></li>
|
<li><?php echo "<?php echo \$html->link(__('List {$pluralHumanName}', true), array('action' => 'index'));?>";?></li>
|
||||||
<?php
|
<?php
|
||||||
$done = array();
|
$done = array();
|
||||||
foreach ($associations as $type => $data) {
|
foreach ($associations as $type => $data) {
|
||||||
foreach ($data as $alias => $details) {
|
foreach ($data as $alias => $details) {
|
||||||
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
||||||
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||||
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||||
$done[] = $details['controller'];
|
$done[] = $details['controller'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ foreach (\${$pluralVar} as \${$singularVar}):
|
||||||
foreach ($associations['belongsTo'] as $alias => $details) {
|
foreach ($associations['belongsTo'] as $alias => $details) {
|
||||||
if ($field === $details['foreignKey']) {
|
if ($field === $details['foreignKey']) {
|
||||||
$isKey = true;
|
$isKey = true;
|
||||||
echo "\t\t<td>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller'=> '{$details['controller']}', 'action'=>'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t</td>\n";
|
echo "\t\t<td>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t</td>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,9 @@ foreach (\${$pluralVar} as \${$singularVar}):
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\t\t<td class=\"actions\">\n";
|
echo "\t\t<td class=\"actions\">\n";
|
||||||
echo "\t\t\t<?php echo \$html->link(__('View', true), array('action'=>'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
|
echo "\t\t\t<?php echo \$html->link(__('View', true), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
|
||||||
echo "\t\t\t<?php echo \$html->link(__('Edit', true), array('action'=>'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
|
echo "\t\t\t<?php echo \$html->link(__('Edit', true), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
|
||||||
echo "\t\t\t<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
|
echo "\t\t\t<?php echo \$html->link(__('Delete', true), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
|
||||||
echo "\t\t</td>\n";
|
echo "\t\t</td>\n";
|
||||||
echo "\t</tr>\n";
|
echo "\t</tr>\n";
|
||||||
|
|
||||||
|
@ -78,18 +78,18 @@ echo "<?php endforeach; ?>\n";
|
||||||
<div class="paging">
|
<div class="paging">
|
||||||
<?php echo "\t<?php echo \$paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?>
|
<?php echo "\t<?php echo \$paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?>
|
||||||
| <?php echo "\t<?php echo \$paginator->numbers();?>\n"?>
|
| <?php echo "\t<?php echo \$paginator->numbers();?>\n"?>
|
||||||
<?php echo "\t<?php echo \$paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>\n";?>
|
<?php echo "\t<?php echo \$paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>\n";?>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo "<?php echo \$html->link(__('New {$singularHumanName}', true), array('action'=>'add')); ?>";?></li>
|
<li><?php echo "<?php echo \$html->link(__('New {$singularHumanName}', true), array('action' => 'add')); ?>";?></li>
|
||||||
<?php
|
<?php
|
||||||
$done = array();
|
$done = array();
|
||||||
foreach ($associations as $type => $data) {
|
foreach ($associations as $type => $data) {
|
||||||
foreach ($data as $alias => $details) {
|
foreach ($data as $alias => $details) {
|
||||||
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
||||||
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||||
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||||
$done[] = $details['controller'];
|
$done[] = $details['controller'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ foreach ($fields as $field) {
|
||||||
if ($field === $details['foreignKey']) {
|
if ($field === $details['foreignKey']) {
|
||||||
$isKey = true;
|
$isKey = true;
|
||||||
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
|
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
|
||||||
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller'=> '{$details['controller']}', 'action'=>'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t \n\t\t</dd>\n";
|
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t \n\t\t</dd>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,17 +49,17 @@ foreach ($fields as $field) {
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
echo "\t\t<li><?php echo \$html->link(__('Edit {$singularHumanName}', true), array('action'=>'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('Edit {$singularHumanName}', true), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||||
echo "\t\t<li><?php echo \$html->link(__('Delete {$singularHumanName}', true), array('action'=>'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('Delete {$singularHumanName}', true), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||||
echo "\t\t<li><?php echo \$html->link(__('List {$pluralHumanName}', true), array('action'=>'index')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('List {$pluralHumanName}', true), array('action' => 'index')); ?> </li>\n";
|
||||||
echo "\t\t<li><?php echo \$html->link(__('New {$singularHumanName}', true), array('action'=>'add')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('New {$singularHumanName}', true), array('action' => 'add')); ?> </li>\n";
|
||||||
|
|
||||||
$done = array();
|
$done = array();
|
||||||
foreach ($associations as $type => $data) {
|
foreach ($associations as $type => $data) {
|
||||||
foreach ($data as $alias => $details) {
|
foreach ($data as $alias => $details) {
|
||||||
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
||||||
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||||
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
|
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||||
$done[] = $details['controller'];
|
$done[] = $details['controller'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ if (!empty($associations['hasOne'])) :
|
||||||
<?php echo "<?php endif; ?>\n";?>
|
<?php echo "<?php endif; ?>\n";?>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo "<?php echo \$html->link(__('Edit ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
|
<li><?php echo "<?php echo \$html->link(__('Edit ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -131,9 +131,9 @@ echo "\t<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\t\t\t<td class=\"actions\">\n";
|
echo "\t\t\t<td class=\"actions\">\n";
|
||||||
echo "\t\t\t\t<?php echo \$html->link(__('View', true), array('controller'=> '{$details['controller']}', 'action'=>'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
echo "\t\t\t\t<?php echo \$html->link(__('View', true), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||||
echo "\t\t\t\t<?php echo \$html->link(__('Edit', true), array('controller'=> '{$details['controller']}', 'action'=>'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
echo "\t\t\t\t<?php echo \$html->link(__('Edit', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||||
echo "\t\t\t\t<?php echo \$html->link(__('Delete', true), array('controller'=> '{$details['controller']}', 'action'=>'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
echo "\t\t\t\t<?php echo \$html->link(__('Delete', true), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||||
echo "\t\t\t</td>\n";
|
echo "\t\t\t</td>\n";
|
||||||
echo "\t\t</tr>\n";
|
echo "\t\t</tr>\n";
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ echo "\t<?php endforeach; ?>\n";
|
||||||
<?php echo "<?php endif; ?>\n\n";?>
|
<?php echo "<?php endif; ?>\n\n";?>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add'));?>";?> </li>
|
<li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -339,7 +339,7 @@ class AuthComponent extends Object {
|
||||||
$this->Session->setFlash($this->authError, 'default', array(), 'auth');
|
$this->Session->setFlash($this->authError, 'default', array(), 'auth');
|
||||||
if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
|
if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
|
||||||
$query = $controller->params['url'];
|
$query = $controller->params['url'];
|
||||||
unset($query['url']);
|
unset($query['url'], $query['ext']);
|
||||||
$url .= Router::queryString($query, array());
|
$url .= Router::queryString($query, array());
|
||||||
}
|
}
|
||||||
$this->Session->write('Auth.redirect', $url);
|
$this->Session->write('Auth.redirect', $url);
|
||||||
|
|
|
@ -168,8 +168,8 @@ class Scaffold extends Object {
|
||||||
$displayField = $this->ScaffoldModel->displayField;
|
$displayField = $this->ScaffoldModel->displayField;
|
||||||
$singularVar = Inflector::variable($modelClass);
|
$singularVar = Inflector::variable($modelClass);
|
||||||
$pluralVar = Inflector::variable($this->controller->name);
|
$pluralVar = Inflector::variable($this->controller->name);
|
||||||
$singularHumanName = Inflector::humanize($modelClass);
|
$singularHumanName = Inflector::humanize(Inflector::underscore($modelClass));
|
||||||
$pluralHumanName = Inflector::humanize($this->controller->name);
|
$pluralHumanName = Inflector::humanize(Inflector::underscore($this->controller->name));
|
||||||
$scaffoldFields = array_keys($this->ScaffoldModel->schema());
|
$scaffoldFields = array_keys($this->ScaffoldModel->schema());
|
||||||
$associations = $this->__associations();
|
$associations = $this->__associations();
|
||||||
|
|
||||||
|
|
|
@ -877,9 +877,10 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$scope['NOT'][$Model->alias . '.' . $Model->primaryKey] = $Model->id;
|
$scope['NOT'][$Model->alias . '.' . $Model->primaryKey] = $Model->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$name = $Model->alias . '.' . $right;
|
||||||
list($edge) = array_values($Model->find('first', array(
|
list($edge) = array_values($Model->find('first', array(
|
||||||
'conditions' => $scope,
|
'conditions' => $scope,
|
||||||
'fields' => $db->calculate($Model, 'max', array($right)),
|
'fields' => $db->calculate($Model, 'max', array($name, $right)),
|
||||||
'recursive' => $recursive
|
'recursive' => $recursive
|
||||||
)));
|
)));
|
||||||
return (empty($edge[$right])) ? 0 : $edge[$right];
|
return (empty($edge[$right])) ? 0 : $edge[$right];
|
||||||
|
@ -895,9 +896,10 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function __getMin($Model, $scope, $left, $recursive = -1) {
|
function __getMin($Model, $scope, $left, $recursive = -1) {
|
||||||
$db =& ConnectionManager::getDataSource($Model->useDbConfig);
|
$db =& ConnectionManager::getDataSource($Model->useDbConfig);
|
||||||
|
$name = $Model->alias . '.' . $left;
|
||||||
list($edge) = array_values($Model->find('first', array(
|
list($edge) = array_values($Model->find('first', array(
|
||||||
'conditions' => $scope,
|
'conditions' => $scope,
|
||||||
'fields' => $db->calculate($Model, 'min', array($left)),
|
'fields' => $db->calculate($Model, 'min', array($name, $left)),
|
||||||
'recursive' => $recursive
|
'recursive' => $recursive
|
||||||
)));
|
)));
|
||||||
return (empty($edge[$left])) ? 0 : $edge[$left];
|
return (empty($edge[$left])) ? 0 : $edge[$left];
|
||||||
|
|
|
@ -384,7 +384,7 @@ class DboMssql extends DboSource {
|
||||||
$error = mssql_get_last_message($this->connection);
|
$error = mssql_get_last_message($this->connection);
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
if (!preg_match('/contexto de la base de datos a|contesto di database|changed database/i', $error)) {
|
if (!preg_match('/contexto de la base de datos a|contesto di database|changed database|datenbankkontext/i', $error)) {
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ class DboSqlite extends DboSource {
|
||||||
'primary_key' => array('name' => 'integer primary key'),
|
'primary_key' => array('name' => 'integer primary key'),
|
||||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||||
'text' => array('name' => 'text'),
|
'text' => array('name' => 'text'),
|
||||||
'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
|
'integer' => array('name' => 'integer', 'limit' => 11, 'formatter' => 'intval'),
|
||||||
'float' => array('name' => 'float', 'formatter' => 'floatval'),
|
'float' => array('name' => 'float', 'formatter' => 'floatval'),
|
||||||
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
|
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
|
||||||
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
|
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
|
||||||
|
@ -196,12 +196,13 @@ class DboSqlite extends DboSource {
|
||||||
'length' => $this->length($column[0]['type'])
|
'length' => $this->length($column[0]['type'])
|
||||||
);
|
);
|
||||||
if ($column[0]['pk'] == 1) {
|
if ($column[0]['pk'] == 1) {
|
||||||
|
$colLength = $this->length($column[0]['type']);
|
||||||
$fields[$column[0]['name']] = array(
|
$fields[$column[0]['name']] = array(
|
||||||
'type' => $fields[$column[0]['name']]['type'],
|
'type' => $fields[$column[0]['name']]['type'],
|
||||||
'null' => false,
|
'null' => false,
|
||||||
'default' => $column[0]['dflt_value'],
|
'default' => $column[0]['dflt_value'],
|
||||||
'key' => $this->index['PRI'],
|
'key' => $this->index['PRI'],
|
||||||
'length' => 11
|
'length'=> ($colLength != null) ? $colLength : 11
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,11 +450,10 @@ class DboSqlite extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
$real = $this->columns[$type];
|
$real = $this->columns[$type];
|
||||||
if (isset($column['key']) && $column['key'] == 'primary') {
|
|
||||||
$out = $this->name($name) . ' ' . $this->columns['primary_key']['name'];
|
|
||||||
} else {
|
|
||||||
$out = $this->name($name) . ' ' . $real['name'];
|
$out = $this->name($name) . ' ' . $real['name'];
|
||||||
|
if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
|
||||||
|
return $this->name($name) . ' ' . $this->columns['primary_key']['name'];
|
||||||
|
}
|
||||||
if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) {
|
if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) {
|
||||||
if (isset($column['length'])) {
|
if (isset($column['length'])) {
|
||||||
$length = $column['length'];
|
$length = $column['length'];
|
||||||
|
@ -466,7 +466,9 @@ class DboSqlite extends DboSource {
|
||||||
}
|
}
|
||||||
$out .= '(' . $length . ')';
|
$out .= '(' . $length . ')';
|
||||||
}
|
}
|
||||||
if (isset($column['key']) && $column['key'] == 'primary') {
|
if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
|
||||||
|
$out .= ' ' . $this->columns['primary_key']['name'];
|
||||||
|
} elseif (isset($column['key']) && $column['key'] == 'primary') {
|
||||||
$out .= ' NOT NULL';
|
$out .= ' NOT NULL';
|
||||||
} elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
|
} elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
|
||||||
$out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
|
$out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
|
||||||
|
@ -477,7 +479,6 @@ class DboSqlite extends DboSource {
|
||||||
} elseif (isset($column['null']) && $column['null'] == false) {
|
} elseif (isset($column['null']) && $column['null'] == false) {
|
||||||
$out .= ' NOT NULL';
|
$out .= ' NOT NULL';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -812,13 +812,18 @@ class Model extends Overloadable {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function deconstruct($field, $data) {
|
function deconstruct($field, $data) {
|
||||||
|
if (!is_array($data)) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
$copy = $data;
|
$copy = $data;
|
||||||
$type = $this->getColumnType($field);
|
$type = $this->getColumnType($field);
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
|
||||||
|
|
||||||
if (in_array($type, array('datetime', 'timestamp', 'date', 'time'))) {
|
if (in_array($type, array('datetime', 'timestamp', 'date', 'time'))) {
|
||||||
$useNewDate = (isset($data['year']) || isset($data['month']) || isset($data['day']) || isset($data['hour']) || isset($data['minute']));
|
$useNewDate = (isset($data['year']) || isset($data['month']) || isset($data['day']) || isset($data['hour']) || isset($data['minute']));
|
||||||
$dateFields = array('Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec');
|
$dateFields = array('Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec');
|
||||||
|
|
||||||
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
$format = $db->columns[$type]['format'];
|
$format = $db->columns[$type]['format'];
|
||||||
$date = array();
|
$date = array();
|
||||||
|
|
||||||
|
@ -2770,7 +2775,7 @@ class Model extends Overloadable {
|
||||||
function afterSave($created) {
|
function afterSave($created) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Called after every deletion operation.
|
* Called before every deletion operation.
|
||||||
*
|
*
|
||||||
* @param boolean $cascade If true records that depend on this record will also be deleted
|
* @param boolean $cascade If true records that depend on this record will also be deleted
|
||||||
* @return boolean True if the operation should continue, false if it should abort
|
* @return boolean True if the operation should continue, false if it should abort
|
||||||
|
|
|
@ -138,10 +138,8 @@ class CakeSession extends Object {
|
||||||
|
|
||||||
if ($start === true) {
|
if ($start === true) {
|
||||||
$this->host = env('HTTP_HOST');
|
$this->host = env('HTTP_HOST');
|
||||||
|
|
||||||
if (empty($base) || strpos($base, '?') === 0 || strpos($base, 'index.php') === 0) {
|
|
||||||
$this->path = '/';
|
$this->path = '/';
|
||||||
} else {
|
if (strpos($base, '?') === false && strpos($base, 'index.php') === false) {
|
||||||
$this->path = $base;
|
$this->path = $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,7 @@ class FormHelper extends AppHelper {
|
||||||
'id' => $options['id'] . '_', 'name' => $options['name'],
|
'id' => $options['id'] . '_', 'name' => $options['name'],
|
||||||
'value' => '0', 'secure' => false
|
'value' => '0', 'secure' => false
|
||||||
);
|
);
|
||||||
if (isset($options['disabled'])) {
|
if (isset($options['disabled']) && $options['disabled'] == true) {
|
||||||
$hiddenOptions['disabled'] = 'disabled';
|
$hiddenOptions['disabled'] = 'disabled';
|
||||||
}
|
}
|
||||||
$output = $this->hidden($fieldName, $hiddenOptions);
|
$output = $this->hidden($fieldName, $hiddenOptions);
|
||||||
|
|
|
@ -316,8 +316,10 @@ class HtmlHelper extends AppHelper {
|
||||||
/**
|
/**
|
||||||
* Creates a link element for CSS stylesheets.
|
* Creates a link element for CSS stylesheets.
|
||||||
*
|
*
|
||||||
* @param mixed $path The name of a CSS style sheet in /app/webroot/css, or an array containing names of CSS stylesheets in that directory.
|
* @param mixed $path The name of a CSS style sheet or an array containing names of
|
||||||
* @param string $rel Rel attribute. Defaults to "stylesheet".
|
* CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot
|
||||||
|
* of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.
|
||||||
|
* @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported.
|
||||||
* @param array $htmlAttributes Array of HTML attributes.
|
* @param array $htmlAttributes Array of HTML attributes.
|
||||||
* @param boolean $inline If set to false, the generated tag appears in the head tag of the layout.
|
* @param boolean $inline If set to false, the generated tag appears in the head tag of the layout.
|
||||||
* @return string CSS <link /> or <style /> tag, depending on the type of link.
|
* @return string CSS <link /> or <style /> tag, depending on the type of link.
|
||||||
|
|
|
@ -32,16 +32,16 @@
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<?php if ($this->action != 'add'):?>
|
<?php if ($this->action != 'add'):?>
|
||||||
<li><?php echo $html->link(__('Delete', true), array('action'=>'delete', $form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $form->value($modelClass.'.'.$primaryKey)); ?></li>
|
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $form->value($modelClass.'.'.$primaryKey)); ?></li>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<li><?php echo $html->link(__('List', true).' '.$pluralHumanName, array('action'=>'index'));?></li>
|
<li><?php echo $html->link(__('List', true).' '.$pluralHumanName, array('action' => 'index'));?></li>
|
||||||
<?php
|
<?php
|
||||||
$done = array();
|
$done = array();
|
||||||
foreach ($associations as $_type => $_data) {
|
foreach ($associations as $_type => $_data) {
|
||||||
foreach ($_data as $_alias => $_details) {
|
foreach ($_data as $_alias => $_details) {
|
||||||
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
||||||
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
|
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index'))."</li>\n";
|
||||||
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
|
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add'))."</li>\n";
|
||||||
$done[] = $_details['controller'];
|
$done[] = $_details['controller'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ echo "\n";
|
||||||
foreach ($associations['belongsTo'] as $_alias => $_details) {
|
foreach ($associations['belongsTo'] as $_alias => $_details) {
|
||||||
if ($_field === $_details['foreignKey']) {
|
if ($_field === $_details['foreignKey']) {
|
||||||
$isKey = true;
|
$isKey = true;
|
||||||
echo "\t\t<td>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n";
|
echo "\t\t<td>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,9 @@ echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\t\t<td class=\"actions\">\n";
|
echo "\t\t<td class=\"actions\">\n";
|
||||||
echo "\t\t\t" . $html->link(__('View', true), array('action'=>'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
|
echo "\t\t\t" . $html->link(__('View', true), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
|
||||||
echo "\t\t\t" . $html->link(__('Edit', true), array('action'=>'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
|
echo "\t\t\t" . $html->link(__('Edit', true), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
|
||||||
echo "\t\t\t" . $html->link(__('Delete', true), array('action'=>'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n";
|
echo "\t\t\t" . $html->link(__('Delete', true), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n";
|
||||||
echo "\t\t</td>\n";
|
echo "\t\t</td>\n";
|
||||||
echo "\t</tr>\n";
|
echo "\t</tr>\n";
|
||||||
|
|
||||||
|
@ -74,20 +74,20 @@ echo "\n";
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="paging">
|
<div class="paging">
|
||||||
<?php echo "\t" . $paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled')) . "\n";?>
|
<?php echo "\t" . $paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?>
|
||||||
| <?php echo $paginator->numbers() . "\n"?>
|
| <?php echo $paginator->numbers() . "\n"?>
|
||||||
<?php echo "\t ". $paginator->next(__('next', true) .' >>', array(), null, array('class'=>'disabled')) . "\n";?>
|
<?php echo "\t ". $paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link('New '.$singularHumanName, array('action'=>'add')); ?></li>
|
<li><?php echo $html->link('New '.$singularHumanName, array('action' => 'add')); ?></li>
|
||||||
<?php
|
<?php
|
||||||
$done = array();
|
$done = array();
|
||||||
foreach ($associations as $_type => $_data) {
|
foreach ($associations as $_type => $_data) {
|
||||||
foreach ($_data as $_alias => $_details) {
|
foreach ($_data as $_alias => $_details) {
|
||||||
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
||||||
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
|
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."</li>\n";
|
||||||
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
|
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."</li>\n";
|
||||||
$done[] = $_details['controller'];
|
$done[] = $_details['controller'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ foreach ($scaffoldFields as $_field) {
|
||||||
if ($_field === $_details['foreignKey']) {
|
if ($_field === $_details['foreignKey']) {
|
||||||
$isKey = true;
|
$isKey = true;
|
||||||
echo "\t\t<dt{$class}>".Inflector::humanize($_alias)."</dt>\n";
|
echo "\t\t<dt{$class}>".Inflector::humanize($_alias)."</dt>\n";
|
||||||
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t </dd>\n";
|
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t </dd>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,17 @@ foreach ($scaffoldFields as $_field) {
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
echo "\t\t<li>" .$html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action'=>'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
|
echo "\t\t<li>" .$html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
|
||||||
echo "\t\t<li>" .$html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action'=>'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
|
echo "\t\t<li>" .$html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
|
||||||
echo "\t\t<li>" .$html->link(sprintf(__('List %s', true), $pluralHumanName), array('action'=>'index')). " </li>\n";
|
echo "\t\t<li>" .$html->link(sprintf(__('List %s', true), $pluralHumanName), array('action' => 'index')). " </li>\n";
|
||||||
echo "\t\t<li>" .$html->link(sprintf(__('New %s', true), $singularHumanName), array('action'=>'add')). " </li>\n";
|
echo "\t\t<li>" .$html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')). " </li>\n";
|
||||||
|
|
||||||
$done = array();
|
$done = array();
|
||||||
foreach ($associations as $_type => $_data) {
|
foreach ($associations as $_type => $_data) {
|
||||||
foreach ($_data as $_alias => $_details) {
|
foreach ($_data as $_alias => $_details) {
|
||||||
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
||||||
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
|
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."</li>\n";
|
||||||
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
|
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."</li>\n";
|
||||||
$done[] = $_details['controller'];
|
$done[] = $_details['controller'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
|
<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -141,9 +141,9 @@ $otherSingularVar = Inflector::variable($_alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\t\t\t<td class=\"actions\">\n";
|
echo "\t\t\t<td class=\"actions\">\n";
|
||||||
echo "\t\t\t\t" . $html->link(__('View', true), array('controller'=> $_details['controller'], 'action'=>'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
|
echo "\t\t\t\t" . $html->link(__('View', true), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
|
||||||
echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller'=> $_details['controller'], 'action'=>'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
|
echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
|
||||||
echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller'=> $_details['controller'], 'action'=>'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
|
echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
|
||||||
echo "\t\t\t</td>\n";
|
echo "\t\t\t</td>\n";
|
||||||
echo "\t\t</tr>\n";
|
echo "\t\t</tr>\n";
|
||||||
endforeach;
|
endforeach;
|
||||||
|
@ -152,7 +152,7 @@ $otherSingularVar = Inflector::variable($_alias);
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'));?> </li>
|
<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
128
cake/tests/cases/console/libs/acl.test.php
Normal file
128
cake/tests/cases/console/libs/acl.test.php
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* AclShell Test file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
||||||
|
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||||
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.console.libs.tasks
|
||||||
|
* @since CakePHP v 1.2.0.7726
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
|
*/
|
||||||
|
App::import('Core', 'Shell');
|
||||||
|
|
||||||
|
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
||||||
|
define('DISABLE_AUTO_DISPATCH', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!class_exists('ShellDispatcher')) {
|
||||||
|
ob_start();
|
||||||
|
$argv = false;
|
||||||
|
require CAKE . 'console' . DS . 'cake.php';
|
||||||
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!class_exists('AclShell')) {
|
||||||
|
require CAKE . 'console' . DS . 'libs' . DS . 'acl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
Mock::generatePartial(
|
||||||
|
'ShellDispatcher', 'TestAclShellMockShellDispatcher',
|
||||||
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
||||||
|
);
|
||||||
|
Mock::generatePartial(
|
||||||
|
'AclShell', 'MockAclShell',
|
||||||
|
array('in', 'out', 'hr', 'createFile')
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* AclShellTest class
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.console.libs.tasks
|
||||||
|
*/
|
||||||
|
class AclShellTest extends CakeTestCase {
|
||||||
|
var $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
|
||||||
|
/**
|
||||||
|
* configure Configure for testcase
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function startCase() {
|
||||||
|
$this->_aclDb = Configure::read('Acl.database');
|
||||||
|
$this->_aclClass = Configure::read('Acl.classname');
|
||||||
|
|
||||||
|
Configure::write('Acl.database', 'test_suite');
|
||||||
|
Configure::write('Acl.classname', 'DbAcl');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* restore Environment settings
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function endCase() {
|
||||||
|
Configure::write('Acl.database', $this->_aclDb);
|
||||||
|
Configure::write('Acl.classname', $this->_aclClass);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* setUp method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function startTest() {
|
||||||
|
$this->Dispatcher =& new TestAclShellMockShellDispatcher();
|
||||||
|
$this->Task =& new MockAclShell($this->Dispatcher);
|
||||||
|
$this->Task->Dispatch = new $this->Dispatcher;
|
||||||
|
$this->Task->params['datasource'] = 'test_suite';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tearDown method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function endTest() {
|
||||||
|
ClassRegistry::flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that model.foreign_key output works when looking at acl rows
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testViewWithModelForeignKeyOutput() {
|
||||||
|
$this->Task->command = 'view';
|
||||||
|
$this->Task->startup();
|
||||||
|
$data = array(
|
||||||
|
'parent_id' => null,
|
||||||
|
'model' => 'MyModel',
|
||||||
|
'foreign_key' => 2,
|
||||||
|
);
|
||||||
|
$this->Task->Acl->Aro->create($data);
|
||||||
|
$this->Task->Acl->Aro->save();
|
||||||
|
$this->Task->args[0] = 'aro';
|
||||||
|
|
||||||
|
$this->Task->expectAt(0, 'out', array('Aro tree:'));
|
||||||
|
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/\[1\]ROOT/')));
|
||||||
|
$this->Task->expectAt(3, 'out', array(new PatternExpectation('/\[3\]Gandalf/')));
|
||||||
|
$this->Task->expectAt(5, 'out', array(new PatternExpectation('/\[5\]MyModel.2/')));
|
||||||
|
|
||||||
|
$this->Task->view();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -116,6 +116,9 @@ class CodeCoverageManagerTest extends CakeTestCase {
|
||||||
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
|
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
|
||||||
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);
|
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);
|
||||||
|
|
||||||
|
$expected = $manager->__testObjectFileFromCaseFile('datasources/some_file.test.php', true);
|
||||||
|
$this->assertIdentical(APP.'models'.DS.'datasources'.DS.'some_file.php', $expected);
|
||||||
|
|
||||||
$expected = $manager->__testObjectFileFromCaseFile('controllers/some_file.test.php', true);
|
$expected = $manager->__testObjectFileFromCaseFile('controllers/some_file.test.php', true);
|
||||||
$this->assertIdentical(APP.'controllers'.DS.'some_file.php', $expected);
|
$this->assertIdentical(APP.'controllers'.DS.'some_file.php', $expected);
|
||||||
|
|
||||||
|
|
|
@ -728,6 +728,7 @@ class AuthTest extends CakeTestCase {
|
||||||
$this->Controller->params['action'] = 'Add';
|
$this->Controller->params['action'] = 'Add';
|
||||||
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
|
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testLoginRedirect method
|
* testLoginRedirect method
|
||||||
*
|
*
|
||||||
|
@ -854,6 +855,22 @@ class AuthTest extends CakeTestCase {
|
||||||
$this->Controller->Auth->startup($this->Controller);
|
$this->Controller->Auth->startup($this->Controller);
|
||||||
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
|
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
|
||||||
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
||||||
|
|
||||||
|
$_GET = array(
|
||||||
|
'url' => '/posts/index/29',
|
||||||
|
'print' => 'true',
|
||||||
|
'refer' => 'menu',
|
||||||
|
'ext' => 'html'
|
||||||
|
);
|
||||||
|
$this->Controller->Session->del('Auth');
|
||||||
|
$url = '/posts/index/29?print=true&refer=menu';
|
||||||
|
$this->Controller->params = Dispatcher::parseParams($url);
|
||||||
|
$this->Controller->Auth->initialize($this->Controller);
|
||||||
|
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
|
||||||
|
$this->Controller->Auth->userModel = 'AuthUser';
|
||||||
|
$this->Controller->Auth->startup($this->Controller);
|
||||||
|
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
|
||||||
|
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
|
||||||
$_GET = $_back;
|
$_GET = $_back;
|
||||||
|
|
||||||
//external authed action
|
//external authed action
|
||||||
|
|
|
@ -332,11 +332,11 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
new Scaffold($this->Controller, $params);
|
new Scaffold($this->Controller, $params);
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
|
|
||||||
$this->assertPattern('#<h2>ScaffoldMock</h2>#', $result);
|
$this->assertPattern('#<h2>Scaffold Mock</h2>#', $result);
|
||||||
$this->assertPattern('#<table cellpadding="0" cellspacing="0">#', $result);
|
$this->assertPattern('#<table cellpadding="0" cellspacing="0">#', $result);
|
||||||
//TODO: add testing for table generation
|
//TODO: add testing for table generation
|
||||||
$this->assertPattern('#<a href="/scaffold_users/view/1">1</a>#', $result); //belongsTo links
|
$this->assertPattern('#<a href="/scaffold_users/view/1">1</a>#', $result); //belongsTo links
|
||||||
$this->assertPattern('#<li><a href="/scaffold_mock/add/">New ScaffoldMock</a></li>#', $result);
|
$this->assertPattern('#<li><a href="/scaffold_mock/add/">New Scaffold Mock</a></li>#', $result);
|
||||||
$this->assertPattern('#<li><a href="/scaffold_users/">List Scaffold Users</a></li>#', $result);
|
$this->assertPattern('#<li><a href="/scaffold_users/">List Scaffold Users</a></li>#', $result);
|
||||||
$this->assertPattern('#<li><a href="/scaffold_comments/add/">New Comment</a></li>#', $result);
|
$this->assertPattern('#<li><a href="/scaffold_comments/add/">New Comment</a></li>#', $result);
|
||||||
}
|
}
|
||||||
|
@ -371,12 +371,12 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
new Scaffold($this->Controller, $params);
|
new Scaffold($this->Controller, $params);
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
|
|
||||||
$this->assertPattern('/<h2>View ScaffoldMock<\/h2>/', $result);
|
$this->assertPattern('/<h2>View Scaffold Mock<\/h2>/', $result);
|
||||||
$this->assertPattern('/<dl>/', $result);
|
$this->assertPattern('/<dl>/', $result);
|
||||||
//TODO: add specific tests for fields.
|
//TODO: add specific tests for fields.
|
||||||
$this->assertPattern('/<a href="\/scaffold_users\/view\/1">1<\/a>/', $result); //belongsTo links
|
$this->assertPattern('/<a href="\/scaffold_users\/view\/1">1<\/a>/', $result); //belongsTo links
|
||||||
$this->assertPattern('/<li><a href="\/scaffold_mock\/edit\/1">Edit ScaffoldMock<\/a>\s<\/li>/', $result);
|
$this->assertPattern('/<li><a href="\/scaffold_mock\/edit\/1">Edit Scaffold Mock<\/a>\s<\/li>/', $result);
|
||||||
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete ScaffoldMock<\/a>\s*<\/li>/', $result);
|
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete Scaffold Mock<\/a>\s*<\/li>/', $result);
|
||||||
//check related table
|
//check related table
|
||||||
$this->assertPattern('/<div class="related">\s*<h3>Related Scaffold Comments<\/h3>\s*<table cellpadding="0" cellspacing="0">/', $result);
|
$this->assertPattern('/<div class="related">\s*<h3>Related Scaffold Comments<\/h3>\s*<table cellpadding="0" cellspacing="0">/', $result);
|
||||||
$this->assertPattern('/<li><a href="\/scaffold_comments\/add\/">New Comment<\/a><\/li>/', $result);
|
$this->assertPattern('/<li><a href="\/scaffold_comments\/add\/">New Comment<\/a><\/li>/', $result);
|
||||||
|
@ -459,10 +459,10 @@ class ScaffoldViewTest extends CakeTestCase {
|
||||||
$Scaffold = new Scaffold($this->Controller, $params);
|
$Scaffold = new Scaffold($this->Controller, $params);
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
|
|
||||||
$this->assertPattern('/<h2>ScaffoldMock<\/h2>/', $result);
|
$this->assertPattern('/<h2>Scaffold Mock<\/h2>/', $result);
|
||||||
$this->assertPattern('/<table cellpadding="0" cellspacing="0">/', $result);
|
$this->assertPattern('/<table cellpadding="0" cellspacing="0">/', $result);
|
||||||
//TODO: add testing for table generation
|
//TODO: add testing for table generation
|
||||||
$this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New ScaffoldMock<\/a><\/li>/', $result);
|
$this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New Scaffold Mock<\/a><\/li>/', $result);
|
||||||
|
|
||||||
Configure::write('Routing.admin', $_backAdmin);
|
Configure::write('Routing.admin', $_backAdmin);
|
||||||
}
|
}
|
||||||
|
@ -580,5 +580,44 @@ class ScaffoldTest extends CakeTestCase {
|
||||||
$result = $Scaffold->getParams();
|
$result = $Scaffold->getParams();
|
||||||
$this->assertEqual($result['action'], 'admin_edit');
|
$this->assertEqual($result['action'], 'admin_edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that the proper names and variable values are set by Scaffold
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testScaffoldVariableSetting() {
|
||||||
|
$this->Controller->action = 'admin_edit';
|
||||||
|
$this->Controller->here = '/admin/scaffold_mock/edit';
|
||||||
|
$this->Controller->webroot = '/';
|
||||||
|
$params = array(
|
||||||
|
'plugin' => null,
|
||||||
|
'pass' => array(),
|
||||||
|
'form' => array(),
|
||||||
|
'named' => array(),
|
||||||
|
'url' => array('url' =>'admin/scaffold_mock/edit'),
|
||||||
|
'controller' => 'scaffold_mock',
|
||||||
|
'action' => 'admin_edit',
|
||||||
|
'admin' => true,
|
||||||
|
);
|
||||||
|
//set router.
|
||||||
|
Router::setRequestInfo(array($params, array('base' => '/', 'here' => 'admin/scaffold_mock', 'webroot' => '/')));
|
||||||
|
|
||||||
|
$this->Controller->params = $params;
|
||||||
|
$this->Controller->controller = 'scaffold_mock';
|
||||||
|
$this->Controller->base = '/';
|
||||||
|
$this->Controller->constructClasses();
|
||||||
|
$Scaffold =& new TestScaffoldMock($this->Controller, $params);
|
||||||
|
$result = $this->Controller->viewVars;
|
||||||
|
|
||||||
|
$this->assertEqual($result['singularHumanName'], 'Scaffold Mock');
|
||||||
|
$this->assertEqual($result['pluralHumanName'], 'Scaffold Mock');
|
||||||
|
$this->assertEqual($result['modelClass'], 'ScaffoldMock');
|
||||||
|
$this->assertEqual($result['primaryKey'], 'id');
|
||||||
|
$this->assertEqual($result['displayField'], 'title');
|
||||||
|
$this->assertEqual($result['singularVar'], 'scaffoldMock');
|
||||||
|
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
|
||||||
|
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1229,7 +1229,7 @@ class ScopedTreeTest extends NumberTreeTest {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $fixtures = array('core.flag_tree', 'core.ad', 'core.campaign', 'core.translate');
|
var $fixtures = array('core.flag_tree', 'core.ad', 'core.campaign', 'core.translate', 'core.number_tree_two');
|
||||||
/**
|
/**
|
||||||
* testStringScope method
|
* testStringScope method
|
||||||
*
|
*
|
||||||
|
@ -1433,6 +1433,61 @@ class ScopedTreeTest extends NumberTreeTest {
|
||||||
);
|
);
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* testGenerateTreeListWithSelfJoin method
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function testAliasesWithScopeInTwoTreeAssociations() {
|
||||||
|
extract($this->settings);
|
||||||
|
$this->Tree =& new $modelClass();
|
||||||
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
|
$this->TreeTwo =& new NumberTreeTwo();
|
||||||
|
|
||||||
|
$record = $this->Tree->find('first');
|
||||||
|
|
||||||
|
$this->Tree->bindModel(array(
|
||||||
|
'hasMany' => array(
|
||||||
|
'SecondTree' => array(
|
||||||
|
'className' => 'NumberTreeTwo',
|
||||||
|
'foreignKey' => 'number_tree_id'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$this->TreeTwo->bindModel(array(
|
||||||
|
'belongsTo' => array(
|
||||||
|
'FirstTree' => array(
|
||||||
|
'className' => $modelClass,
|
||||||
|
'foreignKey' => 'number_tree_id'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$this->TreeTwo->Behaviors->attach('Tree', array(
|
||||||
|
'scope' => 'FirstTree'
|
||||||
|
));
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'NumberTreeTwo' => array(
|
||||||
|
'name' => 'First',
|
||||||
|
'number_tree_id' => $record['FlagTree']['id']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->TreeTwo->create();
|
||||||
|
$this->assertTrue($this->TreeTwo->save($data));
|
||||||
|
|
||||||
|
$result = $this->TreeTwo->find('first');
|
||||||
|
$expected = array('NumberTreeTwo' => array(
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'First',
|
||||||
|
'number_tree_id' => $record['FlagTree']['id'],
|
||||||
|
'parent_id' => null,
|
||||||
|
'lft' => 1,
|
||||||
|
'rght' => 2
|
||||||
|
));
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* AfterTreeTest class
|
* AfterTreeTest class
|
||||||
|
|
|
@ -204,5 +204,69 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
Cache::delete($fileName, '_cake_model_');
|
Cache::delete($fileName, '_cake_model_');
|
||||||
Configure::write('Cache.disable', true);
|
Configure::write('Cache.disable', true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test describe() and normal results.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testDescribe() {
|
||||||
|
$Model =& new Model(array('name' => 'User', 'ds' => 'test_suite', 'table' => 'users'));
|
||||||
|
$result = $this->db->describe($Model);
|
||||||
|
$expected = array(
|
||||||
|
'id' => array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'key' => 'primary',
|
||||||
|
'null' => false,
|
||||||
|
'default' => null,
|
||||||
|
'length' => 11
|
||||||
|
),
|
||||||
|
'user' => array(
|
||||||
|
'type' => 'string',
|
||||||
|
'length' => 255,
|
||||||
|
'null' => false,
|
||||||
|
'default' => null
|
||||||
|
),
|
||||||
|
'password' => array(
|
||||||
|
'type' => 'string',
|
||||||
|
'length' => 255,
|
||||||
|
'null' => false,
|
||||||
|
'default' => null
|
||||||
|
),
|
||||||
|
'created' => array(
|
||||||
|
'type' => 'datetime',
|
||||||
|
'null' => true,
|
||||||
|
'default' => null,
|
||||||
|
'length' => null,
|
||||||
|
),
|
||||||
|
'updated' => array(
|
||||||
|
'type' => 'datetime',
|
||||||
|
'null' => true,
|
||||||
|
'default' => null,
|
||||||
|
'length' => null,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that describe does not corrupt UUID primary keys
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testDescribeWithUuidPrimaryKey() {
|
||||||
|
$tableName = 'uuid_tests';
|
||||||
|
$this->db->query("CREATE TABLE {$tableName} (id VARCHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME)");
|
||||||
|
$Model =& new Model(array('name' => 'UuidTest', 'ds' => 'test_suite', 'table' => 'uuid_tests'));
|
||||||
|
$result = $this->db->describe($Model);
|
||||||
|
$expected = array(
|
||||||
|
'type' => 'string',
|
||||||
|
'length' => 36,
|
||||||
|
'null' => false,
|
||||||
|
'default' => null,
|
||||||
|
'key' => 'primary',
|
||||||
|
);
|
||||||
|
$this->assertEqual($result['id'], $expected);
|
||||||
|
$this->db->query('DROP TABLE ' . $tableName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -94,6 +94,49 @@ class ModelTest extends CakeTestCase {
|
||||||
function endTest() {
|
function endTest() {
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests getAssociated method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testGetAssociated() {
|
||||||
|
$this->loadFixtures('Article');
|
||||||
|
$Article = ClassRegistry::init('Article');
|
||||||
|
|
||||||
|
$assocTypes = array('hasMany', 'hasOne', 'belongsTo', 'hasAndBelongsToMany');
|
||||||
|
foreach ($assocTypes as $type) {
|
||||||
|
$this->assertEqual($Article->getAssociated($type), array_keys($Article->{$type}));
|
||||||
|
}
|
||||||
|
|
||||||
|
$Article->bindModel(array('hasMany' => array('Category')));
|
||||||
|
$this->assertEqual($Article->getAssociated('hasMany'), array('Comment', 'Category'));
|
||||||
|
|
||||||
|
$results = $Article->getAssociated();
|
||||||
|
$this->assertEqual(sort(array_keys($results)), array('Category', 'Comment', 'Tag'));
|
||||||
|
|
||||||
|
$Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
|
||||||
|
$this->assertEqual($Article->getAssociated('hasAndBelongsToMany'), array());
|
||||||
|
|
||||||
|
$result = $Article->getAssociated('Category');
|
||||||
|
$expected = array(
|
||||||
|
'className' => 'Category',
|
||||||
|
'foreignKey' => 'article_id',
|
||||||
|
'conditions' => '',
|
||||||
|
'fields' => '',
|
||||||
|
'order' => '',
|
||||||
|
'limit' => '',
|
||||||
|
'offset' => '',
|
||||||
|
'dependent' => '',
|
||||||
|
'exclusive' => '',
|
||||||
|
'finderQuery' => '',
|
||||||
|
'counterQuery' => '',
|
||||||
|
'association' => 'hasMany',
|
||||||
|
);
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testAutoConstructAssociations method
|
* testAutoConstructAssociations method
|
||||||
*
|
*
|
||||||
|
@ -1775,6 +1818,24 @@ class ModelTest extends CakeTestCase {
|
||||||
array('User' => array('id' => '4', 'user' => 'garrett'), 'Items' => array()));
|
array('User' => array('id' => '4', 'user' => 'garrett'), 'Items' => array()));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that bindModel behaves with Custom primary Key associations
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function bindWithCustomPrimaryKey() {
|
||||||
|
$this->loadFixtures('Story', 'StoriesTag', 'Tag');
|
||||||
|
$Model =& ClassRegistry::init('StoriesTag');
|
||||||
|
$Model->bindModel(array(
|
||||||
|
'belongsTo' => array(
|
||||||
|
'Tag' => array('className' => 'Tag', 'foreignKey' => 'story')
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$result = $Model->find('all');
|
||||||
|
$this->assertFalse(empty($result));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test find('count') method
|
* test find('count') method
|
||||||
*
|
*
|
||||||
|
@ -5840,6 +5901,19 @@ class ModelTest extends CakeTestCase {
|
||||||
$TestModel->set($data);
|
$TestModel->set($data);
|
||||||
$expected = array('Apple'=> array('mytime'=> '03:04:04'));
|
$expected = array('Apple'=> array('mytime'=> '03:04:04'));
|
||||||
$this->assertEqual($TestModel->data, $expected);
|
$this->assertEqual($TestModel->data, $expected);
|
||||||
|
|
||||||
|
$db = ConnectionManager::getDataSource('test_suite');
|
||||||
|
$data = array();
|
||||||
|
$data['Apple']['modified'] = $db->expression('NOW()');
|
||||||
|
$TestModel->data = null;
|
||||||
|
$TestModel->set($data);
|
||||||
|
$this->assertEqual($TestModel->data, $data);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['Apple']['mytime'] = $db->expression('NOW()');
|
||||||
|
$TestModel->data = null;
|
||||||
|
$TestModel->set($data);
|
||||||
|
$this->assertEqual($TestModel->data, $data);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testTablePrefixSwitching method
|
* testTablePrefixSwitching method
|
||||||
|
|
|
@ -2273,6 +2273,28 @@ class NumberTree extends CakeTestModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* NumberTreeTwo class
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.cases.libs.model
|
||||||
|
*/
|
||||||
|
class NumberTreeTwo extends NumberTree {
|
||||||
|
/**
|
||||||
|
* name property
|
||||||
|
*
|
||||||
|
* @var string 'NumberTree'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $name = 'NumberTreeTwo';
|
||||||
|
/**
|
||||||
|
* actsAs property
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $actsAs = array();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* FlagTree class
|
* FlagTree class
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,6 +67,16 @@ class SessionTest extends CakeTestCase {
|
||||||
$this->Session->start();
|
$this->Session->start();
|
||||||
$this->Session->_checkValid();
|
$this->Session->_checkValid();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* testSessionPath
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testSessionPath() {
|
||||||
|
$Session = new CakeSession('/index.php');
|
||||||
|
$this->assertEqual('/', $Session->path);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* testCheck method
|
* testCheck method
|
||||||
*
|
*
|
||||||
|
|
|
@ -3165,6 +3165,21 @@ class FormHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that specifying false in the 'disabled' option will not disable either the hidden input or the checkbox input
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testCheckboxHiddenDisabling() {
|
||||||
|
$result = $this->Form->checkbox('Account.show_name', array('disabled' => false));
|
||||||
|
$expected = array(
|
||||||
|
array('input' => array('type' => 'hidden', 'name' => 'data[Account][show_name]', 'value' => '0', 'id' => 'AccountShowName_')),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Account][show_name]', 'value' => '1', 'id' => 'AccountShowName'))
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDateTime method
|
* testDateTime method
|
||||||
*
|
*
|
||||||
|
@ -4355,6 +4370,9 @@ class FormHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Form->button('Options', array('type' => 'reset', 'name' => 'Post.options', 'id' => 'Opt'));
|
$result = $this->Form->button('Options', array('type' => 'reset', 'name' => 'Post.options', 'id' => 'Opt'));
|
||||||
$this->assertTags($result, array('input' => array('type' => 'reset', 'name' => 'data[Post][options]', 'id' => 'Opt', 'value' => 'Options')));
|
$this->assertTags($result, array('input' => array('type' => 'reset', 'name' => 'data[Post][options]', 'id' => 'Opt', 'value' => 'Options')));
|
||||||
|
|
||||||
|
$result = $this->Form->button('Upload Text', array('onClick' => "$('#postAddForm').ajaxSubmit({target: '#postTextUpload', url: '/posts/text'});return false;'", 'escape' => false));
|
||||||
|
$this->assertNoPattern('/\&039/', $result);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testSubmitButton method
|
* testSubmitButton method
|
||||||
|
|
58
cake/tests/fixtures/number_tree_two_fixture.php
vendored
Normal file
58
cake/tests/fixtures/number_tree_two_fixture.php
vendored
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Tree behavior class.
|
||||||
|
*
|
||||||
|
* Enables a model object to act as a node-based tree.
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||||
|
*
|
||||||
|
* Licensed under The Open Group Test Suite License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||||
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
* @since CakePHP(tm) v 1.2.0.5331
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Number Tree Test Fixture
|
||||||
|
*
|
||||||
|
* Generates a tree of data for use testing the tree behavior
|
||||||
|
*
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
*/
|
||||||
|
class NumberTreeTwoFixture extends CakeTestFixture {
|
||||||
|
/**
|
||||||
|
* name property
|
||||||
|
*
|
||||||
|
* @var string 'NumberTree'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $name = 'NumberTreeTwo';
|
||||||
|
/**
|
||||||
|
* fields property
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer','key' => 'primary'),
|
||||||
|
'name' => array('type' => 'string','null' => false),
|
||||||
|
'number_tree_id' => array('type' => 'integer', 'null' => false),
|
||||||
|
'parent_id' => 'integer',
|
||||||
|
'lft' => array('type' => 'integer','null' => false),
|
||||||
|
'rght' => array('type' => 'integer','null' => false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
|
@ -467,7 +467,8 @@ class CodeCoverageManager {
|
||||||
$folderPrefixMap = array(
|
$folderPrefixMap = array(
|
||||||
'behaviors' => 'models',
|
'behaviors' => 'models',
|
||||||
'components' => 'controllers',
|
'components' => 'controllers',
|
||||||
'helpers' => 'views'
|
'helpers' => 'views',
|
||||||
|
'datasources' => 'models'
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($folderPrefixMap as $dir => $prefix) {
|
foreach ($folderPrefixMap as $dir => $prefix) {
|
||||||
|
|
Loading…
Reference in a new issue