Cheetah
|
Public Member Functions | |
__construct ( $sSystem, $iId, $iInit=1) | |
init ($iId) | |
initVotes () | |
makeVote ($iVote) | |
checkAction ($bPerformAction=false) | |
isDublicateVote () | |
getId () | |
isEnabled () | |
getMaxVote () | |
getVoteCount () | |
getVoteRate () | |
getSystemName () | |
setId ($iId) | |
getSqlParts ($sMailTable, $sMailField) | |
isValidSystem ($sSystem) | |
deleteVotings ($iId) | |
getTopVotedItem ($iDays, $sJoinTable='', $sJoinField='', $sWhere='') | |
getVotedItems ($sIp) | |
maintenance () | |
actionVote () | |
Static Public Member Functions | |
static | getObjectInstance ($sSys, $iId, $iInit=true) |
static & | getSystems () |
Public Attributes | |
$_iId = 0 | |
$_iCount = 0 | |
$_fRate = 0 | |
$_sSystem = 'profile' | |
$_aSystem = array () | |
$_oQuery = null | |
Protected Member Functions | |
_getVoteResult () | |
_triggerVote () | |
Votings for any content
Related classes: ChWsbVotingQuery - votings database queries ChBaseVotingView - votings base representation ChTemplVotingView - custom template representation
AJAX votings for any content. Big and small votings stars are supported
To add votings section to your site you need to add a record to 'sys_objects_vote' table:
ID - autoincremented id for internal usage ObjectName - your unique module name, with vendor prefix, lowercase and spaces are underscored TableRating - table name where sumarry votigs are stored TableTrack - table name where each vote is stored RowPrefix - row prefix for TableRating MaxVotes - max vote number, 5 by default PostName - post variable name with rating IsDuplicate - number of seconds to not allow duplicate vote (for some bad reason it is define here) IsOn - is this vote object enabled ClassName - custom class name for HotOrNot
You can refer to Cheetah modules for sample record in this table.
Example of usage: After filling in the table you can show big votings in any place, using the following code:
ch_import('ChTemplVotingView'); $o = new ChTemplVotingView ('value of ObjectName field', $iYourEntryId); if (!$o->isEnabled()) return ''; echo $o->getBigVoting (1); // 1 - rate is allowed
And small votings, using the following code:
$o = new ChTemplVotingView ('value of ObjectName field', $iYourEntryId); if (!$o->isEnabled()) return ''; echo $o->getSmallVoting (0); // 0 - rate is not allowed, like readony votings
In some cases votes are already in database and there is no need to execute additional query to get ratings, so you can use the following code:
$o = new ChTemplVotingView ('value of ObjectName field', 0); foreach ($aRecords as $aData) echo $o->getJustVotingElement(0, $aData['ID'], $aData['voting_rate']);
Please note that you never need to use ChWsbVoting class directly, use ChTemplVotingView instead. Also if you override votings class with your own then make it child of ChTemplVotingView class.
Memberships/ACL: vote - ACTION_ID_VOTE
Alerts: Alerts type/unit - every module has own type/unit, it equals to ObjectName The following alerts are rised
rate - comment was posted $iObjectId - entry id $iSenderId - rater user id $aExtra['rate'] - rate
Definition at line 89 of file ChWsbVoting.php.
ChWsbVoting::__construct | ( | $sSystem, | |
$iId, | |||
$iInit = 1 |
|||
) |
Constructor
Reimplemented in ChWallVoting, ChNewsVoting, ChFdbVoting, ChArlVoting, ChWsbTextVoting, ChTemplVotingView, ChTemplVotingView, ChTemplVotingView, and ChBaseVotingView.
Definition at line 103 of file ChWsbVoting.php.
|
protected |
Definition at line 359 of file ChWsbVoting.php.
|
protected |
Definition at line 377 of file ChWsbVoting.php.
ChWsbVoting::actionVote | ( | ) |
Definition at line 343 of file ChWsbVoting.php.
ChWsbVoting::checkAction | ( | $bPerformAction = false | ) |
Reimplemented in ChStoreVoting, ChGroupsVoting, and ChEventsVoting.
Definition at line 239 of file ChWsbVoting.php.
ChWsbVoting::deleteVotings | ( | $iId | ) |
Definition at line 310 of file ChWsbVoting.php.
ChWsbVoting::getId | ( | ) |
Definition at line 257 of file ChWsbVoting.php.
ChWsbVoting::getMaxVote | ( | ) |
Definition at line 267 of file ChWsbVoting.php.
|
static |
get voting object instanse
$sSys | voting object name |
$iId | associated content id |
$iInit | perform initialization |
Definition at line 126 of file ChWsbVoting.php.
ChWsbVoting::getSqlParts | ( | $sMailTable, | |
$sMailField | |||
) |
Definition at line 297 of file ChWsbVoting.php.
ChWsbVoting::getSystemName | ( | ) |
Definition at line 282 of file ChWsbVoting.php.
|
static |
Definition at line 142 of file ChWsbVoting.php.
ChWsbVoting::getTopVotedItem | ( | $iDays, | |
$sJoinTable = '' , |
|||
$sJoinField = '' , |
|||
$sWhere = '' |
|||
) |
Definition at line 317 of file ChWsbVoting.php.
ChWsbVoting::getVoteCount | ( | ) |
Definition at line 272 of file ChWsbVoting.php.
ChWsbVoting::getVotedItems | ( | $sIp | ) |
Definition at line 322 of file ChWsbVoting.php.
ChWsbVoting::getVoteRate | ( | ) |
Definition at line 277 of file ChWsbVoting.php.
ChWsbVoting::init | ( | $iId | ) |
Definition at line 193 of file ChWsbVoting.php.
ChWsbVoting::initVotes | ( | ) |
Definition at line 205 of file ChWsbVoting.php.
ChWsbVoting::isDublicateVote | ( | ) |
Definition at line 249 of file ChWsbVoting.php.
ChWsbVoting::isEnabled | ( | ) |
Definition at line 262 of file ChWsbVoting.php.
ChWsbVoting::isValidSystem | ( | $sSystem | ) |
Definition at line 305 of file ChWsbVoting.php.
ChWsbVoting::maintenance | ( | ) |
it is called on cron every day or similar period to clean old votes
Definition at line 330 of file ChWsbVoting.php.
ChWsbVoting::makeVote | ( | $iVote | ) |
Definition at line 218 of file ChWsbVoting.php.
ChWsbVoting::setId | ( | $iId | ) |
set id to operate with votes
Definition at line 290 of file ChWsbVoting.php.
ChWsbVoting::$_aSystem = array () |
Definition at line 96 of file ChWsbVoting.php.
ChWsbVoting::$_fRate = 0 |
Definition at line 93 of file ChWsbVoting.php.
ChWsbVoting::$_iCount = 0 |
Definition at line 92 of file ChWsbVoting.php.
ChWsbVoting::$_iId = 0 |
Definition at line 91 of file ChWsbVoting.php.
ChWsbVoting::$_oQuery = null |
Definition at line 98 of file ChWsbVoting.php.
ChWsbVoting::$_sSystem = 'profile' |
Definition at line 94 of file ChWsbVoting.php.