Perforce Chronicle 2012.2/486814
API Documentation

Content_Form_Decorator_ContentIcon Class Reference

This decorator extends the htmltag decorator and implements the enhanced decorator interface to add the icon from a content type when decorating content. More...

Inheritance diagram for Content_Form_Decorator_ContentIcon:
P4Cms_Content_EnhancedDecoratorInterface

List of all members.

Public Member Functions

 getContentRecord ()
 Get the associated content record (if set).
 render ($content)
 Gets the uri of the icon from the content type of the entry then renders using the parent method by setting applicable options.
 setContentRecord ($content)
 Set the associated content record for this element.

Protected Attributes

 $_contentRecord = null
 $_cssClass = 'content-type-icon'
 $_tag = 'img'

Detailed Description

This decorator extends the htmltag decorator and implements the enhanced decorator interface to add the icon from a content type when decorating content.

It introduces the content-type-icon-small css class, used to style smaller content type icons in a consistent manner.

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_ContentIcon::getContentRecord ( )

Get the associated content record (if set).

Returns:
null|P4Cms_Content the associated content record or null if none set.

Implements P4Cms_Content_EnhancedDecoratorInterface.

    {
        return $this->_contentRecord;
    }
Content_Form_Decorator_ContentIcon::render ( content)

Gets the uri of the icon from the content type of the entry then renders using the parent method by setting applicable options.

If no entry is provided, does not perform render.

Parameters:
string$contentThe content to decorate.
Returns:
string The decorated content.
    {
        if (!$this->getContentRecord()) {
            return $content;
        }
        
        $type    = $this->getContentRecord()->getContentType();
        $view    = $this->getElement()->getView();
        $iconUrl = $view->url(
            array (
                'module'        => 'content',
                'controller'    => 'type',
                'action'        => 'icon',
                'id'            => $type->getId()
            )
        );

        $this->setOption('class',  $this->_cssClass);
        $this->setOption('src',    $iconUrl);
        
        return parent::render($content);
    }
Content_Form_Decorator_ContentIcon::setContentRecord ( content)

Set the associated content record for this element.

Parameters:
P4Cms_Content$contentthe associated content record for this element.
Returns:
Content_Form_Decorator_ContentLink return this instance, for chaining

Implements P4Cms_Content_EnhancedDecoratorInterface.

     {
         $this->_contentRecord = $content;
         return $this;
     }

Member Data Documentation

Content_Form_Decorator_ContentIcon::$_contentRecord = null [protected]
Content_Form_Decorator_ContentIcon::$_cssClass = 'content-type-icon' [protected]
Content_Form_Decorator_ContentIcon::$_tag = 'img' [protected]

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