| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup Timeline Timeline
- * @ingroup UnaModules
- *
- * @{
- */
- class BxTimelineTemplate extends BxBaseModNotificationsTemplate
- {
- protected $_bShowTimelineDividers;
- function __construct(&$oConfig, &$oDb)
- {
- parent::__construct($oConfig, $oDb);
- $this->_bShowTimelineDividers = false;
- }
- public function getCssJs()
- {
- parent::getCssJs();
- $this->addCss(array(
- BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'flickity/|flickity.css',
- 'jquery-ui/jquery-ui.css',
- 'post.css',
- 'repost.css',
- ));
- $this->addJs(array(
- 'jquery-ui/jquery-ui.custom.min.js',
- 'jquery.form.min.js',
- 'jquery.ba-resize.min.js',
- 'autosize.min.js',
- 'masonry.pkgd.min.js',
- 'modernizr.js',
- 'flickity/flickity.pkgd.min.js',
- 'post.js',
- 'repost.js',
- ));
- }
- public function getPostBlock($iOwnerId)
- {
- $aForm = $this->getModule()->getFormPost();
- return $this->parseHtmlByName('block_post.html', array (
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'js_object' => $this->_oConfig->getJsObject('post'),
- 'js_content' => $this->getJsCode('post', array(
- 'oRequestParams' => array('owner_id' => $iOwnerId)
- )),
- 'form' => $aForm['form']
- ));
- }
- public function getViewBlock($aParams)
- {
- list($sContent, $sLoadMore, $sBack, $sEmpty) = $this->getPosts($aParams);
- return $this->parseHtmlByName('block_view.html', array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'html_id' => $this->_oConfig->getHtmlIds('view', 'main_' . $aParams['view']),
- 'view' => $aParams['view'],
- 'back' => $sBack,
- 'empty' => $sEmpty,
- 'content' => $sContent,
- 'load_more' => $sLoadMore,
- 'view_image_popup' => $this->_getImagePopup($aParams),
- 'js_content' => $this->getJsCode('view', array(
- 'oRequestParams' => array(
- 'type' => $aParams['type'],
- 'owner_id' => $aParams['owner_id'],
- 'start' => $aParams['start'],
- 'per_page' => $aParams['per_page'],
- 'filter' => $aParams['filter'],
- 'modules' => $aParams['modules'],
- 'timeline' => $aParams['timeline'],
- )
- )) . $this->getJsCode('repost')
- ));
- }
- public function getSearchBlock($sContent)
- {
- $oModule = $this->getModule();
- $aParams = $oModule->getParams(BX_TIMELINE_VIEW_SEARCH);
- return $this->parseHtmlByName('block_search.html', array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'html_id' => $this->_oConfig->getHtmlIds('view', 'main_' . $aParams['view']),
- 'view' => $aParams['view'],
- 'content' => $sContent,
- 'view_image_popup' => $this->_getImagePopup($aParams),
- 'js_content' => $this->getJsCode('view', array(
- 'oRequestParams' => array(
- 'type' => $aParams['type'],
- 'owner_id' => $aParams['owner_id'],
- 'start' => $aParams['start'],
- 'per_page' => $aParams['per_page'],
- 'filter' => $aParams['filter'],
- 'modules' => $aParams['modules'],
- 'timeline' => $aParams['timeline'],
- )
- ))
- ));
- }
- public function getItemBlock($iId)
- {
- $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
- if(empty($aEvent))
- return '';
- $aParams = array(
- 'view' => BX_TIMELINE_VIEW_DEFAULT,
- 'type' => BX_TIMELINE_TYPE_ITEM
- );
- $sContent = $this->getPost($aEvent, $aParams);
- $oModule = $this->getModule();
- if($oModule->isAllowedViewCounter($aEvent) !== true)
- return '';
- if(!$this->_oConfig->isSystem($aEvent['type'], $aEvent['action'])) {
- $mixedViews = $oModule->getViewsData($aEvent['views']);
- if($mixedViews !== false) {
- list($sSystem, $iObjectId) = $mixedViews;
- $oModule->getViewObject($sSystem, $iObjectId)->doView();
- }
- }
- return $this->parseHtmlByName('block_item.html', array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'html_id' => $this->_oConfig->getHtmlIds('view', 'main_item'),
- 'content' => $sContent,
- 'view_image_popup' => $this->_getImagePopup($aParams),
- 'js_content' => $this->getJsCode('view')
- ));
- }
- public function getUnit(&$aEvent, $aBrowseParams = array())
- {
- $oModule = $this->getModule();
- if(empty($aBrowseParams) || !is_array($aBrowseParams))
- $aBrowseParams = $oModule->getParams(BX_TIMELINE_VIEW_SEARCH);
- return $this->getPost($aEvent, $aBrowseParams);
- }
- public function getPost(&$aEvent, $aBrowseParams = array())
- {
- $aResult = $this->getData($aEvent);
- if($aResult === false)
- return '';
- $aEvent['object_owner_id'] = $aResult['owner_id'];
- $aEvent['icon'] = !empty($aResult['icon']) ? $aResult['icon'] : '';
- $aEvent['sample'] = !empty($aResult['sample']) ? $aResult['sample'] : '_bx_timeline_txt_sample';
- $aEvent['sample_action'] = !empty($aResult['sample_action']) ? $aResult['sample_action'] : '_bx_timeline_txt_added_sample';
- $aEvent['content'] = $aResult['content'];
- $aEvent['views'] = $aResult['views'];
- $aEvent['votes'] = $aResult['votes'];
- $aEvent['reports'] = $aResult['reports'];
- $aEvent['comments'] = $aResult['comments'];
- $sType = !empty($aResult['content_type']) ? $aResult['content_type'] : BX_TIMELINE_PARSE_TYPE_DEFAULT;
- return $this->_getPost($sType, $aEvent, $aBrowseParams);
- }
- public function getPosts($aParams)
- {
- $bViewTimeline = $aParams['view'] == BX_TIMELINE_VIEW_TIMELINE;
- $iStart = $aParams['start'];
- $iPerPage = $aParams['per_page'];
- $aParamsDb = $aParams;
- //--- Check for Previous
- $iDays = -1;
- $bPrevious = false;
- if($iStart - 1 >= 0) {
- $aParamsDb['start'] -= 1;
- $aParamsDb['per_page'] += 1;
- $bPrevious = true;
- }
- //--- Check for Next
- $aParamsDb['per_page'] += 1;
- $aEvents = $this->_oDb->getEvents($aParamsDb);
- //--- Check for Previous
- if($bPrevious) {
- $aEvent = array_shift($aEvents);
- $iDays = (int)$aEvent['days'];
- }
- //--- Check for Next
- $bNext = false;
- if(count($aEvents) > $iPerPage) {
- $aEvent = array_pop($aEvents);
- $bNext = true;
- }
- $iEvents = count($aEvents);
- $sContent = '';
- if($bViewTimeline && $iEvents <= 0)
- $sContent .= $this->getDividerToday();
- $bFirst = true;
- foreach($aEvents as $aEvent) {
- $sEvent = $this->getPost($aEvent, $aParams);
- $bEvent = !empty($sEvent);
- if(!$bEvent)
- continue;
- if($bViewTimeline && $bFirst) {
- $sContent .= $this->getDividerToday($aEvent);
- $bFirst = false;
- }
- $sContent .= $bViewTimeline && $bEvent ? $this->getDivider($iDays, $aEvent) : '';
- $sContent .= $sEvent;
- }
- $sBack = $this->getBack($aParams);
- $sLoadMore = $this->getLoadMore($aParams, $bNext, $iEvents > 0);
- $sEmpty = $this->getEmpty($iEvents <= 0);
- return array($sContent, $sLoadMore, $sBack, $sEmpty);
- }
- public function getEmpty($bVisible)
- {
- return $this->parseHtmlByName('empty.html', array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'visible' => $bVisible ? 'block' : 'none',
- 'content' => MsgBox(_t('_bx_timeline_txt_msg_no_results'))
- ));
- }
- public function getDivider(&$iDays, &$aEvent)
- {
- if(!$this->_bShowTimelineDividers || $iDays == $aEvent['days'])
- return '';
- $iDays = $aEvent['days'];
- $iDaysAgo = (int)$aEvent['ago_days'];
- if($aEvent['today'] == $aEvent['days'] || (($aEvent['today'] - $aEvent['days']) == 1 && $iDaysAgo == 0))
- return '';
- return $this->parseHtmlByName('divider.html', array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'type' => 'common',
- 'bx_if:show_hidden' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'content' => bx_time_js($aEvent['date'])
- ));
- }
- public function getDividerToday($aEvent = array())
- {
- if(!$this->_bShowTimelineDividers)
- return '';
- $bToday = !empty($aEvent) && ($aEvent['today'] == $aEvent['days'] || (($aEvent['today'] - $aEvent['days']) == 1 && (int)$aEvent['ago_days'] == 0));
- return $this->parseHtmlByName('divider.html', array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'type' => 'today',
- 'bx_if:show_hidden' => array(
- 'condition' => !$bToday,
- 'content' => array()
- ),
- 'content' => _t('_bx_timeline_txt_today')
- ));
- }
- public function getBack($aParams)
- {
- $iYearSel = (int)$aParams['timeline'];
- if($iYearSel == 0)
- return '';
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('view');
- $iYearNow = date('Y', time());
- return $this->parseHtmlByName('back.html', array(
- 'style_prefix' => $sStylePrefix,
- 'href' => 'javascript:void(0)',
- 'title' => _t('_bx_timeline_txt_jump_to_n_year', $iYearNow),
- 'bx_repeat:attrs' => array(
- array('key' => 'onclick', 'value' => 'javascript:' . $sJsObject . '.changeTimeline(this, 0)')
- ),
- 'content' => _t('_bx_timeline_txt_jump_to_recent')
- ));
- }
- public function getLoadMore($aParams, $bEnabled, $bVisible = true)
- {
- $iStart = $aParams['start'];
- $iPerPage = $aParams['per_page'];
- $iYearSel = (int)$aParams['timeline'];
- $iYearMin = $this->_oDb->getMaxDuration($aParams);
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('view');
- $sYears = '';
- if(!empty($iYearMin)) {
- $iYearMax = date('Y', time()) - 1;
- for($i = $iYearMax; $i >= $iYearMin; $i--)
- $sYears .= ($i != $iYearSel ? $this->parseHtmlByName('bx_a.html', array(
- 'href' => 'javascript:void(0)',
- 'title' => _t('_bx_timeline_txt_jump_to_n_year', $i),
- 'bx_repeat:attrs' => array(
- array('key' => 'onclick', 'value' => 'javascript:' . $sJsObject . '.changeTimeline(this, ' . $i . ')')
- ),
- 'content' => $i
- )) : $i) . ', ';
- $sYears = substr($sYears, 0, -2);
- }
- $aTmplVars = array(
- 'style_prefix' => $sStylePrefix,
- 'visible' => ($aParams['view'] == BX_TIMELINE_VIEW_TIMELINE && $bVisible) || ($aParams['view'] == BX_TIMELINE_VIEW_OUTLINE && $bEnabled && $bVisible) ? 'block' : 'none',
- 'bx_if:is_disabled' => array(
- 'condition' => !$bEnabled,
- 'content' => array()
- ),
- 'bx_if:show_on_click' => array(
- 'condition' => $bEnabled,
- 'content' => array(
- 'on_click' => 'javascript:' . $sJsObject . '.changePage(this, ' . ($iStart + $iPerPage) . ', ' . $iPerPage . ')'
- )
- ),
- 'bx_if:show_jump_to' => array(
- 'condition' => !empty($sYears),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'years' => $sYears
- )
- )
- );
- return $this->parseHtmlByName('load_more.html', $aTmplVars);
- }
- public function getComments($sSystem, $iId)
- {
- $oModule = $this->getModule();
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $oCmts = $oModule->getCmtsObject($sSystem, $iId);
- if($oCmts === false)
- return '';
- $aComments = $oCmts->getCommentsBlock(0, 0, false);
- return $this->parseHtmlByName('comments.html', array(
- 'style_prefix' => $sStylePrefix,
- 'id' => $iId,
- 'content' => $aComments['content']
- ));
- }
- public function getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
- {
- $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
- if(empty($aReposted) || !is_array($aReposted))
- return '';
- $oModule = $this->getModule();
- $bDisabled = $oModule->isAllowedRepost($aReposted) !== true || $this->_oDb->isReposted($aReposted['id'], $iOwnerId, $oModule->getUserId());
- if($bDisabled && (int)$aReposted['reposts'] == 0)
- return '';
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sStylePrefixRepost = $sStylePrefix . '-repost-';
- $bShowDoRepostAsButtonSmall = isset($aParams['show_do_repost_as_button_small']) && $aParams['show_do_repost_as_button_small'] == true;
- $bShowDoRepostAsButton = !$bShowDoRepostAsButtonSmall && isset($aParams['show_do_repost_as_button']) && $aParams['show_do_repost_as_button'] == true;
- $bShowDoRepostIcon = isset($aParams['show_do_repost_icon']) && $aParams['show_do_repost_icon'] == true;
- $bShowDoRepostLabel = isset($aParams['show_do_repost_label']) && $aParams['show_do_repost_label'] == true;
- $bShowCounter = isset($aParams['show_counter']) && $aParams['show_counter'] === true;
- //--- Do repost link ---//
- $sClass = $sStylePrefixRepost . 'do-repost';
- if($bShowDoRepostAsButton)
- $sClass .= ' bx-btn';
- else if($bShowDoRepostAsButtonSmall)
- $sClass .= ' bx-btn bx-btn-small';
- $sOnClick = '';
- if(!$bDisabled) {
- $sCommonPrefix = $this->_oConfig->getPrefix('common_post');
- if(str_replace($sCommonPrefix, '', $sType) == BX_TIMELINE_PARSE_TYPE_REPOST) {
- $aRepostedData = $this->_getCommonData($aReposted);
-
- $sOnClick = $this->_getRepostJsClick($iOwnerId, $aRepostedData['content']['type'], $aRepostedData['content']['action'], $aRepostedData['content']['object_id']);
- }
- else
- $sOnClick = $this->_getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId);
- }
- else
- $sClass .= $bShowDoRepostAsButton || $bShowDoRepostAsButtonSmall ? ' bx-btn-disabled' : ' ' . $sStylePrefixRepost . 'disabled';
- $aOnClickAttrs = array();
- if(!empty($sClass))
- $aOnClickAttrs[] = array('key' => 'class', 'value' => $sClass);
- if(!empty($sOnClick))
- $aOnClickAttrs[] = array('key' => 'onclick', 'value' => $sOnClick);
- $sDoRepost = '';
- if($bShowDoRepostIcon)
- $sDoRepost .= $this->parseHtmlByName('bx_icon.html', array('name' => 'repeat'));
- if($bShowDoRepostLabel)
- $sDoRepost .= ($sDoRepost != '' ? ' ' : '') . _t('_bx_timeline_txt_do_repost');
- return $this->parseHtmlByName('repost_element_block.html', array(
- 'style_prefix' => $sStylePrefix,
- 'html_id' => $this->_oConfig->getHtmlIds('repost', 'main') . $aReposted['id'],
- 'class' => ($bShowDoRepostAsButton ? $sStylePrefixRepost . 'button' : '') . ($bShowDoRepostAsButtonSmall ? $sStylePrefixRepost . 'button-small' : ''),
- 'count' => $aReposted['reposts'],
- 'do_repost' => $this->parseHtmlByName('bx_a.html', array(
- 'href' => 'javascript:void(0)',
- 'title' => _t('_bx_timeline_txt_do_repost'),
- 'bx_repeat:attrs' => $aOnClickAttrs,
- 'content' => $sDoRepost
- )),
- 'bx_if:show_counter' => array(
- 'condition' => $bShowCounter,
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'bx_if:show_hidden' => array(
- 'condition' => (int)$aReposted['reposts'] == 0,
- 'content' => array()
- ),
- 'counter' => $this->getRepostCounter($aReposted, $aParams)
- )
- ),
- 'script' => $this->getRepostJsScript()
- ));
- }
- public function getRepostCounter($aEvent, $aParams = array())
- {
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('repost');
- $bShowDoRepostAsButtonSmall = isset($aParams['show_do_repost_as_button_small']) && $aParams['show_do_repost_as_button_small'] == true;
- $bShowDoRepostAsButton = !$bShowDoRepostAsButtonSmall && isset($aParams['show_do_repost_as_button']) && $aParams['show_do_repost_as_button'] == true;
- $sClass = $sStylePrefix . '-repost-counter';
- if($bShowDoRepostAsButtonSmall)
- $sClass .= ' bx-btn-small-height';
- if($bShowDoRepostAsButton)
- $sClass .= ' bx-btn-height';
- return $this->parseHtmlByName('repost_counter.html', array(
- 'href' => 'javascript:void(0)',
- 'title' => _t('_bx_timeline_txt_reposted_by'),
- 'bx_repeat:attrs' => array(
- array('key' => 'id', 'value' => $this->_oConfig->getHtmlIds('repost', 'counter') . $aEvent['id']),
- array('key' => 'class', 'value' => $sClass),
- array('key' => 'onclick', 'value' => 'javascript:' . $sJsObject . '.toggleByPopup(this, ' . $aEvent['id'] . ')')
- ),
- 'content' => !empty($aEvent['reposts']) && (int)$aEvent['reposts'] > 0 ? $aEvent['reposts'] : ''
- ));
- }
- public function getRepostedBy($iId)
- {
- $aTmplUsers = array();
- $oModule = $this->getModule();
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $aUserIds = $this->_oDb->getRepostedBy($iId);
- foreach($aUserIds as $iUserId) {
- list($sUserName, $sUserUrl, $sUserIcon, $sUserUnit) = $oModule->getUserInfo($iUserId);
- $aTmplUsers[] = array(
- 'style_prefix' => $sStylePrefix,
- 'user_unit' => $sUserUnit
- );
- }
- if(empty($aTmplUsers))
- $aTmplUsers = MsgBox(_t('_Empty'));
- return $this->parseHtmlByName('repost_by_list.html', array(
- 'style_prefix' => $sStylePrefix,
- 'bx_repeat:list' => $aTmplUsers
- ));
- }
- public function getRepostJsScript()
- {
- $this->addCss(array('repost.css'));
- $this->addJs(array('main.js', 'repost.js'));
- return $this->getJsCode('repost');
- }
- public function getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId)
- {
- $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
- if(empty($aReposted) || !is_array($aReposted))
- return '';
- $sResult = '';
- $sCommonPrefix = $this->_oConfig->getPrefix('common_post');
- if(str_replace($sCommonPrefix, '', $sType) == BX_TIMELINE_PARSE_TYPE_REPOST) {
- $aRepostedData = $this->_getCommonData($aReposted);
- $sResult = $this->_getRepostJsClick($iOwnerId, $aRepostedData['content']['type'], $aRepostedData['content']['action'], $aRepostedData['content']['object_id']);
- }
- else
- $sResult = $this->_getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId);
- return $sResult;
- }
- public function getAttachLinkForm()
- {
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('post');
- $aForm = $this->getModule()->getFormAttachLink();
- return $this->parseHtmlByName('attach_link_form.html', array(
- 'style_prefix' => $sStylePrefix,
- 'js_object' => $sJsObject,
- 'form_id' => $aForm['form_id'],
- 'form' => $aForm['form'],
- ));
- }
- public function getAttachLinkField($iUserId)
- {
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $aLinks = $this->_oDb->getUnusedLinks($iUserId);
- $sLinks = '';
- foreach($aLinks as $aLink)
- $sLinks .= $this->getAttachLinkItem($iUserId, $aLink);
- return $this->parsePageByName('attach_link_form_field.html', array(
- 'html_id' => $this->_oConfig->getHtmlIds('post', 'attach_link_form_field'),
- 'style_prefix' => $sStylePrefix,
- 'links' => $sLinks
- ));
- }
- public function getAttachLinkItem($iUserId, $mixedLink)
- {
- $aLink = is_array($mixedLink) ? $mixedLink : $this->_oDb->getUnusedLinks($iUserId, (int)$mixedLink);
- if(empty($aLink) || !is_array($aLink))
- return '';
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('post');
- $sLinkIdPrefix = $this->_oConfig->getHtmlIds('post', 'attach_link_item');
- $bTmplVarsEmbed = false;
- $aTmplVarsEmbed = array();
- $sEmbedlyKey = $this->_oDb->getParam('sys_embedly_api_key');
- $sEmbedlyPattern = $this->_oDb->getParam('sys_embedly_api_pattern');
- if(!empty($sEmbedlyKey) && !empty($sEmbedlyPattern) && preg_match($sEmbedlyPattern, $aLink['url'])) {
- $bTmplVarsEmbed = true;
- $aTmplVarsEmbed = array(
- 'style_prefix' => $sStylePrefix,
- 'embed' => $this->parsePageByName('bx_a.html', array(
- 'href' => $aLink['url'],
- 'title' => bx_html_attribute($aLink['title']),
- 'bx_repeat:attrs' => array(
- array('key' => 'class', 'value' => 'bx-link-embed')
- ),
- 'content' => $aLink['title'],
- ))
- );
- }
- else {
- $aLinkAttrs = array();
- if(!$this->_oConfig->isEqualUrls(BX_DOL_URL_ROOT, $aLink['url'])) {
- $aLinkAttrs[] = array('key' => 'target', 'value' => '_blank');
-
- if($this->_oDb->getParam('sys_add_nofollow') == 'on')
- $aLinkAttrs[] = array('key' => 'rel', 'value' => 'nofollow');
- }
- $sThumbnail = "";
- if((int)$aLink['media_id'] != 0)
- $sThumbnail = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_preview'))->getFileUrl($aLink['media_id']);
- $aTmplVarsEmbed = array(
- 'style_prefix' => $sStylePrefix,
- 'bx_if:show_thumbnail' => array(
- 'condition' => !empty($sThumbnail),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'thumbnail' => $sThumbnail
- )
- ),
- 'url' => $aLink['url'],
- 'link' => $this->parsePageByName('bx_a.html', array(
- 'href' => $aLink['url'],
- 'title' => bx_html_attribute($aLink['title']),
- 'bx_repeat:attrs' => $aLinkAttrs,
- 'content' => $aLink['title'],
- ))
- );
- }
- return $this->parsePageByName('attach_link_item.html', array(
- 'html_id' => $sLinkIdPrefix . $aLink['id'],
- 'style_prefix' => $sStylePrefix,
- 'js_object' => $sJsObject,
- 'id' => $aLink['id'],
- 'bx_if:show_embed_outer' => array(
- 'condition' => $bTmplVarsEmbed,
- 'content' => $aTmplVarsEmbed
- ),
- 'bx_if:show_embed_inner' => array(
- 'condition' => !$bTmplVarsEmbed,
- 'content' => $aTmplVarsEmbed
- ),
- ));
- }
- public function getData(&$aEvent)
- {
- $aResult = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $this->_getSystemData($aEvent) : $this->_getCommonData($aEvent);
- if(empty($aResult) || empty($aResult['owner_id']) || empty($aResult['content']))
- return false;
- list($sUserName) = $this->getModule()->getUserInfo($aResult['owner_id']);
- $sSample = !empty($aResult['sample']) ? $aResult['sample'] : '_bx_timeline_txt_sample';
- if(empty($aEvent['title']) || empty($aEvent['description'])) {
- $sTitle = !empty($aResult['title']) ? $this->_oConfig->getTitle($aResult['title']) : _t($sSample);
- $sDescription = !empty($aResult['description']) ? $aResult['description'] : _t('_bx_timeline_txt_user_added_sample', $sUserName, _t($sSample));
- if($sDescription == '' && !empty($aResult['content']['text']))
- $sDescription = $aResult['content']['text'];
- $this->_oDb->updateEvent(array(
- 'title' => bx_process_input(strip_tags($sTitle)),
- 'description' => bx_process_input(strip_tags($sDescription))
- ), array('id' => $aEvent['id']));
- }
- return $aResult;
- }
- protected function _getPost($sType, $aEvent, $aBrowseParams = array())
- {
- $CNF = &$this->_oConfig->CNF;
- $oModule = $this->getModule();
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('view');
- list($sAuthorName, $sAuthorUrl, $sAuthorIcon) = $oModule->getUserInfo($aEvent['object_owner_id']);
- $bAuthorIcon = !empty($sAuthorIcon);
- $aTmplVarsMenuItemActions = $this->_getTmplVarsMenuItemActions($aEvent, $aBrowseParams);
- $aTmplVarsTimelineOwner = array();
- if(isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_BASE_MOD_NTFS_TYPE_CONNECTIONS)
- $aTmplVarsTimelineOwner = $this->_getTmplVarsTimelineOwner($aEvent);
- $bBrowseItem = isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_ITEM;
- $bViewOutline = isset($aBrowseParams['view']) && $aBrowseParams['view'] == BX_TIMELINE_VIEW_OUTLINE;
- $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
- $sLocation = $oMetatags->locationsString($aEvent['id']);
-
- $aTmplVars = array (
- 'style_prefix' => $sStylePrefix,
- 'js_object' => $sJsObject,
- 'html_id' => $this->_oConfig->getHtmlIds('view', 'item_' . $aBrowseParams['view']) . $aEvent['id'],
- 'class' => $bBrowseItem || !$bViewOutline ? 'bx-tl-view-sizer' : 'bx-tl-grid-sizer',
- 'class_content' => $bBrowseItem ? 'bx-def-color-bg-block' : 'bx-def-color-bg-box',
- 'id' => $aEvent['id'],
- 'bx_if:show_owner_icon' => array(
- 'condition' => $bAuthorIcon,
- 'content' => array(
- 'owner_icon' => $sAuthorIcon
- )
- ),
- 'bx_if:show_owner_icon_empty' => array(
- 'condition' => !$bAuthorIcon,
- 'content' => array()
- ),
- 'item_icon' => !empty($aEvent['icon']) ? $aEvent['icon'] : $CNF['ICON'],
- 'item_owner_url' => $sAuthorUrl,
- 'item_owner_title' => bx_html_attribute($sAuthorName),
- 'item_owner_name' => $sAuthorName,
- 'item_owner_action' => _t($aEvent['sample_action'], _t($aEvent['sample'])),
- 'bx_if:show_timeline_owner' => array(
- 'condition' => !empty($aTmplVarsTimelineOwner),
- 'content' => $aTmplVarsTimelineOwner
- ),
- 'item_view_url' => $this->_oConfig->getItemViewUrl($aEvent),
- 'item_date' => bx_time_js($aEvent['date']),
- 'bx_if:show_pinned' => array(
- 'condition' => (int)$aEvent['pinned'] != 0,
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- )
- ),
- 'content' => is_string($aEvent['content']) ? $aEvent['content'] : $this->_getContent($sType, $aEvent, $aBrowseParams),
- 'bx_if:show_location' => array(
- 'condition' => !empty($sLocation),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'location' => $sLocation
- )
- ),
- 'bx_if:show_menu_item_actions' => array(
- 'condition' => !empty($aTmplVarsMenuItemActions),
- 'content' => $aTmplVarsMenuItemActions
- ),
- 'comments' => $bBrowseItem ? $this->_getComments($aEvent['comments']) : '',
- );
- return $this->parseHtmlByName('item_' . $aBrowseParams['view'] . '.html', $aTmplVars);
- }
- protected function _getContent($sType, $aEvent, $aBrowseParams = array())
- {
- $sMethod = '_getTmplVarsContent' . ucfirst($sType);
- if(!method_exists($this, $sMethod))
- return '';
- $aTmplVars = $this->$sMethod($aEvent, $aBrowseParams);
- return $this->parseHtmlByName('type_' . $sType . '.html', $aTmplVars);
- }
- protected function _getComments($aComments)
- {
- $mixedComments = $this->getModule()->getCommentsData($aComments);
- if($mixedComments === false)
- return '';
- list($sSystem, $iObjectId, $iCount) = $mixedComments;
- return $this->getComments($sSystem, $iObjectId);
- }
- protected function _getImagePopup($aParams)
- {
- $sViewImagePopupId = $this->_oConfig->getHtmlIds('view', 'photo_popup_' . $aParams['view']);
- $sViewImagePopupContent = $this->parseHtmlByName('popup_image.html', array(
- 'image_url' => ''
- ));
- return BxTemplFunctions::getInstance()->transBox($sViewImagePopupId, $sViewImagePopupContent, true);
- }
- protected function _getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId)
- {
- $sJsObject = $this->_oConfig->getJsObject('repost');
- $sFormat = "%s.repostItem(this, %d, '%s', '%s', %d);";
- $iOwnerId = !empty($iOwnerId) ? (int)$iOwnerId : $this->getModule()->getUserId(); //--- in whose timeline the content will be reposted
- return sprintf($sFormat, $sJsObject, $iOwnerId, $sType, $sAction, (int)$iObjectId);
- }
- protected function _getTmplVarsMenuItemActions(&$aEvent, $aBrowseParams = array())
- {
- $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_item_actions'));
- $oMenu->setEvent($aBrowseParams['view'], $aEvent);
- $oMenu->setDynamicMode(isset($aBrowseParams['dynamic_mode']) && $aBrowseParams['dynamic_mode'] === true);
- $sMenu = $oMenu->getCode();
- if(empty($sMenu))
- return array();
- return array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'js_object' => $this->_oConfig->getJsObject('view'),
- 'menu_item_actions' => $sMenu
- );
- }
- protected function _getTmplVarsTimelineOwner(&$aEvent)
- {
- $oModule = $this->getModule();
- $aTmplVarsTimelineOwner = array();
- if((int)$aEvent['owner_id'] != (int)$aEvent['object_owner_id']) {
- list($sTimelineAuthorName, $sTimelineAuthorUrl) = $oModule->getUserInfo($aEvent['owner_id']);
- $aTmplVarsTimelineOwner = array(
- 'style_prefix' => $this->_oConfig->getPrefix('style'),
- 'owner_url' => $sTimelineAuthorUrl,
- 'owner_username' => $sTimelineAuthorName,
- );
- }
- return $aTmplVarsTimelineOwner;
- }
- protected function _getTmplVarsContentPost($aEvent, $aBrowseParams = array())
- {
- $aContent = &$aEvent['content'];
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sJsObject = $this->_oConfig->getJsObject('view');
- $bBrowseItem = isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_ITEM;
- //--- Process Raw ---//
- $sRaw = isset($aContent['raw']) ? $aContent['raw'] : '';
- //--- Process Text ---//
- $sUrl = isset($aContent['url']) ? bx_html_attribute($aContent['url']) : '';
- $sTitle = $sTitleAttr = '';
- if(isset($aContent['title'])) {
- $sTitle = bx_process_output($aContent['title']);
- $sTitleAttr = bx_html_attribute($aContent['title']);
- }
- if(!empty($sUrl) && !empty($sTitle))
- $sTitle = $this->parseHtmlByName('bx_a.html', array(
- 'href' => $sUrl,
- 'title' => $sTitleAttr,
- 'bx_repeat:attrs' => array(
- array('key' => 'class', 'value' => $sStylePrefix . '-title')
- ),
- 'content' => $sTitle
- ));
- $sText = isset($aContent['text']) ? $aContent['text'] : '';
- $sTextMore = '';
- if($bBrowseItem)
- $sText = strip_tags($sText, '<br><br/><p>');
- else {
- $sText = strip_tags($sText);
- $iMaxLength = $this->_oConfig->getCharsDisplayMax();
- if(strlen($sText) > $iMaxLength) {
- $iLength = strpos($sText, ' ', $iMaxLength);
- $sTextMore = trim(substr($sText, $iLength));
- $sText = trim(substr($sText, 0, $iLength));
- }
- $sTextMore = nl2br($sTextMore);
- $sText = nl2br($sText);
- }
- $sText = $this->_prepareTextForOutput($sText, $aEvent['id']);
- $sTextMore = $this->_prepareTextForOutput($sTextMore, $aEvent['id']);
- //--- Process Links ---//
- $bAddNofollow = $this->_oDb->getParam('sys_add_nofollow') == 'on';
- $aTmplVarsLinks = array();
- if(!empty($aContent['links']))
- foreach($aContent['links'] as $aLink) {
- $bTmplVarsEmbed = false;
- $aTmplVarsEmbed = array();
- $sEmbedlyKey = $this->_oDb->getParam('sys_embedly_api_key');
- $sEmbedlyPattern = $this->_oDb->getParam('sys_embedly_api_pattern');
- if(!empty($sEmbedlyKey) && !empty($sEmbedlyPattern) && preg_match($sEmbedlyPattern, $aLink['url'])) {
- $bTmplVarsEmbed = true;
- $aTmplVarsEmbed = array(
- 'style_prefix' => $sStylePrefix,
- 'embed' => $this->parsePageByName('bx_a.html', array(
- 'href' => $aLink['url'],
- 'title' => bx_html_attribute($aLink['title']),
- 'bx_repeat:attrs' => array(
- array('key' => 'class', 'value' => 'bx-link-embed')
- ),
- 'content' => $aLink['title'],
- ))
- );
- }
- else {
- $aLinkAttrs = array();
- if(!$this->_oConfig->isEqualUrls(BX_DOL_URL_ROOT, $aLink['url'])) {
- $aLinkAttrs[] = array('key' => 'target', 'value' => '_blank');
-
- if($bAddNofollow)
- $aLinkAttrs[] = array('key' => 'rel', 'value' => 'nofollow');
- }
- $aTmplVarsEmbed = array(
- 'bx_if:show_thumbnail' => array(
- 'condition' => !empty($aLink['thumbnail']),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'thumbnail' => $aLink['thumbnail']
- )
- ),
- 'link' => $this->parsePageByName('bx_a.html', array(
- 'href' => $aLink['url'],
- 'title' => $aLink['title'],
- 'bx_repeat:attrs' => $aLinkAttrs,
- 'content' => $aLink['title'],
- )),
- 'bx_if:show_text' => array(
- 'condition' => !empty($aLink['text']),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'text' => $aLink['text']
- )
- )
- );
- }
- $aTmplVarsLinks[] = array(
- 'style_prefix' => $sStylePrefix,
- 'bx_if:show_embed_outer' => array(
- 'condition' => $bTmplVarsEmbed,
- 'content' => $aTmplVarsEmbed
- ),
- 'bx_if:show_embed_inner' => array(
- 'condition' => !$bTmplVarsEmbed,
- 'content' => $aTmplVarsEmbed
- )
- );
- }
- //--- Process Photos ---//
- $aTmplVarsImages = array();
- if(!empty($aContent['images'])) {
- foreach($aContent['images'] as $aImage) {
- $sImage = '';
- if(!empty($aImage['src']))
- $sImage = $this->parseHtmlByName('bx_img.html', array(
- 'src' => $bBrowseItem && !empty($aImage['src_orig']) ? $aImage['src_orig'] : $aImage['src'],
- 'bx_repeat:attrs' => array(
- array('key' => 'class', 'value' => $sStylePrefix . '-item-img')
- )
- ));
- if(!empty($sImage) && (isset($aImage['url']) || isset($aImage['onclick']))) {
- $aAttrs = array();
- if(isset($aImage['onclick']))
- $aAttrs[] = array('key' => 'onclick', 'value' => $aImage['onclick']);
- $sImage = $this->parseHtmlByName('bx_a.html', array(
- 'href' => isset($aImage['url']) ? $aImage['url'] : 'javascript:void(0)',
- 'title' => '',
- 'bx_repeat:attrs' => $aAttrs,
- 'content' => $sImage
- ));
- }
- $aTmplVarsImages[] = array(
- 'style_prefix' => $sStylePrefix,
- 'image' => $sImage
- );
- }
- }
- //--- Process Videos ---//
- $aTmplVarsVideos = array();
- if(!empty($aContent['videos']))
- foreach($aContent['videos'] as $aVideo) {
- $aTmplVarsVideos[] = array(
- 'style_prefix' => $sStylePrefix,
- 'video' => BxTemplFunctions::getInstance()->videoPlayer($aVideo['src_poster'], $aVideo['src_mp4'], $aVideo['src_webm'])
- );
- }
- return array(
- 'style_prefix' => $sStylePrefix,
- 'bx_if:show_title' => array(
- 'condition' => !empty($sTitle),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'title' => $sTitle,
- )
- ),
- 'bx_if:show_content' => array(
- 'condition' => !empty($sText),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'item_content' => $sText,
- 'bx_if:show_more' => array(
- 'condition' => !empty($sTextMore),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'js_object' => $sJsObject,
- 'item_content_more' => $sTextMore
- )
- ),
- )
- ),
- 'bx_if:show_content_raw' => array(
- 'condition' => !empty($sRaw),
- 'content' => array(
- 'item_content_raw' => $sRaw
- )
- ),
- 'bx_if:show_links' => array(
- 'condition' => !empty($aTmplVarsLinks),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'bx_repeat:links' => $aTmplVarsLinks
- )
- ),
- 'bx_if:show_images' => array(
- 'condition' => !empty($aTmplVarsImages),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'bx_repeat:images' => $aTmplVarsImages
- )
- ),
- 'bx_if:show_videos' => array(
- 'condition' => !empty($aTmplVarsVideos),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'bx_repeat:videos' => $aTmplVarsVideos
- )
- )
- );
- }
- protected function _getTmplVarsContentRepost($aEvent, $aBrowseParams = array())
- {
- $aContent = &$aEvent['content'];
- $sStylePrefix = $this->_oConfig->getPrefix('style');
- $sOwnerLink = $this->parseHtmlByName('bx_a.html', array(
- 'href' => $aContent['owner_url'],
- 'title' => '',
- 'bx_repeat:attrs' => array(),
- 'content' => $aContent['owner_name']
- ));
- $sSample = _t($aContent['sample']);
- $sSampleLink = empty($aContent['url']) ? $sSample : $this->parseHtmlByName('bx_a.html', array(
- 'href' => $aContent['url'],
- 'title' => '',
- 'bx_repeat:attrs' => array(),
- 'content' => $sSample
- ));
- $sTitle = _t('_bx_timeline_txt_reposted', $sOwnerLink, $sSampleLink);
- $sText = $this->_getContent($aContent['parse_type'], $aEvent);
- return array(
- 'bx_if:show_title' => array(
- 'condition' => !empty($sTitle),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'title' => $sTitle,
- )
- ),
- 'bx_if:show_content' => array(
- 'condition' => !empty($sText),
- 'content' => array(
- 'style_prefix' => $sStylePrefix,
- 'content' => $sText,
- )
- )
- );
- }
- protected function _getSystemData(&$aEvent)
- {
- $mixedResult = $this->_oConfig->getSystemData($aEvent);
- if($mixedResult !== false)
- return $mixedResult;
- $sMethod = 'display' . bx_gen_method_name($aEvent['type'] . '_' . $aEvent['action']);
- if(!method_exists($this, $sMethod))
- return '';
- return $this->$sMethod($aEvent);
- }
- protected function _getCommonData(&$aEvent)
- {
- $CNF = $this->_oConfig->CNF;
- $oModule = $this->getModule();
- $sJsObject = $this->_oConfig->getJsObject('view');
- $sPrefix = $this->_oConfig->getPrefix('common_post');
- $sType = str_replace($sPrefix, '', $aEvent['type']);
- $aResult = array(
- 'owner_id' => $aEvent['object_id'],
- 'icon' => $CNF['ICON'],
- 'sample' => '_bx_timeline_txt_sample_with_article',
- 'sample_wo_article' => '_bx_timeline_txt_sample',
- 'sample_action' => '_bx_timeline_txt_added_sample',
- 'content_type' => $sType,
- 'content' => array(
- 'sample' => '_bx_timeline_txt_sample_with_article',
- 'sample_wo_article' => '_bx_timeline_txt_sample',
- 'sample_action' => '_bx_timeline_txt_added_sample',
- 'url' => $this->_oConfig->getItemViewUrl($aEvent)
- ), //a string to display or array to parse default template before displaying.
- 'views' => '',
- 'votes' => '',
- 'reports' => '',
- 'comments' => '',
- 'title' => $aEvent['title'], //may be empty.
- 'description' => $aEvent['description'] //may be empty.
- );
- switch($sType) {
- case BX_TIMELINE_PARSE_TYPE_POST:
- if(!empty($aEvent['content']))
- $aResult['content'] = array_merge($aResult['content'], unserialize($aEvent['content']));
- $aLinks = $this->_oDb->getLinks($aEvent['id']);
- if(!empty($aLinks) && is_array($aLinks))
- $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_preview'));
- foreach($aLinks as $aLink)
- $aResult['content']['links'][] = array(
- 'url' => $aLink['url'],
- 'title' => $aLink['title'],
- 'text' => $aLink['text'],
- 'thumbnail' => (int)$aLink['media_id'] != 0 ? $oTranscoder->getFileUrl($aLink['media_id']) : ''
- );
- $aPhotos = $this->_oDb->getMedia(BX_TIMELINE_MEDIA_PHOTO, $aEvent['id']);
- if(!empty($aPhotos) && is_array($aPhotos)) {
- $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));
- $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->_oConfig->getObject('transcoder_photos_view'));
- foreach($aPhotos as $iPhotoId) {
- $sPhotoSrcOrig = $oStorage->getFileUrlById($iPhotoId);
- $aResult['content']['images'][] = array(
- 'src' => $oTranscoder->getFileUrl($iPhotoId),
- 'src_orig' => $sPhotoSrcOrig,
- 'title' => '',
- 'onclick' => $sJsObject . '.showPhoto(this, \'' . $sPhotoSrcOrig . '\')'
- );
- }
- }
- $aVideos = $this->_oDb->getMedia(BX_TIMELINE_MEDIA_VIDEO, $aEvent['id']);
- if(!empty($aVideos) && is_array($aVideos)) {
- $oTranscoderPoster = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_poster'));
- $oTranscoderMp4 = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_mp4'));
- $oTranscoderWebm = BxDolTranscoderVideo::getObjectInstance($this->_oConfig->getObject('transcoder_videos_webm'));
- foreach($aVideos as $iVideoId) {
- $aResult['content']['videos'][] = array(
- 'src_poster' => $oTranscoderPoster->getFileUrl($iVideoId),
- 'src_mp4' => $oTranscoderMp4->getFileUrl($iVideoId),
- 'src_webm' => $oTranscoderWebm->getFileUrl($iVideoId),
- );
- }
- }
- break;
- case BX_TIMELINE_PARSE_TYPE_REPOST:
- if(empty($aEvent['content']))
- return array();
- $aContent = unserialize($aEvent['content']);
- if(!$this->_oConfig->isSystem($aContent['type'] , $aContent['action'])) {
- $aReposted = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $aContent['object_id']));
- $aReposted = $this->_getCommonData($aReposted);
- }
- else
- $aReposted = $this->_getSystemData($aContent);
- if(empty($aReposted) || !is_array($aReposted))
- return array();
- $aResult['content'] = array_merge($aContent, $aReposted['content']);
- $aResult['content']['parse_type'] = !empty($aReposted['content_type']) ? $aReposted['content_type'] : BX_TIMELINE_PARSE_TYPE_DEFAULT;
- $aResult['content']['owner_id'] = $aReposted['owner_id'];
- list($aResult['content']['owner_name'], $aResult['content']['owner_url']) = $oModule->getUserInfo($aReposted['owner_id']);
- if(!empty($aReposted['sample']))
- $aResult['content']['sample'] = $aReposted['sample'];
- if(!empty($aReposted['sample_wo_article']))
- $aResult['content']['sample'] = $aReposted['sample_wo_article'];
- list($sUserName) = $oModule->getUserInfo($aEvent['object_id']);
- $aResult['title'] = _t('_bx_timeline_txt_user_repost', $sUserName, _t($aResult['content']['sample']));
- $aResult['description'] = _t('_bx_timeline_txt_user_reposted_user_sample', $sUserName, $aResult['content']['owner_name'], _t($aResult['content']['sample']));
- break;
- }
- $sSystem = $this->_oConfig->getObject('view');
- if($oModule->getViewObject($sSystem, $aEvent['id']) !== false)
- $aResult['views'] = array(
- 'system' => $sSystem,
- 'object_id' => $aEvent['id'],
- 'count' => $aEvent['views']
- );
- $sSystem = $this->_oConfig->getObject('vote');
- if($oModule->getVoteObject($sSystem, $aEvent['id']) !== false)
- $aResult['votes'] = array(
- 'system' => $sSystem,
- 'object_id' => $aEvent['id'],
- 'count' => $aEvent['votes']
- );
- $sSystem = $this->_oConfig->getObject('report');
- if($oModule->getReportObject($sSystem, $aEvent['id']) !== false)
- $aResult['reports'] = array(
- 'system' => $sSystem,
- 'object_id' => $aEvent['id'],
- 'count' => $aEvent['reports']
- );
- $sSystem = $this->_oConfig->getObject('comment');
- if($oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
- $aResult['comments'] = array(
- 'system' => $sSystem,
- 'object_id' => $aEvent['id'],
- 'count' => $aEvent['comments']
- );
- return $aResult;
- }
- protected function _prepareTextForOutput($s, $iEventId = 0)
- {
- $s = bx_process_output($s, BX_DATA_HTML);
- $s = bx_linkify_html($s, 'class="' . BX_DOL_LINK_CLASS . '"');
- $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags'));
- $s = $oMetatags->keywordsParse($iEventId, $s);
- return $s;
- }
- }
- /** @} */
|