BxBaseModTextSearchResult.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseText Base classes for text modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
  12. {
  13. protected $aUnitViews = array('extended' => 'unit.html', 'gallery' => 'unit_gallery.html', 'full' => 'unit_full.html');
  14. protected $sUnitViewDefault = 'gallery';
  15. protected $sUnitViewParamName = 'unit_view';
  16. function __construct($sMode = '', $aParams = array())
  17. {
  18. parent::__construct($sMode, $aParams);
  19. if (!empty($aParams['unit_view']))
  20. $this->sUnitViewDefault = $aParams['unit_view'];
  21. $this->aGetParams = array($this->sUnitViewParamName);
  22. $this->sUnitTemplate = $this->aUnitViews[$this->sUnitViewDefault];
  23. if (isset($this->aUnitViews[bx_get($this->sUnitViewParamName)]))
  24. $this->sUnitTemplate = $this->aUnitViews[bx_get($this->sUnitViewParamName)];
  25. if ('unit_gallery.html' == $this->sUnitTemplate)
  26. $this->addContainerClass (array('bx-def-margin-sec-lefttopright-neg', 'bx-base-text-unit-gallery-wrapper'));
  27. }
  28. protected function processReplaceableMarkers($oProfileAuthor)
  29. {
  30. if ($oProfileAuthor) {
  31. $this->addMarkers($oProfileAuthor->getInfo()); // profile info is replaceable
  32. $this->addMarkers(array('profile_id' => $oProfileAuthor->id())); // profile id is replaceable
  33. $this->addMarkers(array('display_name' => $oProfileAuthor->getDisplayName())); // profile display name is replaceable
  34. }
  35. $this->sBrowseUrl = $this->_replaceMarkers($this->sBrowseUrl);
  36. $this->aCurrent['title'] = $this->_replaceMarkers($this->aCurrent['title']);
  37. }
  38. protected function addConditionsForPrivateContent($CNF, $oProfileAuthor)
  39. {
  40. // add conditions for private content
  41. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  42. $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oProfileAuthor ? $oProfileAuthor->id() : 0) : array();
  43. if (isset($a['restriction']))
  44. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
  45. if (isset($a['join']))
  46. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
  47. $this->setProcessPrivateContent(false);
  48. }
  49. protected function getCurrentOnclick($aAdditionalParams = array(), $bReplacePagesParams = true)
  50. {
  51. // always add UnitView as additional param
  52. $sUnitView = bx_process_input(bx_get($this->sUnitViewParamName));
  53. if ($sUnitView && isset($this->aUnitViews[$sUnitView]))
  54. $aAdditionalParams = array_merge(array($this->sUnitViewParamName => $sUnitView), $aAdditionalParams);
  55. return parent::getCurrentOnclick($aAdditionalParams, $bReplacePagesParams);
  56. }
  57. function _getPseud ()
  58. {
  59. return array(
  60. 'id' => 'id',
  61. 'title' => 'title',
  62. 'text' => 'text',
  63. 'added' => 'added',
  64. 'author' => 'author',
  65. 'photo' => 'photo',
  66. );
  67. }
  68. }
  69. /** @} */