|
Perforce Chronicle 2012.2/486814
API Documentation
|
Manages content operations (e.g. More...
Public Member Functions | |
| indexAction () | |
| Produce a presentation for the specified category;. | |
Manages content operations (e.g.
add).
| 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');
}
}