Cheetah
ChWallTemplate.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbModuleTemplate');
9 
11 {
12  var $_oModule;
13 
17  function __construct(&$oConfig, &$oDb)
18  {
19  parent::__construct($oConfig, $oDb);
20 
21  $this->_aTemplates = array('divider', 'balloon', 'repost', 'common', 'common_media', 'comments', 'actions');
22  }
23 
24  function setModule(&$oModule)
25  {
26  $this->_oModule = $oModule;
27  }
28 
33  function getSystem($aEvent, $sDisplayType = CH_WALL_VIEW_TIMELINE)
34  {
35  $sHandler = $aEvent['type'] . '_' . $aEvent['action'];
36  if(!$this->_oConfig->isHandler($sHandler))
37  return '';
38 
39  $aResult = $this->_getSystemData($aEvent, $sDisplayType);
41 
42  if($bResult && isset($aResult['perform_delete']) && $aResult['perform_delete'] == true) {
43  $this->_oDb->deleteEvent(array('id' => $aEvent['id']));
44  return '';
45  }
46  else if(!$bResult || ($bResult && empty($aResult['content'])))
47  return '';
48 
49  $sResult = "";
50  switch($sDisplayType) {
52  if((empty($aEvent['title']) && !empty($aResult['title'])) || (empty($aEvent['description']) && !empty($aResult['description'])))
53  $this->_oDb->updateEvent(array(
54  'title' => process_db_input($aResult['title'], CH_TAGS_STRIP),
55  'description' => process_db_input($aResult['description'], CH_TAGS_STRIP)
56  ), $aEvent['id']);
57 
58  $sResult = $this->parseHtmlByTemplateName('balloon', array(
59  'post_type' => $aEvent['type'],
60  'post_id' => $aEvent['id'],
61  'post_owner_icon' => $this->getOwnerThumbnail((int)$aEvent['owner_id']),
62  'post_content' => $aResult['content'],
63  'comments_content' => $this->getComments($aEvent, $aResult)
64  ));
65  break;
66 
68  //--- Votes
69  $sVote = '';
70  $oVote = $this->_oModule->_getObjectVoting($aEvent);
71  if($oVote->isEnabled() && $oVote->isVotingAllowed())
72  $sVote = $oVote->getVotingOutline();
73 
74  //--- Repost
75  $sRepost = '';
76  if($this->_oModule->_isRepostAllowed($aEvent)) {
77  $iOwnerId = $this->_oModule->_getAuthorId(); //--- in whose timeline the content will be shared
78  $iObjectId = $this->_oModule->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['object_id'] : $aEvent['id'];
79 
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
84  ));
85  }
86 
87  $sResult = $this->parseHtmlByContent($aResult['content'], array(
88  'post_id' => $aEvent['id'],
89  'post_owner_icon' => $this->getOwnerIcon((int)$aEvent['owner_id']),
90  'post_vote' => $sVote,
91  'post_repost' => $sRepost
92  ));
93  break;
94  }
95 
96  return $sResult;
97  }
98 
99  function getCommon($aEvent)
100  {
101  $sPrefix = $this->_oConfig->getCommonPostPrefix();
102  if(strpos($aEvent['type'], $sPrefix) !== 0)
103  return '';
104 
105  $sEventType = ch_ltrim_str($aEvent['type'], $sPrefix, '');
106 
107  $aResult = $this->_getCommonData($aEvent);
108  if(isset($aResult['perform_delete']) && $aResult['perform_delete'] === true) {
109  $this->_oDb->deleteEvent(array('id' => $aEvent['id']));
110  return '';
111  }
112 
113  if(empty($aResult) || empty($aResult['content']))
114  return '';
115 
116  switch($sEventType) {
120  $aContent = unserialize($aEvent['content']);
121 
122  $oComments = new ChWallCmts($this->_oConfig->getCommonName($aContent['type']), $aContent['id']);
123  if($oComments->isEnabled())
124  $aResult['comments'] = $oComments->getCommentsFirstSystem('comment', $aEvent['id']);
125  else
126  $aResult['comments'] = $this->getDefaultComments($aEvent['id']);
127  break;
128 
129  default:
130  $aResult['comments'] = $this->getDefaultComments($aEvent['id']);
131  }
132 
133  return $this->parseHtmlByTemplateName('balloon', array(
134  'post_type' => ch_ltrim_str($aEvent['type'], $sPrefix, ''),
135  'post_id' => $aEvent['id'],
136  'post_owner_icon' => $this->getOwnerThumbnail((int)$aEvent['object_id']),
137  'post_content' => $aResult['content'],
138  'comments_content' => $aResult['comments']
139  ));
140  }
141 
142  function _getSystemData(&$aEvent, $sDisplayType = CH_WALL_VIEW_TIMELINE)
143  {
144  $sHandler = $aEvent['type'] . '_' . $aEvent['action'];
145  if(!$this->_oConfig->isHandler($sHandler))
146  return array();
147 
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))
152  return array();
153 
154  $aResult = $this->$sMethod($aEvent, $sDisplayType);
155  }
156  else {
157  $aEvent['js_mode'] = $this->_oConfig->getJsMode();
158 
159  $aResult = $this->_oConfig->getSystemData($aEvent, $sDisplayType);
160  if(isset($aResult['save']))
161  $this->_oDb->updateEvent($aResult['save'], $aEvent['id']);
162  }
163 
164  return $aResult;
165  }
166 
167  function _getCommonData($aEvent)
168  {
169  $sPrefix = $this->_oConfig->getPrefix('common_post');
170  $sEventType = ch_ltrim_str($aEvent['type'], $sPrefix, '');
171 
172  $sTmplName = '';
173  $aTmplVars = array();
174 
175  $aResult = array(
176  'content' => '',
177  'comments' => ''
178  );
179  switch($sEventType) {
181  $aResult['content'] = ch_linkify_html($aEvent['content'], 'class="' . CH_WSB_LINK_CLASS . '"');
182 
183  $sTmplName = 'common';
184  $aTmplVars['cpt_added_new'] = _t('_wall_added_' . $sEventType);
185  break;
186 
188  $aResult['content'] = $this->parseHtmlByContent($aEvent['content'], array(
189  'ch_wall_get_image_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'get_image/' . $aEvent['id'] . '/'
190  ), array('{', '}'));
191 
192  $sTmplName = 'common';
193  $aTmplVars['cpt_added_new'] = _t('_wall_added_' . $sEventType);
194  break;
195 
199  $aContent = unserialize($aEvent['content']);
200  $iContent = (int)$aContent['id'];
201 
202  $aResultMedia = $this->_getCommonMedia($aContent['type'], $iContent);
203  if(empty($aResultMedia) || !is_array($aResultMedia))
204  return array('perform_delete' => true);
205 
206  $aResult = array_merge($aResult, $aResultMedia);
207 
208  $sTmplName = 'common';
209  $aTmplVars['cpt_added_new'] = _t('_wall_added_' . $sEventType);
210  break;
211 
213  if(empty($aEvent['content']))
214  return array();
215 
216  $aContent = unserialize($aEvent['content']);
217  $aReposted = $this->_oDb->getReposted($aContent['type'], $aContent['action'], $aContent['object_id']);
218 
219  $sMethod = $this->_oConfig->isSystem($aContent['type'] , $aContent['action']) ? '_getSystemData' : '_getCommonData';
220  $aResult = array_merge($aResult, $this->$sMethod($aReposted));
221  if(empty($aResult) || !is_array($aResult))
222  return array();
223 
224  $sTmplName = 'repost';
225  $aTmplVars['cpt_reposted'] = _t($this->_oModule->getRepostedLanguageKey($aReposted['type'], $aReposted['action'], $aReposted['object_id']));
226  break;
227  }
228 
229  $aResult['content'] = $this->parseHtmlByTemplateName($sTmplName, array_merge(array(
230  'post_type' => $sEventType,
231  'author_url' => getProfileLink($aEvent['object_id']),
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'],
235  'content' => array(
236  'owner_url' => getProfileLink($aEvent['owner_id']),
237  'owner_username' => getNickName($aEvent['owner_id']),
238  )
239  ),
240  'content' => $aResult['content'],
241  ), $aTmplVars));
242 
243  return $aResult;
244  }
245 
246  function _getCommonMedia($sType, $iObject)
247  {
248  $aConverter = array(
249  CH_WALL_PARSE_TYPE_PHOTOS => 'photo',
250  CH_WALL_PARSE_TYPE_SOUNDS => 'sound',
251  CH_WALL_PARSE_TYPE_VIDEOS => 'video'
252  );
253 
254  $aMediaInfo = ChWsbService::call($sType, 'get_' . $aConverter[$sType] . '_array', array($iObject, 'browse'), 'Search');
255  if(empty($aMediaInfo) || !is_array($aMediaInfo) || empty($aMediaInfo['file']))
256  return array();
257 
258  return array(
259  'title' => _t('_wall_added_title_' . $sType, getNickName($aMediaInfo['owner'])),
260  'description' => $aMediaInfo['description'],
261  'content' => $this->parseHtmlByTemplateName('common_media', array(
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']),
270  'content' => array(
271  'duration_f' => $aMediaInfo['duration_f']
272  )
273  )
274  ))
275  );
276  }
277 
278  function getEmpty($bVisible)
279  {
280  return $this->parseHtmlByName('empty.html', array(
281  'visible' => $bVisible ? 'block' : 'none',
282  'content' => MsgBox(_t('_wall_msg_no_results'))
283  ));
284  }
285  function getDivider(&$iDays, &$aEvent)
286  {
287  if($iDays == $aEvent['days'])
288  return "";
289 
290  $iDaysAgo = (int)$aEvent['ago_days'];
291  if($aEvent['today'] == $aEvent['days'] || (($aEvent['today'] - $aEvent['days']) == 1 && $iDaysAgo == 0)) {
292  $iDays = $aEvent['days'];
293  return "";
294  }
295 
296  $sDaysAgo = "";
297  if($iDaysAgo == 1)
298  $sDaysAgo = _t('_wall_1_days_ago');
299  else if($iDaysAgo > 1 && $iDaysAgo < 31)
300  $sDaysAgo = _t('_wall_n_days_ago', $aEvent['ago_days']);
301  else
302  $sDaysAgo = $aEvent['print_date'];
303 
304  $sResult = $this->parseHtmlByTemplateName('divider', array(
305  'cpt_class' => 'wall-divider',
306  'content' => $sDaysAgo
307  ));
308 
309  $iDays = $aEvent['days'];
310  return $sResult;
311  }
312  function getDividerToday($aEvent = array())
313  {
314  $bToday = !empty($aEvent) && ($aEvent['today'] == $aEvent['days'] || (($aEvent['today'] - $aEvent['days']) == 1 && (int)$aEvent['ago_days'] == 0));
315  return $this->parseHtmlByTemplateName('divider', array(
316  'cpt_class' => 'wall-divider-today ' . ($bToday ? 'visible' : 'hidden'),
317  'content' => _t('_wall_today')
318  ));
319  }
320  function getTimeline($iStart, $iPerPage, $sFilter, $sTimeline, $aModules)
321  {
322  $aEvent = $this->_oDb->getEvents(array('browse' => 'last', 'owner_id' => $this->_oModule->_iOwnerId, 'filter' => $sFilter, 'modules' => $aModules));
323  if(empty($aEvents) || !is_array($aEvents))
324  return "";
325 
326  $iMaxDuration = (int)$aEvent['ago_days'] + 1;
327  if(empty($sTimeline))
328  $sTimeline = '0' . CH_WALL_DIVIDER_TIMELINE . $iMaxDuration;
329 
330  $aInput = array(
331  'type' => 'doublerange',
332  'name' => 'timeline',
333  'value' => $sTimeline,
334  'attrs' => array(
335  'min' => 0,
336  'max' => $iMaxDuration,
337  'onchange' => $this->_oConfig->getJsObject('view') . ".changeTimeline(e)"
338  )
339  );
340 
341  ch_import('ChTemplFormView');
342  $oForm = new ChTemplFormView(array());
343  $sContent = $oForm->genInput($aInput);
344  $sContent = $oForm->genWrapperInput($aInput, $sContent);
345  return $this->parseHtmlByName('timeline.html', array('content' => $sContent));
346  }
347  function getLoadMore($iStart, $iPerPage, $bEnabled = true, $bVisible = true)
348  {
349  $aTmplVars = array(
350  'visible' => $bVisible ? 'block' : 'none',
351  'ch_if:is_disabled' => array(
352  'condition' => !$bEnabled,
353  'content' => array()
354  ),
355  'ch_if:show_on_click' => array(
356  'condition' => $bEnabled,
357  'content' => array(
358  'on_click' => $this->_oConfig->getJsObject('view') . '.changePage(' . ($iStart + $iPerPage) . ', ' . $iPerPage . ')'
359  )
360  )
361  );
362  return $this->parseHtmlByName('load_more.html', $aTmplVars);
363  }
364  function getLoadMoreOutline($iStart, $iPerPage, $bEnabled = true, $bVisible = true)
365  {
366  $aTmplVars = array(
367  'visible' => $bVisible ? 'block' : 'none',
368  'ch_if:is_disabled' => array(
369  'condition' => !$bEnabled,
370  'content' => array()
371  ),
372  'ch_if:show_on_click' => array(
373  'condition' => $bEnabled,
374  'content' => array(
375  'on_click' => $this->_oConfig->getJsObject('outline') . '.changePage(' . ($iStart + $iPerPage) . ', ' . $iPerPage . ')'
376  )
377  )
378  );
379  return $this->parseHtmlByName('load_more.html', $aTmplVars);
380  }
381 
382  function getUploader($iOwnerId, $sType, $sSubType = '')
383  {
384  $sModule = $sType . 's';
385 
386  $aUploaders = ChWsbService::call($sModule, 'get_uploaders_list', array(), 'Uploader');
387  $bUploaders = !empty($aUploaders) && is_array($aUploaders) && count($aUploaders) > 1;
388 
389  $aTmplVarsItems = array();
390  if($bUploaders)
391  foreach($aUploaders as $sValue => $sCaption)
392  $aTmplVarsItems[] = array(
393  'value' => $sValue,
394  'caption' => _t($sCaption),
395  'ch_if:show_selected' => array(
396  'condition' => $sValue == $sSubType,
397  'content' => array()
398  )
399  );
400 
401  return $this->parseHtmlByName('uploader.html', array(
402  'ch_if:show_selector' => array(
403  'condition' => $bUploaders,
404  'content' => array(
405  'js_object' => $this->_oConfig->getJsObject('post'),
406  'type' => $sType,
407  'ch_repeat:items' => $aTmplVarsItems
408  )
409  ),
410  'uploader' => ChWsbService::call($sModule, 'get_uploader_form', array(array(
411  'mode' => $sSubType,
412  'category' => 'wall',
413  'album'=>_t('_wall_' . $sType . '_album', getNickName(getLoggedId())),
414  'from_wall' => 1,
415  'owner_id' => $iOwnerId,
416  'txt' => array(
417  'select_files' => _t('_wall_select_file')
418  )
419  )), 'Uploader')
420  ));
421  }
422 
423  function displayProfileEdit($aEvent)
424  {
425  $aOwner = $this->_oDb->getUser($aEvent['owner_id']);
426  if(empty($aOwner))
427  return array('perform_delete' => true);
428 
429  if($aOwner['status'] != 'Active')
430  return array();
431 
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');
438 
439  $sOwner = getNickName((int)$aEvent['owner_id']);
440  return array(
441  'title' => $sOwner . ' ' . $sTxtEditedProfile,
442  'description' => '',
443  'content' => $this->parseHtmlByName('p_edit.html', array(
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']
448  ))
449  );
450  }
451 
453  {
454  $aOwner = $this->_oDb->getUser($aEvent['owner_id']);
455  if(empty($aOwner))
456  return array('perform_delete' => true);
457 
458  if($aOwner['status'] != 'Active')
459  return array();
460 
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');
467 
468  $aParams = array();
469  if(!empty($aEvent['content']))
470  $aParams = unserialize($aEvent['content']);
471 
472  $sOwner = getNickName((int)$aEvent['owner_id']);
473  $sMessage = isset($aParams[0]) ? stripslashes($aParams[0]) : '';
474  return array(
475  'title' => $sOwner . ' ' . $sTxtEditedProfile,
476  'description' => $sMessage,
477  'content' => $this->parseHtmlByName('p_edit_status_message.html', array(
478  'cpt_user_name' => $sOwner,
479  'cpt_edited_profile_status_message' => $sTxtEditedProfile,
480  'cnt_status_message' => $sMessage,
481  'post_id' => $aEvent['id']
482  ))
483  );
484  }
485 
486  function displayProfileCommentAdd($aEvent)
487  {
488  $iComment = (int)$aEvent['object_id'];
489  $iOwner = (int)$aEvent['owner_id'];
490  $sOwner = getNickName($iOwner);
491 
492  $aContent = unserialize($aEvent['content']);
493  if(empty($aContent) || empty($aContent['object_id']))
494  return array();
495 
496  $iItem = (int)$aContent['object_id'];
497  $aItem = getProfileInfo($iItem);
498  if(empty($aItem) || !is_array($aItem))
499  return array('perform_delete' => true);
500 
501  ch_import('ChWsbCmtsProfile');
502  $oCmts = new ChWsbCmtsProfile('profile', $iItem);
503  if(!$oCmts->isEnabled())
504  return array();
505 
506  $aItem['url'] = getProfileLink($iItem);
507  $aComment = $oCmts->getCommentRow($iComment);
508  if(empty($aComment) || !is_array($aComment))
509  return array('perform_delete' => true);
510 
511  $sTextWallObject = _t('_wall_object_profile');
512  return array(
513  'title' => _t('_wall_added_new_title_comment_profile', $sOwner, $sTextWallObject),
514  'description' => $aComment['cmt_text'],
515  'content' => $this->parseHtmlByName('p_comment.html', array(
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'],
522  'cnt_item_icon' => get_member_thumbnail($iItem, 'none', true),
523  'cnt_item_title' => $aItem['title'],
524  'cnt_item_description' => $aItem['description'],
525  'post_id' => $aEvent['id'],
526  ))
527  );
528  }
529 
533  function displayProfileCommentPost($aEvent)
534  {
535  $iId = (int)$aEvent['object_id'];
536  $iOwner = (int)$aEvent['owner_id'];
537  $sOwner = getNickName($iOwner);
538 
539  $aItem = getProfileInfo($iId);
540  if(empty($aItem) || !is_array($aItem))
541  return array('perform_delete' => true);
542 
543  $aContent = unserialize($aEvent['content']);
544  if(empty($aContent) || !isset($aContent['comment_id']))
545  return array();
546 
547  ch_import('ChWsbCmtsProfile');
548  $oCmts = new ChWsbCmtsProfile('profile', $iId);
549  if(!$oCmts->isEnabled())
550  return array();
551 
552  $aItem['url'] = getProfileLink($iId);
553  $aComment = $oCmts->getCommentRow((int)$aContent['comment_id']);
554  if(empty($aComment) || !is_array($aComment))
555  return array('perform_delete' => true);
556 
557  $sTextWallObject = _t('_wall_object_profile');
558  return array(
559  'title' => _t('_wall_added_new_title_comment_profile', $sOwner, $sTextWallObject),
560  'description' => $aComment['cmt_text'],
561  'content' => $this->parseHtmlByName('p_comment.html', array(
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'],
568  'cnt_item_icon' => get_member_thumbnail($iId, 'none', true),
569  'cnt_item_title' => $aItem['title'],
570  'cnt_item_description' => $aItem['description'],
571  'post_id' => $aEvent['id'],
572  ))
573  );
574  }
575 
576  function displayFriendAccept($aEvent)
577  {
578  $aOwner = $this->_oDb->getUser($aEvent['owner_id']);
579  $aFriend = $this->_oDb->getUser($aEvent['object_id']);
580  if(empty($aOwner) || empty($aFriend))
581  return array('perform_delete' => true);
582 
583  if($aOwner['status'] != 'Active' || $aFriend['status'] != 'Active')
584  return array();
585 
586  $sOwner = getNickName((int)$aEvent['owner_id']);
587 
588  $iFriend = (int)$aFriend['id'];
589  $sFriend = getNickName($iFriend);
590  return array(
591  'title' => $sOwner . ' ' . _t('_wall_friends_with') . ' ' . $aFriend['username'],
592  'description' => '',
593  'content' => $this->parseHtmlByName('f_accept.html', array(
594  'cpt_user_name' => $sOwner,
595  'cpt_friend_url' => getProfileLink($aFriend['id']),
596  'cpt_friend_name' => $sFriend,
597  'cnt_friend' => get_member_thumbnail($iFriend, 'none', true),
598  'post_id' => $aEvent['id']
599  ))
600  );
601  }
602 
603  function getOwnerThumbnail($iOwnerId)
604  {
605  return $this->getOwnerImage('thumbnail', $iOwnerId);
606  }
607 
608  function getOwnerIcon($iOwnerId)
609  {
610  return $this->getOwnerImage('icon', $iOwnerId);
611  }
612 
613  protected function getOwnerImage($sType, $iOwnerId)
614  {
615  $sFunction = 'get_member_' . $sType;
616  if($iOwnerId != 0 && function_exists($sFunction))
617  return $sFunction($iOwnerId, 'none');
618 
619  $aType2Icon = array('icon' => 'small', 'thumbnail' => 'medium');
620  return $this->parseHtmlByName('owner_image.html', array(
621  'class' => 'thumbnail_block_' . $sType,
622  'src' => $GLOBALS['oFunctions']->getSexPic('', $aType2Icon[$sType])
623  ));
624  }
625 
626  function getComments($aEvent, $aResult)
627  {
628  if(in_array($aEvent['type'], array('profile', 'friend')))
629  return $this->getDefaultComments($aEvent['id']);
630 
631  $sType = $aEvent['type'];
632  $iObjectId = $aEvent['object_id'];
633 
634  if($aEvent['action'] == 'comment_add') {
635  $aContent = unserialize($aEvent['content']);
636  $iObjectId = (int)$aContent['object_id'];
637  }
638 
639  if($this->_oConfig->isGrouped($aEvent['type'], $aEvent['action'], $iObjectId)) {
640  $sType = isset($aResult['grouped']['group_cmts_name']) ? $aResult['grouped']['group_cmts_name'] : '';
641  $iObjectId = isset($aResult['grouped']['group_id']) ? (int)$aResult['grouped']['group_id'] : 0;
642  }
643 
644  if($this->_oConfig->isGroupedObject($iObjectId))
645  return $this->getDefaultComments($aEvent['id']);
646 
647  $oComments = new ChWallCmts($sType, $iObjectId);
648  if($oComments->isEnabled())
649  return $oComments->getCommentsFirstSystem('comment', $aEvent['id']);
650 
651  return $this->getDefaultComments($aEvent['id']);
652  }
653 
654  function getDefaultComments($iEventId)
655  {
656  $oComments = new ChWallCmts($this->_oConfig->getCommentSystemName(), $iEventId);
657  return $oComments->getCommentsFirstDefault('comment');
658  }
659 
660  function getJsCode($sType, $aParams = array(), $aRequestParams = array())
661  {
662  $sBaseUri = $this->_oConfig->getBaseUri();
663  $sJsClass = $this->_oConfig->getJsClass($sType);
664  $sJsObject = $this->_oConfig->getJsObject($sType);
665 
666  $aParams = array_merge(array(
667  'sActionUri' => $sBaseUri,
668  'sActionUrl' => CH_WSB_URL_ROOT . $sBaseUri,
669  'sObjName' => $sJsObject,
670  'iOwnerId' => 0,
671  'sAnimationEffect' => $this->_oConfig->getAnimationEffect(),
672  'iAnimationSpeed' => $this->_oConfig->getAnimationSpeed(),
673  'aHtmlIds' => $this->_oConfig->getHtmlIds($sType),
674  'oRequestParams' => $aRequestParams
675  ), $aParams);
676 
677  return $this->_wrapInTagJsCode("var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode($aParams) . ");");
678  }
679 
683  function getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
684  {
685  $aReposted = $this->_oDb->getReposted($sType, $sAction, $iObjectId);
686  if(empty($aReposted) || !is_array($aReposted))
687  return '';
688 
689  $bDisabled = $this->_oModule->_isRepostAllowed($aReposted) !== true || $this->_oDb->isReposted($aReposted['id'], $iOwnerId, $this->_oModule->_getAuthorId());
690  if($bDisabled && (int)$aReposted['reposts'] == 0)
691  return '';
692 
693  $sStylePrefix = $this->_oConfig->getPrefix('style');
694  $sStylePrefixRepost = $sStylePrefix . '-repost-';
695 
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;
698 
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;
702 
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';
705 
706  //--- Do repost link ---//
707  $sClass = $sStylePrefixRepost . 'do-repost';
708  if($bShowDoRepostAsButton)
709  $sClass .= ' ch-btn';
710  else if($bShowDoRepostAsButtonSmall)
711  $sClass .= ' ch-btn ch-btn-small';
712 
713  $sOnClick = '';
714  if(!$bDisabled) {
715  $sCommonPrefix = $this->_oConfig->getPrefix('common_post');
716  if($sType == $sCommonPrefix . CH_WALL_PARSE_TYPE_REPOST) {
717  $aRepostedContent = unserialize($aReposted['content']);
718 
719  $sOnClick = $this->getRepostJsClick($iOwnerId, $aRepostedContent['type'], $aRepostedContent['action'], $aRepostedContent['object_id']);
720  }
721  else
722  $sOnClick = $this->getRepostJsClick($iOwnerId, $sType, $sAction, $iObjectId);
723  }
724  else
725  $sClass .= $bShowDoRepostAsButton || $bShowDoRepostAsButtonSmall ? ' ch-btn-disabled' : ' ' . $sStylePrefixRepost . 'disabled';
726 
727  $aOnClickAttrs = array();
728  if(!empty($sClass))
729  $aOnClickAttrs[] = array('key' => 'class', 'value' => $sClass);
730  if(!empty($sOnClick))
731  $aOnClickAttrs[] = array('key' => 'onclick', 'value' => $sOnClick);
732 
733  return $this->parseHtmlByName($sTmplMain, array(
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,
744  'content' => array()
745  ),
746  'ch_if:show_text' => array(
747  'condition' => $bShowDoRepostLabel,
748  'content' => array(
749  'content' => _t('_wall_txt_do_repost')
750  )
751  )
752  )),
753  'ch_if:show_counter' => array(
754  'condition' => $bShowCounter,
755  'content' => array(
756  'style_prefix' => $sStylePrefix,
757  'ch_if:show_hidden' => array(
758  'condition' => (int)$aReposted['reposts'] == 0,
759  'content' => array()
760  ),
761  'counter' => $this->getRepostCounter($aReposted, $aParams)
762  )
763  ),
764  'script' => $this->getRepostJsScript()
765  ));
766  }
767 
768  function getRepostCounter($aEvent, $aParams = array())
769  {
770  $sStylePrefix = $this->_oConfig->getPrefix('style');
771  $sJsObject = $this->_oConfig->getJsObject('repost');
772 
773  $sTmplCounter = !empty($aParams['template_counter']) ? $aParams['template_counter'] : 'repost_counter.html';
774 
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';
777 
778  return $this->parseHtmlByName($sTmplCounter, array(
779  'href' => 'javascript:void(0)',
780  'title' => ch_html_attribute(_t('_wall_txt_reposted_by')),
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'] . ')')
785  ),
786  'content' => !empty($aEvent['reposts']) && (int)$aEvent['reposts'] > 0 ? _t($sTxtCounter, $aEvent['reposts']) : _t($sTxtCounterEmpty, $aEvent['reposts'])
787  ));
788  }
789 
790  function getRepostedBy($iId)
791  {
792  $sStylePrefix = $this->_oConfig->getPrefix('style');
793 
794  $aUserIds = $this->_oDb->getRepostedBy($iId);
795 
796  $aTmplUsers = array();
797  foreach($aUserIds as $iUserId)
798  $aTmplUsers[] = array(
799  'style_prefix' => $sStylePrefix,
800  'thumbnail' => get_member_thumbnail($iUserId, 'none', true)
801  );
802 
803  if(empty($aTmplUsers))
804  $aTmplUsers = MsgBox(_t('_Empty'));
805 
806  $sName = $this->_oConfig->getHtmlIds('repost', 'by_popup') . $iId;
807  $sContent = $this->parseHtmlByName('repost_by_list.html', array(
808  'style_prefix' => $sStylePrefix,
809  'ch_repeat:list' => $aTmplUsers
810  ));
811 
812  return PopupBox($sName, _t('_wall_txt_reposted_by'), $sContent);
813  }
814 
815  function getRepostJsScript()
816  {
817  $this->addCss(array('repost.css'));
818  $this->addJs(array('main.js', 'repost.js'));
819 
820  return $this->getJsCode('repost', array(
821  'iOwnerId' => $oModule->_iOwnerId
822  ));
823  }
824 
825  function getRepostJsClick($iOwnerId, $sType, $sAction, $mixedObjectId)
826  {
827  $sJsObject = $this->_oConfig->getJsObject('repost');
828  $sFormat = "%s.repostItem(this, %d, '%s', '%s', " . (is_int($mixedObjectId) ? "%d" : "'%s'") . ");";
829 
830  $iOwnerId = !empty($iOwnerId) ? (int)$iOwnerId : $this->_oModule->_getAuthorId(); //--- in whose timeline the content will be reposted
831  return sprintf($sFormat, $sJsObject, $iOwnerId, $sType, $sAction, $mixedObjectId);
832  }
833 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChWallTemplate\displayFriendAccept
displayFriendAccept($aEvent)
Definition: ChWallTemplate.php:576
$sMessage
$sMessage
Definition: actions.inc.php:17
ChWallTemplate\getSystem
getSystem($aEvent, $sDisplayType=CH_WALL_VIEW_TIMELINE)
Definition: ChWallTemplate.php:33
$oModule
if(! @isAdmin()) $oModule
Definition: admin.php:25
ChWallTemplate\displayProfileEdit
displayProfileEdit($aEvent)
Definition: ChWallTemplate.php:423
ChTemplFormView
Definition: ChTemplFormView.php:11
ChWallTemplate\setModule
setModule(&$oModule)
Definition: ChWallTemplate.php:24
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWallTemplate\displayProfileCommentPost
displayProfileCommentPost($aEvent)
Definition: ChWallTemplate.php:533
ChWallTemplate\_getSystemData
_getSystemData(&$aEvent, $sDisplayType=CH_WALL_VIEW_TIMELINE)
Definition: ChWallTemplate.php:142
$sResult
$sResult
Definition: advanced_settings.php:26
ChWallTemplate\__construct
__construct(&$oConfig, &$oDb)
Definition: ChWallTemplate.php:17
ChWallTemplate\getRepostJsClick
getRepostJsClick($iOwnerId, $sType, $sAction, $mixedObjectId)
Definition: ChWallTemplate.php:825
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ChWallTemplate\getDefaultComments
getDefaultComments($iEventId)
Definition: ChWallTemplate.php:654
ChWallTemplate\getRepostCounter
getRepostCounter($aEvent, $aParams=array())
Definition: ChWallTemplate.php:768
ChWsbTemplate\addCss
addCss($mixedFiles, $bDynamic=false)
Definition: ChWsbTemplate.php:1114
php
$iId
$iId
Definition: license.php:15
$sModule
if(!file_exists($sRayHeaderPath)) $sModule
Definition: index.php:14
ChWallTemplate\getLoadMoreOutline
getLoadMoreOutline($iStart, $iPerPage, $bEnabled=true, $bVisible=true)
Definition: ChWallTemplate.php:364
CH_WSB_LINK_CLASS
const CH_WSB_LINK_CLASS
Definition: utils.inc.php:12
ch_gen_method_name
ch_gen_method_name($s, $sWordsDelimiter='_')
Definition: utils.inc.php:1942
$iPerPage
else $iPerPage
Definition: browse.php:61
CH_WALL_VIEW_OUTLINE
const CH_WALL_VIEW_OUTLINE
Definition: ChWallModule.php:24
ChWallTemplate\getOwnerImage
getOwnerImage($sType, $iOwnerId)
Definition: ChWallTemplate.php:613
ChWallTemplate\getJsCode
getJsCode($sType, $aParams=array(), $aRequestParams=array())
Definition: ChWallTemplate.php:660
ChWallTemplate\$_oModule
$_oModule
Definition: ChWallTemplate.php:12
CH_WALL_PARSE_TYPE_SOUNDS
const CH_WALL_PARSE_TYPE_SOUNDS
Definition: ChWallModule.php:29
ChWallTemplate\getTimeline
getTimeline($iStart, $iPerPage, $sFilter, $sTimeline, $aModules)
Definition: ChWallTemplate.php:320
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
$oForm
$oForm
Definition: host_tools.php:42
ChWallTemplate\getOwnerIcon
getOwnerIcon($iOwnerId)
Definition: ChWallTemplate.php:608
ChWallTemplate\getEmpty
getEmpty($bVisible)
Definition: ChWallTemplate.php:278
ChWsbTemplate\parseHtmlByContent
parseHtmlByContent($sContent, $aVariables, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:687
CH_WALL_VIEW_TIMELINE
const CH_WALL_VIEW_TIMELINE
Definition: ChWallModule.php:23
$sType
$sType
Definition: actions.inc.php:11
ChWsbTemplate\_wrapInTagJsCode
_wrapInTagJsCode($sCode)
Definition: ChWsbTemplate.php:1102
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ch_linkify_html
ch_linkify_html($sHtmlOrig, $sAttrs='')
Definition: utils.inc.php:1901
ChWallTemplate\getCommon
getCommon($aEvent)
Definition: ChWallTemplate.php:99
ChWallTemplate\getLoadMore
getLoadMore($iStart, $iPerPage, $bEnabled=true, $bVisible=true)
Definition: ChWallTemplate.php:347
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
ChWallTemplate\_getCommonMedia
_getCommonMedia($sType, $iObject)
Definition: ChWallTemplate.php:246
$oDb
global $oDb
Definition: db.inc.php:39
ChWallTemplate\getRepostJsScript
getRepostJsScript()
Definition: ChWallTemplate.php:815
ChWallTemplate
Definition: ChWallTemplate.php:11
CH_WALL_PARSE_TYPE_VIDEOS
const CH_WALL_PARSE_TYPE_VIDEOS
Definition: ChWallModule.php:30
$bResult
$bResult
Definition: get_file.php:11
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWallTemplate\getDividerToday
getDividerToday($aEvent=array())
Definition: ChWallTemplate.php:312
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
CH_WALL_PARSE_TYPE_REPOST
const CH_WALL_PARSE_TYPE_REPOST
Definition: ChWallModule.php:31
ChWallTemplate\getDivider
getDivider(&$iDays, &$aEvent)
Definition: ChWallTemplate.php:285
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
ChWallTemplate\getOwnerThumbnail
getOwnerThumbnail($iOwnerId)
Definition: ChWallTemplate.php:603
CH_WALL_DIVIDER_TIMELINE
const CH_WALL_DIVIDER_TIMELINE
Definition: ChWallModule.php:37
ChWsbTemplate\addJs
addJs($mixedFiles, $bDynamic=false)
Definition: ChWsbTemplate.php:999
$aModules
$aModules
Definition: constants.inc.php:29
ChWallCmts
Definition: ChWallCmts.php:11
PopupBox
PopupBox($sName, $sTitle, $sContent, $aActions=array())
Definition: design.inc.php:189
ChWsbModuleTemplate
Definition: ChWsbModuleTemplate.php:11
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChWsbTemplate\parseHtmlByTemplateName
parseHtmlByTemplateName($sName, $aVariables, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:704
ChWallTemplate\getRepostElement
getRepostElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams=array())
Definition: ChWallTemplate.php:683
CH_WALL_PARSE_TYPE_TEXT
const CH_WALL_PARSE_TYPE_TEXT
Definition: ChWallModule.php:26
ChWallTemplate\displayProfileCommentAdd
displayProfileCommentAdd($aEvent)
Definition: ChWallTemplate.php:486
ChWallTemplate\_getCommonData
_getCommonData($aEvent)
Definition: ChWallTemplate.php:167
$sCaption
$sCaption
Definition: tellfriend.php:39
ChWsbCmtsProfile
Definition: ChWsbCmtsProfile.php:11
ChWallTemplate\getRepostedBy
getRepostedBy($iId)
Definition: ChWallTemplate.php:790
$sAction
$sAction
Definition: categories.php:274
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChWsbTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:660
ch_ltrim_str
ch_ltrim_str($sString, $sPrefix, $sReplace='')
Definition: utils.inc.php:1787
ChWallTemplate\getUploader
getUploader($iOwnerId, $sType, $sSubType='')
Definition: ChWallTemplate.php:382
ChWallTemplate\getComments
getComments($aEvent, $aResult)
Definition: ChWallTemplate.php:626
CH_WALL_PARSE_TYPE_LINK
const CH_WALL_PARSE_TYPE_LINK
Definition: ChWallModule.php:27
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChWallTemplate\displayProfileEditStatusMessage
displayProfileEditStatusMessage($aEvent)
Definition: ChWallTemplate.php:452
CH_WALL_PARSE_TYPE_PHOTOS
const CH_WALL_PARSE_TYPE_PHOTOS
Definition: ChWallModule.php:28