[ Index ] |
|
Code source de CakePHP 1.1.13.4450 |
1 <?php 2 /* SVN FILE: $Id: view.thtml 4409 2007-02-02 13:20:59Z phpnut $ */ 3 /** 4 * 5 * PHP versions 4 and 5 6 * 7 * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> 8 * Copyright 2005-2007, Cake Software Foundation, Inc. 9 * 1785 E. Sahara Avenue, Suite 490-204 10 * Las Vegas, Nevada 89104 11 * 12 * Licensed under The MIT License 13 * Redistributions of files must retain the above copyright notice. 14 * 15 * @filesource 16 * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. 17 * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project 18 * @package cake 19 * @subpackage cake.cake.libs.view.templates.scaffolds 20 * @since CakePHP(tm) v 0.10.0.1076 21 * @version $Revision: 4409 $ 22 * @modifiedby $LastChangedBy: phpnut $ 23 * @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $ 24 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 25 */ 26 ?> 27 <?php 28 $modelName = ucwords(Inflector::singularize($this->name)); 29 $modelKey = Inflector::underscore($modelName); 30 $objModel =& ClassRegistry::getObject($modelKey); 31 if(is_null($this->plugin)) { 32 $path = '/'; 33 } else { 34 $path = '/'.$this->plugin.'/'; 35 } 36 if(!empty($objModel->alias)) { 37 foreach ($objModel->alias as $key => $value) { 38 $alias[] = $key; 39 } 40 $count = 0; 41 }?> 42 <h1>View 43 <?php echo Inflector::humanize($modelName)?> 44 </h1> 45 <dl> 46 <?php 47 foreach($fieldNames as $field => $value) { 48 echo "<dt>".$value['prompt']."</dt>"; 49 if(isset($value['foreignKey'])) { 50 $otherModelObject =& ClassRegistry::getObject(Inflector::underscore($objModel->tableToModel[$value['table']])); 51 $displayField = $otherModelObject->getDisplayField(); 52 $displayText = $data[$alias[$count]][$displayField]; 53 if(!empty($data[$objModel->tableToModel[$objModel->table]][$field]) && (isset($displayText))) { 54 echo "<dd>".$html->link($displayText, $path.Inflector::underscore($value['controller']).'/view/' 55 .$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>"; 56 } else { 57 echo "<dd> </dd>"; 58 } 59 $count++; 60 } else { 61 if( !empty($data[$objModel->tableToModel[$objModel->table]][$field])) { 62 echo "<dd>".$data[$objModel->tableToModel[$objModel->table]][$field]."</dd>"; 63 } else { 64 echo "<dd> </dd>"; 65 } 66 } 67 }?> 68 </dl> 69 <ul class='actions'> 70 <?php 71 echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>"; 72 echo "<li>".$html->link('Delete '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey], null, 'Are you sure you want to delete id '.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey].' ?')."</li>"; 73 echo "<li>".$html->link('List '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/index')."</li>"; 74 echo "<li>".$html->link('New '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/add')."</li>"; 75 76 foreach( $fieldNames as $field => $value ) { 77 if( isset( $value['foreignKey'] ) ) { 78 echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/index/")."</li>"; 79 } 80 }?> 81 </ul> 82 83 <!--hasOne relationships --> 84 <?php 85 foreach ($objModel->hasOne as $association => $relation) { 86 $model = $relation['className']; 87 $otherModelName = $objModel->tableToModel[$objModel->{$model}->table]; 88 $controller = Inflector::pluralize($model); 89 $new = true; 90 echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>"; 91 echo "<dl>"; 92 if(isset($data[$association]) && is_array($data[$association])) { 93 foreach($data[$association] as $field => $value) { 94 if(isset($value)) { 95 echo "<dt>".Inflector::humanize($field)."</dt>"; 96 if(!empty($value)) { 97 echo "<dd>".$value."</dd>"; 98 } else { 99 echo "<dd> </dd>"; 100 } 101 $new = null; 102 } 103 } 104 echo "</dl>"; 105 if($new == null) { 106 echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>"; 107 } else { 108 echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>"; 109 } 110 } 111 } 112 ?> 113 114 <!-- HAS MANY AND HASANDBELONGSTOMANY --> 115 <?php 116 $relations = array_merge($objModel->hasMany, $objModel->hasAndBelongsToMany); 117 foreach($relations as $association => $relation) { 118 $model = $relation['className']; 119 $count = 0; 120 $otherModelName = Inflector::singularize($model); 121 $controller = Inflector::pluralize($model); 122 123 echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($association))."</H2>"; 124 if(isset($data[$association][0]) && is_array($data[$association])) {?> 125 <table class="inav" cellspacing="0"> 126 <tr> 127 <?php 128 $bFound = false; 129 foreach($data[$association][0] as $column=>$value) { 130 echo "<th>".Inflector::humanize($column)."</th>"; 131 }?> 132 <th>Actions</th> 133 </tr> 134 <?php 135 foreach($data[$association] as $row) { 136 echo "<tr>"; 137 foreach($row as $column=>$value) { 138 echo "<td>".$value."</td>"; 139 } 140 if (isset($this->controller->{$modelName}->{$association})) {?> 141 <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller). 142 "/view/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?> 143 <?php echo $html->link('Edit',$path.Inflector::underscore($controller). 144 "/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?> 145 <?php echo $html->link('Delete',$path.Inflector::underscore($controller). 146 "/delete/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$this->controller->{$modelName}->{$association}->primaryKey].' ?')?> 147 </td> 148 <?php 149 } else {?> 150 <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller). 151 "/view/{$row[$this->controller->{$modelName}->primaryKey]}/")?> 152 <?php echo $html->link('Edit',$path.Inflector::underscore($controller). 153 "/edit/{$row[$this->controller->{$modelName}->primaryKey]}/")?> 154 <?php echo $html->link('Delete',$path.Inflector::underscore($controller). 155 "/delete/{$row[$this->controller->{$modelName}->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$this->controller->{$modelName}->primaryKey].' ?')?> 156 </td> 157 <?php 158 } 159 echo "</tr>"; 160 } 161 }?> 162 </table> 163 <ul class="actions"> 164 <?php echo "<li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/")."</li>";?> 165 </ul></div> 166 <?php }?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 19:27:47 2007 | par Balluche grâce à PHPXref 0.7 |