Overview

Packages

  • alpha::controller
  • alpha::controller::front
  • alpha::exceptions
  • alpha::model
  • alpha::model::types
  • alpha::tasks
  • alpha::tests
  • alpha::util
  • alpha::util::cache
  • alpha::util::codehighlight
  • alpha::util::convertors
  • alpha::util::feeds
  • alpha::util::filters
  • alpha::util::graphs
  • alpha::util::helpers
  • alpha::util::metrics
  • alpha::view
  • alpha::view::renderers
  • alpha::view::widgets

Classes

  • AlphaView
  • ArticleCommentView
  • ArticleView
  • DEnumView
  • PersonView
  • SequenceView
  • ViewState
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * The rendering class for the Sequence class
  6:  * 
  7:  * @package alpha::view
  8:  * @since 1.0
  9:  * @author John Collins <dev@alphaframework.org>
 10:  * @version $Id: SequenceView.inc 1497 2012-02-14 20:28:45Z alphadev $
 11:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
 12:  * @copyright Copyright (c) 2012, John Collins (founder of Alpha Framework).  
 13:  * All rights reserved.
 14:  * 
 15:  * <pre>
 16:  * Redistribution and use in source and binary forms, with or 
 17:  * without modification, are permitted provided that the 
 18:  * following conditions are met:
 19:  * 
 20:  * * Redistributions of source code must retain the above 
 21:  *   copyright notice, this list of conditions and the 
 22:  *   following disclaimer.
 23:  * * Redistributions in binary form must reproduce the above 
 24:  *   copyright notice, this list of conditions and the 
 25:  *   following disclaimer in the documentation and/or other 
 26:  *   materials provided with the distribution.
 27:  * * Neither the name of the Alpha Framework nor the names 
 28:  *   of its contributors may be used to endorse or promote 
 29:  *   products derived from this software without specific 
 30:  *   prior written permission.
 31:  *   
 32:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
 33:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 34:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 35:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 36:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
 37:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 38:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
 39:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 40:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 41:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 42:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 43:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 44:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 45:  * </pre>
 46:  *  
 47:  */
 48: class SequenceView extends AlphaView {
 49:     /**
 50:      * Trace logger
 51:      * 
 52:      * @var Logger
 53:      * @since 1.0
 54:      */
 55:     private static $logger = null;
 56:     
 57:     /**
 58:      * Constructor
 59:      * 
 60:      * @param AlphaDAO $BO
 61:      * @throws IllegalArguementException
 62:      * @since 1.0
 63:      */
 64:     protected function __construct($BO) {
 65:         self::$logger = new Logger('SequenceView');
 66:         self::$logger->debug('>>__construct(BO=['.var_export($BO, true).'])');
 67:         
 68:         parent::__construct($BO);
 69:         
 70:         self::$logger->debug('<<__construct');
 71:     }
 72:     
 73:     /**
 74:      * Custom list view
 75:      * 
 76:      * @param array $fields Hash array of HTML fields to pass to the template.
 77:      * @since 1.0
 78:      */
 79:     public function listView($fields=array()) {
 80:         self::$logger->debug('>>listView(fields=['.var_export($fields, true).'])');
 81:         
 82:         if(method_exists($this, 'before_listView_callback'))
 83:             $this->before_listView_callback();
 84:         
 85:         global $config;
 86:         
 87:         // the form action
 88:         $fields['formAction'] = $_SERVER['REQUEST_URI'];
 89:         
 90:         // work out how many columns will be in the table
 91:         $reflection = new ReflectionClass(get_class($this->BO));
 92:         $properties = array_keys($reflection->getDefaultProperties());      
 93:         $fields['colCount'] = 1+count(array_diff($properties, $this->BO->getDefaultAttributes(), $this->BO->getTransientAttributes()));
 94:         
 95:         // get the class attributes
 96:         $properties = $reflection->getProperties();
 97:         
 98:         $html = '';
 99:         
100:         $html .= '<tr>';
101:         foreach($properties as $propObj) {
102:             $propName = $propObj->name;
103:             
104:             // skip over password fields
105:             $property = $this->BO->getPropObject($propName);
106:             if(!($property instanceof String && $property->checkIsPassword())) {            
107:                 if (!in_array($propName, $this->BO->getDefaultAttributes()) && !in_array($propName, $this->BO->getTransientAttributes())) {
108:                     $html .= '  <th>'.$this->BO->getDataLabel($propName).'</th>';               
109:                 }
110:                 if ($propName == 'OID')
111:                     $html .= '  <th>'.$this->BO->getDataLabel($propName).'</th>';
112:             }else{
113:                 $fields['colCount'] = $fields['colCount']-1;
114:             }
115:         }
116:         $html .= '</tr><tr>';
117:         
118:         $fields['formHeadings'] = $html;
119:         
120:         $html = '';
121: 
122:         // and now the values
123:         foreach($properties as $propObj) {
124:             $propName = $propObj->name;
125:             
126:             $property = $this->BO->getPropObject($propName);
127:             if(!($property instanceof String && $property->checkIsPassword())) {
128:                 if (!in_array($propName, $this->BO->getDefaultAttributes()) && !in_array($propName, $this->BO->getTransientAttributes())) {
129:                     $propClass = get_class($this->BO->getPropObject($propName));
130:                     
131:                     if ($propClass == 'Text') {
132:                         $text = htmlentities($this->BO->get($propName));
133:                         if(strlen($text) > 70)
134:                             $html .= '  <td>&nbsp;'.substr($text, 0, 70).'...</td>';
135:                         else
136:                             $html .= '  <td>&nbsp;'.$text.'</td>';
137:                     }elseif($propClass == 'DEnum') {
138:                         $html .= '  <td>&nbsp;'.$this->BO->getPropObject($propName)->getDisplayValue().'</td>';
139:                     }else{
140:                         $html .= '  <td>&nbsp;'.$this->BO->get($propName).'</td>';
141:                     }
142:                 }
143:                 if ($propName == 'OID')
144:                     $html .= '  <td>&nbsp;'.$this->BO->getOID().'</td>';
145:             }
146:         }
147:         $html .= '</tr>';
148:         
149:         $fields['formFields'] = $html;
150:         
151:         // View button
152:         if(strpos($_SERVER['REQUEST_URI'], '/tk/') !== false) {
153:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=Detail&bo='.get_class($this->BO).'&oid='.$this->BO->getOID())."';", 'View', 'viewBut');
154:             $fields['viewButton'] = $button->render();
155:         }else{
156:             $button = new Button("document.location = '".$this->BO->get('URL')."';", 'View', 'viewBut');
157:             $fields['viewButton'] = $button->render();
158:         }
159:         
160:         // supressing the edit/delete buttons for Sequences
161:         $fields['adminButtons'] = '';
162: 
163:         // buffer security fields to $formSecurityFields variable
164:         $fields['formSecurityFields'] = $this->renderSecurityFields();
165: 
166:         $this->loadTemplate($this->BO, 'list', $fields);
167:         
168:         if(method_exists($this, 'after_listView_callback'))
169:             $this->after_listView_callback();
170:             
171:         self::$logger->debug('<<listView');
172:     }
173:     
174:     /**
175:      * Custom display view
176:      * 
177:      * @param array $fields Hash array of HTML fields to pass to the template.
178:      * @since 1.0
179:      */
180:     public function detailedView($fields=array()) {
181:         self::$logger->debug('>>detailedView(fields=['.var_export($fields, true).'])');
182:         
183:         if(method_exists($this, 'before_detailedView_callback'))
184:             $this->before_detailedView_callback();
185:         
186:         global $config;
187:         
188:         // we may want to display the OID regardless of class
189:         $fields['OIDLabel'] = $this->BO->getDataLabel('OID');       
190:         $fields['OID'] = $this->BO->getOID();       
191:         
192:         // buffer form fields to $formFields
193:         $fields['formFields'] = $this->renderAllFields('view');
194:         
195:         // Back button
196:         $button = new Button('history.back()', 'Back', 'backBut');
197:         $fields['backButton'] = $button->render();
198:         
199:         $fields['adminButtons'] = '';
200:         
201:         $this->loadTemplate($this->BO, 'detail', $fields);
202:         
203:         if(method_exists($this, 'after_detailedView_callback'))
204:             $this->after_detailedView_callback();
205:             
206:         self::$logger->debug('<<detailedView');
207:     }
208: }
209: 
210: ?>
Alpha Framework API Documentation API documentation generated by ApiGen 2.8.0