Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes

Robo47_View_Helper_Ckeditor Class Reference

List of all members.

Public Member Functions

 __construct ($options=array())
 ckeditor ($name, $value=null, $attribs=null)
 Generates a 'textarea' element and adds Ckeditor.
 getEditorOptions ()
 Get Editor Options.
 getInitMode ()
 Get InitMode.
 getOptions ()
 Get Options.
 getPlacement ()
 Get Placement.
 setEditorOptions ($options)
 Set Editor Options.
 setInitMode ($initMode)
 Set initMode.
 setOptions ($options)
 Set Options.
 setPlacement ($placement)
 Set Placement.

Static Public Member Functions

static getDefaultOption ($option, $default=null)
 Get default Option.
static getDefaultOptions ()
 Get default options.
static setDefaultOption ($option, $value)
 Set default Option.
static setDefaultOptions ($options=array())
 Set default Options.
static unsetDefaultOptions ()
 Clears default options.

Public Attributes

const INIT_MODE_JQUERY = 'jquery'
 Option to use jquerys .ready; via the Headscript-View-Helper.
const INIT_MODE_SCRIPT = 'script'
 Option to use <script>-tags directly behind textarea.

Protected Attributes

 $_editorOptions = ''
 $_initMode = 'script'
 $_placement = 'append'

Static Protected Attributes

static $_defaultOptions = array()

Detailed Description

Definition at line 36 of file Ckeditor.php.


Constructor & Destructor Documentation

Robo47_View_Helper_Ckeditor::__construct ( options = array()  ) 
Parameters:
array|Zend_Config $options

Definition at line 76 of file Ckeditor.php.

References setOptions().

    {
        $this->setOptions(self::$_defaultOptions);
        $this->setOptions($options);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_View_Helper_Ckeditor::ckeditor ( name,
value = null,
attribs = null 
)

Generates a 'textarea' element and adds Ckeditor.

Parameters:
string|array $name
mixed $value The element value.
array $attribs Attributes for the element tag.
Returns:
string The element XHTML
Exceptions:
Robo47_View_Helper_Exception 

Definition at line 228 of file Ckeditor.php.

References getEditorOptions(), getInitMode(), and getPlacement().

    {
        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;
    }

Here is the call graph for this function:

static Robo47_View_Helper_Ckeditor::getDefaultOption ( option,
default = null 
) [static]

Get default Option.

Parameters:
string $option
mixed $default
Returns:
mixed

Definition at line 287 of file Ckeditor.php.

    {
        if (isset(self::$_defaultOptions[$option])) {
            return self::$_defaultOptions[$option];
        } else {
            return $default;
        }
    }

static Robo47_View_Helper_Ckeditor::getDefaultOptions (  )  [static]

Get default options.

Returns:
array

Definition at line 301 of file Ckeditor.php.

    {
        return self::$_defaultOptions;
    }

Robo47_View_Helper_Ckeditor::getEditorOptions (  ) 

Get Editor Options.

Returns:
string

Definition at line 147 of file Ckeditor.php.

Referenced by ckeditor(), and getOptions().

    {
        return $this->_editorOptions;
    }

Here is the caller graph for this function:

Robo47_View_Helper_Ckeditor::getInitMode (  ) 

Get InitMode.

Returns:
string

Definition at line 127 of file Ckeditor.php.

Referenced by ckeditor(), and getOptions().

    {
        return $this->_initMode;
    }

Here is the caller graph for this function:

Robo47_View_Helper_Ckeditor::getOptions (  ) 

Get Options.

Returns:
array

Definition at line 113 of file Ckeditor.php.

References getEditorOptions(), getInitMode(), and getPlacement().

    {
        return array(
            'initMode' => $this->getInitMode(),
            'placement' => $this->getPlacement(),
            'editorOptions' => $this->getEditorOptions(),
        );
    }

Here is the call graph for this function:

Robo47_View_Helper_Ckeditor::getPlacement (  ) 

Get Placement.

Returns:
string

Definition at line 137 of file Ckeditor.php.

Referenced by ckeditor(), and getOptions().

    {
        return $this->_placement;
    }

Here is the caller graph for this function:

static Robo47_View_Helper_Ckeditor::setDefaultOption ( option,
value 
) [static]

Set default Option.

Parameters:
string $option
mixed $value

Definition at line 275 of file Ckeditor.php.

    {
        self::$_defaultOptions[$option] = $value;
    }

static Robo47_View_Helper_Ckeditor::setDefaultOptions ( options = array()  )  [static]

Set default Options.

Parameters:
array|Zend_Config $options

Definition at line 211 of file Ckeditor.php.

    {
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        }
        self::$_defaultOptions = $options;
    }

