Inheritance: extends Gc\Core\Object
Example #1
0
 /**
  * Load Textrich prevalue editor
  *
  * @return string
  */
 public function load()
 {
     $parameters = $this->getConfig();
     $ckeditor = new CkEditor();
     if (empty($parameters) or !is_array($parameters)) {
         $parameters = array();
     }
     $ckeditor->setParameters($parameters);
     return $this->addPath(__DIR__)->render('ckeditor-prevalue.phtml', array('textrich' => $ckeditor->getAllItems()));
 }
Example #2
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);
    }