BxBaseCmtsPageView.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. class BxBaseCmtsPageView extends BxTemplPage
  10. {
  11. protected $_oCmts;
  12. protected $_iCmtId;
  13. public function __construct($aObject, $oTemplate)
  14. {
  15. parent::__construct($aObject, $oTemplate);
  16. $sSystem = bx_get('sys');
  17. $sSystem = $sSystem !== false ? $sSystem = bx_process_input($sSystem) : '';
  18. $iObjectId = bx_get('id');
  19. $iObjectId = $iObjectId !== false ? bx_process_input($iObjectId, BX_DATA_INT) : 0;
  20. $iCommentId = bx_get('cmt_id');
  21. $this->_iCmtId = $iCommentId !== false ? bx_process_input($iCommentId, BX_DATA_INT) : 0;
  22. if(!$sSystem || !$iObjectId)
  23. return;
  24. $this->_oCmts = BxDolCmts::getObjectInstance($sSystem, $iObjectId, true);
  25. if(!$this->_oCmts)
  26. return;
  27. $sObjectTitle = bx_process_output(strip_tags($this->_oCmts->getObjectTitle($iObjectId)));
  28. $sObjectUrl = $this->_oCmts->getBaseUrl();
  29. $this->addMarkers(array(
  30. 'system' => $sSystem,
  31. 'object_id' => $iObjectId,
  32. 'object_title' => $sObjectTitle,
  33. 'object_url' => $sObjectUrl,
  34. 'comment_id' => $iCommentId
  35. ));
  36. }
  37. protected function _isAvailablePage ($a)
  38. {
  39. if (!$this->_iCmtId)
  40. return false;
  41. return parent::_isAvailablePage($a);
  42. }
  43. public function getCode()
  44. {
  45. if($this->_oCmts)
  46. BxDolTemplate::getInstance()->setPageUrl($this->_oCmts->getViewUrl($this->_iCmtId));
  47. return parent::getCode();
  48. }
  49. }
  50. /** @} */