Perforce Chronicle 2012.2/486814
API Documentation
|
Provides a facility for content entry links. More...
Public Member Functions | |
getContentAction () | |
Returns the action name for the content. | |
getContentId () | |
Returns the id of the content entry associated with this item. | |
getHref () | |
The url of our content entry or an empty string. | |
getLabel () | |
If we have a content entry set, and no label has been set on this page, returns the entries title. | |
getPrivilege () | |
Returns ACL privilege associated with this page Extended to always return 'access' privilege. | |
getResource () | |
Returns ACL resource assoicated with this page. | |
isActive ($recursive=false) | |
Returns whether page should be considered active or not. | |
isVisible ($recursive=false) | |
Extend parent to make this entry invisble if it isn't valid. | |
setContentAction ($action) | |
Set the content action name. | |
setContentId ($id) | |
Set the id of the content entry associated with this item. | |
toArray () | |
Returns an array representation of the page. | |
Public Attributes | |
const | ACL_PRIVILEGE = 'access' |
const | ACL_RESOURCE = 'content' |
Protected Member Functions | |
_getEntry () | |
If a content entry id has been set and it can be fetched this will return it. | |
Protected Attributes | |
$_contentAction | |
$_contentEntry = false | |
$_contentId |
Provides a facility for content entry links.
These links store the content entry id they are associated with to dynamically generate a URL. Also, they will defer to the content entry's title if no label is provided.
P4Cms_Navigation_Page_Content::_getEntry | ( | ) | [protected] |
If a content entry id has been set and it can be fetched this will return it.
Otherwise if no id has been set or fetch fails null is returned.
Deleted entries will be returned if possible; it is up to caller to screen them if needed.
{ // attempt to fetch content entry if we haven't already done so. if ($this->_contentEntry === false) { $this->_contentEntry = null; try { $id = $this->getContentId(); if ($id) { $this->_contentEntry = P4Cms_Content::fetch($id, array('includeDeleted' => true)); } } catch (Exception $e) { // eat any exceptions we don't want to break // menu management or menu display } } return $this->_contentEntry; }
P4Cms_Navigation_Page_Content::getContentAction | ( | ) |
Returns the action name for the content.
'View' action will be returned by default if no action has been previously set.
{ return $this->_contentAction ?: 'view'; }
P4Cms_Navigation_Page_Content::getContentId | ( | ) |
Returns the id of the content entry associated with this item.
{
return is_string($this->_contentId) ? $this->_contentId : null;
}
P4Cms_Navigation_Page_Content::getHref | ( | ) |
The url of our content entry or an empty string.
{ $entry = $this->_getEntry(); // we only return a link if we have a non-deleted entry if (!$entry || $entry->isDeleted()) { return ""; } // return link to content with specified action (defaults to view if no action was specified) $action = $this->get('contentAction') ?: 'view'; return $entry->getUri($action); }
P4Cms_Navigation_Page_Content::getLabel | ( | ) |
If we have a content entry set, and no label has been set on this page, returns the entries title.
Otherwise returns the label as per normal.
{ if ($this->_label) { return $this->_label; } $entry = $this->_getEntry(); if (!$entry) { return $this->getContentId(); } return $entry->getTitle(); }
P4Cms_Navigation_Page_Content::getPrivilege | ( | ) |
Returns ACL privilege associated with this page Extended to always return 'access' privilege.
{ return static::ACL_PRIVILEGE; }
P4Cms_Navigation_Page_Content::getResource | ( | ) |
Returns ACL resource assoicated with this page.
Extended to always incorporate associated content id.
{ return static::ACL_RESOURCE . ($this->_contentId ? '/' . $this->_contentId : ''); }
P4Cms_Navigation_Page_Content::isActive | ( | $ | recursive = false | ) |
Returns whether page should be considered active or not.
A content link is considered active if the content entry is currently being viewed. We determine this by looking for an active (default) entry on the content entry view helper.
bool | $recursive | [optional] whether page should be considered active if any child pages are active. Default is false. |
{ $layout = Zend_Layout::getMvcInstance(); $view = $layout ? $layout->getView() : null; if (!$view || $this->_active) { return parent::isActive($recursive); } // if we have a content entry view helper, check it for an active entry. $helpers = $view->getPluginLoader('helper'); $helper = $helpers->load('contentEntry', false) ? $view->getHelper('contentEntry') : false; if ($helper && $helper->getDefaultEntry() && $helper->getDefaultEntry()->getId() == $this->getContentId() ) { return true; } // check the child pages if $recursive is set if ($recursive) { foreach ($this->_pages as $page) { if ($page->isActive(true)) { return true; } } } return false; }
P4Cms_Navigation_Page_Content::isVisible | ( | $ | recursive = false | ) |
Extend parent to make this entry invisble if it isn't valid.
bool | $recursive | [optional] whether page should be considered invisible if parent is invisible. Default is false. |
{ // if no entry is accessible; hide if (!$this->_getEntry()) { return false; } // if our entry is deleted only show if we have children if ($this->_getEntry()->isDeleted() && !count($this->getPages())) { return false; } return parent::isVisible($recursive); }
P4Cms_Navigation_Page_Content::setContentAction | ( | $ | action | ) |
Set the content action name.
string | null | $action | content action |
{
$this->_contentAction = $action;
return $this;
}
P4Cms_Navigation_Page_Content::setContentId | ( | $ | id | ) |
Set the id of the content entry associated with this item.
string | null | $id | id of the associated content entry or null |
{ $this->_contentId = $id; // reset instance copy of content entry. $this->_contentEntry = false; return $this; }
P4Cms_Navigation_Page_Content::toArray | ( | ) |
Returns an array representation of the page.
{ return array_merge( parent::toArray(), array( 'contentId' => $this->getContentId(), 'contentAction' => $this->getContentAction(), 'label' => $this->_label, 'visible' => $this->_visible ) ); }
P4Cms_Navigation_Page_Content::$_contentAction [protected] |
P4Cms_Navigation_Page_Content::$_contentEntry = false [protected] |
P4Cms_Navigation_Page_Content::$_contentId [protected] |
const P4Cms_Navigation_Page_Content::ACL_PRIVILEGE = 'access' |
const P4Cms_Navigation_Page_Content::ACL_RESOURCE = 'content' |