Exemple #1
0
 /**
  * Load upload editor
  *
  * @return string
  */
 public function load()
 {
     $data = unserialize($this->getValue());
     $property = $this->getProperty();
     $textarea = new Element\Textarea($this->getName());
     $textarea->setAttribute('id', $this->getName());
     $textarea->setAttribute('class', 'form-control');
     $textarea->setAttribute('required', $property->isRequired());
     $textarea->setLabel($this->getProperty()->getName());
     $textarea->setValue(!empty($data['source']) ? $data['source'] : '');
     return $this->addPath(__DIR__)->render('markdown-editor.phtml', array('textarea' => $textarea, 'id' => $this->getName(), 'value' => $this->getValue(), 'property' => $property));
 }
Exemple #2
0
 /**
  * @param UploaderModelInterface $model
  * @param null $values
  * @return string
  * @throws InvalidArgumentException
  */
 public function render($model, $values = null)
 {
     if (!$model instanceof UploaderModelInterface) {
         throw new InvalidArgumentException("Unsupportable type of model, required type UploaderModelInterface");
     }
     $textArea = new Textarea();
     $textArea->setName('response');
     $textAreaViewHelper = new FormTextarea();
     $jsonEncoder = new Json();
     $value = $jsonEncoder->encode($model->getVariables());
     $textArea->setValue($value);
     return $textAreaViewHelper->render($textArea);
 }
Exemple #3
0
 /**
  * Load textarea editor
  *
  * @return Element\Textarea
  */
 public function load()
 {
     $config = $this->getConfig();
     $property = $this->getProperty();
     $textarea = new Element\Textarea($this->getName());
     $textarea->setAttribute('class', 'form-control');
     $textarea->setAttribute('required', $property->isRequired());
     $textarea->setAttribute('id', $this->getName());
     $textarea->setLabel($this->getProperty()->getName());
     $textarea->setValue($this->getValue());
     $config = empty($config) ? array() : $config;
     foreach ($config as $key => $value) {
         if (!empty($value)) {
             $textarea->setAttribute($key, $value);
         }
     }
     return $textarea;
 }
Exemple #4
0
    /**
     * Load textrich editor
     *
     * @return mixed
     */
    public function load()
    {
        $this->getHelper('headscript')->appendFile('/backend/assets/datatypes/textrich/ckeditor.js', 'text/javascript');
        $this->getHelper('headscript')->appendFile('/backend/assets/datatypes/textrich/ckeditor-adapters-jquery.js', 'text/javascript');
        $parameters = $this->getConfig();
        $ckeditor = new CkEditor();
        if (empty($parameters) or !is_array($parameters)) {
            $parameters = array();
        }
        $ckeditor->setParameters($parameters);
        $id = 'textrich' . $this->getProperty()->getId();
        $textrich = new Element\Textarea($this->getName());
        $textrich->setLabel($this->getProperty()->getName());
        $textrich->setAttribute('id', $id);
        $textrich->setAttribute('class', $id);
        $textrich->setValue($this->getProperty()->getValue());
        $script = '<script type="text/javascript">
            $(function () {
                var config = {
                    skin: "moono",
                    toolbar: ' . $ckeditor->getToolbarAsJs() . ',
                    allowedContent: true
                };

                $("#' . $id . '").ckeditor(config)
                .ckeditor(function () {
                    this.addCommand("saveDocument",
                    {
                        exec : function (editor, data) {
                            $("#input-save").click();
                        }
                    });
                    this.keystrokeHandler.keystrokes[CKEDITOR.CTRL + 83 /* S */] =  "saveDocument";
                });
            });
        </script>';
        return array($textrich, $script);
    }