Perforce Chronicle 2012.2/486814
API Documentation

Category_Model_Category Class Reference

Implements categorization of content primarily for navigation. More...

Inheritance diagram for Category_Model_Category:
P4Cms_Categorization_CategoryAbstract P4Cms_Record P4Cms_Record_Connected P4Cms_Model P4Cms_ModelInterface

List of all members.

Public Member Functions

 getEntries (array $options=array())
 Retrieve the content entries within this category.
 getIndexContent ()
 Get the content entry id used as an index page for this category or null if utilizing the default presentation.
 getUri ()
 Get the URI to view this category.
 hasIndexContent ()
 Check if the category specifies a valid index content page.
 setIndexContent ($indexContent)
 Update the index content with a new value.

Public Attributes

const OPTION_DEREFERENCE = 'dereference'

Static Protected Attributes

static $_fields
 Specify the fields for category metadata.
static $_idField = 'id'
 All records should have an id field.
static $_nestingAllowed = true
 Specifies whether this category allows child categories.
static $_storageSubPath = 'categories'
 Specifies the root path for folder category entries.

Detailed Description

Implements categorization of content primarily for navigation.

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

Category_Model_Category::getEntries ( array $  options = array())

Retrieve the content entries within this category.

By default, this will return a list of unique entry identifiers sorted by 'title' field.

Parameters:
array$optionsoptions to influence fetching content entries: OPTION_RECURSIVE - whether to include entries in sub-categories OPTION_DEREFERENCE - influence type of values returned in the output array; if true, then return entry objects, otherwise return entry ids any other options will be passed to the record query
Returns:
array all unique content entries within this category.

Reimplemented from P4Cms_Categorization_CategoryAbstract.

    {
        // convert $options to record query options
        $options['paths'] = parent::getEntries($options);

        // sort by title if sorting key is not set in options
        if (!isset($options['sortBy'])) {
            $options['sortBy'] = 'title';
        }

        // if not dereferencing, limit fields to id as we don't need other fields
        $dereference = isset($options[static::OPTION_DEREFERENCE])
            && $options[static::OPTION_DEREFERENCE];
        if (!$dereference) {
            $options['limitFields'] = P4Cms_Content::getIdField();
        }

        // remove special options to avoid possible interference with query options
        unset($options[static::OPTION_DEREFERENCE]);
        unset($options[static::OPTION_RECURSIVE]);

        // create record query with assembled options
        $query = new P4Cms_Record_Query($options);

        // get content entries via P4Cms_Content::fetchAll() to ensure that
        // all third-parties filtering via pub/sub is applied
        $entries = P4Cms_Content::fetchAll($query, $this->getAdapter());

        // if dereference, return shallow copy of the entries iterator,
        // otherwise return list of entries ids
        return $dereference ? $entries->toArray(true) : $entries->invoke('getId');
    }
Category_Model_Category::getIndexContent ( )

Get the content entry id used as an index page for this category or null if utilizing the default presentation.

Returns:
string|null The index content entries ID, or null for default presentation.
    {
        return $this->_getValue('indexContent');
    }
Category_Model_Category::getUri ( )

Get the URI to view this category.

Returns:
string the URI to view this category.
    {
        $params = array(
            'module'        => 'category',
            'controller'    => 'index',
            'action'        => 'index',
            'category'      => $this->getId(),
        );

        $router = Zend_Controller_Front::getInstance()->getRouter();
        return $router->assemble($params, 'category', null, false);
    }
Category_Model_Category::hasIndexContent ( )

Check if the category specifies a valid index content page.

Returns:
bool true if index content is specified; false otherwise.
    {
        $id = $this->_getValue('indexContent');
        return (strlen($id) && P4Cms_Content::exists($id));
    }
Category_Model_Category::setIndexContent ( indexContent)

Update the index content with a new value.

Parameters:
string$indexContentThe new content
Returns:
P4Cms_Category To maintain a fluent interface
    {
        return $this->_setValue('indexContent', $indexContent);
    }

Member Data Documentation

Category_Model_Category::$_fields [static, protected]
Initial value:
 array(
        'title'         => array(
            'accessor'  => 'getTitle',
            'mutator'   => 'setTitle'
        ),
        'description'   => array(
            'accessor'  => 'getDescription',
            'mutator'   => 'setDescription'
        ),
        'indexContent'  => array(
            'accessor'  => 'getIndexContent',
            'mutator'   => 'setIndexContent'
        )
    )

Specify the fields for category metadata.

Reimplemented from P4Cms_Categorization_CategoryAbstract.

Category_Model_Category::$_idField = 'id' [static, protected]

All records should have an id field.

Reimplemented from P4Cms_Record.

Category_Model_Category::$_nestingAllowed = true [static, protected]

Specifies whether this category allows child categories.

Reimplemented from P4Cms_Categorization_CategoryAbstract.

Category_Model_Category::$_storageSubPath = 'categories' [static, protected]

Specifies the root path for folder category entries.

Reimplemented from P4Cms_Categorization_CategoryAbstract.


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