[Solar-svn] Revision 3056

pmjones at solarphp.com pmjones at solarphp.com
Sat Mar 29 12:10:51 CDT 2008


Solar_Cli_MakeApp: [ADD] Add a partial view '_record' to reduce repetition in views.


Added: trunk/Solar/Cli/MakeApp/Data/view-_record.php
===================================================================
--- trunk/Solar/Cli/MakeApp/Data/view-_record.php	                        (rev 0)
+++ trunk/Solar/Cli/MakeApp/Data/view-_record.php	2008-03-29 17:10:51 UTC (rev 3056)
@@ -0,0 +1,42 @@
+<?php
+/**
+ * 
+ * Generic record display.
+ * 
+ * @var $record Solar_Sql_Model_Record from the calling code.
+ * 
+ */
+
+// the name of the model this record came from
+$model_name = $record->getModel()->model_name;
+
+// the CSS class to use for the <dl> tag
+$css_class = $this->escape($model_name) . ' record';
+
+// the CSS id to use for the <dl> tag
+$css_id = $this->escape(
+    $model_name . "-record-" . $record->getPrimaryVal()
+);
+
+// the table cols to show
+$cols = array_keys($record->getModel()->table_cols);
+?>
+<dl id="<?php echo $css_id ?>" class="<?php echo $css_class ?>"><?php
+
+    // output each table column and value as a dt/dd pair
+    foreach ($cols as $col) {
+        
+        // localized label
+        $locale_key = strtoupper("LABEL_$col");
+        echo "\n    <dt>" . $this->getText($locale_key) . "</dt>\n";
+        
+        // value
+        $val = $record->$col;
+        if ($val === null) {
+            echo "    <dd><em>null</em></dd>\n";
+        } else {
+            echo "    <dd>" . $this->escape($val) . "</dd>\n";
+        }
+    }
+    
+?></dl>

Modified: trunk/Solar/Cli/MakeApp/Data/view-delete.php
===================================================================
--- trunk/Solar/Cli/MakeApp/Data/view-delete.php	2008-03-27 14:00:56 UTC (rev 3055)
+++ trunk/Solar/Cli/MakeApp/Data/view-delete.php	2008-03-29 17:10:51 UTC (rev 3056)
@@ -1,12 +1,6 @@
 <h2><?php echo $this->getText('HEADING_DELETE'); ?></h2>
 
-<ul>
-    <?php foreach ($this->item as $key => $val) {
-        echo "<li>" . $this->escape($key) . ": "
-           . $this->escape($val)
-           . "</li>\n";
-    } ?>
-</ul>
+<?php echo $this->partial('_record', $this->item); ?>
 
 <?php echo $this->form()
                 ->addProcess('delete_confirm')

Modified: trunk/Solar/Cli/MakeApp/Data/view-read.php
===================================================================
--- trunk/Solar/Cli/MakeApp/Data/view-read.php	2008-03-27 14:00:56 UTC (rev 3055)
+++ trunk/Solar/Cli/MakeApp/Data/view-read.php	2008-03-29 17:10:51 UTC (rev 3056)
@@ -2,13 +2,7 @@
 
 <p>[ <?php echo $this->action("/{$this->controller}", 'ACTION_BROWSE');?> ]</p>
 
-<ul>
-    <?php foreach ($this->item as $key => $val) {
-        echo "<li>" . $this->escape($key) . ": "
-           . $this->escape($val)
-           . "</li>\n";
-    } ?>
-</ul>
+<?php echo $this->partial('_record', $this->item); ?>
 
 <p><?php echo $this->action(
     "/{$this->controller}/edit/{$this->item->getPrimaryVal()}",

Modified: trunk/Solar/Cli/MakeApp.php
===================================================================
--- trunk/Solar/Cli/MakeApp.php	2008-03-27 14:00:56 UTC (rev 3055)
+++ trunk/Solar/Cli/MakeApp.php	2008-03-29 17:10:51 UTC (rev 3056)
@@ -195,6 +195,7 @@
             $list = array('index');
         } else {
             $list = array(
+                '_record',
                 'browse',
                 'read',
                 'edit',




More information about the Solar-svn mailing list