PHP Class BxDolVoting, dolphin.pro

Related classes: BxDolVotingQuery - votings database queries BxBaseVotingView - votings base representation BxTemplVotingView - 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 @see BxDolRate ClassFile - custom class path for HotOrNot TriggerTable - table to be updated upon each vote TriggerFieldRate - TriggerTable table field with average rate TriggerFieldRateCount - TriggerTable table field with votes count TriggerFieldId - TriggerTable table field with unique record id, primary key OverrideClassName - your custom class name, if you overrride default class OverrideClassFile - your custom class path You can refer to BoonEx 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: bx_import('BxTemplVotingView'); $o = new BxTemplVotingView ('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 BxTemplVotingView ('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 BxTemplVotingView ('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 BxDolVoting class directly, use BxTemplVotingView instead. Also if you override votings class with your own then make it child of BxTemplVotingView 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
Exibir arquivo Open project: boonex/dolphin.pro Class Usage Examples

Public Properties

Property Type Description
$_aSystem current rating system name
$_fRate number of votes
$_iCount item id to be rated
$_iId
$_oQuery current rating system array
$_sSystem average rate

Public Methods

Method Description
__construct ( $sSystem, $iId, $iInit = 1 ) Constructor
actionVote ( )
checkAction ( $bPerformAction = false )
deleteVotings ( $iId )
getId ( )
getMaxVote ( )
getObjectInstance ( $sSys, $iId, $iInit = true ) : null get voting object instanse
getSqlParts ( $sMailTable, $sMailField )
getSystemName ( )
getSystems ( )
getTopVotedItem ( $iDays, $sJoinTable = '', $sJoinField = '', $sWhere = '' )
getVoteCount ( )
getVoteRate ( )
getVotedItems ( $sIp )
init ( $iId )
initVotes ( )
isDublicateVote ( )
isEnabled ( )
isValidSystem ( $sSystem )
maintenance ( ) it is called on cron every day or similar period to clean old votes
makeVote ( $iVote )
setId ( $iId ) set id to operate with votes

Protected Methods

Method Description
_getVoteResult ( )
_triggerVote ( )

Method Details

__construct() public method

Constructor
public __construct ( $sSystem, $iId, $iInit = 1 )

_getVoteResult() protected method

protected _getVoteResult ( )

_triggerVote() protected method

protected _triggerVote ( )

actionVote() public method

public actionVote ( )

checkAction() public method

public checkAction ( $bPerformAction = false )

deleteVotings() public method

public deleteVotings ( $iId )

getId() public method

public getId ( )

getMaxVote() public method

public getMaxVote ( )

getObjectInstance() static public method

get voting object instanse
static public getObjectInstance ( $sSys, $iId, $iInit = true ) : null
$sSys voting object name
$iId associated content id
$iInit perform initialization
return null on error, or ready to use class instance

getSqlParts() public method

public getSqlParts ( $sMailTable, $sMailField )

getSystemName() public method

public getSystemName ( )

getSystems() public static method

public static getSystems ( )

getTopVotedItem() public method

public getTopVotedItem ( $iDays, $sJoinTable = '', $sJoinField = '', $sWhere = '' )

getVoteCount() public method

public getVoteCount ( )

getVoteRate() public method

public getVoteRate ( )

getVotedItems() public method

public getVotedItems ( $sIp )

init() public method

public init ( $iId )

initVotes() public method

public initVotes ( )

isDublicateVote() public method

public isDublicateVote ( )

isEnabled() public method

public isEnabled ( )

isValidSystem() public method

public isValidSystem ( $sSystem )

maintenance() public method

it is called on cron every day or similar period to clean old votes
public maintenance ( )

makeVote() public method

public makeVote ( $iVote )

setId() public method

set id to operate with votes
public setId ( $iId )

Property Details

$_aSystem public_oe property

current rating system name
public $_aSystem

$_fRate public_oe property

number of votes
public $_fRate

$_iCount public_oe property

item id to be rated
public $_iCount

$_iId public_oe property

public $_iId

$_oQuery public_oe property

current rating system array
public $_oQuery

$_sSystem public_oe property

average rate
public $_sSystem