19 parent::__construct($oConfig,
$oDb);
21 $this->_aTemplates = array(
'divider',
'balloon',
'repost',
'common',
'common_media',
'comments',
'actions');
35 $sHandler = $aEvent[
'type'] .
'_' . $aEvent[
'action'];
36 if(!$this->_oConfig->isHandler($sHandler))
43 $this->_oDb->deleteEvent(array(
'id' => $aEvent[
'id']));
50 switch($sDisplayType) {
53 $this->_oDb->updateEvent(array(
59 'post_type' => $aEvent[
'type'],
60 'post_id' => $aEvent[
'id'],
62 'post_content' =>
$aResult[
'content'],
70 $oVote = $this->_oModule->_getObjectVoting($aEvent);
71 if($oVote->isEnabled() && $oVote->isVotingAllowed())
72 $sVote = $oVote->getVotingOutline();
76 if($this->_oModule->_isRepostAllowed($aEvent)) {
77 $iOwnerId = $this->_oModule->_getAuthorId();
78 $iObjectId = $this->_oModule->_oConfig->isSystem($aEvent[
'type'], $aEvent[
'action']) ? $aEvent[
'object_id'] : $aEvent[
'id'];
80 $sRepost = $this->_oModule->serviceGetRepostElementBlock($iOwnerId, $aEvent[
'type'], $aEvent[
'action'], $iObjectId, array(
81 'show_do_repost_as_button_small' =>
true,
82 'show_do_repost_icon' =>
true,
83 'show_do_repost_label' =>
false
88 'post_id' => $aEvent[
'id'],
89 'post_owner_icon' => $this->
getOwnerIcon((
int)$aEvent[
'owner_id']),
90 'post_vote' => $sVote,
91 'post_repost' => $sRepost
101 $sPrefix = $this->_oConfig->getCommonPostPrefix();
102 if(strpos($aEvent[
'type'], $sPrefix) !== 0)
105 $sEventType =
ch_ltrim_str($aEvent[
'type'], $sPrefix,
'');
108 if(isset(
$aResult[
'perform_delete']) &&
$aResult[
'perform_delete'] ===
true) {
109 $this->_oDb->deleteEvent(array(
'id' => $aEvent[
'id']));
116 switch($sEventType) {
120 $aContent = unserialize($aEvent[
'content']);
122 $oComments =
new ChWallCmts($this->_oConfig->getCommonName($aContent[
'type']), $aContent[
'id']);
123 if($oComments->isEnabled())
124 $aResult[
'comments'] = $oComments->getCommentsFirstSystem(
'comment', $aEvent[
'id']);
134 'post_type' =>
ch_ltrim_str($aEvent[
'type'], $sPrefix,
''),
135 'post_id' => $aEvent[
'id'],
137 'post_content' =>
$aResult[
'content'],
138 'comments_content' =>
$aResult[
'comments']
144 $sHandler = $aEvent[
'type'] .
'_' . $aEvent[
'action'];
145 if(!$this->_oConfig->isHandler($sHandler))
148 $aHandler = $this->_oConfig->getHandlers($sHandler);
149 if(
empty($aHandler[
'module_uri']) &&
empty($aHandler[
'module_class']) &&
empty($aHandler[
'module_method'])) {
150 $sMethod =
'display' .
ch_gen_method_name($aHandler[
'alert_unit'] .
'_' . $aHandler[
'alert_action']);
151 if(!method_exists($this, $sMethod))
154 $aResult = $this->$sMethod($aEvent, $sDisplayType);
157 $aEvent[
'js_mode'] = $this->_oConfig->getJsMode();
159 $aResult = $this->_oConfig->getSystemData($aEvent, $sDisplayType);
161 $this->_oDb->updateEvent(
$aResult[
'save'], $aEvent[
'id']);
169 $sPrefix = $this->_oConfig->getPrefix(
'common_post');
170 $sEventType =
ch_ltrim_str($aEvent[
'type'], $sPrefix,
'');
173 $aTmplVars = array();
179 switch($sEventType) {
183 $sTmplName =
'common';
184 $aTmplVars[
'cpt_added_new'] =
_t(
'_wall_added_' . $sEventType);
189 'ch_wall_get_image_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'get_image/' . $aEvent[
'id'] .
'/'
192 $sTmplName =
'common';
193 $aTmplVars[
'cpt_added_new'] =
_t(
'_wall_added_' . $sEventType);
199 $aContent = unserialize($aEvent[
'content']);
200 $iContent = (int)$aContent[
'id'];
203 if(
empty($aResultMedia) || !is_array($aResultMedia))
204 return array(
'perform_delete' =>
true);
208 $sTmplName =
'common';
209 $aTmplVars[
'cpt_added_new'] =
_t(
'_wall_added_' . $sEventType);
213 if(
empty($aEvent[
'content']))
216 $aContent = unserialize($aEvent[
'content']);
217 $aReposted = $this->_oDb->getReposted($aContent[
'type'], $aContent[
'action'], $aContent[
'object_id']);
219 $sMethod = $this->_oConfig->isSystem($aContent[
'type'] , $aContent[
'action']) ?
'_getSystemData' :
'_getCommonData';
224 $sTmplName =
'repost';
225 $aTmplVars[
'cpt_reposted'] =
_t($this->_oModule->getRepostedLanguageKey($aReposted[
'type'], $aReposted[
'action'], $aReposted[
'object_id']));
230 'post_type' => $sEventType,
232 'author_username' =>
getNickName($aEvent[
'object_id']),
233 'ch_if:show_wall_owner' => array(
234 'condition' => (
int)$aEvent[
'owner_id'] != 0 && (
int)$aEvent[
'owner_id'] != (
int)$aEvent[
'object_id'],
237 'owner_username' =>
getNickName($aEvent[
'owner_id']),
255 if(
empty($aMediaInfo) || !is_array($aMediaInfo) ||
empty($aMediaInfo[
'file']))
260 'description' => $aMediaInfo[
'description'],
262 'image_url' => isset($aMediaInfo[
'file']) ? $aMediaInfo[
'file'] :
'',
263 'image_width' => isset($aMediaInfo[
'width']) ? (
int)$aMediaInfo[
'width'] : 0,
264 'image_height' => isset($aMediaInfo[
'height']) ? (
int)$aMediaInfo[
'height'] : 0,
265 'link' => isset($aMediaInfo[
'url']) ? $aMediaInfo[
'url'] :
'',
266 'title' => isset($aMediaInfo[
'title']) ?
ch_html_attribute($aMediaInfo[
'title']) :
'',
267 'description' => isset($aMediaInfo[
'description']) ? $aMediaInfo[
'description'] :
'',
268 'ch_if:show_duration' => array(
269 'condition' => !
empty($aMediaInfo[
'duration_f']),
271 'duration_f' => $aMediaInfo[
'duration_f']
281 'visible' => $bVisible ?
'block' :
'none',
282 'content' =>
MsgBox(
_t(
'_wall_msg_no_results'))
287 if($iDays == $aEvent[
'days'])
290 $iDaysAgo = (int)$aEvent[
'ago_days'];
291 if($aEvent[
'today'] == $aEvent[
'days'] || (($aEvent[
'today'] - $aEvent[
'days']) == 1 && $iDaysAgo == 0)) {
292 $iDays = $aEvent[
'days'];
298 $sDaysAgo =
_t(
'_wall_1_days_ago');
299 else if($iDaysAgo > 1 && $iDaysAgo < 31)
300 $sDaysAgo =
_t(
'_wall_n_days_ago', $aEvent[
'ago_days']);
302 $sDaysAgo = $aEvent[
'print_date'];
305 'cpt_class' =>
'wall-divider',
306 'content' => $sDaysAgo
309 $iDays = $aEvent[
'days'];
314 $bToday = !
empty($aEvent) && ($aEvent[
'today'] == $aEvent[
'days'] || (($aEvent[
'today'] - $aEvent[
'days']) == 1 && (
int)$aEvent[
'ago_days'] == 0));
316 'cpt_class' =>
'wall-divider-today ' . ($bToday ?
'visible' :
'hidden'),
317 'content' =>
_t(
'_wall_today')
322 $aEvent = $this->_oDb->getEvents(array(
'browse' =>
'last',
'owner_id' => $this->_oModule->_iOwnerId,
'filter' => $sFilter,
'modules' =>
$aModules));
323 if(
empty($aEvents) || !is_array($aEvents))
326 $iMaxDuration = (int)$aEvent[
'ago_days'] + 1;
327 if(
empty($sTimeline))
331 'type' =>
'doublerange',
332 'name' =>
'timeline',
333 'value' => $sTimeline,
336 'max' => $iMaxDuration,
337 'onchange' => $this->_oConfig->getJsObject(
'view') .
".changeTimeline(e)"
350 'visible' => $bVisible ?
'block' :
'none',
351 'ch_if:is_disabled' => array(
352 'condition' => !$bEnabled,
355 'ch_if:show_on_click' => array(
356 'condition' => $bEnabled,
358 'on_click' => $this->_oConfig->getJsObject(
'view') .
'.changePage(' . ($iStart +
$iPerPage) .
', ' .
$iPerPage .
')'
367 'visible' => $bVisible ?
'block' :
'none',
368 'ch_if:is_disabled' => array(
369 'condition' => !$bEnabled,
372 'ch_if:show_on_click' => array(
373 'condition' => $bEnabled,
375 'on_click' => $this->_oConfig->getJsObject(
'outline') .
'.changePage(' . ($iStart +
$iPerPage) .
', ' .
$iPerPage .
')'
387 $bUploaders = !
empty($aUploaders) && is_array($aUploaders) && count($aUploaders) > 1;
389 $aTmplVarsItems = array();
392 $aTmplVarsItems[] = array(
395 'ch_if:show_selected' => array(
396 'condition' => $sValue == $sSubType,
402 'ch_if:show_selector' => array(
403 'condition' => $bUploaders,
405 'js_object' => $this->_oConfig->getJsObject(
'post'),
407 'ch_repeat:items' => $aTmplVarsItems
412 'category' =>
'wall',
415 'owner_id' => $iOwnerId,
417 'select_files' =>
_t(
'_wall_select_file')
425 $aOwner = $this->_oDb->getUser($aEvent[
'owner_id']);
427 return array(
'perform_delete' =>
true);
429 if($aOwner[
'status'] !=
'Active')
432 if($aOwner[
'couple'] == 0 && $aOwner[
'sex'] ==
'male')
433 $sTxtEditedProfile =
_t(
'_wall_edited_his_profile');
434 else if($aOwner[
'couple'] == 0 && $aOwner[
'sex'] ==
'female')
435 $sTxtEditedProfile =
_t(
'_wall_edited_her_profile');
436 else if($aOwner[
'couple'] > 0)
437 $sTxtEditedProfile =
_t(
'_wall_edited_their_profile');
441 'title' => $sOwner .
' ' . $sTxtEditedProfile,
444 'cpt_user_name' => $sOwner,
445 'cpt_edited_profile' => $sTxtEditedProfile,
446 'cpt_info_url' => CH_WSB_URL_ROOT .
'profile_info.php?ID=' . $aOwner[
'id'],
447 'post_id' => $aEvent[
'id']
454 $aOwner = $this->_oDb->getUser($aEvent[
'owner_id']);
456 return array(
'perform_delete' =>
true);
458 if($aOwner[
'status'] !=
'Active')
461 if($aOwner[
'couple'] == 0 && $aOwner[
'sex'] ==
'male')
462 $sTxtEditedProfile =
_t(
'_wall_edited_his_profile_status_message');
463 else if($aOwner[
'couple'] == 0 && $aOwner[
'sex'] ==
'female')
464 $sTxtEditedProfile =
_t(
'_wall_edited_her_profile_status_message');
465 else if($aOwner[
'couple'] > 0)
466 $sTxtEditedProfile =
_t(
'_wall_edited_their_profile_status_message');
469 if(!
empty($aEvent[
'content']))
470 $aParams = unserialize($aEvent[
'content']);
473 $sMessage = isset($aParams[0]) ? stripslashes($aParams[0]) :
'';
475 'title' => $sOwner .
' ' . $sTxtEditedProfile,
477 'content' => $this->
parseHtmlByName(
'p_edit_status_message.html', array(
478 'cpt_user_name' => $sOwner,
479 'cpt_edited_profile_status_message' => $sTxtEditedProfile,
481 'post_id' => $aEvent[
'id']
488 $iComment = (int)$aEvent[
'object_id'];
489 $iOwner = (int)$aEvent[
'owner_id'];
492 $aContent = unserialize($aEvent[
'content']);
493 if(
empty($aContent) ||
empty($aContent[
'object_id']))
496 $iItem = (int)$aContent[
'object_id'];
498 if(
empty($aItem) || !is_array($aItem))
499 return array(
'perform_delete' =>
true);
503 if(!$oCmts->isEnabled())
507 $aComment = $oCmts->getCommentRow($iComment);
508 if(
empty($aComment) || !is_array($aComment))
509 return array(
'perform_delete' =>
true);
511 $sTextWallObject =
_t(
'_wall_object_profile');
513 'title' =>
_t(
'_wall_added_new_title_comment_profile', $sOwner, $sTextWallObject),
514 'description' => $aComment[
'cmt_text'],
516 'cpt_user_name' => $sOwner,
517 'cpt_added_new' =>
_t(
'_wall_added_new_comment_profile'),
518 'cpt_object' => $sTextWallObject,
519 'cpt_item_url' => $aItem[
'url'],
520 'cnt_comment_text' => $aComment[
'cmt_text'],
521 'cnt_item_page' => $aItem[
'url'],
523 'cnt_item_title' => $aItem[
'title'],
524 'cnt_item_description' => $aItem[
'description'],
525 'post_id' => $aEvent[
'id'],
535 $iId = (int)$aEvent[
'object_id'];
536 $iOwner = (int)$aEvent[
'owner_id'];
540 if(
empty($aItem) || !is_array($aItem))
541 return array(
'perform_delete' =>
true);
543 $aContent = unserialize($aEvent[
'content']);
544 if(
empty($aContent) || !isset($aContent[
'comment_id']))
549 if(!$oCmts->isEnabled())
553 $aComment = $oCmts->getCommentRow((
int)$aContent[
'comment_id']);
554 if(
empty($aComment) || !is_array($aComment))
555 return array(
'perform_delete' =>
true);
557 $sTextWallObject =
_t(
'_wall_object_profile');
559 'title' =>
_t(
'_wall_added_new_title_comment_profile', $sOwner, $sTextWallObject),
560 'description' => $aComment[
'cmt_text'],
562 'cpt_user_name' => $sOwner,
563 'cpt_added_new' =>
_t(
'_wall_added_new_comment_profile'),
564 'cpt_object' => $sTextWallObject,
565 'cpt_item_url' => $aItem[
'url'],
566 'cnt_comment_text' => $aComment[
'cmt_text'],
567 'cnt_item_page' => $aItem[
'url'],
569 'cnt_item_title' => $aItem[
'title'],
570 'cnt_item_description' => $aItem[
'description'],
571 'post_id' => $aEvent[
'id'],
578 $aOwner = $this->_oDb->getUser($aEvent[
'owner_id']);
579 $aFriend = $this->_oDb->getUser($aEvent[
'object_id']);
581 return array(
'perform_delete' =>
true);
583 if($aOwner[
'status'] !=
'Active' || $aFriend[
'status'] !=
'Active')
588 $iFriend = (int)$aFriend[
'id'];
591 'title' => $sOwner .
' ' .
_t(
'_wall_friends_with') .
' ' . $aFriend[
'username'],
594 'cpt_user_name' => $sOwner,
596 'cpt_friend_name' => $sFriend,
598 'post_id' => $aEvent[
'id']
615 $sFunction =
'get_member_' .
$sType;
616 if($iOwnerId != 0 && function_exists($sFunction))
617 return $sFunction($iOwnerId,
'none');
619 $aType2Icon = array(
'icon' =>
'small',
'thumbnail' =>
'medium');
621 'class' =>
'thumbnail_block_' .
$sType,
622 'src' =>
$GLOBALS[
'oFunctions']->getSexPic(
'', $aType2Icon[
$sType])
628 if(in_array($aEvent[
'type'], array(
'profile',
'friend')))
632 $iObjectId = $aEvent[
'object_id'];
634 if($aEvent[
'action'] ==
'comment_add') {
635 $aContent = unserialize($aEvent[
'content']);
636 $iObjectId = (int)$aContent[
'object_id'];
639 if($this->_oConfig->isGrouped($aEvent[
'type'], $aEvent[
'action'], $iObjectId)) {
641 $iObjectId = isset(
$aResult[
'grouped'][
'group_id']) ? (int)
$aResult[
'grouped'][
'group_id'] : 0;
644 if($this->_oConfig->isGroupedObject($iObjectId))
648 if($oComments->isEnabled())
649 return $oComments->getCommentsFirstSystem(
'comment', $aEvent[
'id']);
656 $oComments =
new ChWallCmts($this->_oConfig->getCommentSystemName(), $iEventId);
657 return $oComments->getCommentsFirstDefault(
'comment');
662 $sBaseUri = $this->_oConfig->getBaseUri();
663 $sJsClass = $this->_oConfig->getJsClass(
$sType);
664 $sJsObject = $this->_oConfig->getJsObject(
$sType);
666 $aParams = array_merge(array(
667 'sActionUri' => $sBaseUri,
668 'sActionUrl' => CH_WSB_URL_ROOT . $sBaseUri,
669 'sObjName' => $sJsObject,
671 'sAnimationEffect' => $this->_oConfig->getAnimationEffect(),
672 'iAnimationSpeed' => $this->_oConfig->getAnimationSpeed(),
673 'aHtmlIds' => $this->_oConfig->getHtmlIds(
$sType),
674 'oRequestParams' => $aRequestParams
677 return $this->
_wrapInTagJsCode(
"var " . $sJsObject .
" = new " . $sJsClass .
"(" . json_encode($aParams) .
");");
685 $aReposted = $this->_oDb->getReposted(
$sType,
$sAction, $iObjectId);
686 if(
empty($aReposted) || !is_array($aReposted))
689 $bDisabled = $this->_oModule->_isRepostAllowed($aReposted) !==
true || $this->_oDb->isReposted($aReposted[
'id'], $iOwnerId, $this->_oModule->_getAuthorId());
690 if($bDisabled && (
int)$aReposted[
'reposts'] == 0)
693 $sStylePrefix = $this->_oConfig->getPrefix(
'style');
694 $sStylePrefixRepost = $sStylePrefix .
'-repost-';
696 $bShowDoRepostAsButtonSmall = isset($aParams[
'show_do_repost_as_button_small']) && $aParams[
'show_do_repost_as_button_small'] ==
true;
697 $bShowDoRepostAsButton = !$bShowDoRepostAsButtonSmall && isset($aParams[
'show_do_repost_as_button']) && $aParams[
'show_do_repost_as_button'] ==
true;
699 $bShowDoRepostIcon = isset($aParams[
'show_do_repost_icon']) && $aParams[
'show_do_repost_icon'] ==
true;
700 $bShowDoRepostLabel = isset($aParams[
'show_do_repost_label']) && $aParams[
'show_do_repost_label'] ==
true;
701 $bShowCounter = isset($aParams[
'show_counter']) && $aParams[
'show_counter'] ===
true;
703 $sTmplMain = !
empty($aParams[
'template_main']) ? $aParams[
'template_main'] :
'repost_element_block.html';
704 $sTmplDoRepost = !
empty($aParams[
'template_do_repost']) ? $aParams[
'template_do_repost'] :
'repost_link.html';
707 $sClass = $sStylePrefixRepost .
'do-repost';
708 if($bShowDoRepostAsButton)
709 $sClass .=
' ch-btn';
710 else if($bShowDoRepostAsButtonSmall)
711 $sClass .=
' ch-btn ch-btn-small';
715 $sCommonPrefix = $this->_oConfig->getPrefix(
'common_post');
717 $aRepostedContent = unserialize($aReposted[
'content']);
719 $sOnClick = $this->
getRepostJsClick($iOwnerId, $aRepostedContent[
'type'], $aRepostedContent[
'action'], $aRepostedContent[
'object_id']);
725 $sClass .= $bShowDoRepostAsButton || $bShowDoRepostAsButtonSmall ?
' ch-btn-disabled' :
' ' . $sStylePrefixRepost .
'disabled';
727 $aOnClickAttrs = array();
729 $aOnClickAttrs[] = array(
'key' =>
'class',
'value' => $sClass);
730 if(!
empty($sOnClick))
731 $aOnClickAttrs[] = array(
'key' =>
'onclick',
'value' => $sOnClick);
734 'style_prefix' => $sStylePrefix,
735 'html_id' => $this->_oConfig->getHtmlIds(
'repost',
'main') . $aReposted[
'id'],
736 'class' => ($bShowDoRepostAsButton ? $sStylePrefixRepost .
'button' :
'') . ($bShowDoRepostAsButtonSmall ? $sStylePrefixRepost .
'button-small' :
''),
737 'count' => $aReposted[
'reposts'],
738 'do_repost' => $this->parseHtmlByName($sTmplDoRepost, array(
739 'href' =>
'javascript:void(0)',
740 'title' =>
_t(
'_wall_txt_do_repost'),
741 'ch_repeat:attrs' => $aOnClickAttrs,
742 'ch_if:show_icon' => array(
743 'condition' => $bShowDoRepostIcon,
746 'ch_if:show_text' => array(
747 'condition' => $bShowDoRepostLabel,
749 'content' =>
_t(
'_wall_txt_do_repost')
753 'ch_if:show_counter' => array(
754 'condition' => $bShowCounter,
756 'style_prefix' => $sStylePrefix,
757 'ch_if:show_hidden' => array(
758 'condition' => (
int)$aReposted[
'reposts'] == 0,
770 $sStylePrefix = $this->_oConfig->getPrefix(
'style');
771 $sJsObject = $this->_oConfig->getJsObject(
'repost');
773 $sTmplCounter = !
empty($aParams[
'template_counter']) ? $aParams[
'template_counter'] :
'repost_counter.html';
775 $sTxtCounter = !
empty($aParams[
'text_counter']) ? $aParams[
'text_counter'] :
'_wall_n_reposts';
776 $sTxtCounterEmpty = !
empty($aParams[
'text_counter_empty']) ? $aParams[
'text_counter_empty'] :
'_wall_no_reposts';
779 'href' =>
'javascript:void(0)',
781 'ch_repeat:attrs' => array(
782 array(
'key' =>
'id',
'value' => $this->_oConfig->getHtmlIds(
'repost',
'counter') . $aEvent[
'id']),
783 array(
'key' =>
'class',
'value' => $sStylePrefix .
'-repost-counter'),
784 array(
'key' =>
'onclick',
'value' =>
'javascript:' . $sJsObject .
'.toggleByPopup(this, ' . $aEvent[
'id'] .
')')
786 'content' => !
empty($aEvent[
'reposts']) && (
int)$aEvent[
'reposts'] > 0 ?
_t($sTxtCounter, $aEvent[
'reposts']) :
_t($sTxtCounterEmpty, $aEvent[
'reposts'])
792 $sStylePrefix = $this->_oConfig->getPrefix(
'style');
794 $aUserIds = $this->_oDb->getRepostedBy(
$iId);
796 $aTmplUsers = array();
797 foreach($aUserIds
as $iUserId)
798 $aTmplUsers[] = array(
799 'style_prefix' => $sStylePrefix,
803 if(
empty($aTmplUsers))
806 $sName = $this->_oConfig->getHtmlIds(
'repost',
'by_popup') .
$iId;
808 'style_prefix' => $sStylePrefix,
809 'ch_repeat:list' => $aTmplUsers
817 $this->
addCss(array(
'repost.css'));
818 $this->
addJs(array(
'main.js',
'repost.js'));
827 $sJsObject = $this->_oConfig->getJsObject(
'repost');
828 $sFormat =
"%s.repostItem(this, %d, '%s', '%s', " . (is_int($mixedObjectId) ?
"%d" :
"'%s'") .
");";
830 $iOwnerId = !
empty($iOwnerId) ? (int)$iOwnerId : $this->_oModule->_getAuthorId();
831 return sprintf($sFormat, $sJsObject, $iOwnerId,
$sType,
$sAction, $mixedObjectId);