Perforce Chronicle 2012.2/486814
API Documentation

Category_IndexController Class Reference

Manages content operations (e.g. More...

List of all members.

Public Member Functions

 indexAction ()
 Produce a presentation for the specified category;.

Detailed Description

Manages content operations (e.g.

add).

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_IndexController::indexAction ( )

Produce a presentation for the specified category;.

    {
        // enforce permissions.
        $this->acl->check('categories', 'access');

        $view    = $this->view;
        $request = $this->getRequest();
        $id      = $request->getParam('category');

        // if a category is specified, display it; otherwise, start at root.
        if (strlen($id)) {
            try {
                $category = Category_Model_Category::fetch($id);
            } catch (P4Cms_Model_NotFoundException $e) {
                return $this->_forward('page-not-found', 'index', 'error');
            }

            // if the category specifies a valid content entry for its index
            // forward to the view action of the content controller.
            if ($category->hasIndexContent()) {
                return $this->_forward(
                    'view',
                    'index',
                    'content',
                    array('id' => $category->getValue('indexContent'))
                );
            }

            // populate view with current category and its contents.
            $view->category     = $category;
            $view->categories   = $category->getChildren();
            $options            = array(Category_Model_Category::OPTION_DEREFERENCE => true);
            $view->entries      = $category->getEntries($options);
            $view->headTitle()->set($category->getTitle());

        } else {
            $query = new P4Cms_Record_Query;
            $query->addPath('*')
                  ->setSortBy('title');

            $view->categories = Category_Model_Category::fetchAll($query);
            $view->headTitle()->set('Categories');
        }
    }

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