mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
dfcc29f6bf
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3983 3807eeeb-6ff5-0310-8944-8be069107fe0
162 lines
No EOL
6.3 KiB
Text
162 lines
No EOL
6.3 KiB
Text
<?php
|
|
/* SVN FILE: $Id$ */
|
|
/**
|
|
*
|
|
* 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
|
|
$modelObj =& ClassRegistry::getObject($modelKey);
|
|
if(!empty($modelObj->alias)) {
|
|
$alias = array_combine(array_keys($modelObj->alias), array_keys($modelObj->alias));
|
|
}?>
|
|
<h1>View <?php echo $humanSingularName?>
|
|
</h1>
|
|
<dl>
|
|
<?php
|
|
foreach($fieldNames as $field => $value) {
|
|
echo "<dt>".$value['label']."</dt>";
|
|
if(isset($value['foreignKey'])) {
|
|
$otherControllerName = $value['controller'];
|
|
$otherControllerPath = Inflector::underscore($value['controller']);
|
|
$otherModelObj =& ClassRegistry::getObject($value['modelKey']);
|
|
$othereDisplayField = $otherModelObj->getDisplayField();
|
|
$displayText = $data[$alias[$value['model']]][$othereDisplayField];
|
|
if(!empty($data[$modelClass][$field]) && (!empty($displayText))) {
|
|
echo "<dd>".$html->link($displayText, $path . $otherControllerPath.'/view/'
|
|
.$data[$modelClass][$field] )."</dd>";
|
|
} else {
|
|
echo "<dd> </dd>";
|
|
}
|
|
} else {
|
|
if( !empty($data[$modelClass][$field])) {
|
|
echo "<dd>".$data[$modelClass][$field]."</dd>";
|
|
} else {
|
|
echo "<dd> </dd>";
|
|
}
|
|
}
|
|
}?>
|
|
</dl>
|
|
<ul class='actions'>
|
|
<?php
|
|
echo "<li>".$html->link('Edit '.$humanSingularName, $path . $viewPath.'/edit/'.$data[$modelClass][$modelObj->primaryKey])."</li>";
|
|
echo "<li>".$html->link('Delete '.$humanSingularName, $path . $viewPath.'/delete/'.$data[$modelClass][$modelObj->primaryKey], null, 'Are you sure you want to delete id '.$data[$modelClass][$modelObj->primaryKey].' ?')."</li>";
|
|
echo "<li>".$html->link('List '.$humanPluralName, $path . $viewPath.'/index')."</li>";
|
|
echo "<li>".$html->link('New '.$humanSingularName, $path . $viewPath.'/add')."</li>";
|
|
|
|
foreach( $fieldNames as $field => $value ) {
|
|
if( isset( $value['foreignKey'] ) ) {
|
|
echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path . $value['controller'] ."/index/")."</li>";
|
|
echo "<li>".$html->link( "Add ".Inflector::humanize($value['controller']), $path . $value['controller'] ."/add/")."</li>";
|
|
}
|
|
}?>
|
|
</ul>
|
|
|
|
<!--hasOne relationships -->
|
|
<?php
|
|
foreach ($modelObj->hasOne as $associationNameName => $relation) {
|
|
$otherModelKey = Inflector::underscore($relation['className']);
|
|
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
|
|
$otherControllerPath = Inflector::pluralize($otherModelKey);
|
|
$new = true;
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($associationNameName)."</H2>";
|
|
echo "<dl>";
|
|
if(isset($data[$associationNameName]) && is_array($data[$associationNameName])) {
|
|
foreach($data[$associationNameName] 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($associationNameName), $path . $otherControllerPath."/edit/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
|
|
} else {
|
|
echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($associationNameName), $path . $otherControllerPath."/add/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
<?php
|
|
$relations = array_merge($modelObj->hasMany, $modelObj->hasAndBelongsToMany);
|
|
foreach($relations as $associationName => $relation) {
|
|
|
|
$otherModelKey = Inflector::underscore($relation['className']);
|
|
$otherModelObj = &ClassRegistry::getObject($otherModelKey);
|
|
$otherControllerPath = Inflector::pluralize($otherModelKey);
|
|
|
|
$otherModelName = $relation['className'];
|
|
|
|
echo "<div class='related'><h2>Related ".Inflector::humanize($otherControllerPath)."</h2>";
|
|
if(isset($data[$associationName][0]) && is_array($data[$associationName])) {?>
|
|
<table class="inav" cellspacing="0">
|
|
<tr>
|
|
<?php
|
|
$bFound = false;
|
|
foreach($data[$associationName][0] as $column => $value) {
|
|
if(false !== strpos($column, "_id")) {
|
|
$column = substr($column, 0, strpos($column, "_id" ));
|
|
}
|
|
echo "<th>".Inflector::humanize($column)."</th>";
|
|
}?>
|
|
<th>Actions</th>
|
|
</tr>
|
|
<?php
|
|
foreach($data[$associationName] as $row) {
|
|
echo "<tr>";
|
|
foreach($row as $column => $value) {
|
|
echo "<td>".$value."</td>";
|
|
}
|
|
if (isset($otherModelObj->{$associationName})) {?>
|
|
<td class="listactions"><?php echo $html->link('View', $path . $otherControllerPath .
|
|
"/view/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link('Edit', $path . $otherControllerPath .
|
|
"/edit/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link('Delete', $path . $otherControllerPath .
|
|
"/delete/{$row[$otherModelObj->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$otherModelObj->primaryKey].' ?')?>
|
|
</td>
|
|
<?php
|
|
} else {?>
|
|
<td class="listactions"><?php echo $html->link('View', $path . $otherControllerPath .
|
|
"/view/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link('Edit', $path . $otherControllerPath .
|
|
"/edit/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link('Delete', $path . $otherControllerPath .
|
|
"/delete/{$row[$otherModelObj->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$otherModelObj->primaryKey].' ?')?>
|
|
</td>
|
|
<?php
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
}?>
|
|
</table>
|
|
<ul class="actions">
|
|
<?php echo "<li>".$html->link('New '.Inflector::humanize($associationName), $path . $otherControllerPath ."/add/")."</li>";?>
|
|
</ul></div>
|
|
<?php }?> |