BxBaseModGeneralModule.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  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 BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolAcl');
  12. /**
  13. * Base module class.
  14. */
  15. class BxBaseModGeneralModule extends BxDolModule
  16. {
  17. protected $_iProfileId;
  18. function __construct(&$aModule)
  19. {
  20. parent::__construct($aModule);
  21. $this->_iProfileId = bx_get_logged_profile_id();
  22. }
  23. // ====== ACTIONS METHODS
  24. public function actionRss ()
  25. {
  26. $aArgs = func_get_args();
  27. $this->_rss($aArgs);
  28. }
  29. // ====== SERVICE METHODS
  30. public function serviceGetAuthor ($iContentId)
  31. {
  32. $mixedResult = $this->_getFieldValue('FIELD_AUTHOR', $iContentId);
  33. return $mixedResult !== false ? (int)$mixedResult : 0;
  34. }
  35. public function serviceGetDateAdded ($iContentId)
  36. {
  37. $mixedResult = $this->_getFieldValue('FIELD_ADDED', $iContentId);
  38. return $mixedResult !== false ? (int)$mixedResult : 0;
  39. }
  40. public function serviceGetDateChanged ($iContentId)
  41. {
  42. $mixedResult = $this->_getFieldValue('FIELD_CHANGED', $iContentId);
  43. return $mixedResult !== false ? (int)$mixedResult : 0;
  44. }
  45. public function serviceGetLink ($iContentId)
  46. {
  47. $CNF = &$this->_oConfig->CNF;
  48. if(empty($CNF['URI_VIEW_ENTRY']))
  49. return '';
  50. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  51. if(empty($aContentInfo))
  52. return '';
  53. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  54. }
  55. public function serviceGetTitle ($iContentId)
  56. {
  57. $mixedResult = $this->_getFieldValue('FIELD_TITLE', $iContentId);
  58. return $mixedResult !== false ? $mixedResult : '';
  59. }
  60. public function serviceGetText ($iContentId)
  61. {
  62. $mixedResult = $this->_getFieldValue('FIELD_TEXT', $iContentId);
  63. return $mixedResult !== false ? $mixedResult : '';
  64. }
  65. public function serviceGetInfo ($iContentId, $bSearchableFieldsOnly = true)
  66. {
  67. $CNF = &$this->_oConfig->CNF;
  68. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  69. if(empty($aContentInfo))
  70. return array();
  71. if(!$bSearchableFieldsOnly)
  72. return $aContentInfo;
  73. if(empty($CNF['PARAM_SEARCHABLE_FIELDS']))
  74. return array();
  75. $aFields = explode(',', getParam($CNF['PARAM_SEARCHABLE_FIELDS']));
  76. if(empty($aFields))
  77. return array();
  78. return array_flip(array_intersect(array_flip($aContentInfo), $aFields));
  79. }
  80. public function serviceGetSearchResultUnit ($iContentId)
  81. {
  82. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  83. if(empty($aContentInfo))
  84. return '';
  85. return $this->_oTemplate->unit($aContentInfo);
  86. }
  87. public function serviceModuleIcon ()
  88. {
  89. return isset($this->_oConfig->CNF['ICON']) ? $this->_oConfig->CNF['ICON'] : '';
  90. }
  91. public function serviceGetSearchableFields ()
  92. {
  93. $CNF = $this->_oConfig->CNF;
  94. if (!isset($CNF['PARAM_SEARCHABLE_FIELDS']) || !isset($CNF['OBJECT_FORM_ENTRY']) || !isset($CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']))
  95. return array();
  96. $aTextTypes = array('text', 'textarea');
  97. $aTextFields = array();
  98. $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
  99. foreach ($oForm->aInputs as $r) {
  100. if (in_array($r['type'], $aTextTypes))
  101. $aTextFields[$r['name']] = $r['caption'];
  102. }
  103. return $aTextFields;
  104. }
  105. public function serviceManageTools($sType = 'common')
  106. {
  107. $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->getGridObject($sType));
  108. if(!$oGrid)
  109. return '';
  110. $CNF = &$this->_oConfig->CNF;
  111. $sMenu = '';
  112. if(BxDolAcl::getInstance()->isMemberLevelInSet(192)) {
  113. $oPermalink = BxDolPermalinks::getInstance();
  114. $aMenuItems = array();
  115. if(!empty($CNF['OBJECT_GRID_COMMON']) && !empty($CNF['T']['menu_item_manage_my']))
  116. $aMenuItems[] = array('id' => 'manage-common', 'name' => 'manage-common', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_COMMON']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_my']), 'active' => 1);
  117. if(!empty($CNF['OBJECT_GRID_ADMINISTRATION']) && !empty($CNF['T']['menu_item_manage_all']))
  118. $aMenuItems[] = array('id' => 'manage-administration', 'name' => 'manage-administration', 'class' => '', 'link' => $oPermalink->permalink($CNF['URL_MANAGE_ADMINISTRATION']), 'target' => '_self', 'title' => _t($CNF['T']['menu_item_manage_all']), 'active' => 1);
  119. if(count($aMenuItems) > 1) {
  120. $oMenu = new BxTemplMenu(array(
  121. 'template' => 'menu_vertical.html',
  122. 'menu_items' => $aMenuItems
  123. ), $this->_oTemplate);
  124. $oMenu->setSelected($this->_aModule['name'], 'manage-' . $sType);
  125. $sMenu = $oMenu->getCode();
  126. }
  127. }
  128. if(!empty($CNF['OBJECT_MENU_SUBMENU'])) {
  129. BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_SUBMENU'])->setSelected($this->_aModule['name'], $CNF['URI_MANAGE_COMMON']);
  130. }
  131. $this->_oTemplate->addCss(array('manage_tools.css'));
  132. $this->_oTemplate->addJs(array('manage_tools.js'));
  133. $this->_oTemplate->addJsTranslation(array('_sys_grid_search'));
  134. return array(
  135. 'content' => $this->_oTemplate->getJsCode('manage_tools', array('sObjNameGrid' => $this->_oConfig->getGridObject($sType))) . $oGrid->getCode(),
  136. 'menu' => $sMenu
  137. );
  138. }
  139. public function serviceGetMenuAddonManageTools()
  140. {
  141. return 0;
  142. }
  143. public function serviceGetMenuAddonManageToolsProfileStats()
  144. {
  145. return 0;
  146. }
  147. /**
  148. * Display featured entries
  149. * @return HTML string
  150. */
  151. public function serviceBrowseFeatured ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  152. {
  153. return $this->_serviceBrowse ('featured', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  154. }
  155. /**
  156. * Display entries favored by a member
  157. * @return HTML string
  158. */
  159. public function serviceBrowseFavorite ($iProfileId = 0, $aParams = array())
  160. {
  161. $oProfile = null;
  162. if((int)$iProfileId)
  163. $oProfile = BxDolProfile::getInstance($iProfileId);
  164. if(!$oProfile && bx_get('profile_id') !== false)
  165. $oProfile = BxDolProfile:: getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT));
  166. if(!$oProfile)
  167. $oProfile = BxDolProfile::getInstance();
  168. if(!$oProfile)
  169. return '';
  170. return $this->_serviceBrowse ('favorite', array_merge(array('user' => $oProfile->id()), $aParams), BX_DB_PADDING_DEF, true);
  171. }
  172. public function serviceFormsHelper ()
  173. {
  174. bx_import('FormsEntryHelper', $this->_aModule);
  175. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  176. return new $sClass($this);
  177. }
  178. /**
  179. * Add entry using provided fields' values.
  180. * @return HTML string
  181. */
  182. public function serviceEntityAdd ($iAccount, $aValues)
  183. {
  184. bx_import('FormsEntryHelper', $this->_aModule);
  185. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  186. $oFormsHelper = new $sClass($this);
  187. return $oFormsHelper->addData($iAccount, $aValues);
  188. }
  189. /**
  190. * Create entry form
  191. * @return HTML string
  192. */
  193. public function serviceEntityCreate ()
  194. {
  195. bx_import('FormsEntryHelper', $this->_aModule);
  196. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  197. $oFormsHelper = new $sClass($this);
  198. return $oFormsHelper->addDataForm();
  199. }
  200. public function serviceEntityEdit ($iContentId = 0)
  201. {
  202. return $this->_serviceEntityForm ('editDataForm', $iContentId);
  203. }
  204. public function serviceEntityDelete ($iContentId = 0)
  205. {
  206. return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
  207. }
  208. public function serviceEntityTextBlock ($iContentId = 0)
  209. {
  210. return $this->_serviceEntityForm ('viewDataEntry', $iContentId);
  211. }
  212. public function serviceEntityInfo ($iContentId = 0)
  213. {
  214. return $this->_serviceEntityForm ('viewDataForm', $iContentId);
  215. }
  216. public function serviceEntityInfoFull ($iContentId = 0)
  217. {
  218. $CNF = &$this->_oConfig->CNF;
  219. $sDisplayName = 'OBJECT_FORM_ENTRY_DISPLAY_VIEW_FULL';
  220. return $this->_serviceEntityForm ('viewDataForm', $iContentId, !empty($CNF[$sDisplayName]) ? $CNF[$sDisplayName] : false);
  221. }
  222. public function serviceEntityInfoExtended ($iContentId = 0)
  223. {
  224. return $this->_serviceTemplateFunc ('entryInfo', $iContentId);
  225. }
  226. /**
  227. * Entry location info
  228. */
  229. public function serviceEntityLocation ($iContentId = 0)
  230. {
  231. if (!$iContentId)
  232. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  233. if (!$iContentId)
  234. return false;
  235. return $this->_oTemplate->entryLocation ($iContentId);
  236. }
  237. /**
  238. * Delete content entry
  239. * @param $iContentId content id
  240. * @return error message or empty string on success
  241. */
  242. public function serviceDeleteEntity ($iContentId, $sFuncDelete = 'deleteData')
  243. {
  244. bx_import('FormsEntryHelper', $this->_aModule);
  245. $sClass = $this->_oConfig->getClassPrefix() . 'FormsEntryHelper';
  246. $oFormsHelper = new $sClass($this);
  247. return $oFormsHelper->$sFuncDelete($iContentId);
  248. }
  249. /**
  250. * Entry actions and social sharing block
  251. */
  252. public function serviceEntityAllActions ($iContentId = 0)
  253. {
  254. return $this->_oTemplate->entryAllActions('', $this->serviceEntitySocialSharing($iContentId));
  255. }
  256. /**
  257. * Entry actions block
  258. */
  259. public function serviceEntityActions ($iContentId = 0)
  260. {
  261. if (!$iContentId)
  262. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  263. if (!$iContentId)
  264. return false;
  265. $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
  266. return $oMenu ? $oMenu->getCode() : false;
  267. }
  268. /**
  269. * Entry social sharing block
  270. */
  271. public function serviceEntitySocialSharing ($iContentId = 0)
  272. {
  273. if (!$iContentId)
  274. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  275. if (!$iContentId)
  276. return false;
  277. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  278. if (!$aContentInfo)
  279. return false;
  280. $CNF = &$this->_oConfig->CNF;
  281. return $this->_entitySocialSharing ($iContentId, array(
  282. 'id_timeline' => $iContentId,
  283. 'id_thumb' => !empty($CNF['FIELD_THUMB']) && !empty($aContentInfo[$CNF['FIELD_THUMB']]) ? $aContentInfo[$CNF['FIELD_THUMB']] : '',
  284. 'title' => !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '',
  285. 'object_storage' => !empty($CNF['OBJECT_STORAGE']) ? $CNF['OBJECT_STORAGE'] : '',
  286. 'object_transcoder' => false,
  287. 'object_view' => !empty($CNF['OBJECT_VIEWS']) ? $CNF['OBJECT_VIEWS'] : '',
  288. 'object_vote' => !empty($CNF['OBJECT_VOTES']) ? $CNF['OBJECT_VOTES'] : '',
  289. 'object_favorite' => !empty($CNF['OBJECT_FAVORITES']) ? $CNF['OBJECT_FAVORITES'] : '',
  290. 'object_feature' => !empty($CNF['OBJECT_FEATURED']) ? $CNF['OBJECT_FEATURED'] : '',
  291. 'object_report' => !empty($CNF['OBJECT_REPORTS']) ? $CNF['OBJECT_REPORTS'] : '',
  292. 'uri_view_entry' => !empty($CNF['URI_VIEW_ENTRY']) ? $CNF['URI_VIEW_ENTRY'] : '',
  293. ));
  294. }
  295. /**
  296. * Data for Notifications module
  297. */
  298. public function serviceGetNotificationsData()
  299. {
  300. $sModule = $this->_aModule['name'];
  301. $sEventPrivacy = $sModule . '_allow_view_event_to';
  302. if(BxDolPrivacy::getObjectInstance($sEventPrivacy) === false)
  303. $sEventPrivacy = '';
  304. return array(
  305. 'handlers' => array(
  306. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  307. array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
  308. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted'),
  309. array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  310. array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
  311. array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module', 'module_event_privacy' => $sEventPrivacy),
  312. array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
  313. ),
  314. 'alerts' => array(
  315. array('unit' => $sModule, 'action' => 'added'),
  316. array('unit' => $sModule, 'action' => 'edited'),
  317. array('unit' => $sModule, 'action' => 'deleted'),
  318. array('unit' => $sModule, 'action' => 'commentPost'),
  319. array('unit' => $sModule, 'action' => 'commentRemoved'),
  320. array('unit' => $sModule, 'action' => 'doVote'),
  321. array('unit' => $sModule, 'action' => 'undoVote'),
  322. )
  323. );
  324. }
  325. /**
  326. * Entry post for Notifications module
  327. */
  328. public function serviceGetNotificationsPost($aEvent)
  329. {
  330. $CNF = &$this->_oConfig->CNF;
  331. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  332. if(empty($aContentInfo) || !is_array($aContentInfo))
  333. return array();
  334. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  335. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  336. return array(
  337. 'entry_sample' => $CNF['T']['txt_sample_single'],
  338. 'entry_url' => $sEntryUrl,
  339. 'entry_caption' => $sEntryCaption,
  340. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  341. 'entry_privacy' => '', //may be empty or not specified. In this case Public privacy will be used.
  342. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  343. );
  344. }
  345. /**
  346. * Entry post comment for Notifications module
  347. */
  348. public function serviceGetNotificationsComment($aEvent)
  349. {
  350. $CNF = &$this->_oConfig->CNF;
  351. $iContentId = (int)$aEvent['object_id'];
  352. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  353. if(empty($aContentInfo) || !is_array($aContentInfo))
  354. return array();
  355. $oComment = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId);
  356. if(!$oComment || !$oComment->isEnabled())
  357. return array();
  358. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  359. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  360. return array(
  361. 'entry_sample' => $CNF['T']['txt_sample_single'],
  362. 'entry_url' => $sEntryUrl,
  363. 'entry_caption' => $sEntryCaption,
  364. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  365. 'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
  366. 'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
  367. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  368. );
  369. }
  370. /**
  371. * Entry post vote for Notifications module
  372. */
  373. public function serviceGetNotificationsVote($aEvent)
  374. {
  375. $CNF = &$this->_oConfig->CNF;
  376. $iContentId = (int)$aEvent['object_id'];
  377. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  378. if(empty($aContentInfo) || !is_array($aContentInfo))
  379. return array();
  380. $oVote = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContentId);
  381. if(!$oVote || !$oVote->isEnabled())
  382. return array();
  383. $sEntryUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  384. $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  385. return array(
  386. 'entry_sample' => $CNF['T']['txt_sample_single'],
  387. 'entry_url' => $sEntryUrl,
  388. 'entry_caption' => $sEntryCaption,
  389. 'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  390. 'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
  391. 'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
  392. );
  393. }
  394. public function _serviceGetNotification($aEvent, $sLangKey)
  395. {
  396. $CNF = &$this->_oConfig->CNF;
  397. $iContentId = (int)$aEvent['object_id'];
  398. $oGroupProfile = BxDolProfile::getInstanceByContentAndType((int)$iContentId, $this->getName());
  399. if (!$oGroupProfile)
  400. return false;
  401. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  402. if(empty($aContentInfo) || !is_array($aContentInfo))
  403. return array();
  404. $oProfile = BxDolProfile::getInstance((int)$aEvent['subobject_id']);
  405. if (!$oProfile)
  406. return false;
  407. return array(
  408. 'entry_sample' => $CNF['T']['txt_sample_single'],
  409. 'entry_url' => $oGroupProfile->getUrl(),
  410. 'entry_caption' => $oGroupProfile->getDisplayName(),
  411. 'entry_author' => $oGroupProfile->id(),
  412. 'subentry_sample' => $oProfile->getDisplayName(),
  413. 'subentry_url' => $oProfile->getUrl(),
  414. 'lang_key' => $sLangKey,
  415. );
  416. }
  417. /**
  418. * Data for Timeline module
  419. */
  420. public function serviceGetTimelineData()
  421. {
  422. $sModule = $this->_aModule['name'];
  423. return array(
  424. 'handlers' => array(
  425. array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_timeline_post', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
  426. array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
  427. array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted')
  428. ),
  429. 'alerts' => array(
  430. array('unit' => $sModule, 'action' => 'added'),
  431. array('unit' => $sModule, 'action' => 'edited'),
  432. array('unit' => $sModule, 'action' => 'deleted'),
  433. )
  434. );
  435. }
  436. /**
  437. * Entry post for Timeline module
  438. */
  439. public function serviceGetTimelinePost($aEvent)
  440. {
  441. $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
  442. if(empty($aContentInfo) || !is_array($aContentInfo))
  443. return '';
  444. $CNF = &$this->_oConfig->CNF;
  445. //--- Views
  446. $oViews = isset($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $aEvent['object_id']) : null;
  447. $aViews = array();
  448. if ($oViews && $oViews->isEnabled())
  449. $aViews = array(
  450. 'system' => $CNF['OBJECT_VIEWS'],
  451. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  452. 'count' => $aContentInfo['views']
  453. );
  454. //--- Votes
  455. $oVotes = isset($CNF['OBJECT_VOTES']) ? BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aEvent['object_id']) : null;
  456. $aVotes = array();
  457. if ($oVotes && $oVotes->isEnabled())
  458. $aVotes = array(
  459. 'system' => $CNF['OBJECT_VOTES'],
  460. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  461. 'count' => $aContentInfo['votes']
  462. );
  463. //--- Reports
  464. $oReports = isset($CNF['OBJECT_REPORTS']) ? BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $aEvent['object_id']) : null;
  465. $aReports = array();
  466. if ($oReports && $oReports->isEnabled())
  467. $aReports = array(
  468. 'system' => $CNF['OBJECT_REPORTS'],
  469. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  470. 'count' => $aContentInfo['reports']
  471. );
  472. //--- Comments
  473. $oCmts = isset($CNF['OBJECT_COMMENTS']) ? BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']) : null;
  474. $aComments = array();
  475. if($oCmts && $oCmts->isEnabled())
  476. $aComments = array(
  477. 'system' => $CNF['OBJECT_COMMENTS'],
  478. 'object_id' => $aContentInfo[$CNF['FIELD_ID']],
  479. 'count' => $aContentInfo['comments']
  480. );
  481. //--- Title & Description
  482. $sTitle = !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '';
  483. if(empty($sTitle) && !empty($aContentInfo[$CNF['FIELD_TEXT']]))
  484. $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
  485. return array(
  486. 'owner_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
  487. 'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
  488. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  489. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  490. 'sample_action' => isset($CNF['T']['txt_sample_single_action']) ? $CNF['T']['txt_sample_single_action'] : '',
  491. 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
  492. 'content' => $this->_getContentForTimelinePost($aEvent, $aContentInfo), //a string to display or array to parse default template before displaying.
  493. 'date' => $aContentInfo[$CNF['FIELD_ADDED']],
  494. 'views' => $aViews,
  495. 'votes' => $aVotes,
  496. 'reports' => $aReports,
  497. 'comments' => $aComments,
  498. 'title' => $sTitle, //may be empty.
  499. 'description' => '' //may be empty.
  500. );
  501. }
  502. // ====== PERMISSION METHODS
  503. /**
  504. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make "true === " checking.
  505. */
  506. public function checkAllowedBrowse ()
  507. {
  508. return CHECK_ACTION_RESULT_ALLOWED;
  509. }
  510. /**
  511. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  512. */
  513. public function checkAllowedView ($aDataEntry, $isPerformAction = false)
  514. {
  515. $CNF = &$this->_oConfig->CNF;
  516. // moderator and owner always have access
  517. if ($aDataEntry[$CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
  518. return CHECK_ACTION_RESULT_ALLOWED;
  519. // check ACL
  520. $aCheck = checkActionModule($this->_iProfileId, 'view entry', $this->getName(), $isPerformAction);
  521. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  522. return $aCheck[CHECK_ACTION_MESSAGE];
  523. // check privacy
  524. if (!empty($CNF['OBJECT_PRIVACY_VIEW'])) {
  525. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  526. if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]))
  527. return _t('_sys_access_denied_to_private_content');
  528. }
  529. return CHECK_ACTION_RESULT_ALLOWED;
  530. }
  531. /**
  532. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  533. */
  534. public function checkAllowedAdd ($isPerformAction = false)
  535. {
  536. // check ACL
  537. $aCheck = checkActionModule($this->_iProfileId, 'create entry', $this->getName(), $isPerformAction);
  538. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  539. return $aCheck[CHECK_ACTION_MESSAGE];
  540. return CHECK_ACTION_RESULT_ALLOWED;
  541. }
  542. /**
  543. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  544. */
  545. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  546. {
  547. // moderator and owner always have access
  548. if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
  549. return CHECK_ACTION_RESULT_ALLOWED;
  550. return _t('_sys_txt_access_denied');
  551. }
  552. /**
  553. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  554. */
  555. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  556. {
  557. // moderator always has access
  558. if ($this->_isModerator($isPerformAction))
  559. return CHECK_ACTION_RESULT_ALLOWED;
  560. // check ACL
  561. $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
  562. if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  563. return CHECK_ACTION_RESULT_ALLOWED;
  564. return _t('_sys_txt_access_denied');
  565. }
  566. /**
  567. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  568. */
  569. public function checkAllowedSetMembership (&$aDataEntry, $isPerformAction = false)
  570. {
  571. // admin always has access
  572. if (isAdmin())
  573. return CHECK_ACTION_RESULT_ALLOWED;
  574. // check ACL
  575. $aCheck = checkActionModule($this->_iProfileId, 'set acl level', 'system', $isPerformAction);
  576. if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  577. return $aCheck[CHECK_ACTION_MESSAGE];
  578. return CHECK_ACTION_RESULT_ALLOWED;
  579. }
  580. /**
  581. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
  582. */
  583. public function checkAllowedEditAnyEntry ($isPerformAction = false)
  584. {
  585. $aCheck = checkActionModule($this->_iProfileId, 'edit any entry', $this->getName(), $isPerformAction);
  586. if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
  587. return CHECK_ACTION_RESULT_ALLOWED;
  588. return _t('_sys_txt_access_denied');
  589. }
  590. public function _serviceBrowse ($sMode, $aParams = false, $iDesignBox = BX_DB_PADDING_DEF, $bDisplayEmptyMsg = false, $bAjaxPaginate = true, $sClassSearchResult = 'SearchResult')
  591. {
  592. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse()))
  593. return MsgBox($sMsg);
  594. bx_import($sClassSearchResult, $this->_aModule);
  595. $sClass = $this->_aModule['class_prefix'] . $sClassSearchResult;
  596. $o = new $sClass($sMode, $aParams);
  597. $o->setDesignBoxTemplateId($iDesignBox);
  598. $o->setDisplayEmptyMsg($bDisplayEmptyMsg);
  599. $o->setAjaxPaginate($bAjaxPaginate);
  600. $o->setUnitParams(array('context' => $sMode));
  601. if ($o->isError)
  602. return '';
  603. if ($s = $o->processing())
  604. return $s;
  605. else
  606. return '';
  607. }
  608. // ====== COMMON METHODS
  609. public function getProfileId()
  610. {
  611. return bx_get_logged_profile_id();
  612. }
  613. public function getProfileInfo($iUserId = 0)
  614. {
  615. $oProfile = $this->getObjectUser($iUserId);
  616. $oAccount = null;
  617. if($oProfile && !($oProfile instanceof BxDolProfileUndefined))
  618. $oAccount = $oProfile->getAccountObject();
  619. $bAccount = !empty($oAccount);
  620. return array(
  621. 'id' => $oProfile->id(),
  622. 'name' => $oProfile->getDisplayName(),
  623. 'email' => $bAccount ? $oAccount->getEmail() : '',
  624. 'link' => $oProfile->getUrl(),
  625. 'icon' => $oProfile->getIcon(),
  626. 'thumb' => $oProfile->getThumb(),
  627. 'avatar' => $oProfile->getAvatar(),
  628. 'unit' => $oProfile->getUnit(),
  629. 'active' => $oProfile->isActive(),
  630. );
  631. }
  632. public function getObjectUser($iUserId = 0)
  633. {
  634. bx_import('BxDolProfile');
  635. $oProfile = BxDolProfile::getInstance($iUserId);
  636. if (!$oProfile) {
  637. bx_import('BxDolProfileUndefined');
  638. $oProfile = BxDolProfileUndefined::getInstance();
  639. }
  640. return $oProfile;
  641. }
  642. public function getObjectFavorite($sSystem = '', $iId = 0)
  643. {
  644. $CNF = &$this->_oConfig->CNF;
  645. if(empty($sSystem) && !empty($CNF['OBJECT_FAVORITES']))
  646. $sSystem = $CNF['OBJECT_FAVORITES'];
  647. if(empty($sSystem))
  648. return false;
  649. $oFavorite = BxDolFavorite::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
  650. if(!$oFavorite->isEnabled())
  651. return false;
  652. return $oFavorite;
  653. }
  654. public function getUserId()
  655. {
  656. return isLogged() ? bx_get_logged_profile_id() : 0;
  657. }
  658. public function getUserIp()
  659. {
  660. return getVisitorIP();
  661. }
  662. public function getUserInfo($iUserId = 0)
  663. {
  664. $oProfile = BxDolProfile::getInstance($iUserId);
  665. if (!$oProfile)
  666. $oProfile = BxDolProfileUndefined::getInstance();
  667. return array(
  668. $oProfile->getDisplayName(),
  669. $oProfile->getUrl(),
  670. $oProfile->getThumb(),
  671. $oProfile->getUnit()
  672. );
  673. }
  674. // ====== PROTECTED METHODS
  675. protected function _isModerator ($isPerformAction = false)
  676. {
  677. return CHECK_ACTION_RESULT_ALLOWED === $this->checkAllowedEditAnyEntry ($isPerformAction);
  678. }
  679. protected function _serviceEntityForm ($sFormMethod, $iContentId = 0, $sDisplay = false)
  680. {
  681. if (!$iContentId)
  682. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  683. if (!$iContentId)
  684. return false;
  685. bx_import('FormsEntryHelper', $this->_aModule);
  686. $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
  687. $oFormsHelper = new $sClass($this);
  688. return $oFormsHelper->$sFormMethod((int)$iContentId, $sDisplay);
  689. }
  690. protected function _serviceTemplateFunc ($sFunc, $iContentId, $sFuncGetContent = 'getContentInfoById')
  691. {
  692. if (!$iContentId)
  693. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  694. if (!$iContentId)
  695. return false;
  696. $aContentInfo = $this->_oDb->$sFuncGetContent($iContentId);
  697. if (!$aContentInfo)
  698. return false;
  699. return $this->_oTemplate->$sFunc($aContentInfo);
  700. }
  701. protected function _rss ($aArgs, $sClass = 'SearchResult')
  702. {
  703. $sMode = array_shift($aArgs);
  704. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse())) {
  705. $this->_oTemplate->displayAccessDenied ($sMsg);
  706. exit;
  707. }
  708. $aParams = $this->_buildRssParams($sMode, $aArgs);
  709. bx_import ($sClass, $this->_aModule);
  710. $sClass = $this->_aModule['class_prefix'] . $sClass;
  711. $o = new $sClass($sMode, $aParams);
  712. if ($o->isError)
  713. $this->_oTemplate->displayPageNotFound ();
  714. else
  715. $o->outputRSS();
  716. exit;
  717. }
  718. protected function _getContentForTimelinePost($aEvent, $aContentInfo)
  719. {
  720. $CNF = &$this->_oConfig->CNF;
  721. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
  722. //--- Image(s)
  723. $aImages = $this->_getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl);
  724. return array(
  725. 'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
  726. 'sample_wo_article' => $CNF['T']['txt_sample_single'],
  727. 'sample_action' => isset($CNF['T']['txt_sample_single_action']) ? $CNF['T']['txt_sample_single_action'] : '',
  728. 'url' => $sUrl,
  729. 'title' => isset($CNF['FIELD_TITLE']) && isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] :
  730. (isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...') : ''),
  731. 'text' => isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? $aContentInfo[$CNF['FIELD_TEXT']] : '',
  732. 'images' => $aImages,
  733. );
  734. }
  735. protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl)
  736. {
  737. $CNF = &$this->_oConfig->CNF;
  738. $sImage = '';
  739. if(isset($CNF['FIELD_COVER']) && isset($aContentInfo[$CNF['FIELD_COVER']]) && $aContentInfo[$CNF['FIELD_COVER']]) {
  740. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_COVER'])) {
  741. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_COVER']);
  742. if($oTranscoder)
  743. $sImage = $oTranscoder->getFileUrl($aContentInfo[$CNF['FIELD_COVER']]);
  744. }
  745. if($sImage == '' && !empty($CNF['OBJECT_IMAGES_TRANSCODER_THUMB'])) {
  746. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_THUMB']);
  747. if($oTranscoder)
  748. $sImage = $oTranscoder->getFileUrl($aContentInfo[$CNF['FIELD_COVER']]);
  749. }
  750. }
  751. if($sImage == '' && isset($CNF['FIELD_THUMB']) && isset($aContentInfo[$CNF['FIELD_THUMB']]) && $aContentInfo[$CNF['FIELD_THUMB']]) {
  752. if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_THUMB'])) {
  753. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_THUMB']);
  754. if($oTranscoder)
  755. $sImage = $oTranscoder->getFileUrl($aContentInfo[$CNF['FIELD_THUMB']]);
  756. }
  757. if($sImage == '' && !empty($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY'])) {
  758. $oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']);
  759. if($oTranscoder)
  760. $sImage = $oTranscoder->getFileUrl($aContentInfo[$CNF['FIELD_THUMB']]);
  761. }
  762. }
  763. if(empty($sImage))
  764. return array();
  765. return array(
  766. array('url' => $sUrl, 'src' => $sImage),
  767. );
  768. }
  769. protected function _entitySocialSharing ($iId, $aParams = array())
  770. {
  771. $sUrl = !empty($aParams['uri_view_entry']) ? BxDolPermalinks::getInstance()->permalink('page.php?i=' . $aParams['uri_view_entry'] . '&id=' . $iId) : '';
  772. $sTitle = !empty($aParams['title']) ? $aParams['title'] : '';
  773. //--- Comments
  774. $sComments = '';
  775. $oComments = !empty($aParams['object_comments']) ? BxTemplCmts::getObjectInstance($aParams['object_comments'], $iId) : false;
  776. if ($oComments) {
  777. $iNum = $oComments->getCommentsCountAll();
  778. $sComments = $this->_oTemplate->parseHtmlByName('comments-item.html', array (
  779. 'url' => $sUrl . '#' . $oComments->getListAnchor(),
  780. 'bx_if:comments' => array (
  781. 'condition' => $iNum,
  782. 'content' => array (
  783. 'num' => $iNum,
  784. ),
  785. ),
  786. ));
  787. }
  788. $aCustomParams = array();
  789. $iIdThumb = isset($aParams['id_thumb']) ? (int)$aParams['id_thumb'] : 0;
  790. $bSocialSharing = isset($aParams['social_sharing']) ? (bool)$aParams['social_sharing'] : true;
  791. if ($iIdThumb && $bSocialSharing) {
  792. if(!empty($aParams['object_transcoder']))
  793. $o = BxDolTranscoder::getObjectInstance($aParams['object_transcoder']);
  794. else if(!empty($aParams['object_storage']))
  795. $o = BxDolStorage::getObjectInstance($aParams['object_storage']);
  796. $sImgUrl = $o ? $o->getFileUrlById($iIdThumb) : '';
  797. if($sImgUrl)
  798. $aCustomParams = array (
  799. 'img_url' => $sImgUrl,
  800. 'img_url_encoded' => rawurlencode($sImgUrl),
  801. );
  802. }
  803. //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
  804. //--- Views
  805. $sViews = '';
  806. $oViews = !empty($aParams['object_view']) ? BxDolView::getObjectInstance($aParams['object_view'], $iId) : false;
  807. if ($oViews)
  808. $sViews = $oViews->getElementBlock(array('show_do_view_as_button' => true));
  809. //--- Votes
  810. $sVotes = '';
  811. $oVotes = !empty($aParams['object_vote']) ? BxDolVote::getObjectInstance($aParams['object_vote'], $iId) : false;
  812. if ($oVotes)
  813. $sVotes = $oVotes->getElementBlock(array('show_do_vote_as_button' => true));
  814. //--- Favorite
  815. $sFavorites = '';
  816. $oFavorites = !empty($aParams['object_favorite']) ? BxDolFavorite::getObjectInstance($aParams['object_favorite'], $iId) : false;
  817. if ($oFavorites)
  818. $sFavorites = $oFavorites->getElementBlock(array('show_do_favorite_as_button' => true));
  819. //--- Featured
  820. $sFeatured = '';
  821. $oFeatured = !empty($aParams['object_feature']) ? BxDolFeature::getObjectInstance($aParams['object_feature'], $iId) : false;
  822. if ($oFeatured)
  823. $sFeatured = $oFeatured->getElementBlock(array('show_do_feature_as_button' => true));
  824. //--- Timeline Repost
  825. $sRepost = '';
  826. $iIdTimeline = isset($aParams['id_timeline']) ? (int)$aParams['id_timeline'] : $iId;
  827. if ($iIdTimeline && BxDolRequest::serviceExists('bx_timeline', 'get_repost_element_block'))
  828. $sRepost = BxDolService::call('bx_timeline', 'get_repost_element_block', array(bx_get_logged_profile_id(), $this->_aModule['name'], 'added', $iIdTimeline, array('show_do_repost_as_button' => true)));
  829. //--- Report
  830. $sReport = '';
  831. $oReport = !empty($aParams['object_report']) ? BxDolReport::getObjectInstance($aParams['object_report'], $iId) : false;
  832. if ($oReport)
  833. $sReport = $oReport->getElementBlock(array('show_do_report_as_button' => true));
  834. $sSocial = '';
  835. if($bSocialSharing) {
  836. $oSocial = BxDolMenu::getObjectInstance('sys_social_sharing');
  837. $oSocial->addMarkers(array_merge(array(
  838. 'id' => $iId,
  839. 'module' => $this->_aModule['name'],
  840. 'url' => BX_DOL_URL_ROOT . $sUrl,
  841. 'title' => $sTitle,
  842. ), $aCustomParams));
  843. $sSocial = $oSocial->getCode();
  844. }
  845. if(empty($sComments) && empty($sViews) && empty($sVotes) && empty($sFavorites) && empty($sFeatured) && empty($sRepost) && empty($sReport) && empty($sSocial))
  846. return '';
  847. return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
  848. 'comments' => $sComments,
  849. 'view' => $sViews,
  850. 'vote' => $sVotes,
  851. 'favorite' => $sFavorites,
  852. 'feature' => $sFeatured,
  853. 'repost' => $sRepost,
  854. 'report' => $sReport,
  855. 'social' => $sSocial,
  856. ));
  857. //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Repost, etc.
  858. }
  859. protected function _getFieldValue($sField, $iContentId)
  860. {
  861. $CNF = &$this->_oConfig->CNF;
  862. if(empty($CNF[$sField]))
  863. return false;
  864. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  865. if(empty($aContentInfo) || empty($aContentInfo[$CNF[$sField]]))
  866. return false;
  867. return $aContentInfo[$CNF[$sField]];
  868. }
  869. protected function _getFieldValueThumb($sField, $iContentId, $sTranscoder = '')
  870. {
  871. $CNF = &$this->_oConfig->CNF;
  872. if(empty($sTranscoder) || empty($CNF[$sField]))
  873. return false;
  874. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  875. if(empty($aContentInfo) || empty($aContentInfo[$CNF[$sField]]))
  876. return false;
  877. $oImagesTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscoder);
  878. if(!$oImagesTranscoder)
  879. return false;
  880. return $oImagesTranscoder->getFileUrl($aContentInfo[$CNF[$sField]]);
  881. }
  882. }
  883. /** @} */