Perforce Chronicle 2012.2/486814
API Documentation

Content_Form_Decorator_Value Class Reference

Renders the value of an element wrapped in a span with a 'value-node' class name to identify it in a content element dijit. More...

List of all members.

Public Member Functions

 render ($content)
 Return the value of the element for display wrapped in a span tag w.

Protected Member Functions

 _renderArray (array $value)
 Return the value of the element with array value for display wrapped in a span tag w.

Protected Attributes

 $_htmlArrayItemTag = 'li'
 $_htmlArrayTag = 'ul'
 $_htmlClassName = "value-node"
 $_skipElements

Detailed Description

Renders the value of an element wrapped in a span with a 'value-node' class name to identify it in a content element dijit.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

Content_Form_Decorator_Value::_renderArray ( array $  value) [protected]

Return the value of the element with array value for display wrapped in a span tag w.

a special class.

Parameters:
array$valueArray to render
Returns:
string
    {
        $html = '';
        foreach ($value as $key => $item) {
            if ($this->_htmlArrayItemTag) {
                $item = "<{$this->_htmlArrayItemTag}>$item</{$this->_htmlArrayItemTag}>";
            }
            $html .= $item;
        }
        if ($this->_htmlArrayTag) {
            $html = "<{$this->_htmlArrayTag} class='" . $this->_htmlClassName
                  . "'>$html</{$this->_htmlArrayTag}>";
        } else {
            $html = "<div class='" . $this->_htmlClassName
                  . "'>" . $html . "</div>";
        }

        return $html;
    }
Content_Form_Decorator_Value::render ( content)

Return the value of the element for display wrapped in a span tag w.

a special class.

Parameters:
string$contentThe content to render.
Returns:
string
    {
        $element        = $this->getElement();
        $value          = $element->getValue();
        $multiOptions   = $element->options;

        foreach ($this->_skipElements as $elementClass) {
            if ($element instanceof $elementClass) {
                return $content;
            }
        }

        // expand values from options for multi-option form elements
        // as value contains only option keys
        if (!empty($multiOptions)) {
            if (is_array($value)) {
                foreach ($value as $key => $item) {
                    $value[$key] = array_key_exists($item, $multiOptions)
                        ? $multiOptions[$item]
                        : $item;
                }
            } else {
                $value = array_key_exists($value, $multiOptions)
                    ? $multiOptions[$value]
                    : $value;
            }
        }

        if ($element->isArray() && is_array($value)) {
            $value = $this->_renderArray($value);
        } else {
            $value = "<span class='" . $this->_htmlClassName
                   . "'>" . $value . "</span>";
        }

        switch ($this->getPlacement()) {
            case self::APPEND:
                return $content . $value;
            case self::PREPEND:
                return $value . $content;
            default:
                return $value;
        }
    }

Member Data Documentation

Content_Form_Decorator_Value::$_htmlArrayItemTag = 'li' [protected]
Content_Form_Decorator_Value::$_htmlArrayTag = 'ul' [protected]
Content_Form_Decorator_Value::$_htmlClassName = "value-node" [protected]
Content_Form_Decorator_Value::$_skipElements [protected]
Initial value:
 array (
        'Zend_Form_Element_Captcha'
    )

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