Cheetah
ChWallVoting.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbModule');
9 ch_import('ChTemplVotingView');
10 
12 {
13  var $_oModule;
14 
15  function __construct($sSystem, $iId, $iInit = 1)
16  {
17  parent::__construct($sSystem, $iId, $iInit);
18 
19  $this->_oModule = ChWsbModule::getInstance('ChWallModule');
20  }
21 
22  function getHtmlId($iObjectId = 0)
23  {
24  if(empty($iObjectId))
25  $iObjectId = $this->getId();
26 
27  return $this->_sSystem . '_voting_like_' . $iObjectId;
28  }
29 
30  function getVotingTimeline($bCount = false)
31  {
32  return $this->_getVotingElement(array(
33  'template_main' => 'timeline_voting.html',
34  'template_do_vote' => 'timeline_voting_do_vote.html',
35  'show_count' => $bCount
36  ));
37  }
38 
40  {
41  return $this->_oModule->_oTemplate->parseHtmlByName('timeline_voting_counter.html', array(
42  'counter' => _t('_wall_n_votes_long', $this->getVoteCount())
43  ));
44  }
45 
46  function getVotingOutline($bCount = true)
47  {
48  return $this->_getVotingElement(array(
49  'template_do_vote' => 'outline_voting_do_vote.html',
50  'show_count' => $bCount
51  ));
52  }
53 
54  function isVotingAllowed($isPerformAction = false)
55  {
56  return $this->checkAction($isPerformAction);
57  }
58 
59  protected function _getVotingElement($aParams = array())
60  {
61  if(!$this->isVotingAllowed())
62  return '';
63 
64  $sTmplMain = !empty($aParams['template_main']) ? $aParams['template_main'] : 'voting.html';
65  $sTmplDoVote = !empty($aParams['template_do_vote']) ? $aParams['template_do_vote'] : 'voting_do_vote.html';
66  $bCount = isset($aParams['show_count']) ? (bool)$aParams['show_count'] : true;
67 
68  $iObjectId = $this->getId();
69 
70  $sHtmlId = $this->getHtmlId($iObjectId);
71  $sJsObject = $this->_oModule->_oConfig->getJsObject('voting') . $this->_toName($sHtmlId);
72 
73  $iMax = $this->getMaxVote();
74  return $this->_oModule->_oTemplate->parseHtmlByName($sTmplMain, array(
75  'html_id' => $sHtmlId,
76  'js_object' => $sJsObject,
77  'class' => 'wall-voting',
78  'system' => $this->_sSystem,
79  'object_id' => $iObjectId,
80  'size_x' => $this->_iSizeStarSmallX,
81  'max' => $iMax,
82  'do_vote' => $this->_oModule->_oTemplate->parseHtmlByName($sTmplDoVote, array(
83  'js_object' => $sJsObject,
84  'max' => $iMax,
85  'ch_if:show_count' => array(
86  'condition' => $bCount,
87  'content' => array(
88  'count' => _t('_wall_n_votes', $this->getVoteCount())
89  )
90  )
91  ))
92  ));
93  }
94 
95  protected function _toName($s)
96  {
97  return str_replace(' ', '', ucwords(str_replace('_', ' ', $s)));
98  }
99 }
ChWallVoting
Definition: ChWallVoting.php:12
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChWallVoting\$_oModule
$_oModule
Definition: ChWallVoting.php:13
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChWallVoting\_toName
_toName($s)
Definition: ChWallVoting.php:95
ChWallVoting\isVotingAllowed
isVotingAllowed($isPerformAction=false)
Definition: ChWallVoting.php:54
php
$iId
$iId
Definition: license.php:15
ChWallVoting\getVotingTimelineCounter
getVotingTimelineCounter()
Definition: ChWallVoting.php:39
ChWallVoting\getHtmlId
getHtmlId($iObjectId=0)
Definition: ChWallVoting.php:22
ChWallVoting\_getVotingElement
_getVotingElement($aParams=array())
Definition: ChWallVoting.php:59
ChWallVoting\getVotingTimeline
getVotingTimeline($bCount=false)
Definition: ChWallVoting.php:30
ChWsbVoting\checkAction
checkAction($bPerformAction=false)
Definition: ChWsbVoting.php:239
ChWsbVoting\getId
getId()
Definition: ChWsbVoting.php:257
ChWsbVoting\getMaxVote
getMaxVote()
Definition: ChWsbVoting.php:267
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWallVoting\getVotingOutline
getVotingOutline($bCount=true)
Definition: ChWallVoting.php:46
ChWsbVoting\getVoteCount
getVoteCount()
Definition: ChWsbVoting.php:272
$s
$s
Definition: embed.php:13
ChWallVoting\__construct
__construct($sSystem, $iId, $iInit=1)
Definition: ChWallVoting.php:15
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChTemplVotingView
Definition: ChTemplVotingView.php:14