BxBaseCmtsMenuUnitMeta.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. /**
  10. * Menu representation.
  11. * @see BxDolMenu
  12. */
  13. class BxBaseCmtsMenuUnitMeta extends BxTemplMenuUnitMeta
  14. {
  15. protected $_oCmts;
  16. protected $_aCmtsSystem;
  17. protected $_aCmt;
  18. public function __construct ($aObject, $oTemplate)
  19. {
  20. parent::__construct ($aObject, $oTemplate);
  21. }
  22. public function setCmtsData($oCmts, $iCmtId)
  23. {
  24. if(empty($oCmts) || empty($iCmtId))
  25. return;
  26. $this->_oCmts = $oCmts;
  27. $this->_aCmtsSystem = $oCmts->getSystemInfo();
  28. $this->_aCmt = $oCmts->getCommentRow($iCmtId);
  29. $this->_sStylePrefix = (!empty($this->_aCmtsSystem['root_style_prefix']) ? $this->_aCmtsSystem['root_style_prefix'] : 'cmt') . '-meta';
  30. $this->addMarkers(array(
  31. 'cmt_system' => $this->_oCmts->getSystemName(),
  32. 'cmt_object_id' => $this->_oCmts->getId(),
  33. 'cmt_id' => $iCmtId,
  34. 'content_id' => $iCmtId,
  35. ));
  36. }
  37. protected function _getMenuItemAuthor($aItem)
  38. {
  39. list($sAuthorName, $sAuthorLink, $sAuthorIcon, $sAuthorUnit) = $this->_oCmts->getAuthorInfo($this->_aCmt['cmt_author_id']);
  40. if(!empty($sAuthorLink))
  41. return $this->getUnitMetaItemLink($sAuthorName, array(
  42. 'href' => $sAuthorLink,
  43. 'class' => $this->_sStylePrefix . '-username',
  44. 'title' => bx_html_attribute($sAuthorName),
  45. ));
  46. else
  47. return $this->getUnitMetaItemText($sAuthorName, array(
  48. 'class' => $this->_sStylePrefix . '-username'
  49. ));
  50. }
  51. protected function _getMenuItemDate($aItem)
  52. {
  53. $sAgo = bx_time_js($this->_aCmt['cmt_time']);
  54. if(!empty($this->_aCmtsSystem['trigger_field_title']))
  55. return $this->getUnitMetaItemLink($sAgo, array(
  56. 'href' => $this->_oCmts->getViewUrl($this->_aCmt['cmt_id']),
  57. 'class' => $this->_sStylePrefix . '-ago'
  58. ));
  59. else
  60. return $this->getUnitMetaItemText($sAgo, array(
  61. 'class' => $this->_sStylePrefix . '-ago'
  62. ));
  63. }
  64. }
  65. /** @} */