mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-21 12:06:15 +00:00
93f7a48a2a
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4224 3807eeeb-6ff5-0310-8944-8be069107fe0
157 lines
No EOL
6.6 KiB
Text
157 lines
No EOL
6.6 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 sprintf(__("View %s", true), $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(sprintf(__("Edit %s", true), $humanSingularName), array('action' => 'edit', $data[$modelClass][$modelObj->primaryKey])) . '</li>';
|
|
echo '<li>' . $html->link(sprintf(__("Delete %s", true), $humanSingularName), array('action' => 'delete', $data[$modelClass][$modelObj->primaryKey]), null, sprintf(__("Are you sure you want to delete id %s?", true), $data[$modelClass][$modelObj->primaryKey])) . '</li>';
|
|
echo '<li>' . $html->link(sprintf(__("List %s", true), $humanPluralName), array('action' => 'index')) . '</li>';
|
|
echo '<li>' . $html->link(sprintf(__("New %s", true), $humanSingularName), array('action' => 'add')) . '</li>';
|
|
|
|
foreach($fieldNames as $field => $value) {
|
|
if(isset($value['foreignKey'])) {
|
|
echo "<li>".$html->link(sprintf(__("List %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action' => 'index')) . '</li>';
|
|
echo "<li>".$html->link(sprintf(__("Add %s", true), 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>".sprintf(__("Related %s", true), 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(sprintf(__("Edit %s", true), Inflector::humanize($associationNameName)), $path . $otherControllerPath."/edit/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
|
|
} else {
|
|
echo "<ul class='actions'><li>".$html->link(sprintf(__("New %s", true), 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>".sprintf(__("Related %s", true), 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', true), $path . $otherControllerPath . "/view/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link(__('Edit', true), $path . $otherControllerPath . "/edit/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link(__('Delete', true), $path . $otherControllerPath . "/delete/{$row[$otherModelObj->primaryKey]}/", null, sprintf(__("Are you sure you want to delete id %s?", true), $row[$otherModelObj->primaryKey]))?>
|
|
</td>
|
|
<?php
|
|
} else {?>
|
|
<td class="listactions"><?php echo $html->link(__('View', true), $path . $otherControllerPath . "/view/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link(__('Edit', true), $path . $otherControllerPath . "/edit/{$row[$otherModelObj->primaryKey]}/")?>
|
|
<?php echo $html->link(__('Delete', true), $path . $otherControllerPath . "/delete/{$row[$otherModelObj->primaryKey]}/", null, sprintf(__("Are you sure you want to delete id %s?", true), $row[$otherModelObj->primaryKey]))?>
|
|
</td>
|
|
<?php
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
}?>
|
|
</table>
|
|
<ul class="actions">
|
|
<?php echo "<li>".$html->link(__('New ', true).Inflector::humanize($associationName), $path . $otherControllerPath . '/add') . '</li>'; ?>
|
|
</ul></div>
|
|
<?php }?> |