PHP Класс 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
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$_aSystem current rating system name
$_fRate number of votes
$_iCount item id to be rated
$_iId
$_oQuery current rating system array
$_sSystem average rate

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
_getVoteResult ( )
_triggerVote ( )

Описание методов

__construct() публичный Метод

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

_getVoteResult() защищенный Метод

protected _getVoteResult ( )

_triggerVote() защищенный Метод

protected _triggerVote ( )

actionVote() публичный Метод

public actionVote ( )

checkAction() публичный Метод

public checkAction ( $bPerformAction = false )

deleteVotings() публичный Метод

public deleteVotings ( $iId )

getId() публичный Метод

public getId ( )

getMaxVote() публичный Метод

public getMaxVote ( )

getObjectInstance() статический публичный Метод

get voting object instanse
static public getObjectInstance ( $sSys, $iId, $iInit = true ) : null
$sSys voting object name
$iId associated content id
$iInit perform initialization
Результат null on error, or ready to use class instance

getSqlParts() публичный Метод

public getSqlParts ( $sMailTable, $sMailField )

getSystemName() публичный Метод

public getSystemName ( )

getSystems() публичный статический Метод

public static getSystems ( )

getTopVotedItem() публичный Метод

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

getVoteCount() публичный Метод

public getVoteCount ( )

getVoteRate() публичный Метод

public getVoteRate ( )

getVotedItems() публичный Метод

public getVotedItems ( $sIp )

init() публичный Метод

public init ( $iId )

initVotes() публичный Метод

public initVotes ( )

isDublicateVote() публичный Метод

public isDublicateVote ( )

isEnabled() публичный Метод

public isEnabled ( )

isValidSystem() публичный Метод

public isValidSystem ( $sSystem )

maintenance() публичный Метод

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

makeVote() публичный Метод

public makeVote ( $iVote )

setId() публичный Метод

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

Описание свойств

$_aSystem публичное свойство

current rating system name
public $_aSystem

$_fRate публичное свойство

number of votes
public $_fRate

$_iCount публичное свойство

item id to be rated
public $_iCount

$_iId публичное свойство

public $_iId

$_oQuery публичное свойство

current rating system array
public $_oQuery

$_sSystem публичное свойство

average rate
public $_sSystem