/**
  * Custom edit view.
  *
  * @param array $fields Hash array of HTML fields to pass to the template.
  *
  * @since 1.0
  *
  * @return string
  */
 public function editView($fields = array())
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $html = '<table cols="2" class="edit_view" style="width:100%; margin:0px">';
     $html .= '<form action="' . $fields['formAction'] . '" method="POST" accept-charset="UTF-8">';
     $textBox = new TextBox($this->BO->getPropObject('content'), $this->BO->getDataLabel('content'), 'content', '', 5, $this->BO->getID());
     $html .= $textBox->render();
     $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('version_num')) : 'version_num';
     $html .= '<input type="hidden" name="' . $fieldname . '" value="' . $this->BO->getVersion() . '"/>';
     $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordOID')) : 'ActiveRecordOID';
     $html .= '<input type="hidden" name="' . $fieldname . '" value="' . $this->BO->getID() . '"/>';
     // render special buttons for admins only
     if ($session->get('currentUser')->inGroup('Admin') && strpos($fields['formAction'], '/tk/') !== false) {
         $html .= '<tr><td colspan="2">';
         $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('saveBut')) : 'saveBut';
         $temp = new Button('submit', 'Save', $fieldname);
         $html .= $temp->render();
         $html .= '&nbsp;&nbsp;';
         $js = "\$('#dialogDiv').text('Are you sure you wish to delete this item?');\n                \$('#dialogDiv').dialog({\n                buttons: {\n                    'OK': function(event, ui) {\n                        \$('[id=\"" . ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordOID')) : 'ActiveRecordOID') . "\"]').attr('value', '" . $this->BO->getOID() . "');\n                        \$('#deleteForm').submit();\n                    },\n                    'Cancel': function(event, ui) {\n                        \$(this).dialog('close');\n                    }\n                }\n            })\n            \$('#dialogDiv').dialog('open');\n            return false;";
         $temp = new Button($js, 'Delete', 'deleteBut');
         $html .= $temp->render();
         $html .= '&nbsp;&nbsp;';
         $temp = new Button("document.location = '" . FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType=' . get_class($this->BO)) . "'", 'Back to List', 'cancelBut');
         $html .= $temp->render();
         $html .= '</td></tr>';
         $html .= View::renderSecurityFields();
         $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('_METHOD')) : '_METHOD';
         $html .= '<input type="hidden" name="' . $fieldname . '" id="' . $fieldname . '" value="PUT"/>';
         $html .= '</form></table>';
     } else {
         $html .= '</table>';
         $html .= '<div align="center">';
         $temp = new Button('submit', 'Update Your Comment', 'saveBut' . $this->BO->getID());
         $html .= $temp->render();
         $html .= '</div>';
         $html .= View::renderSecurityFields();
         $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('_METHOD')) : '_METHOD';
         $html .= '<input type="hidden" name="' . $fieldname . '" id="' . $fieldname . '" value="PUT"/>';
         $html .= '</form>';
     }
     return $html;
 }
 /**
  * {@inheritdoc}
  */
 public function renderTextField($name, $label, $mode, $value = '')
 {
     self::$logger->debug('>>renderTextField(name=[' . $name . '], label=[' . $label . '], mode=[' . $mode . '], value=[' . $value . '])');
     $config = ConfigProvider::getInstance();
     $html = '';
     if ($mode == 'create') {
         // give 10 rows for content fields (other 5 by default)
         if ($name == 'content') {
             $text = new TextBox($this->BO->getPropObject($name), $label, $name, 10);
         } else {
             $text = new TextBox($this->BO->getPropObject($name), $label, $name);
         }
         $html .= $text->render();
     }
     if ($mode == 'edit') {
         // give 10 rows for content fields (other 5 by default)
         if ($name == 'content') {
             $viewState = ViewState::getInstance();
             if ($viewState->get('markdownTextBoxRows') == '') {
                 $text = new TextBox($this->BO->getPropObject($name), $label, $name, 10);
             } else {
                 $text = new TextBox($this->BO->getPropObject($name), $label, $name, (int) $viewState->get('markdownTextBoxRows'));
             }
             $html .= $text->render();
         } else {
             $text = new TextBox($this->BO->getPropObject($name), $label, $name);
             $html .= $text->render();
         }
     }
     if ($mode == 'view') {
         $html .= '<p><strong>';
         $html .= $label;
         $html .= ':</strong>';
         // filter ouput to prevent malicious injection
         $value = InputFilter::encode($value);
         // ensures that line returns are rendered
         $value = str_replace("\n", '<br>', $value);
         $html .= '&nbsp;';
         $html .= $value;
         $html .= '</p>';
     }
     self::$logger->debug('<<renderTextField [' . $html . ']');
     return $html;
 }