       1: <?php
       2:
       3: /**
       4:  * HTML renderer.  Will invoke widgets from the alpha::view::widgets package
       5:  * automatically for the correct data type.  Templates from ./templates/html
       6:  * loaded by default, but these can be overridden on a per-DAO level in
       7:  * the application when required (consider the default ones to be scaffolding).
       8:  *
       9:  * @package alpha::view::renderers
      10:  * @since 1.2
      11:  * @author John Collins <dev@alphaframework.org>
      12:  * @version $Id: AlphaRendererProviderInterface.inc 1499 2012-02-16 19:29:16Z alphadev $
      13:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
      14:  * @copyright Copyright (c) 2014, John Collins (founder of Alpha Framework).
      15:  * All rights reserved.
      16:  *
      17:  * <pre>
      18:  * Redistribution and use in source and binary forms, with or
      19:  * without modification, are permitted provided that the
      20:  * following conditions are met:
      21:  *
      22:  * * Redistributions of source code must retain the above
      23:  *   copyright notice, this list of conditions and the
      24:  *   following disclaimer.
      25:  * * Redistributions in binary form must reproduce the above
      26:  *   copyright notice, this list of conditions and the
      27:  *   following disclaimer in the documentation and/or other
      28:  *   materials provided with the distribution.
      29:  * * Neither the name of the Alpha Framework nor the names
      30:  *   of its contributors may be used to endorse or promote
      31:  *   products derived from this software without specific
      32:  *   prior written permission.
      33:  *
      34:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
      35:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
      36:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
      37:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
      38:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
      39:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      40:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
      41:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
      42:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      43:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
      44:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
      45:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
      46:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      47:  * </pre>
      48:  *
      49:  */
      50: class AlphaRendererProviderHTML implements AlphaRendererProviderInterface {
      51:     /**
      52:      * Trace logger
      53:      *
      54:      * @var Logger
      55:      * @since 1.2
      56:      */
      57:     private static $logger = null;
      58:
      59:     /**
      60:      * The business object that we are renderering
      61:      *
      62:      * @var AlphaDAO
      63:      * @since 1.2
      64:      */
      65:     private $BO;
      66:
      67:     /**
      68:      * The constructor
      69:      *
      70:      * @since 1.2
      71:      */
      72:     public function __construct() {
      73:         self::$logger = new Logger('AlphaRendererProviderHTML');
      74:         self::$logger->debug('>>__construct()');
      75:
      76:         self::$logger->debug('<<__construct');
      77:     }
      78:
      79:     /**
      80:      * (non-PHPdoc)
      81:      * @see alpha/view/renderers/AlphaRendererProvider::setBO()
      82:      */
      83:     public function setBO($BO) {
      84:         $this->BO = $BO;
      85:     }
      86:
      87:     /**
      88:      * (non-PHPdoc)
      89:      * @see alpha/view/renderers/AlphaRendererProviderInterface::createView()
      90:      */
      91:     public function createView($fields=array()) {
      92:         self::$logger->debug('>>createView(fields=['.var_export($fields, true).'])');
      93:
      94:         global $config;
      95:
      96:         // the form action
      97:         $fields['formAction'] = $_SERVER['REQUEST_URI'];
      98:
      99:         // the form ID
     100:         $fields['formID'] = get_class($this->BO).'_'.$this->BO->getOID();
     101:
     102:         // buffer form fields to $formFields
     103:         $fields['formFields'] = $this->renderAllFields('create');
     104:
     105:         // buffer HTML output for Create and Cancel buttons
     106:         $button = new Button('submit', 'Create', 'createBut');
     107:         $fields['createButton'] = $button->render();
     108:
     109:         $button = new Button("document.location.replace('".FrontController::generateSecureURL('act=ListBusinessObjects')."')", 'Cancel', 'cancelBut');
     110:         $fields['cancelButton'] = $button->render();
     111:
     112:         // buffer security fields to $formSecurityFields variable
     113:         $fields['formSecurityFields'] = self::renderSecurityFields();
     114:
     115:         self::$logger->debug('<<createView [HTML]');
     116:         return AlphaView::loadTemplate($this->BO, 'create', $fields);
     117:     }
     118:
     119:     /**
     120:      * (non-PHPdoc)
     121:      * @see alpha/view/renderers/AlphaRendererProviderInterface::editView()
     122:      */
     123:     public function editView($fields=array()) {
     124:         self::$logger->debug('>>editView(fields=['.var_export($fields, true).'])');
     125:
     126:         global $config;
     127:
     128:         // the form action
     129:         $fields['formAction'] = $_SERVER['REQUEST_URI'];
     130:
     131:         // the form ID
     132:         $fields['formID'] = get_class($this->BO).'_'.$this->BO->getOID();
     133:
     134:         // buffer form fields to $formFields
     135:         $fields['formFields'] = $this->renderAllFields('edit');
     136:
     137:         // buffer HTML output for Create and Cancel buttons
     138:         $button = new Button('submit', 'Save', 'saveBut');
     139:         $fields['saveButton'] = $button->render();
     140:
     141:         $js = "if(window.jQuery) {
     142:                     BootstrapDialog.show({
     143:                         title: 'Confirmation',
     144:                         message: 'Are you sure you wish to delete this item?',
     145:                         buttons: [
     146:                             {
     147:                                 icon: 'glyphicon glyphicon-remove',
     148:                                 label: 'Cancel',
     149:                                 cssClass: 'btn btn-default btn-xs',
     150:                                 action: function(dialogItself){
     151:                                     dialogItself.close();
     152:                                 }
     153:                             },
     154:                             {
     155:                                 icon: 'glyphicon glyphicon-ok',
     156:                                 label: 'Okay',
     157:                                 cssClass: 'btn btn-default btn-xs',
     158:                                 action: function(dialogItself) {
     159:                                     $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('deleteOID')) : 'deleteOID')."\"]').attr('value', '".$this->BO->getOID()."');
     160:                                     $('#deleteForm').submit();
     161:                                     dialogItself.close();
     162:                                 }
     163:                             }
     164:                         ]
     165:                     });
     166:                 }";
     167:         $button = new Button($js, "Delete", "deleteBut");
     168:         $fields['deleteButton'] = $button->render();
     169:
     170:         $button = new Button("document.location = '".FrontController::generateSecureURL('act=ListAll&bo='.get_class($this->BO))."'", "Back to List", "cancelBut");
     171:         $fields['cancelButton'] = $button->render();
     172:
     173:         // buffer security fields to $formSecurityFields variable
     174:         $fields['formSecurityFields'] = self::renderSecurityFields();
     175:
     176:         // OID will need to be posted for optimistic lock checking
     177:         $fields['version_num'] = $this->BO->getVersionNumber();
     178:
     179:         self::$logger->debug('<<editView [HTML]');
     180:         return AlphaView::loadTemplate($this->BO, 'edit', $fields);
     181:     }
     182:
     183:     /**
     184:      * (non-PHPdoc)
     185:      * @see alpha/view/renderers/AlphaRendererProviderInterface::listView()
     186:      */
     187:     public function listView($fields=array()) {
     188:         self::$logger->debug('>>listView(fields=['.var_export($fields, true).'])');
     189:
     190:         global $config;
     191:
     192:         // the form action
     193:         $fields['formAction'] = $_SERVER['REQUEST_URI'];
     194:
     195:         // work out how many columns will be in the table
     196:         $reflection = new ReflectionClass(get_class($this->BO));
     197:         $properties = array_keys($reflection->getDefaultProperties());
     198:         $fields['colCount'] = 1+count(array_diff($properties, $this->BO->getDefaultAttributes(), $this->BO->getTransientAttributes()));
     199:
     200:         // get the class attributes
     201:         $properties = $reflection->getProperties();
     202:
     203:         $html = '';
     204:
     205:         $html .= '<tr>';
     206:         foreach($properties as $propObj) {
     207:             $propName = $propObj->name;
     208:
     209:             // skip over password fields
     210:             $property = $this->BO->getPropObject($propName);
     211:             if(!($property instanceof String && $property->checkIsPassword())) {
     212:                 if (!in_array($propName, $this->BO->getDefaultAttributes()) && !in_array($propName, $this->BO->getTransientAttributes())) {
     213:                     $html .= '  <th>'.$this->BO->getDataLabel($propName).'</th>';
     214:                 }
     215:                 if ($propName == 'OID')
     216:                     $html .= '  <th>'.$this->BO->getDataLabel($propName).'</th>';
     217:             }else{
     218:                 $fields['colCount'] = $fields['colCount']-1;
     219:             }
     220:         }
     221:         $html .= '</tr><tr>';
     222:
     223:         $fields['formHeadings'] = $html;
     224:
     225:         $html = '';
     226:
     227:         // and now the values
     228:         foreach($properties as $propObj) {
     229:             $propName = $propObj->name;
     230:
     231:             $property = $this->BO->getPropObject($propName);
     232:             if(!($property instanceof String && $property->checkIsPassword())) {
     233:                 if (!in_array($propName, $this->BO->getDefaultAttributes()) && !in_array($propName, $this->BO->getTransientAttributes())) {
     234:                     $propClass = get_class($this->BO->getPropObject($propName));
     235:
     236:                     if ($propClass == 'Text') {
     237:                         $text = htmlentities($this->BO->get($propName), ENT_COMPAT, 'utf-8');
     238:                         if(mb_strlen($text) > 70)
     239:                             $html .= '  <td>&nbsp;'.mb_substr($text, 0, 70).'...</td>';
     240:                         else
     241:                             $html .= '  <td>&nbsp;'.$text.'</td>';
     242:                     }elseif($propClass == 'DEnum') {
     243:                         $html .= '  <td>&nbsp;'.$this->BO->getPropObject($propName)->getDisplayValue().'</td>';
     244:                     }else{
     245:                         $html .= '  <td>&nbsp;'.$this->BO->get($propName).'</td>';
     246:                     }
     247:                 }
     248:                 if ($propName == 'OID')
     249:                     $html .= '  <td>&nbsp;'.$this->BO->getOID().'</td>';
     250:             }
     251:         }
     252:         $html .= '</tr>';
     253:
     254:         $fields['formFields'] = $html;
     255:
     256:         // View button
     257:         if(mb_strpos($_SERVER['REQUEST_URI'], '/tk/') !== false) {
     258:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=Detail&bo='.get_class($this->BO).'&oid='.$this->BO->getOID())."';", 'View', 'view'.$this->BO->getOID().'But');
     259:             $fields['viewButton'] = $button->render();
     260:         }else{
     261:             if($this->BO->hasAttribute('URL'))
     262:                 $button = new Button("document.location = '".$this->BO->get('URL')."';", 'View', 'view'.$this->BO->getOID().'But');
     263:             else
     264:                 $button = new Button("document.location = '".$config->get('app.url')."Detail/bo/".get_class($this->BO)."/oid/".$this->BO->getOID()."';", 'View', 'view'.$this->BO->getOID().'But');
     265:
     266:             $fields['viewButton'] = $button->render();
     267:         }
     268:
     269:         $html = '';
     270:         // render edit and delete buttons for admins only
     271:         if (isset($_SESSION['currentUser']) && $_SESSION['currentUser']->inGroup('Admin')) {
     272:             $html .= '&nbsp;&nbsp;';
     273:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=Edit&bo='.get_class($this->BO)."&oid=".$this->BO->getOID())."'", "Edit", "edit".$this->BO->getOID()."But");
     274:             $html .= $button->render();
     275:             $html .= '&nbsp;&nbsp;';
     276:
     277:             $js = "if(window.jQuery) {
     278:                     BootstrapDialog.show({
     279:                         title: 'Confirmation',
     280:                         message: 'Are you sure you wish to delete this item?',
     281:                         buttons: [
     282:                             {
     283:                                 icon: 'glyphicon glyphicon-remove',
     284:                                 label: 'Cancel',
     285:                                 cssClass: 'btn btn-default btn-xs',
     286:                                 action: function(dialogItself){
     287:                                     dialogItself.close();
     288:                                 }
     289:                             },
     290:                             {
     291:                                 icon: 'glyphicon glyphicon-ok',
     292:                                 label: 'Okay',
     293:                                 cssClass: 'btn btn-default btn-xs',
     294:                                 action: function(dialogItself) {
     295:                                     $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('deleteOID')) : 'deleteOID')."\"]').attr('value', '".$this->BO->getOID()."');
     296:                                     $('#deleteForm').submit();
     297:                                     dialogItself.close();
     298:                                 }
     299:                             }
     300:                         ]
     301:                     });
     302:                 }";
     303:
     304:             $button = new Button($js, "Delete", "delete".$this->BO->getOID()."But");
     305:             $html .= $button->render();
     306:         }
     307:         $fields['adminButtons'] = $html;
     308:
     309:         // buffer security fields to $formSecurityFields variable
     310:         $fields['formSecurityFields'] = self::renderSecurityFields();
     311:
     312:         self::$logger->debug('<<listView [HTML]');
     313:         return AlphaView::loadTemplate($this->BO, 'list', $fields);
     314:     }
     315:
     316:     /**
     317:      * (non-PHPdoc)
     318:      * @see alpha/view/renderers/AlphaRendererProviderInterface::detailedView()
     319:      */
     320:     public function detailedView($fields=array()) {
     321:         self::$logger->debug('>>detailedView(fields=['.var_export($fields, true).'])');
     322:
     323:         global $config;
     324:
     325:         // we may want to display the OID regardless of class
     326:         $fields['OIDLabel'] = $this->BO->getDataLabel('OID');
     327:         $fields['OID'] = $this->BO->getOID();
     328:
     329:         // buffer form fields to $formFields
     330:         $fields['formFields'] = $this->renderAllFields('view');
     331:
     332:         // Back button
     333:         $button = new Button('history.back()', 'Back', 'backBut');
     334:         $fields['backButton'] = $button->render();
     335:
     336:         $html = '';
     337:         // render edit and delete buttons for admins only
     338:         if (isset($_SESSION['currentUser']) && $_SESSION['currentUser']->inGroup('Admin')) {
     339:
     340:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=Edit&bo='.get_class($this->BO)."&oid=".$this->BO->getOID())."'", "Edit", "editBut");
     341:             $html .= $button->render();
     342:
     343:             $js = "if(window.jQuery) {
     344:                     BootstrapDialog.show({
     345:                         title: 'Confirmation',
     346:                         message: 'Are you sure you wish to delete this item?',
     347:                         buttons: [
     348:                             {
     349:                                 icon: 'glyphicon glyphicon-remove',
     350:                                 label: 'Cancel',
     351:                                 cssClass: 'btn btn-default btn-xs',
     352:                                 action: function(dialogItself){
     353:                                     dialogItself.close();
     354:                                 }
     355:                             },
     356:                             {
     357:                                 icon: 'glyphicon glyphicon-ok',
     358:                                 label: 'Okay',
     359:                                 cssClass: 'btn btn-default btn-xs',
     360:                                 action: function(dialogItself) {
     361:                                     $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('deleteOID')) : 'deleteOID')."\"]').attr('value', '".$this->BO->getOID()."');
     362:                                     $('#deleteForm').submit();
     363:                                     dialogItself.close();
     364:                                 }
     365:                             }
     366:                         ]
     367:                     });
     368:                 }";
     369:
     370:             $button = new Button($js, "Delete", "deleteBut");
     371:             $html .= $button->render();
     372:         }
     373:         $fields['adminButtons'] = $html;
     374:
     375:         self::$logger->debug('<<detailedView [HTML]');
     376:         return AlphaView::loadTemplate($this->BO, 'detail', $fields);
     377:     }
     378:
     379:     /**
     380:      * (non-PHPdoc)
     381:      * @see alpha/view/renderers/AlphaRendererProviderInterface::adminView()
     382:      */
     383:     public function adminView($fields=array()) {
     384:         self::$logger->debug('>>adminView(fields=['.var_export($fields, true).'])');
     385:
     386:         global $config;
     387:
     388:         // the form action
     389:         $fields['formAction'] = $_SERVER['REQUEST_URI'];
     390:
     391:         // the class name of the BO
     392:         $fields['className'] = get_class($this->BO);
     393:
     394:         // the table name in the DB for the BO
     395:         $fields['tableName'] = $this->BO->getTableName();
     396:
     397:         // record count for the BO in the DB
     398:         $fields['count'] = ($this->BO->checkTableExists() ? $this->BO->getCount() : '<span class="warning">unavailable</span>');
     399:
     400:         // table exists in the DB?
     401:         $fields['tableExists'] = ($this->BO->checkTableExists() ? '<span class="success">Yes</span>' : '<span class="warning">No</span>');
     402:
     403:         if($this->BO->getMaintainHistory())
     404:             $fields['tableExists'] = ($this->BO->checkTableExists(true) ? '<span class="success">Yes</span>' : '<span class="warning">No history table</span>');
     405:
     406:         // table schema needs to be updated in the DB?
     407:         $fields['tableNeedsUpdate'] = ($this->BO->checkTableNeedsUpdate() ? '<span class="warning">Yes</span>' : '<span class="success">No</span>');
     408:
     409:         // create button
     410:         if($this->BO->checkTableExists()) {
     411:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=Create&bo='.get_class($this->BO))."'", "Create New", "create".get_class($this->BO)."But");
     412:             $fields['createButton'] = $button->render();
     413:         }else{
     414:             $fields['createButton'] = '';
     415:         }
     416:
     417:         // list all button
     418:         if($this->BO->checkTableExists()) {
     419:             $button = new Button("document.location = '".FrontController::generateSecureURL('act=ListAll&bo='.get_class($this->BO))."'", "List All", "list".get_class($this->BO)."But");
     420:             $fields['listButton'] = $button->render();
     421:         }else{
     422:             $fields['listButton'] = '';
     423:         }
     424:
     425:         // the create table button (if required)
     426:         $html = '';
     427:
     428:         if (!$this->BO->checkTableExists()) {
     429:             $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('createTableBut')) : 'createTableBut');
     430:             $button = new Button('submit', 'Create Table', $fieldname);
     431:             $html .= $button->render();
     432:             // hidden field so that we know which class to create the table for
     433:             $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('createTableClass')) : 'createTableClass');
     434:             $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->BO).'"/>';
     435:         }
     436:
     437:         if ($html == '' && $this->BO->getMaintainHistory() && !$this->BO->checkTableExists(true)) {
     438:             $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('createHistoryTableBut')) : 'createHistoryTableBut');
     439:             $button = new Button('submit', 'Create History Table', $fieldname);
     440:             $html .= $button->render();
     441:             // hidden field so that we know which class to create the table for
     442:             $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('createTableClass')) : 'createTableClass');
     443:             $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->BO).'"/>';
     444:         }
     445:         $fields['createTableButton'] = $html;
     446:
     447:         // recreate and update table buttons (if required)
     448:         $html = '';
     449:         if ($this->BO->checkTableNeedsUpdate() && $this->BO->checkTableExists()) {
     450:
     451:             $js = "if(window.jQuery) {
     452:                     BootstrapDialog.show({
     453:                         title: 'Confirmation',
     454:                         message: 'Are you sure you wish to recreate this class table (all data will be lost)?',
     455:                         buttons: [
     456:                             {
     457:                                 icon: 'glyphicon glyphicon-remove',
     458:                                 label: 'Cancel',
     459:                                 cssClass: 'btn btn-default btn-xs',
     460:                                 action: function(dialogItself){
     461:                                     dialogItself.close();
     462:                                 }
     463:                             },
     464:                             {
     465:                                 icon: 'glyphicon glyphicon-ok',
     466:                                 label: 'Okay',
     467:                                 cssClass: 'btn btn-default btn-xs',
     468:                                 action: function(dialogItself) {
     469:                                     $('[Id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('admin_'.get_class($this->BO).'_button_pressed')) : 'admin_'.get_class($this->BO).'_button_pressed')."\"]').attr('value', 'recreateTableBut');
     470:                                     $('#admin_".get_class($this->BO)."').submit();
     471:                                     dialogItself.close();
     472:                                 }
     473:                             }
     474:                         ]
     475:                     });
     476:                 }";
     477:
     478:             $button = new Button($js , "Recreate Table", "recreateTableBut");
     479:             $html .= $button->render();
     480:             // hidden field so that we know which class to recreate the table for
     481:             $html .= '<input type="hidden" name="recreateTableClass" value="'.get_class($this->BO).'"/>';
     482:             $html .= '&nbsp;&nbsp;';
     483:
     484:             $js = "if(window.jQuery) {
     485:                     BootstrapDialog.show({
     486:                         title: 'Confirmation',
     487:                         message: 'Are you sure you wish to attempt to modify this class table by adding new attributes?',
     488:                         buttons: [
     489:                             {
     490:                                 icon: 'glyphicon glyphicon-remove',
     491:                                 label: 'Cancel',
     492:                                 cssClass: 'btn btn-default btn-xs',
     493:                                 action: function(dialogItself){
     494:                                     dialogItself.close();
     495:                                 }
     496:                             },
     497:                             {
     498:                                 icon: 'glyphicon glyphicon-ok',
     499:                                 label: 'Okay',
     500:                                 cssClass: 'btn btn-default btn-xs',
     501:                                 action: function(dialogItself) {
     502:                                     $('[Id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('admin_'.get_class($this->BO).'_button_pressed')) : 'admin_'.get_class($this->BO).'_button_pressed')."\"]').attr('value', 'updateTableBut');
     503:                                     $('#admin_".get_class($this->BO)."').submit();
     504:                                     dialogItself.close();
     505:                                 }
     506:                             }
     507:                         ]
     508:                     });
     509:                 }";
     510:
     511:             $button = new Button($js , "Update Table", "updateTableBut");
     512:             $html .= $button->render();
     513:             // hidden field so that we know which class to update the table for
     514:             $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('updateTableClass')) : 'updateTableClass');
     515:             $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->BO).'"/>';
     516:             // hidden field to tell us which button was pressed
     517:             $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('admin_'.get_class($this->BO).'_button_pressed')) : 'admin_'.get_class($this->BO).'_button_pressed');
     518:             $html .= '<input type="hidden" id="'.$fieldname.'" name="'.$fieldname.'" value=""/>';
     519:         }
     520:         $fields['recreateOrUpdateButtons'] = $html;
     521:
     522:         // buffer security fields to $formSecurityFields variable
     523:         $fields['formSecurityFields'] = self::renderSecurityFields();
     524:
     525:         self::$logger->debug('<<adminView [HTML]');
     526:         return AlphaView::loadTemplate($this->BO, 'admin', $fields);
     527:     }
     528:
     529:     /**
     530:      * (non-PHPdoc)
     531:      * @see alpha/view/renderers/AlphaRendererProviderInterface::displayPageHead()
     532:      */
     533:     public static function displayPageHead($controller) {
     534:         if(self::$logger == null)
     535:             self::$logger = new Logger('AlphaRendererProviderHTML');
     536:
     537:         self::$logger->debug('>>displayPageHead(controller=['.var_export($controller, true).'])');
     538:
     539:         global $config;
     540:
     541:         if(!AlphaController::checkControllerDefExists(get_class($controller)))
     542:             throw new IllegalArguementException('The controller provided ['.get_class($controller).'] is not defined anywhere!');
     543:
     544:         if (isset($_SESSION['currentUser']) && AlphaDAO::isInstalled() && $_SESSION['currentUser']->inGroup('Admin') && mb_strpos($_SERVER['REQUEST_URI'], '/tk/') !== false) {
     545:             $allowCSSOverrides = false;
     546:         }else{
     547:             $allowCSSOverrides = true;
     548:         }
     549:         $html = AlphaView::loadTemplateFragment('html', 'head.phtml', array('title' => $controller->getTitle(), 'description' => $controller->getDescription(), 'allowCSSOverrides' => $allowCSSOverrides));
     550:
     551:         if(method_exists($controller, 'during_displayPageHead_callback'))
     552:             $html.= $controller->during_displayPageHead_callback();
     553:
     554:         $html.= '</head>';
     555:
     556:         try {
     557:             if($controller->getBO() != null)
     558:                 $html.= '<body'.($controller->getBO()->get('bodyOnload') != '' ? ' onload="'.$controller->getBO()->get('bodyOnload').'"' : '').'>';
     559:             else
     560:                 $html.= '<body>';
     561:         } catch (AlphaException $e) {
     562:             $html.= '<body>';
     563:         }
     564:
     565:         $html .= '<div class="container">';
     566:
     567:         if(method_exists($controller, 'insert_CMSDisplayStandardHeader_callback'))
     568:             $html.= $controller->insert_CMSDisplayStandardHeader_callback();
     569:
     570:
     571:         self::$logger->debug('<<displayPageHead [HTML]');
     572:         return $html;
     573:     }
     574:
     575:     /**
     576:      * (non-PHPdoc)
     577:      * @see alpha/view/renderers/AlphaRendererProviderInterface::displayPageFoot()
     578:      */
     579:     public static function displayPageFoot($controller) {
     580:         if(self::$logger == null)
     581:             self::$logger = new Logger('AlphaRendererProviderHTML');
     582:
     583:         self::$logger->debug('>>displayPageFoot(controller=['.get_class($controller).'])');
     584:
     585:
     586:         $html = AlphaView::loadTemplateFragment('html', 'footer.phtml', array());
     587:
     588:         self::$logger->debug('<<displayPageFoot ['.$html.']');
     589:         return $html;
     590:     }
     591:
     592:     /**
     593:      * (non-PHPdoc)
     594:      * @see alpha/view/renderers/AlphaRendererProviderInterface::displayUpdateMessage()
     595:      */
     596:     public static function displayUpdateMessage($message) {
     597:         if(self::$logger == null)
     598:             self::$logger = new Logger('AlphaRendererProviderHTML');
     599:         self::$logger->debug('>>displayUpdateMessage(message=['.$message.'])');
     600:
     601:         $html = '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'.$message.'</div>';
     602:
     603:         self::$logger->debug('<<displayUpdateMessage ['.$html.']');
     604:         return $html;
     605:     }
     606:
     607:     /**
     608:      * (non-PHPdoc)
     609:      * @see alpha/view/renderers/AlphaRendererProviderInterface::displayErrorMessage()
     610:      */
     611:     public static function displayErrorMessage($message) {
     612:         if(self::$logger == null)
     613:             self::$logger = new Logger('AlphaRendererProviderHTML');
     614:         self::$logger->debug('>>displayErrorMessage(message=['.$message.'])');
     615:
     616:         $html = '<div class="alert alert-danger">'.$message.'</div>';
     617:
     618:         self::$logger->debug('<<displayErrorMessage ['.$html.']');
     619:         return $html;
     620:     }
     621:
     622:     /**
     623:      * (non-PHPdoc)
     624:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderErrorPage()
     625:      */
     626:     public static function renderErrorPage($code, $message) {
     627:         global $config;
     628:
     629:         $html = '<html><head>';
     630:         $html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('app.url').'alpha/lib/jquery/ui/themes/'.$config->get('app.css.theme').'/jquery.ui.all.css">';
     631:         $html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('app.url').'alpha/css/alpha.css">';
     632:         $html .= '<title>'.$code.' - '.$message.'</title></head>';
     633:         $html .= '<body>';
     634:         $html .= self::displayErrorMessage('<strong>'.$code.':</strong> '.$message);
     635:         $html .= '</body></html>';
     636:
     637:         return $html;
     638:     }
     639:
     640:     /**
     641:      * (non-PHPdoc)
     642:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderDeleteForm()
     643:      */
     644:     public static function renderDeleteForm() {
     645:         if(self::$logger == null)
     646:             self::$logger = new Logger('AlphaRendererProviderHTML');
     647:         self::$logger->debug('>>renderDeleteForm()');
     648:
     649:         global $config;
     650:
     651:         $html = '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST" id="deleteForm" accept-charset="UTF-8">';
     652:         $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('deleteOID')) : 'deleteOID');
     653:         $html .= '<input type="hidden" name="'.$fieldname.'" id="'.$fieldname.'" value=""/>';
     654:         $html .= self::renderSecurityFields();
     655:         $html .= '</form>';
     656:
     657:         self::$logger->debug('<<renderDeleteForm ['.$html.']');
     658:         return $html;
     659:     }
     660:
     661:     /**
     662:      * (non-PHPdoc)
     663:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderSecurityFields()
     664:      */
     665:     public static function renderSecurityFields() {
     666:         if(self::$logger == null)
     667:             self::$logger = new Logger('AlphaRendererProviderHTML');
     668:
     669:         self::$logger->debug('>>renderSecurityFields()');
     670:
     671:         global $config;
     672:
     673:         $html = '';
     674:
     675:         $fields = AlphaController::generateSecurityFields();
     676:
     677:         if($config->get('security.encrypt.http.fieldnames'))
     678:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt('var1'));
     679:         else
     680:             $fieldname = 'var1';
     681:
     682:         $html .= '<input type="hidden" name="'.$fieldname.'" value="'.$fields[0].'"/>';
     683:
     684:         if($config->get('security.encrypt.http.fieldnames'))
     685:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt('var2'));
     686:         else
     687:             $fieldname = 'var2';
     688:
     689:         $html .= '<input type="hidden" name="'.$fieldname.'" value="'.$fields[1].'"/>';
     690:
     691:         self::$logger->debug('<<renderSecurityFields ['.$html.']');
     692:         return $html;
     693:     }
     694:
     695:     /**
     696:      * (non-PHPdoc)
     697:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderIntegerField()
     698:      * @todo remove table tags and use Bootstrap CSS
     699:      */
     700:     public function renderIntegerField($name, $label, $mode, $value='') {
     701:         self::$logger->debug('>>renderIntegerField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     702:
     703:         global $config;
     704:
     705:         if($config->get('security.encrypt.http.fieldnames'))
     706:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt($name));
     707:         else
     708:             $fieldname = $name;
     709:
     710:         $html = '<div class="form-group">';
     711:         $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
     712:
     713:         if ($mode == 'create') {
     714:             $html .= '<input type="text" style="width:100%;" name="'.$fieldname.'" value="'. (isset ($_POST[$name]) ? $_POST[$name] : '').'"/>';
     715:         }
     716:
     717:         if ($mode == 'edit') {
     718:             $html .= '<input type="text" style="width:100%;" name="'.$fieldname.'" value="'.$value.'"/>';
     719:         }
     720:
     721:         $html .= '</div>';
     722:
     723:         self::$logger->debug('<<renderIntegerField ['.$html.']');
     724:         return $html;
     725:     }
     726:
     727:     /**
     728:      * (non-PHPdoc)
     729:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderDoubleField()
     730:      * @todo remove table tags and use Bootstrap CSS
     731:      */
     732:     public function renderDoubleField($name, $label, $mode, $value='') {
     733:         self::$logger->debug('>>renderDoubleField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     734:
     735:         global $config;
     736:
     737:         if($config->get('security.encrypt.http.fieldnames'))
     738:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt($name));
     739:         else
     740:             $fieldname = $name;
     741:
     742:         $html = '<div class="form-group">';
     743:         $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
     744:
     745:         if ($mode == 'create') {
     746:             $html .= '<input type="text" size="13" name="'.$fieldname.'" value="'. (isset ($_POST[$name]) ? $_POST[$name] : '').'"/>';
     747:         }
     748:
     749:         if ($mode == 'edit') {
     750:             $html .= '<input type="text" size="13" name="'.$fieldname.'" value="'.$value.'"/>';
     751:         }
     752:
     753:         $html .= '</div>';
     754:
     755:         self::$logger->debug('<<renderDoubleField ['.$html.']');
     756:         return $html;
     757:     }
     758:
     759:     /**
     760:      * (non-PHPdoc)
     761:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderBooleanField()
     762:      */
     763:     public function renderBooleanField($name, $label, $mode, $value='') {
     764:         self::$logger->debug('>>renderBooleanField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     765:
     766:         global $config;
     767:
     768:         if($config->get('security.encrypt.http.fieldnames'))
     769:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt($name));
     770:         else
     771:             $fieldname = $name;
     772:
     773:         $html = '<div class="checkbox">';
     774:         $html .= '  <label>';
     775:
     776:         if ($mode == 'create') {
     777:             $html .= '      <input type="hidden" name="'.$fieldname.'" value="0">';
     778:             $html .= '      <input type="checkbox" name="'.$fieldname.'" id="'.$fieldname.'">';
     779:             $html .= '          '.$label;
     780:
     781:         }
     782:
     783:         if ($mode == 'edit') {
     784:             $html .= '      <input type="hidden" name="'.$fieldname.'" value="0">';
     785:             $html .= '      <input type="checkbox" name="'.$fieldname.'" id="'.$fieldname.'"'.($value == '1'? ' checked':'').' />';
     786:             $html .= '          '.$label;
     787:         }
     788:
     789:         $html .= '  </label>';
     790:         $html .= '</div>';
     791:
     792:         self::$logger->debug('<<renderBooleanField ['.$html.']');
     793:         return $html;
     794:     }
     795:
     796:     /**
     797:      * (non-PHPdoc)
     798:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderEnumField()
     799:      */
     800:     public function renderEnumField($name, $label, $mode, $options, $value='') {
     801:         self::$logger->debug('>>renderEnumField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     802:
     803:         global $config;
     804:
     805:         if($config->get('security.encrypt.http.fieldnames'))
     806:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt($name));
     807:         else
     808:             $fieldname = $name;
     809:
     810:         $html = '<div class="form-group">';
     811:         $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
     812:
     813:         if ($mode == 'create') {
     814:             $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
     815:             foreach ($options as $val) {
     816:                 $html .= '      <option value="'.$val.'">'.$val.'</option>';
     817:             }
     818:             $html .= '  </select>';
     819:         }
     820:
     821:         if ($mode == 'edit') {
     822:             $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
     823:             foreach ($options as $val) {
     824:                 if ($value == $val)
     825:                     $html .= '      <option value="'.$val.'" selected>'.$val.'</option>';
     826:                 else
     827:                     $html .= '      <option value="'.$val.'">'.$val.'</option>';
     828:             }
     829:             $html .= '  </select>';
     830:         }
     831:
     832:         $html .= '</div>';
     833:
     834:         self::$logger->debug('<<renderEnumField ['.$html.']');
     835:         return $html;
     836:     }
     837:
     838:     /**
     839:      * (non-PHPdoc)
     840:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderDEnumField()
     841:      */
     842:     public function renderDEnumField($name, $label, $mode, $options, $value='') {
     843:         self::$logger->debug('>>renderDEnumField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     844:
     845:         global $config;
     846:
     847:         if($config->get('security.encrypt.http.fieldnames'))
     848:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt($name));
     849:         else
     850:             $fieldname = $name;
     851:
     852:         $html = '<div class="form-group">';
     853:         $html .= '  <label for="'.$fieldname.'">'.$label.'</label>';
     854:
     855:         if ($mode == 'create') {
     856:             $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
     857:             foreach (array_keys($options) as $index) {
     858:                 $html .= '<option value="'.$index.'">'.$options[$index].'</option>';
     859:             }
     860:             $html .= '  </select>';
     861:         }
     862:
     863:         if ($mode == 'edit') {
     864:             $html .= '  <select name="'.$fieldname.'" id="'.$fieldname.'" class="form-control"/>';
     865:             foreach (array_keys($options) as $index) {
     866:                 if ($value == $index)
     867:                     $html .= '<option value="'.$index.'" selected>'.$options[$index].'</option>';
     868:                 else
     869:                     $html .= '<option value="'.$index.'">'.$options[$index].'</option>';
     870:             }
     871:             $html .= '  </select>';
     872:         }
     873:
     874:         $html .= '</div>';
     875:
     876:         self::$logger->debug('<<renderDEnumField ['.$html.']');
     877:         return $html;
     878:     }
     879:
     880:     /**
     881:      * (non-PHPdoc)
     882:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderDefaultField()
     883:      */
     884:     public function renderDefaultField($name, $label, $mode, $value='') {
     885:         self::$logger->debug('>>renderDefaultField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     886:
     887:         global $config;
     888:
     889:         if($config->get('security.encrypt.http.fieldnames'))
     890:             $fieldname = base64_encode(AlphaSecurityUtils::encrypt($name));
     891:         else
     892:             $fieldname = $name;
     893:
     894:         $html = '';
     895:
     896:         if ($mode == 'create') {
     897:             $html .= '<textarea cols="100" rows="3" name="'.$fieldname.'">'. (isset ($_POST[$name]) ? $_POST[$name] : '').'</textarea>';
     898:         }
     899:
     900:         if ($mode == 'edit') {
     901:             $html .= '<textarea cols="100" rows="3" name="'.$fieldname.'">'.$value.'</textarea>';
     902:         }
     903:
     904:         if ($mode == 'view') {
     905:             $html .= '<p><strong>'.$label.':</strong> '.$value.'</p>';
     906:         }
     907:
     908:         self::$logger->debug('<<renderDefaultField ['.$html.']');
     909:         return $html;
     910:     }
     911:
     912:     /**
     913:      * (non-PHPdoc)
     914:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderTextField()
     915:      */
     916:     public function renderTextField($name, $label, $mode, $value='') {
     917:         self::$logger->debug('>>renderTextField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     918:
     919:         global $config;
     920:
     921:         $html = '';
     922:
     923:         if ($mode == 'create') {
     924:             // give 10 rows for content fields (other 5 by default)
     925:             if($name == 'content')
     926:                 $text = new TextBox($this->BO->getPropObject($name), $label, $name, 10);
     927:             else
     928:                 $text = new TextBox($this->BO->getPropObject($name), $label, $name);
     929:             $html .= $text->render();
     930:         }
     931:
     932:         if ($mode == 'edit') {
     933:             // give 10 rows for content fields (other 5 by default)
     934:             if($name == 'content') {
     935:                 $viewState = ViewState::getInstance();
     936:
     937:                 if($viewState->get('markdownTextBoxRows') == '')
     938:                     $text = new TextBox($this->BO->getPropObject($name), $label, $name, 10);
     939:                 else
     940:                     $text = new TextBox($this->BO->getPropObject($name), $label, $name, (integer)$viewState->get('markdownTextBoxRows'));
     941:
     942:                 $html .= $text->render();
     943:             }else{
     944:                 $text = new TextBox($this->BO->getPropObject($name), $label, $name);
     945:                 $html .= $text->render();
     946:             }
     947:         }
     948:
     949:         if ($mode == 'view') {
     950:             $html .= '<p><strong>';
     951:
     952:             $html .= $label;
     953:
     954:             $html .= ':</strong>';
     955:
     956:             // filter ouput to prevent malicious injection
     957:             $value = InputFilter::encode($value);
     958:
     959:             // ensures that line returns are rendered
     960:             $value = str_replace("\n", '<br>', $value);
     961:
     962:             $html .= '&nbsp;';
     963:
     964:             $html .= $value;
     965:
     966:             $html .= '</p>';
     967:         }
     968:
     969:         self::$logger->debug('<<renderTextField ['.$html.']');
     970:         return $html;
     971:     }
     972:
     973:     /**
     974:      * (non-PHPdoc)
     975:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderStringField()
     976:      */
     977:     public function renderStringField($name, $label, $mode, $value='') {
     978:         self::$logger->debug('>>renderStringField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])');
     979:
     980:         global $config;
     981:
     982:         $html = '';
     983:
     984:         if ($mode == 'create' || $mode == 'edit') {
     985:             $string = new StringBox($this->BO->getPropObject($name), $label, $name);
     986:             $html .= $string->render();
     987:         }
     988:
     989:         if ($mode == 'view') {
     990:             $html .= '<p><strong>'.$label.':</strong> '.$value.'</p>';
     991:         }
     992:
     993:         self::$logger->debug('<<renderStringField ['.$html.']');
     994:         return $html;
     995:     }
     996:
     997:     /**
     998:      * (non-PHPdoc)
     999:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderRelationField()
    1000:      */
    1001:     public function renderRelationField($name, $label, $mode, $value='', $expanded=false, $buttons=true) {
    1002:         self::$logger->debug('>>renderRelationField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'], expanded=['.$expanded.'], buttons=['.$buttons.'])');
    1003:
    1004:         global $config;
    1005:
    1006:         $html = '';
    1007:
    1008:         $rel = $this->BO->getPropObject($name);
    1009:
    1010:         if ($mode == 'create' || $mode == 'edit') {
    1011:             if($rel->getRelationType() == 'MANY-TO-MANY') {
    1012:                 try{
    1013:                     // check to see if the rel is on this class
    1014:                     $rel->getSide(get_class($this->BO));
    1015:                     $widget = new RecordSelector($rel, $label, $name, get_class($this->BO));
    1016:                     $html .= $widget->render($expanded, $buttons);
    1017:                 }catch (IllegalArguementException $iae) {
    1018:                     // the rel may be on a parent class
    1019:                     $parentClassName = ucfirst($this->BO->getTableName()).'Object';
    1020:                     $widget = new RecordSelector($rel, $label, $name, $parentClassName);
    1021:                     $html .= $widget->render($expanded, $buttons);
    1022:                 }
    1023:             }else{
    1024:                 $rel = new RecordSelector($rel, $label, $name);
    1025:                 $html .= $rel->render($expanded, $buttons);
    1026:             }
    1027:         }
    1028:
    1029:         if ($mode == 'view') {
    1030:             if($rel->getRelationType() == 'MANY-TO-ONE') {
    1031:                 $html .= $this->renderDefaultField($name, $label, 'view', $rel->getRelatedClassDisplayFieldValue());
    1032:             }elseif($rel->getRelationType() == 'MANY-TO-MANY') {
    1033:                 try{
    1034:                     // check to see if the rel is on this class
    1035:                     $rel->getSide(get_class($this->BO));
    1036:                     $html .= $this->renderDefaultField($name, $label, 'view', $rel->getRelatedClassDisplayFieldValue(get_class($this->BO)));
    1037:                 }catch (IllegalArguementException $iae) {
    1038:                     // the rel may be on a parent class
    1039:                     $parentClassName = ucfirst($this->BO->getTableName()).'Object';
    1040:                     $html .= $this->renderDefaultField($name, $label, 'view', $rel->getRelatedClassDisplayFieldValue($parentClassName));
    1041:                 }
    1042:             }else{
    1043:                 $rel = new RecordSelector($rel, $label, $name);
    1044:                 $html .= $rel->render($expanded, $buttons);
    1045:             }
    1046:         }
    1047:
    1048:         self::$logger->debug('<<renderRelationField ['.$html.']');
    1049:         return $html;
    1050:     }
    1051:
    1052:     /**
    1053:      * (non-PHPdoc)
    1054:      * @see alpha/view/renderers/AlphaRendererProviderInterface::renderAllFields()
    1055:      */
    1056:     public function renderAllFields($mode, $filterFields=array(), $readOnlyFields=array()) {
    1057:         self::$logger->debug('>>renderAllFields(mode=['.$mode.'], filterFields=['.var_export($filterFields, true).'], readOnlyFields=['.var_export($readOnlyFields, true).'])');
    1058:
    1059:         $html = '';
    1060:
    1061:         // get the class attributes
    1062:         $properties = array_keys($this->BO->getDataLabels());
    1063:
    1064:         $orignalMode = $mode;
    1065:
    1066:         foreach($properties as $propName) {
    1067:             if (!in_array($propName, $this->BO->getDefaultAttributes()) && !in_array($propName, $filterFields)) {
    1068:                 // render readonly fields in the supplied array
    1069:                 if(in_array($propName, $readOnlyFields))
    1070:                     $mode = 'view';
    1071:                 else
    1072:                     $mode = $orignalMode;
    1073:
    1074:                 if(!is_object($this->BO->getPropObject($propName)))
    1075:                     continue;
    1076:
    1077:                 $propClass = get_class($this->BO->getPropObject($propName));
    1078:
    1079:                 // exclude non-Relation transient attributes from create and edit screens
    1080:                 if($propClass != 'Relation' && ($mode == 'edit' || $mode == 'create') && in_array($propName, $this->BO->getTransientAttributes())) {
    1081:                     continue;
    1082:                 }
    1083:
    1084:                 switch (mb_strtoupper($propClass)) {
    1085:                     case 'INTEGER' :
    1086:                         if($mode == 'view') {
    1087:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName));
    1088:                         }else{
    1089:                             $html .= $this->renderIntegerField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1090:                         }
    1091:                     break;
    1092:                     case 'DOUBLE' :
    1093:                         if($mode == 'view') {
    1094:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName));
    1095:                         }else{
    1096:                             $html .= $this->renderDoubleField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1097:                         }
    1098:                     break;
    1099:                     case 'DATE' :
    1100:                         if($mode == 'view') {
    1101:                             $value = $this->BO->get($propName);
    1102:                             if ($value == '0000-00-00')
    1103:                                 $value = '';
    1104:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $value);
    1105:                         }else{
    1106:                             $date = new DateBox($this->BO->getPropObject($propName), $this->BO->getDataLabel($propName), $propName);
    1107:                             $html .= $date->render();
    1108:                         }
    1109:                     break;
    1110:                     case 'TIMESTAMP' :
    1111:                         if($mode == 'view') {
    1112:                             $value = $this->BO->get($propName);
    1113:                             if ($value == '0000-00-00 00:00:00')
    1114:                                 $value = '';
    1115:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $value);
    1116:                         }else{
    1117:                             $timestamp = new DateBox($this->BO->getPropObject($propName), $this->BO->getDataLabel($propName), $propName);
    1118:                             $html .= $timestamp->render();
    1119:                         }
    1120:                     break;
    1121:                     case 'STRING' :
    1122:                         $html .= $this->renderStringField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1123:                     break;
    1124:                     case 'TEXT' :
    1125:                         $html .= $this->renderTextField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1126:                     break;
    1127:                     case 'BOOLEAN' :
    1128:                         if($mode == 'view') {
    1129:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName));
    1130:                         }else{
    1131:                             $html .= $this->renderBooleanField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1132:                         }
    1133:                     break;
    1134:                     case 'ENUM' :
    1135:                         if($mode == 'view') {
    1136:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName));
    1137:                         }else{
    1138:                             $enum = $this->BO->getPropObject($propName);
    1139:                             $html .= $this->renderEnumField($propName, $this->BO->getDataLabel($propName), $mode, $enum->getOptions(), $this->BO->get($propName));
    1140:                         }
    1141:                     break;
    1142:                     case 'DENUM' :
    1143:                         if($mode == 'view') {
    1144:                             $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->getPropObject($propName)->getDisplayValue());
    1145:                         }else{
    1146:                             $denum = $this->BO->getPropObject($propName);
    1147:                             $html .= $this->renderDEnumField($propName, $this->BO->getDataLabel($propName), $mode, $denum->getOptions(), $this->BO->get($propName));
    1148:                         }
    1149:                     break;
    1150:                     case 'RELATION' :
    1151:                         $html .= $this->renderRelationField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1152:                     break;
    1153:                     default :
    1154:                         $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName));
    1155:                     break;
    1156:                 }
    1157:             }
    1158:         }
    1159:
    1160:         self::$logger->debug('<<renderAllFields ['.$html.']');
    1161:         return $html;
    1162:     }
    1163: }
    1164:
    1165: ?>