public function ckeditorElement($name, $value = null, $attribs = null)
 {
     $helper = new Zend_View_Helper_FormTextarea();
     $helper->setView($this->view);
     //add ckeditor script inside the header
     $this->view->headScript()->appendFile($this->_sCkeditorDefaultPath);
     $this->html .= $helper->formTextarea($name, $value = null, $attribs = null);
     //add inline script to bottom of the body
     $scripts = $this->view->inlineScript();
     $scripts->appendScript("CKEDITOR.replace( '" . $name . "' );");
     return $this->html;
 }
示例#2
0
 /** The function to return
  * @param string $name
  * @param string $value
  * @param array $params
  * @param array $attribs
  * @return string
  * @access public
  */
 public function formCKEditor($name, $value = null, $params = null, $attribs = null)
 {
     $hTextA = new Zend_View_Helper_FormTextarea();
     $hTextA->setView($this->view);
     $xhtml = $hTextA->formTextarea($name, $value, $attribs);
     $this->view->jQuery()->addJavascript('$(document).ready(function () {$("#' . $this->_normalizeId($name) . '").ckeditor(' . (!is_null($params) ? 'function () {},' . Zend_Json_Encoder::encode($params) : '') . ')});');
     if (self::$set == false) {
         $this->view->jQuery()->addJavascriptFile($this->view->baseUrl() . '/js/ckeditor/ckeditor.js');
         $this->view->jQuery()->addJavascriptFile($this->view->baseUrl() . '/js/ckeditor/adapters/jquery.js');
         self::$set = true;
     }
     return $xhtml;
 }
 /**
  * Generates a 'textarea' element.
  *
  * @access public
  *
  * @param string|array $name If a string, the element name.  If an
  * array, all other parameters are ignored, and the array elements
  * are used in place of added parameters.
  *
  * @param mixed $value The element value.
  *
  * @param array $attribs Attributes for the element tag.
  *
  * @return string The element XHTML.
  */
 public function formTextareaOverwrite($name, $value = null, $attribs = null)
 {
     $info = $this->_getInfo($name, $value, $attribs);
     extract($info);
     // name, value, attribs, options, listsep, disabled
     $viewHelperFormCheckbox = new Zend_View_Helper_FormCheckbox();
     $viewHelperFormCheckbox->setView($this->view);
     $viewHelperFormElement = new Zend_View_Helper_FormTextarea();
     $viewHelperFormElement->setView($this->view);
     $checked = '';
     if ($attribs['overwrite']) {
         $checked = 'checked';
         $disabled = true;
         unset($attribs['overwrite']);
     } else {
         $disabled = false;
         if (isset($attribs['class']) && $attribs['class'] != '') {
             $attribs['class'] = $attribs['class'] . ' disabled';
         } else {
             $attribs['class'] = 'disabled';
         }
     }
     $separator = '';
     if (isset($attribs['separator'])) {
         $separator = $attribs['separator'];
         unset($attribs['separator']);
     }
     $xhtml = '';
     $xhtml .= '<div class="checkboxTextFieldCombo">';
     $xhtml .= $viewHelperFormCheckbox->formCheckbox($name . '[overwrite]', null, array_merge($attribs, array('checked' => $checked, 'class' => 'checkbox text-overwrite-checkbox')));
     $xhtml .= ' ' . $separator;
     if (!$disabled) {
         $xhtml .= $viewHelperFormElement->formTextarea($name . '[value]', $value, array_merge($attribs, array('disabled' => 'disabled')));
     } else {
         $xhtml .= $viewHelperFormElement->formTextarea($name . '[value]', $value, $attribs);
     }
     $xhtml .= '</div>';
     return $xhtml;
 }
