mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
c899c085f5
Revision: [2448] removing tabs in last commit Revision: [2447] Adding fix for limit in all associations Revision: [2446] Added fix for Ticket #569 Revision: [2443] Adding fix for Ticket #592. Revision: [2437] Adding fix for Model::findNeighbours(). Was returning all associations and fields. Now recursive is set to 0 and only returns the prev and next keys array Example $this->Category->findNeighbours(null, 'Category.id', 4); Will return, Array ( [prev] => Array ( [Category] => Array ( [id] => 3 ) ) [next] => Array ( [Category] => Array ( [id] => 5 ) ) ) Revision: [2432] Removed the DS constant from the plugin var when it is set in Dispatcher. Added "$this->plugin.DS." constant in files where needed after change above. Added fix for Ticket #577. Revision: [2428] Added fix for HtmlHelper::checkbox() it ignored the value provided as a parameter Fix for Ticket #605. Fix for Ticket #607. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2449 3807eeeb-6ff5-0310-8944-8be069107fe0
219 lines
No EOL
7.6 KiB
Text
219 lines
No EOL
7.6 KiB
Text
<?php
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
* Base controller class.
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
* Las Vegas, Nevada 89104
|
|
*
|
|
* Licensed under The MIT License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @filesource
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
|
* @package cake
|
|
* @subpackage cake.cake.libs.view.templates.scaffolds
|
|
* @since CakePHP v 0.10.0.1076
|
|
* @version $Revision$
|
|
* @modifiedby $LastChangedBy$
|
|
* @lastmodified $Date$
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
*/
|
|
?>
|
|
|
|
<?php
|
|
$modelName = ucwords(Inflector::singularize($this->name));
|
|
$modelKey = Inflector::underscore($modelName);
|
|
$objModel =& ClassRegistry::getObject($modelKey);
|
|
if(is_null($this->plugin))
|
|
{
|
|
$path = '/';
|
|
}
|
|
else
|
|
{
|
|
$path = '/'.$this->plugin.'/';
|
|
}
|
|
if(!empty($objModel->alias))
|
|
{
|
|
foreach ($objModel->alias as $key => $value)
|
|
{
|
|
$alias[] = $key;
|
|
}
|
|
$count = 0;
|
|
}
|
|
?>
|
|
<h1>Show
|
|
<?php echo Inflector::humanize($modelName)?>
|
|
</h1>
|
|
|
|
<dl>
|
|
<?php
|
|
foreach($fieldNames as $field => $value)
|
|
{
|
|
echo "<dt>".$value['prompt']."</dt>";
|
|
if(isset($value['foreignKey']))
|
|
{
|
|
$otherModelObject =& ClassRegistry::getObject(Inflector::underscore($objModel->tableToModel[$value['table']]));
|
|
$displayField = $otherModelObject->getDisplayField();
|
|
$displayText = $data[$alias[$count]][$displayField];
|
|
|
|
if(!empty($data[$objModel->tableToModel[$objModel->table]][$field]) && (isset($displayText)))
|
|
{
|
|
echo "<dd>".$html->link($displayText, $path.Inflector::underscore($value['controller']).'/show/'
|
|
.$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>";
|
|
}
|
|
else
|
|
{
|
|
echo "<dd> </dd>";
|
|
}
|
|
$count++;
|
|
}
|
|
else
|
|
{
|
|
if( !empty($data[$objModel->tableToModel[$objModel->table]][$field]))
|
|
{
|
|
echo "<dd>".$data[$objModel->tableToModel[$objModel->table]][$field]."</dd>";
|
|
}
|
|
else
|
|
{
|
|
echo "<dd> </dd>";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
</dl>
|
|
<ul class='actions'>
|
|
<?php
|
|
echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
|
|
echo "<li>".$html->link('Delete '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
|
|
echo "<li>".$html->link('List '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/index')."</li>";
|
|
echo "<li>".$html->link('New '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/add')."</li>";
|
|
|
|
foreach( $fieldNames as $field => $value )
|
|
{
|
|
if( isset( $value['foreignKey'] ) )
|
|
{
|
|
echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/index/")."</li>";
|
|
}
|
|
}
|
|
?>
|
|
</ul>
|
|
|
|
<!--hasOne relationships -->
|
|
<?php
|
|
foreach ($objModel->hasOne as $association => $relation)
|
|
{
|
|
$model = $relation['className'];
|
|
$otherModelName = $objModel->tableToModel[$objModel->{$model}->table];
|
|
$controller = Inflector::pluralize($model);
|
|
$new = true;
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>";
|
|
echo "<dl>";
|
|
if(isset($data[$association]) && is_array($data[$association]))
|
|
{
|
|
foreach($data[$association] as $field => $value)
|
|
{
|
|
if(isset($value))
|
|
{
|
|
echo "<dt>".Inflector::humanize($field)."</dt>";
|
|
if(!empty($value))
|
|
{
|
|
echo "<dd>".$value."</dd>";
|
|
}
|
|
else
|
|
{
|
|
echo "<dd> </dd>";
|
|
}
|
|
$new = null;
|
|
}
|
|
}
|
|
echo "</dl>";
|
|
if($new == null)
|
|
{
|
|
echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
|
|
}
|
|
else
|
|
{
|
|
echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
<?php
|
|
$relations = array_merge($objModel->hasMany, $objModel->hasAndBelongsToMany);
|
|
foreach($relations as $association => $relation)
|
|
{
|
|
$model = $relation['className'];
|
|
$count = 0;
|
|
$otherModelName = Inflector::singularize($model);
|
|
$controller = Inflector::pluralize($model);
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($association))."</H2>";
|
|
if(isset($data[$association]) && is_array($data[$association]))
|
|
{
|
|
?>
|
|
<table class="inav" cellspacing="0">
|
|
<tr>
|
|
<?php
|
|
$bFound = false;
|
|
foreach($data[$association][0] as $column=>$value)
|
|
{
|
|
echo "<th>".Inflector::humanize($column)."</th>";
|
|
}
|
|
?>
|
|
<th>Actions</th>
|
|
</tr>
|
|
<?php
|
|
foreach($data[$association] as $row)
|
|
{
|
|
echo "<tr>";
|
|
foreach($row as $column=>$value)
|
|
{
|
|
echo "<td>".$value."</td>";
|
|
}
|
|
if (isset($this->controller->{$modelName}->{$association}))
|
|
{
|
|
?>
|
|
<td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller).
|
|
"/show/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
<?php echo $html->link('Edit',$path.Inflector::underscore($controller).
|
|
"/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
<?php echo $html->link('Delete',$path.Inflector::underscore($controller).
|
|
"/delete/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
</td>
|
|
<?php
|
|
}
|
|
else
|
|
{
|
|
?>
|
|
<td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller).
|
|
"/show/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
|
|
<?php echo $html->link('Edit',$path.Inflector::underscore($controller).
|
|
"/edit/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
|
|
<?php echo $html->link('Delete',$path.Inflector::underscore($controller).
|
|
"/delete/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
|
|
</td>
|
|
<?php
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
?>
|
|
</table>
|
|
<ul class="actions">
|
|
<?php
|
|
echo "<li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/")."</li>";
|
|
?>
|
|
</ul></div>
|
|
<?php
|
|
}
|
|
?> |