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::util::search
  • 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 DEnum class
  6:  *
  7:  * @package alpha::view
  8:  * @since 1.0
  9:  * @author John Collins <dev@alphaframework.org>
 10:  * @version $Id: DEnumView.inc 1757 2014-04-09 22:18:37Z alphadevx $
 11:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
 12:  * @copyright Copyright (c) 2014, 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 DEnumView extends AlphaView {
 49:     /**
 50:      * Custom list view
 51:      *
 52:      * @return string
 53:      * @since 1.0
 54:      */
 55:     public function listView() {
 56:         global $config;
 57: 
 58:         $reflection = new ReflectionClass(get_class($this->BO));
 59:         $properties = $reflection->getProperties();
 60:         $labels = $this->BO->getDataLabels();
 61:         $colCount = 1;
 62: 
 63:         $html = '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
 64:         $html .= '<table class="table">';
 65:         // first render all of the table headers
 66:         $html .= '<tr>';
 67:         foreach($properties as $propObj) {
 68:             $prop = $propObj->name;
 69:             if (!in_array($prop, $this->BO->getDefaultAttributes()) && !in_array($prop, $this->BO->getTransientAttributes())) {
 70:                 if (get_class($this->BO->getPropObject($prop)) != 'Text') {
 71:                     $colCount ++;
 72:                     $html .= '  <th>'.$labels[$prop].'</th>';
 73:                 }
 74:             }
 75:             if ($prop == 'OID')
 76:                 $html .= '  <th>'.$labels[$prop].'</th>';
 77:         }
 78:         // render the count
 79:         $html .= '  <th>Item count</th>';
 80: 
 81:         $html .= '</tr><tr>';
 82: 
 83:         // and now the values
 84:         foreach($properties as $propObj) {
 85:             $prop = $propObj->name;
 86:             if (!in_array($prop, $this->BO->getDefaultAttributes()) && !in_array($prop, $this->BO->getTransientAttributes())) {
 87:                 if (get_class($this->BO->getPropObject($prop)) != 'Text') {
 88:                     $html .= '  <td>&nbsp;'.$this->BO->get($prop).'</td>';
 89:                 }
 90:             }
 91:             if ($prop == 'OID')
 92:                 $html .= '  <td>&nbsp;'.$this->BO->getID().'</td>';
 93:         }
 94:         // render the count
 95:         $html .= '  <td>&nbsp;'.$this->BO->getItemCount().'</td>';
 96: 
 97:         $html .= '</tr>';
 98: 
 99:         $html .= '<tr><td colspan="'.($colCount+1).'" style="text-align:center;">';
100:         // render edit buttons for admins only
101:         if (isset($_SESSION['currentUser']) && $_SESSION['currentUser']->inGroup('Admin')) {
102:             $html .= '&nbsp;&nbsp;';
103:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=EditDEnum&oid='.$this->BO->getOID())."'", "Edit", "edit".$this->BO->getOID()."But");
104:             $html .= $button->render();
105:         }
106:         $html .= '</td></tr>';
107: 
108:         $html .= '</table>';
109: 
110:         $html .= '</form>';
111: 
112:         return $html;
113:     }
114: 
115:     /**
116:      * Custom edit view
117:      *
118:      * @return string
119:      * @since 1.0
120:      */
121:     public function editView() {
122:         global $config;
123: 
124:         $labels = $this->BO->getDataLabels();
125:         $obj_type = '';
126: 
127:         $html = '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST" accept-charset="UTF-8">';
128: 
129:         $temp = new StringBox($this->BO->getPropObject('name'), $labels['name'], 'name', '', 0, true, true);
130:         $html .= $temp->render();
131: 
132:         $html .= '<h3>DEnum display values:</h3>';
133: 
134:         // now get all of the options for the enum and render
135:         $denum = $this->BO;
136:         $tmp = new DEnumItem();
137:         $denumItems = $tmp->loadItems($denum->getID());
138: 
139:         foreach ($denumItems as $item) {
140:             $labels = $item->getDataLabels();
141:             $temp = new StringBox($item->getPropObject('value'), $labels['value'], 'value_'.$item->getID(), '');
142:             $html .= $temp->render();
143:         }
144: 
145:         $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('version_num')) : 'version_num');
146: 
147:         $html .= '<input type="hidden" name="'.$fieldname.'" value="'.$this->BO->getVersion().'"/>';
148: 
149:         $html .= '<h3>Add a new value to the DEnum dropdown list:</h3>';
150: 
151:         $temp = new StringBox(new String(), 'Dropdown value', 'new_value', '');
152:         $html .= $temp->render();
153: 
154:         $temp = new Button('submit', 'Save', 'saveBut');
155:         $html .= $temp->render();
156:         $html .= '&nbsp;&nbsp;';
157:         $temp = new Button("document.location = '".FrontController::generateSecureURL('act=ListDEnums')."'", 'Back to List', 'cancelBut');
158:         $html .= $temp->render();
159:         $html .= '';
160: 
161:         $html .= AlphaView::renderSecurityFields();
162: 
163:         $html .= '</form>';
164: 
165:         return $html;
166:     }
167: }
168: 
169: ?>
Alpha Framework 1.2.4 API Documentation API documentation generated by ApiGen 2.8.0