示例#4
0
 /**
  * Generates CUI validator
  *
  * @see Zend_View_Helper_FormTextarea::formTextarea()
  * @param mixed $value The element value.
  * @param array $attribs Attributes for the element tag.
  * @return string The element XHTML.
  */
 public function formTextarea($name, $value = null, $attribs = null)
 {
     $xhtml = parent::formTextarea($name, $value, $attribs);
     if (isset($this->view->form) && null !== $this->view->form->getElement($name)) {
         $validators = $this->view->form->getElement($name)->getValidators();
         foreach ($validators as $validator) {
             $class = get_class($validator);
             //TODO: add more validator
             if ($class == 'Zend_Validate_StringLength') {
                 $xhtml = '<script>$(function(){$("#' . $name . '").form(\'letterLimit\', {maxChar: ' . $validator->getMax() . '});});</script>' . $xhtml;
             }
         }
     }
     return $xhtml;
 }
示例#5
0
 public function formWysiwyg($name, $value = null, $attribs = null)
 {
     $info = $this->_getInfo($name, $value, $attribs);
     extract($info);
     // name, value, attribs, options, listsep, disable
     if (isset($attribs['baseUrl'])) {
         unset($attribs['baseUrl']);
         $_SESSION['CKFINDER_BASEURL'] = $attribs['baseUrl'];
     } else {
         unset($_SESSION['CKFINDER_BASEURL']);
     }
     if (isset($attribs['baseDir'])) {
         unset($attribs['baseDir']);
         $_SESSION['CKFINDER_BASEDIR'] = $attribs['baseDir'];
     } else {
         unset($_SESSION['CKFINDER_BASEDIR']);
     }
     $this->_renderScript($name, $value, $attribs);
     return parent::formTextarea($name, $value, $attribs);
 }
示例#6
0
 /**
  * Generates a 'textarea' element.
  *
  * @access public
  *
  * @param string|array $name If a string, the element name.  If an
  * array, all other parameters are ignored, and the array elements
  * are extracted in place of added parameters.
  *
  * @param mixed $value The element value.
  *
  * @param array $attribs Attributes for the element tag.
  *
  * @return string The element XHTML.
  */
 public function formTextarea($name, $value = null, $attribs = null)
 {
     $value = htmlspecialchars_decode($value, ENT_QUOTES);
     return parent::formTextarea($name, $value, $attribs);
 }
示例#7
0
 /**
  * Generates a 'textarea' element and adds Ckeditor
  *
  * @param string|array $name
  * @param mixed $value The element value.
  * @param array $attribs Attributes for the element tag.
  * @return string The element XHTML
  * @throws Robo47_View_Helper_Exception
  */
 public function ckeditor($name, $value = null, $attribs = null)
 {
     if (!isset($attribs['id'])) {
         $message = 'Cant create CDKEditor for textarea without an id';
         throw new Robo47_View_Helper_Exception($message);
     }
     $textArea = parent::formTextarea($name, $value, $attribs);
     $ckeditorOptions = $this->getEditorOptions();
     $id = $attribs['id'];
     if (!empty($ckeditorOptions)) {
         $ckeditorCode = "CKEDITOR.replace('{$id}', {$ckeditorOptions});";
     } else {
         $ckeditorCode = "CKEDITOR.replace('{$id}');";
     }
     $initMode = $this->getInitMode();
     switch ($initMode) {
         case self::INIT_MODE_SCRIPT:
             $code = '<script type="text/javascript">' . PHP_EOL . '//<![CDATA[' . PHP_EOL . $ckeditorCode . PHP_EOL . '//]]>' . PHP_EOL . '</script>';
             $returnCode = $textArea . $code;
             break;
         case self::INIT_MODE_JQUERY:
             $headScript = $this->view->HeadScript();
             /* @var $headScript Zend_View_Helper_HeadScript */
             $code = '$(document).ready( function() { ' . PHP_EOL . $ckeditorCode . PHP_EOL . '});' . PHP_EOL;
             $placement = $this->getPlacement();
             $headScript->headScript('script', $code, $placement);
             $returnCode = $textArea;
             break;
     }
     return $returnCode;
 }