Robo47_View_Helper_Ckeditor::setEditorOptions ( options  ) 

Set Editor Options.

Parameters:
string $options
Returns:
Robo47_View_Helper_Ckeditor *Provides Fluent Interface*

Definition at line 200 of file Ckeditor.php.

Referenced by setOptions().

    {
        $this->_editorOptions = $options;
        return $this;
    }

Here is the caller graph for this function:

Robo47_View_Helper_Ckeditor::setInitMode ( initMode  ) 

Set initMode.

Parameters:
string $initMode
Returns:
Robo47_View_Helper_Ckeditor *Provides Fluent Interface*

Definition at line 158 of file Ckeditor.php.

Referenced by setOptions().

    {
        $initMode = strtolower($initMode);
        switch ($initMode) {
            case self::INIT_MODE_SCRIPT:
            case self::INIT_MODE_JQUERY:
                $this->_initMode = $initMode;
                break;
            default:
                $message = 'Invalid initMode: ' . $initMode;
                throw new Robo47_View_Helper_Exception($message);
        }
        return $this;
    }

Here is the caller graph for this function:

Robo47_View_Helper_Ckeditor::setOptions ( options  ) 

Set Options.

Parameters:
array|Zend_Config $options
Returns:

Definition at line 88 of file Ckeditor.php.

References setEditorOptions(), setInitMode(), and setPlacement().

Referenced by __construct().

    {
        foreach ($options as $option => $value) {
            switch ($option) {
                case 'initMode':
                    $this->setInitMode($value);
                    break;
                case 'placement':
                    $this->setPlacement($value);
                    break;
                case 'editorOptions':
                    $this->setEditorOptions($value);
                    break;
                default:
                    break;
            }
        }
        return $this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_View_Helper_Ckeditor::setPlacement ( placement  ) 

Set Placement.

Parameters:
string $placement
Returns:
Robo47_View_Helper_Ckeditor *Provides Fluent Interface*

Definition at line 179 of file Ckeditor.php.

Referenced by setOptions().

    {
        $placement = strtolower($placement);
        switch ($placement) {
            case 'append':
            case 'prepend':
                $this->_placement = $placement;
                break;
            default:
                $message = 'Invalid placement: ' . $placement;
                throw new Robo47_View_Helper_Exception($message);
        }
        return $this;
    }

Here is the caller graph for this function:

static Robo47_View_Helper_Ckeditor::unsetDefaultOptions (  )  [static]

Clears default options.

Definition at line 309 of file Ckeditor.php.

    {
        self::$_defaultOptions = array();
    }


Member Data Documentation

Robo47_View_Helper_Ckeditor::$_defaultOptions = array() [static, protected]

Definition at line 53 of file Ckeditor.php.

Robo47_View_Helper_Ckeditor::$_editorOptions = '' [protected]

Definition at line 71 of file Ckeditor.php.

Robo47_View_Helper_Ckeditor::$_initMode = 'script' [protected]

Definition at line 59 of file Ckeditor.php.

Robo47_View_Helper_Ckeditor::$_placement = 'append' [protected]

Definition at line 65 of file Ckeditor.php.

Option to use jquerys .ready; via the Headscript-View-Helper.

Definition at line 41 of file Ckeditor.php.

Option to use <script>-tags directly behind textarea.

Definition at line 46 of file Ckeditor.php.


The documentation for this class was generated from the following file: