123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- /**
- *
- * PHP Pro Bid $Id$ XZ5Ny3tFt1+kV4xJCoPYhkGeMygzsAUGNn6ts3nHYOg=
- *
- * @link http://www.phpprobid.com
- * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
- * @license http://www.phpprobid.com/license Commercial License
- *
- * @version 7.0
- */
- /**
- * content section page class - used by location navigation container
- */
- namespace Ppb\Navigation\Page;
- use Cube\Navigation\Page\AbstractPage,
- Cube\Controller\Front;
- class ContentSection extends AbstractPage
- {
- /**
- *
- * active section id
- *
- * @var int
- */
- protected $_sectionId;
- /**
- *
- * sluggable value
- *
- * @var string
- */
- protected $_slug;
- /**
- *
- * set active section id
- *
- * @param int $sectionId
- *
- * @return $this
- */
- public function setSectionId($sectionId)
- {
- $this->_sectionId = $sectionId;
- return $this;
- }
- /**
- *
- * get active section id
- *
- * @return int
- */
- public function getSectionId()
- {
- if (!$this->_sectionId) {
- $this->setSectionId(
- Front::getInstance()->getRequest()->getParam('id'));
- }
- return $this->_sectionId;
- }
- /**
- *
- * set slug
- *
- * @param string $slug
- *
- * @return $this
- */
- public function setSlug($slug)
- {
- $this->_slug = $slug;
- return $this;
- }
- /**
- *
- * get slug
- *
- * @return string
- */
- public function getSlug()
- {
- return $this->_slug;
- }
- /**
- *
- * override get method to use the slug if available for the url
- *
- * @param string $name
- * @return mixed|null|string
- */
- public function get($name)
- {
- if ($name == 'params' && !empty($this->_slug)) {
- return $this->getSlug();
- }
- return parent::get($name);
- }
- /**
- *
- * check if a section is active
- *
- * @param bool $recursive check in sub-sections as well, and if a sub-section is active, return the current page as active
- *
- * @return bool returns active status
- */
- public function isActive($recursive = false)
- {
- if (!$this->_active) {
- if ($this->getSectionId() == $this->_id) {
- $this->_active = true;
- return true;
- }
- }
- return parent::isActive($recursive);
- }
- }
|