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

Source for file DEnumView.inc

Documentation is available at DEnumView.inc

  1. <?php
  2.  
  3. require_once $config->get('sysRoot').'alpha/model/types/DEnum.inc';
  4. require_once $config->get('sysRoot').'alpha/model/types/DEnumItem.inc';
  5. require_once $config->get('sysRoot').'alpha/view/AlphaView.inc';
  6.  
  7. /**
  8.  *
  9.  * The rendering class for the DEnum class
  10.  * 
  11.  * @package alpha::view
  12.  * @since 1.0
  13.  * @author John Collins <dev@alphaframework.org>
  14.  * @version $Id: DEnumView.inc 1453 2011-12-04 15:12:54Z johnc $
  15.  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  16.  * @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
  17.  *  All rights reserved.
  18.  * 
  19.  *  <pre>
  20.  *  Redistribution and use in source and binary forms, with or
  21.  *  without modification, are permitted provided that the
  22.  *  following conditions are met:
  23.  * 
  24.  *  * Redistributions of source code must retain the above
  25.  *    copyright notice, this list of conditions and the
  26.  *    following disclaimer.
  27.  *  * Redistributions in binary form must reproduce the above
  28.  *    copyright notice, this list of conditions and the
  29.  *    following disclaimer in the documentation and/or other
  30.  *    materials provided with the distribution.
  31.  *  * Neither the name of the Alpha Framework nor the names
  32.  *    of its contributors may be used to endorse or promote
  33.  *    products derived from this software without specific
  34.  *    prior written permission.
  35.  *   
  36.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  37.  *  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  38.  *  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  39.  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  40.  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  41.  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42.  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  43.  *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  44.  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  45.  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  46.  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  47.  *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  48.  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49.  *  </pre>
  50.  *  
  51.  */
  52. class DEnumView extends AlphaView {
  53.     /**
  54.      * Custom list view
  55.      * 
  56.      * @return string 
  57.      * @since 1.0
  58.      */
  59.     public function listView({
  60.         global $config;
  61.  
  62.         $reflection new ReflectionClass(get_class($this->BO));
  63.         $properties $reflection->getProperties();
  64.         $labels $this->BO->getDataLabels();
  65.         $colCount 1;
  66.  
  67.         $html '<table class="list_view">';
  68.         $html .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
  69.         // first render all of the table headers
  70.         $html .= '<tr>';
  71.         foreach($properties as $propObj{
  72.             $prop $propObj->name;
  73.             if (!in_array($prop$this->BO->getDefaultAttributes()) && !in_array($prop$this->BO->getTransientAttributes())) {
  74.                 if (get_class($this->BO->getPropObject($prop)) != 'Text'{
  75.                     $colCount ++;
  76.                     $html .= '    <th>'.$labels[$prop].'</th>';
  77.                 }
  78.             }
  79.             if ($prop == 'OID')
  80.                 $html .= '    <th>'.$labels[$prop].'</th>';            
  81.         }
  82.         // render the count
  83.         $html .= '    <th>Item count</th>';
  84.         
  85.         $html .= '</tr><tr>';
  86.  
  87.         // and now the values
  88.         foreach($properties as $propObj{
  89.             $prop $propObj->name;
  90.             if (!in_array($prop$this->BO->getDefaultAttributes()) && !in_array($prop$this->BO->getTransientAttributes())) {
  91.                 if (get_class($this->BO->getPropObject($prop)) != 'Text'{
  92.                     $html .= '    <td>&nbsp;'.$this->BO->get($prop).'</td>';
  93.                 }
  94.             }
  95.             if ($prop == 'OID')
  96.                 $html .= '    <td>&nbsp;'.$this->BO->getID().'</td>';
  97.         }
  98.         // render the count
  99.         $html .= '    <td>&nbsp;'.$this->BO->getItemCount().'</td>';
  100.         
  101.         $html .= '</tr>';
  102.  
  103.         $html .= '<tr><td colspan="'.($colCount+1).'" align="center">';
  104.         // render edit buttons for admins only
  105.         if (isset($_SESSION['currentUser']&& $_SESSION['currentUser']->inGroup('Admin')) {
  106.             $html .= '&nbsp;&nbsp;';
  107.             $button new Button("document.location = '".FrontController::generateSecureURL('act=EditDEnum&oid='.$this->BO->getOID())."'""Edit""edit".$this->BO->getOID()."But");
  108.             $html .= $button->render();
  109.         }
  110.         $html .= '</td></tr>';
  111.  
  112.         $html .= '</form>';
  113.         $html .= '</table>';
  114.         
  115.         return $html;
  116.     }
  117.     
  118.     /**
  119.      * Custom edit view
  120.      * 
  121.      * @return string 
  122.      * @since 1.0
  123.      */
  124.     public function editView({        
  125.         global $config;
  126.  
  127.         $labels $this->BO->getDataLabels();
  128.         $obj_type '';
  129.  
  130.         $html '<table cols="2" class="edit_view">';
  131.         $html .= '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
  132.         
  133.         $temp new StringBox($this->BO->getPropObject('name')$labels['name']'name'''0truetrue);
  134.         $html .= $temp->render();
  135.         
  136.         $html .= '<tr><td colspan="2"><h3>DEnum display values:</h3></td></tr>';
  137.         
  138.         // now get all of the options for the enum and render
  139.         $denum $this->BO;
  140.         $tmp new DEnumItem();
  141.         $denumItems $tmp->loadItems($denum->getID());                        
  142.         
  143.         foreach ($denumItems as $item{
  144.             $labels $item->getDataLabels();
  145.             $temp new StringBox($item->getPropObject('value')$labels['value']'value_'.$item->getID()'');
  146.             $html .= $temp->render();
  147.         }
  148.         
  149.         $html .= '<input type="hidden" name="version_num" value="'.$this->BO->getVersion().'"/>';
  150.         
  151.         $html .= '<tr><td colspan="2"><h3>Add a new value to the DEnum dropdown list:</h3></td></tr>';
  152.         
  153.         $temp new StringBox(new String()'Dropdown value''new_value''');
  154.         $html .= $temp->render();
  155.         
  156.         $html .= '<tr><td colspan="2">';
  157.         
  158.         $temp new button('submit''Save''saveBut');
  159.         $html .= $temp->render();
  160.         $html .= '&nbsp;&nbsp;';
  161.         $temp new button("document.location = '".FrontController::generateSecureURL('act=ListDEnums')."'"'Back to List''cancelBut');
  162.         $html .= $temp->render();
  163.         $html .= '</td></tr>';
  164.  
  165.         $html .= AlphaView::renderSecurityFields();
  166.         
  167.         $html .= '</form></table>';
  168.         
  169.         return $html;
  170.     }
  171. }
  172.  
  173. ?>

Documentation generated on Tue, 13 Dec 2011 20:26:42 +0000 by phpDocumentor 1.4.3