Alpha Framework alpha--view
[ class tree: alpha--view ] [ index: alpha--view ] [ all elements ]

Source for file SequenceView.inc

Documentation is available at SequenceView.inc

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

Documentation generated on Thu, 17 Mar 2011 16:44:50 +0000 by phpDocumentor 1.4.3