Category.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ K9PfLDm6IYP5RLNLNc//Ik1uYkiidL77Wm6NaMualOA=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * category page class - used by category navigation container
  14. */
  15. namespace Ppb\Navigation\Page;
  16. use Cube\Navigation\Page\AbstractPage;
  17. class Category extends AbstractPage
  18. {
  19. /**
  20. *
  21. * active category id
  22. *
  23. * @var integer
  24. */
  25. protected $_categoryId;
  26. /**
  27. *
  28. * custom fees flag
  29. *
  30. * @var bool
  31. */
  32. protected $_customFees;
  33. /**
  34. *
  35. * sluggable value
  36. *
  37. * @var string
  38. */
  39. protected $_slug;
  40. /**
  41. *
  42. * get active category id
  43. *
  44. * @return integer
  45. */
  46. public function getCategoryId()
  47. {
  48. return $this->_categoryId;
  49. }
  50. /**
  51. *
  52. * set active category id
  53. *
  54. * @param integer $categoryId
  55. * @return \Ppb\Navigation\Page\Category
  56. */
  57. public function setCategoryId($categoryId)
  58. {
  59. $this->_categoryId = (int) $categoryId;
  60. return $this;
  61. }
  62. /**
  63. *
  64. * get custom fees flag
  65. *
  66. * @return bool
  67. */
  68. public function getCustomFees()
  69. {
  70. return $this->_customFees;
  71. }
  72. /**
  73. *
  74. * set custom fees flag
  75. *
  76. * @param int $customFees
  77. * @return \Ppb\Navigation\Page\Category
  78. */
  79. public function setCustomFees($customFees)
  80. {
  81. $this->_customFees = (bool) $customFees;
  82. return $this;
  83. }
  84. /**
  85. *
  86. * set slug
  87. *
  88. * @param string $slug
  89. *
  90. * @return $this
  91. */
  92. public function setSlug($slug)
  93. {
  94. $this->_slug = $slug;
  95. return $this;
  96. }
  97. /**
  98. *
  99. * get slug
  100. *
  101. * @return string
  102. */
  103. public function getSlug()
  104. {
  105. return $this->_slug;
  106. }
  107. /**
  108. *
  109. * override get method to use the slug if available for the url
  110. *
  111. * @param string $name
  112. * @return mixed|null|string
  113. */
  114. public function get($name)
  115. {
  116. if ($name == 'params' && !empty($this->_slug)) {
  117. return $this->getSlug();
  118. }
  119. return parent::get($name);
  120. }
  121. /**
  122. *
  123. * check if a page is active, based on the page id
  124. *
  125. * @param bool $recursive check in sub-pages as well, and if a sub-page is active, return the current page as active
  126. * @return bool returns active status
  127. */
  128. public function isActive($recursive = false)
  129. {
  130. if (!$this->_active) {
  131. if ($this->_id == $this->_categoryId) {
  132. $this->_active = true;
  133. return true;
  134. }
  135. }
  136. return parent::isActive($recursive);
  137. }
  138. }