BxDolVoting::getSystems PHP Method

getSystems() public static method

public static getSystems ( )
    public static function &getSystems()
    {
        if (isset($GLOBALS['bx_dol_voting_systems'])) {
            return $GLOBALS['bx_dol_voting_systems'];
        }
        $oCache = $GLOBALS['MySQL']->getDbCacheObject();
        $GLOBALS['bx_dol_voting_systems'] = $oCache->getData($GLOBALS['MySQL']->genDbCacheKey('sys_objects_vote'));
        if (null === $GLOBALS['bx_dol_voting_systems']) {
            // cache is empty | load data from DB
            $sQuery = "SELECT * FROM `sys_objects_vote`";
            $rResult = db_res($sQuery);
            $GLOBALS['bx_dol_voting_systems'] = array();
            while ($aRow = $rResult->fetch()) {
                $GLOBALS['bx_dol_voting_systems'][$aRow['ObjectName']] = array('table_rating' => $aRow['TableRating'], 'table_track' => $aRow['TableTrack'], 'row_prefix' => $aRow['RowPrefix'], 'max_votes' => $aRow['MaxVotes'], 'post_name' => $aRow['PostName'], 'is_duplicate' => is_int($aRow['IsDuplicate']) ? $aRow['IsDuplicate'] : constant($aRow['IsDuplicate']), 'is_on' => $aRow['IsOn'], 'className' => $aRow['className'], 'classFile' => $aRow['classFile'], 'trigger_table' => $aRow['TriggerTable'], 'trigger_field_rate' => $aRow['TriggerFieldRate'], 'trigger_field_rate_count' => $aRow['TriggerFieldRateCount'], 'trigger_field_id' => $aRow['TriggerFieldId'], 'override_class_name' => $aRow['OverrideClassName'], 'override_class_file' => $aRow['OverrideClassFile']);
            }
            // write data into cache file
            $oCache = $GLOBALS['MySQL']->getDbCacheObject();
            $oCache->setData($GLOBALS['MySQL']->genDbCacheKey('sys_objects_vote'), $GLOBALS['bx_dol_voting_systems']);
        }
        return $GLOBALS['bx_dol_voting_systems'];
    }

Usage Example

Ejemplo n.º 1
0
<?php

/**
 * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
 * CC-BY License - http://creativecommons.org/licenses/by/3.0/
 */
require_once 'inc/header.inc.php';
require_once BX_DIRECTORY_PATH_INC . 'design.inc.php';
require_once BX_DIRECTORY_PATH_INC . 'profiles.inc.php';
require_once BX_DIRECTORY_PATH_INC . 'utils.inc.php';
check_logged();
bx_import("BxDolVoting");
$aSystems =& BxDolVoting::getSystems();
$sSys = isset($_GET['sys']) ? $_GET['sys'] : false;
if ($sSys && isset($aSystems[$sSys])) {
    if ($aSystems[$sSys]['override_class_name']) {
        require_once BX_DIRECTORY_PATH_ROOT . $aSystems[$sSys]['override_class_file'];
        $sClassName = $aSystems[$sSys]['override_class_name'];
        new $sClassName($_GET['sys'], (int) $_GET['id']);
    } else {
        new BxDolVoting($_GET['sys'], (int) $_GET['id']);
    }
}