Cheetah
ChWallCmts.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChTemplCmtsView');
9 
11 {
12  var $_oModule;
13 
17  function __construct($sSystem, $iId, $iInit = 1)
18  {
19  parent::__construct($sSystem, $iId, $iInit);
20 
21  $this->_oModule = ChWsbModule::getInstance('ChWallModule');
22  $this->iAutoHideRootPostForm = 1;
23  }
24 
25  function init ($iId)
26  {
27  if(empty($this->iId) && $iId)
28  $this->setId($iId);
29  }
30 
31  function actionCmtPost ()
32  {
33  $mixedResult = parent::actionCmtPost();
34  if(empty($mixedResult))
35  return $mixedResult;
36 
37  $aEvent = $this->_oModule->_oDb->getEvents(array('browse' => 'id', 'object_id' => (int)$this->getId()));
38  if(isset($aEvent['owner_id']) && (int)$aEvent['owner_id'] > 0) {
39  //--- Wall -> Update for Alerts Engine ---//
40  ch_import('ChWsbAlerts');
41  $oAlert = new ChWsbAlerts('ch_' . $this->_oModule->_oConfig->getUri(), 'update', $aEvent['owner_id']);
42  $oAlert->alert();
43  //--- Wall -> Update for Alerts Engine ---//
44  }
45 
46  return $mixedResult;
47  }
48 
53  {
54  $iObjectId = $this->getId();
55  return $this->_oModule->_oTemplate->parseHtmlByTemplateName('comments', array(
56  'actions' => $this->getActionsExt(0, $sType, $iObjectId),
57  'cmt_system' => $this->_sSystem,
58  'cmt_object' => $iObjectId,
59  'ch_if:show_replies' => array(
60  'condition' => false,
61  'content' => array()
62  ),
63  'cmt_addon' => $this->getCmtsInit()
64  ));
65  }
66 
70  function getCommentsFirstSystem($sType, $iEventId, $iCommentId = 0)
71  {
72  return $this->_oModule->_oTemplate->parseHtmlByTemplateName('comments', array(
73  'actions' => $this->getActionsExt($iCommentId, $sType, $iEventId),
74  'cmt_system' => $this->_sSystem,
75  'cmt_object' => $this->getId(),
76  'ch_if:show_replies' => array(
77  'condition' => $iCommentId != 0,
78  'content' => array(
79  'id' => $iCommentId,
80  )
81  ),
82  'cmt_addon' => $this->getCmtsInit()
83  ));
84  }
85 
86  function getActionsExt($iCmtId, $sType = 'comment', $iEventId = 0)
87  {
88  $aEvent = $this->_oModule->_oDb->getEvents(array('browse' => 'id', 'object_id' => $iEventId));
89 
90  //--- Comment
91  $iObjectId = $this->getId();
92  $aParams = array(
93  'cmt_id' => $iCmtId,
94  'cmt_replies' => $this->_oQuery->getObjectCommentsCount($iObjectId, $iCmtId),
95  'cmt_type' => $sType
96  );
97 
98  //--- Reply & Replies
99  $aReply = array();
100  $bReply = $this->isEnabled() && $this->isPostReplyAllowed();
101  if($bReply)
102  $aReply = array(
103  'js_object' => $this->_sJsObjName,
104  'id' => $aParams['cmt_id']
105  );
106 
107  $aReplies = array();
108  $bReplies = $this->isEnabled();
109  if($bReplies) {
110  $sReplies = _t('_wall_n_comments_long', $aParams['cmt_replies']);
111  $aReplies = array(
112  'js_object' => $this->_sJsObjName,
113  'id' => $aParams['cmt_id'],
114  'show' => $sReplies,
115  'hide' => $sReplies,
116  );
117  }
118 
119  //--- Vote & Votes
120  $oVote = $this->_oModule->_getObjectVoting($aEvent);
121 
122  $aVote = array();
123  $bVote = $oVote->isEnabled() && $oVote->isVotingAllowed();
124  if($bVote)
125  $aVote = array(
126  'content' => $oVote->getVotingTimeline()
127  );
128 
129  $sVotes = '';
130  $aVotes = array();
131  $bVotes = $oVote->isEnabled();
132  if($bVotes) {
133  $sVotes = $oVote->getHtmlId();
134  $aVotes = array(
135  'content' => $oVote->getVotingTimelineCounter()
136  );
137  }
138 
139  //--- Repost & Reposts
140  $sRepost = $sReposts = '';
141  $bRepost = $this->_oModule->_isRepostAllowed($aEvent);
142  if($bRepost) {
143  $iOwnerId = $this->_oModule->_getAuthorId(); //--- in whose timeline the content will be shared
144  $iObjectId = $this->_oModule->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['object_id'] : $aEvent['id'];
145 
146  $sRepost = $this->_oModule->serviceGetRepostElementBlock($iOwnerId, $aEvent['type'], $aEvent['action'], $iObjectId, array(
147  'show_do_repost_as_button_small' => true,
148  'show_do_repost_icon' => true,
149  'show_do_repost_label' => false,
150  'show_counter' => false
151  ));
152 
153  $sReposts = $this->_oModule->serviceGetRepostCounter($aEvent['type'], $aEvent['action'], $iObjectId, array(
154  'text_counter' => '_wall_n_reposts_long',
155  'text_counter_empty' => '_wall_no_reposts_long',
156  ));
157  }
158 
159  return $this->_oModule->_oTemplate->parseHtmlByTemplateName('actions', array(
160  'html_id_voting' => $sVotes,
161  'date' => $aEvent['ago'],
162  'ch_if:show_delete' => array(
163  'condition' => $this->_oModule->_isCommentDeleteAllowed($aEvent),
164  'content' => array(
165  'js_view_object' => $this->_oModule->_oConfig->getJsObject('view'),
166  'id' => $aEvent['id']
167  )
168  ),
169  'ch_if:show_reply' => array(
170  'condition' => $bReply,
171  'content' => $aReply
172  ),
173  'ch_if:show_replies' => array(
174  'condition' => $bReplies,
175  'content' => $aReplies
176  ),
177  'ch_if:show_vote' => array(
178  'condition' => $bVote,
179  'content' => $aVote
180  ),
181  'ch_if:show_votes' => array(
182  'condition' => $bVotes,
183  'content' => $aVotes
184  ),
185  'ch_if:show_repost' => array(
186  'condition' => $bRepost,
187  'content' => array(
188  'content' => $sRepost
189  )
190  ),
191  'ch_if:show_reposts' => array(
192  'condition' => $bRepost,
193  'content' => array(
194  'content' => $sReposts
195  )
196  ),
197  ));
198  }
199 }
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChWallCmts\getCommentsFirstDefault
getCommentsFirstDefault($sType)
Definition: ChWallCmts.php:52
ChWallCmts\getActionsExt
getActionsExt($iCmtId, $sType='comment', $iEventId=0)
Definition: ChWallCmts.php:86
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$oAlert
$oAlert
Definition: embed.php:15
php
$iId
$iId
Definition: license.php:15
ChWallCmts\actionCmtPost
actionCmtPost()
Definition: ChWallCmts.php:31
ChWsbCmts\getId
getId()
Definition: ChWsbCmts.php:228
ChWsbCmts\isPostReplyAllowed
isPostReplyAllowed($isPerformAction=false)
Definition: ChWsbCmts.php:368
ChWsbAlerts
Definition: ChWsbAlerts.php:39
$sType
$sType
Definition: actions.inc.php:11
ChWsbCmts\setId
setId($iId)
Definition: ChWsbCmts.php:251
ChWsbCmts\isEnabled
isEnabled()
Definition: ChWsbCmts.php:233
ChTemplCmtsView
Definition: ChTemplCmtsView.php:14
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWallCmts\__construct
__construct($sSystem, $iId, $iInit=1)
Definition: ChWallCmts.php:17
ChWallCmts\getCommentsFirstSystem
getCommentsFirstSystem($sType, $iEventId, $iCommentId=0)
Definition: ChWallCmts.php:70
ChBaseCmtsView\getCmtsInit
getCmtsInit()
Definition: ChBaseCmtsView.php:224
ChWallCmts
Definition: ChWallCmts.php:11
ChWallCmts\init
init($iId)
Definition: ChWallCmts.php:25
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChWallCmts\$_oModule
$_oModule
Definition: ChWallCmts.php:12