mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-16 11:58:25 +00:00
67d156ef2b
Author: phpnut Date: 10:09:03 PM, Monday, October 31, 2005 Message: Removed references in the Session class [1283] Author: phpnut Date: 8:47:37 PM, Monday, October 31, 2005 Message: Added fix to the Controller::constructClassess(). The database should have an instance available if a component will use it. [1282] Author: phpnut Date: 8:36:07 PM, Monday, October 31, 2005 Message: Updated the Model association methods to correct and error I introduced when reactoring last week. Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented. Updated scaffold and dipatcher with changes to the session class. Fixed problem with session not working properly. Added a regenrate id for sessions. When CAKE_SECURITY is set to high this will regenrate a new session key on each request. The old session file will be removed from the file system. This is a added security measure. [1270] Author: phpnut Date: 1:55:28 PM, Sunday, October 30, 2005 Message: Updated Session class to regenrate a new session key on each request when security level set to high. Updated doc comments in some classes [1269] Author: phpnut Date: 9:49:43 AM, Sunday, October 30, 2005 Message: Added a fix for Ticket #105 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
189 lines
No EOL
6.7 KiB
Text
189 lines
No EOL
6.7 KiB
Text
<?php
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
* Base controller class.
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
|
*
|
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
|
*
|
|
* Licensed under The MIT License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @filesource
|
|
* @author CakePHP Authors/Developers
|
|
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
|
|
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
|
|
* @package cake
|
|
* @subpackage cake.cake.libs.controller.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 = Inflector::singularize($this->name);
|
|
$modelKey = Inflector::underscore($modelName);
|
|
$registry =& ClassRegistry::getInstance();
|
|
$objModel = $registry->getObject($modelKey);
|
|
|
|
?>
|
|
<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 = $registry->getObject(Inflector::underscore($objModel->tableToModel[$value['table']]));
|
|
$displayField = $otherModelObject->getDisplayField();
|
|
$displayText = $data[$objModel->tableToModel[$value['table']]][$displayField];
|
|
|
|
if(!empty($data[$objModel->tableToModel[$objModel->table]][$field]))
|
|
{
|
|
echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'
|
|
.$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>";
|
|
}
|
|
else
|
|
{
|
|
echo "<dd> </dd>";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// this is just a plain old field.
|
|
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->linkTo('Edit '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]]['id'])."</li>";
|
|
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/destroy/'.$data[$objModel->tableToModel[$objModel->table]]['id'])."</li>";
|
|
echo "<li>".$html->linkTo('List '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/index')."</li>";
|
|
echo "<li>".$html->linkTo('New '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/add')."</li>";
|
|
foreach( $fieldNames as $field => $value ) {
|
|
if( isset( $value['foreignKey'] ) )
|
|
{
|
|
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[$objModel->tableToModel[$value['table']]]['id'] )."</li>";
|
|
}
|
|
}
|
|
?>
|
|
</ul>
|
|
|
|
<!--hasOne relationships -->
|
|
<?php
|
|
foreach ($objModel->_oneToOne as $relation)
|
|
{
|
|
list($model, $value) = $relation;
|
|
$otherModelName = $objModel->tableToModel[$model];
|
|
$controller = Inflector::pluralize($model);
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($otherModelName)."</H2>";
|
|
echo "<dl>";
|
|
if( isset($data[$otherModelName]) && is_array($data[$otherModelName]) )
|
|
{
|
|
foreach( $data[$otherModelName] as $field=>$value )
|
|
{
|
|
echo "<dt>".Inflector::humanize($field)."</dt>";
|
|
if( !empty($value) )
|
|
{
|
|
echo "<dd>".$value."</dd>";
|
|
} else {
|
|
echo "<dd> </dd>";
|
|
}
|
|
}
|
|
|
|
}
|
|
echo "</dl>";
|
|
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($otherModelName),"/".Inflector::underscore($controller)."/edit/{$data[$otherModelName]['id']}")."</li></ul></div>";
|
|
}
|
|
?>
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
<?php
|
|
$relations = array();
|
|
foreach( $objModel->_oneToMany as $relation )
|
|
{
|
|
$relations[] = $relation;
|
|
} // end loop through onetomany relations.
|
|
|
|
foreach( $objModel->_manyToMany as $relation )
|
|
{
|
|
$relations[] = $relation;
|
|
} // end loop through manytomany relations.
|
|
|
|
foreach( $relations as $relation )
|
|
{
|
|
list($model, $value) = $relation;
|
|
$count = 0;
|
|
$otherModelName = Inflector::singularize($model);
|
|
$controller = Inflector::pluralize($model);
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($objModel->tableToModel[$objModel->{$model}->table]))."</H2>";
|
|
if( isset($data[$objModel->tableToModel[$objModel->{$model}->table]]) && is_array($data[$objModel->tableToModel[$objModel->{$model}->table]]) )
|
|
{
|
|
?>
|
|
|
|
<table class="inav" cellspacing="0">
|
|
<tr>
|
|
<?php // Loop through and create the header row.
|
|
// find a row that matches this title.
|
|
$bFound = false;
|
|
foreach( $data[$objModel->tableToModel[$objModel->{$model}->table]][0] as $column=>$value ) {
|
|
echo "<th>".Inflector::humanize($column)."</th>";
|
|
}
|
|
?>
|
|
<th>Actions</th>
|
|
</tr>
|
|
<?php
|
|
// now find all matching rows
|
|
foreach( $data[$objModel->tableToModel[$objModel->$model->table]] as $row )
|
|
{
|
|
echo "<tr>";
|
|
foreach( $row as $column=>$value )
|
|
{
|
|
echo "<td>".$value."</td>";
|
|
}
|
|
?>
|
|
<td class="listactions"><?php echo $html->linkTo('View',"/".Inflector::underscore($controller)."/show/{$row['id']}/")?>
|
|
<?php echo $html->linkTo('Edit',"/".Inflector::underscore($controller)."/edit/{$row['id']}/")?>
|
|
<?php echo $html->linkTo('Delete',"/".Inflector::underscore($controller)."/destroy/{$row['id']}/")?>
|
|
</td>
|
|
<?php
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
?>
|
|
|
|
</table>
|
|
<ul class="actions">
|
|
<?php
|
|
// add a link to create a new relation.
|
|
|
|
echo "<li>".$html->linkTo('New '.Inflector::humanize($otherModelName),"/".Inflector::underscore($controller)."/add/")."</li>";
|
|
// echo "<li>".$html->linkTo( "View ".Inflector::humanize($table), "/".Inflector::underscore($table)."/list/".$modelName."/".$data[$modelName]['id'])."</li>";
|
|
?>
|
|
</ul></div>
|
|
|
|
<?php } // end loop through relations
|
|
?> |