本文整理汇总了PHP中OA类的典型用法代码示例。如果您正苦于以下问题:PHP OA类的具体用法?PHP OA怎么用?PHP OA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableSSLExtensions
/**
* A method to detect the available SSL enabling extensions
*
* @return mixed An array of the available extensions, or false if none is present
*/
public static function getAvailableSSLExtensions($forceReload = false)
{
if ($forceReload || !isset(self::$sslExtensions)) {
self::$sslExtensions = OA::getAvailableSSLExtensions();
}
return self::$sslExtensions;
}
示例2: getPlacementFirstStatsDate
/**
* A method to determine the day/hour that a placement first became active,
* based on the first record of its children ads delivering.
*
* @param integer $placementId The placement ID.
* @return mixed PEAR:Error on database error, null on no result, or a
* PEAR::Date object representing the time the placement started
* delivery, or, if not yet active, the current date/time.
*/
function getPlacementFirstStatsDate($placementId)
{
// Test the input values
if (!is_numeric($placementId)) {
return null;
}
// Get the required data
$conf = $GLOBALS['_MAX']['CONF'];
$adTable = $this->oDbh->quoteIdentifier($conf['table']['prefix'] . $conf['table']['banners'], true);
$dsahTable = $this->oDbh->quoteIdentifier($conf['table']['prefix'] . $conf['table']['data_summary_ad_hourly'], true);
$query = "\n SELECT\n DATE_FORMAT(dsah.date_time, '%Y-%m-%d') AS day,\n HOUR(dsah.date_time) AS hour\n FROM\n {$adTable} AS a,\n {$dsahTable} AS dsah\n WHERE\n a.campaignid = " . $this->oDbh->quote($placementId, 'integer') . "\n AND\n a.bannerid = dsah.ad_id\n ORDER BY\n day ASC, hour ASC\n LIMIT 1";
$message = "Finding start date of placement ID {$placementId} based on delivery statistics.";
OA::debug($message, PEAR_LOG_DEBUG);
$rc = $this->oDbh->query($query);
if (PEAR::isError($rc)) {
return $rc;
}
// Was a result found?
if ($rc->numRows() == 0) {
// Return the current time
$oDate = new Date();
} else {
// Store the results
$aRow = $rc->fetchRow();
$oDate = new Date($aRow['day'] . ' ' . $aRow['hour'] . ':00:00');
}
return $oDate;
}
示例3: run
function run()
{
// Make sure that the output is sent to the browser before
// loading libraries and connecting to the db
flush();
$aConf = $GLOBALS['_MAX']['CONF'];
// Set longer time out, and ignore user abort
if (!ini_get('safe_mode')) {
@set_time_limit($aConf['maintenance']['timeLimitScripts']);
@ignore_user_abort(true);
}
if (!defined('OA_VERSION')) {
// If the code is executed inside delivery, the constants
// need to be initialized
require_once MAX_PATH . '/constants.php';
setupConstants();
}
$oLock =& OA_DB_AdvisoryLock::factory();
if ($oLock->get(OA_DB_ADVISORYLOCK_MAINTENANCE)) {
OA::debug('Running Automatic Maintenance Task', PEAR_LOG_INFO);
OA_Preferences::loadAdminAccountPreferences();
require_once LIB_PATH . '/Maintenance.php';
$oMaint = new OX_Maintenance();
$oMaint->run();
$oLock->release();
OA::debug('Automatic Maintenance Task Completed', PEAR_LOG_INFO);
} else {
OA::debug('Automatic Maintenance Task not run: could not acquire lock', PEAR_LOG_INFO);
}
}
示例4: defaultData
function defaultData()
{
$oManager = new OX_Plugin_ComponentGroupManager();
if (!array_key_exists('testPlugin', $GLOBALS['_MAX']['CONF']['pluginGroupComponents'])) {
$oManager->disableComponentGroup('testPlugin');
}
$this->oManager->enableComponentGroup('testPlugin');
$oTestPluginTable = OA_Dal::factoryDO('testplugin_table');
if (!$oTestPluginTable) {
OA::debug('Failed to instantiate DataObject for testplugin_table');
return false;
}
$oTestPluginTable->myplugin_desc = 'Hello World';
$aSettings[0]['data'] = $oTestPluginTable->insert();
$aSettings[0]['section'] = 'myPlugin';
$aSettings[0]['key'] = 'english';
$oTestPluginTable->myplugin_desc = 'Hola Mundo';
$aSettings[1]['data'] = $oTestPluginTable->insert();
$aSettings[1]['section'] = 'myPlugin';
$aSettings[1]['key'] = 'spanish';
$oTestPluginTable->myplugin_desc = 'Look Simon, you\'re just making it up now';
$aSettings[2]['data'] = $oTestPluginTable->insert();
$aSettings[2]['section'] = 'myPlugin';
$aSettings[2]['key'] = 'russian';
$oManager->_registerSettings($aSettings);
$oManager->disableComponentGroup('testPlugin');
return true;
}
示例5: display
/**
* A method to launch and display the widget
*
* @param array $aParams The parameters array, usually $_REQUEST
*/
function display()
{
if (!$this->oTpl->is_cached()) {
OA::disableErrorHandling();
$oRss = new XML_RSS($this->url);
$result = $oRss->parse();
OA::enableErrorHandling();
// ignore bad character error which could appear if rss is using invalid characters
if (PEAR::isError($result)) {
if (!strstr($result->getMessage(), 'Invalid character')) {
PEAR::raiseError($result);
// rethrow
$this->oTpl->caching = false;
}
}
$aPost = array_slice($oRss->getItems(), 0, $this->posts);
foreach ($aPost as $key => $aValue) {
$aPost[$key]['origTitle'] = $aValue['title'];
if (strlen($aValue['title']) > 38) {
$aPost[$key]['title'] = substr($aValue['title'], 0, 38) . '...';
}
}
$this->oTpl->assign('title', $this->title);
$this->oTpl->assign('feed', $aPost);
$this->oTpl->assign('siteTitle', $this->siteTitle);
$this->oTpl->assign('siteUrl', $this->siteUrl);
}
$this->oTpl->display();
}
示例6: execute
function execute($aParams)
{
$this->oUpgrade =& $aParams[0];
$this->oDbh =& OA_DB::singleton();
$prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
if ($this->oDbh->dbsyntax == 'pgsql') {
$oTable =& $this->oUpgrade->oDBUpgrader->oTable;
foreach ($oTable->aDefinition['tables'] as $tableName => $aTable) {
foreach ($aTable['fields'] as $fieldName => $aField) {
if (!empty($aField['autoincrement'])) {
// Check actual sequence name
$oldSequenceName = $this->getLinkedSequence($prefix . $tableName, $fieldName);
if ($oldSequenceName) {
$newSequenceName = OA_DB::getSequenceName($this->oDbh, $tableName, $fieldName);
if ($oldSequenceName != $newSequenceName) {
$this->logOnly("Non standard sequence name found: " . $oldSequenceName);
$qTable = $this->oDbh->quoteIdentifier($prefix . $tableName, true);
$qField = $this->oDbh->quoteIdentifier($fieldName, true);
$qOldSequence = $this->oDbh->quoteIdentifier($oldSequenceName, true);
$qNewSequence = $this->oDbh->quoteIdentifier($newSequenceName, true);
OA::disableErrorHandling();
$result = $this->oDbh->exec("ALTER TABLE {$qOldSequence} RENAME TO {$qNewSequence}");
if (PEAR::isError($result)) {
if ($result->getCode() == MDB2_ERROR_ALREADY_EXISTS) {
$result = $this->oDbh->exec("DROP SEQUENCE {$qNewSequence}");
if (PEAR::isError($result)) {
$this->logError("Could not drop existing sequence {$newSequenceName}: " . $result->getUserInfo());
return false;
}
$result = $this->oDbh->exec("ALTER TABLE {$qOldSequence} RENAME TO {$qNewSequence}");
}
}
if (PEAR::isError($result)) {
$this->logError("Could not rename {$oldSequenceName} to {$newSequenceName}: " . $result->getUserInfo());
return false;
}
$result = $this->oDbh->exec("ALTER TABLE {$qTable} ALTER {$qField} SET DEFAULT nextval(" . $this->oDbh->quote($qNewSequence) . ")");
if (PEAR::isError($result)) {
$this->logError("Could not set column default to sequence {$newSequenceName}: " . $result->getUserInfo());
return false;
}
OA::enableErrorHandling();
$result = $oTable->resetSequenceByData($tableName, $fieldName);
if (PEAR::isError($result)) {
$this->logError("Could not reset sequence value for {$newSequenceName}: " . $result->getUserInfo());
return false;
}
$this->logOnly("Successfully renamed {$oldSequenceName} to {$newSequenceName}");
}
} else {
$this->logOnly("No sequence found for {$tableName}.{$fieldName}");
}
}
}
}
}
return true;
}
示例7: __construct
function __construct($path, $server, $port = 0, $proxy = '', $proxy_port = 0, $proxy_user = '', $proxy_pass = '')
{
if ($aExtensions = OA::getAvailableSSLExtensions()) {
$this->hasCurl = in_array('curl', $aExtensions);
$this->hasOpenssl = in_array('openssl', $aExtensions);
}
$this->verifyPeer = false;
$this->caFile = MAX_PATH . '/etc/curl-ca-bundle.crt';
parent::__construct($path, $server, $port);
}
示例8: _saveSummary
/**
* A private method for summarising data into the final tables when
* at least one hour is complete.
*
* @access private
* @param PEAR::Date $oStartDate The start date of the complete hour(s).
* @param PEAR::Date $oEndDate The end date of the complete hour(s).
*/
function _saveSummary($oStartDate, $oEndDate)
{
$message = '- Updating the data_summary_ad_hourly table for data after ' . $oStartDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oStartDate->tz->getShortName();
$this->oController->report .= $message . ".\n";
OA::debug($message, PEAR_LOG_DEBUG);
$oServiceLocator =& OA_ServiceLocator::instance();
$oDal =& $oServiceLocator->get('OX_Dal_Maintenance_Statistics');
$aTypes = array('types' => array(0 => 'request', 1 => 'impression', 2 => 'click'), 'connections' => array(1 => MAX_CONNECTION_AD_IMPRESSION, 2 => MAX_CONNECTION_AD_CLICK));
$oDal->saveSummary($oStartDate, $oEndDate, $aTypes, 'data_intermediate_ad', 'data_summary_ad_hourly');
}
示例9: runTasks
/**
* A method to run the run() method of each task in the collection,
* in the registered order.
*
* @todo We should really make OA_Task::run return a boolean we can check.
*/
function runTasks()
{
// Remove tasks from the queue and unset them when done to prevent
// useless memory consumption
while ($oTask = array_shift($this->aTasks)) {
OA::debug('Task begin: ' . get_class($oTask), PEAR_LOG_INFO);
$oTask->run();
OA::debug('Task complete: ' . get_class($oTask), PEAR_LOG_INFO);
unset($oTask);
}
}
示例10: run
/**
* The implementation of the OA_Task::run() method that performs
* the required task of activating/deactivating campaigns.
*/
function run()
{
if ($this->oController->updateIntermediate) {
$oServiceLocator =& OA_ServiceLocator::instance();
$oDate =& $oServiceLocator->get('now');
$oDal =& $oServiceLocator->get('OX_Dal_Maintenance_Statistics');
$message = '- Managing (activating/deactivating) campaigns';
$this->oController->report .= "{$message}.\n";
OA::debug($message);
$this->report .= $oDal->manageCampaigns($oDate);
}
}
示例11: OA_XML_RPC_Client
function OA_XML_RPC_Client($path, $server, $port = 0, $proxy = '', $proxy_port = 0, $proxy_user = '', $proxy_pass = '')
{
if ($aExtensions = OA::getAvailableSSLExtensions()) {
$this->hasCurl = in_array('curl', $aExtensions);
$this->hasOpenssl = in_array('openssl', $aExtensions);
}
$this->verifyPeer = false;
// This CA file is reused in openXMarket plugin
// to setup curl in Zend_Http_Client_Adapter_Curl in same way as here
$this->caFile = MAX_PATH . '/etc/curl-ca-bundle.crt';
parent::XML_RPC_Client($path, $server, $port);
}
示例12: deriveClassName
/**
* A method to derive the class name to instantiate.
*
* @return string The name of the class object to create.
*/
function deriveClassName()
{
$aConf = $GLOBALS['_MAX']['CONF'];
$filename = ucfirst(strtolower($aConf['database']['type']));
$classname = 'OX_Dal_Maintenance_Statistics_' . $filename;
$includeFile = LIB_PATH . "/Dal/Maintenance/Statistics/{$filename}.php";
require_once $includeFile;
if (!class_exists($classname)) {
// Unable to include the specified class file - raise error and halt
OA::debug('Unable to find the "' . $classname . '" class in the "' . $includeFile . '" file.', PEAR_LOG_ERR);
OA::debug('Aborting script execution', PEAR_LOG_ERR);
exit;
}
return $classname;
}
示例13: pruneBucket
/**
* A method to prune a bucket of all records up to and
* including the timestamp given.
*
* @param Date $oEnd Prune until this interval_start (inclusive).
* @param Date $oStart Only prune before this interval_start date (inclusive)
* as well. Optional.
* @return mixed Either the number of rows pruned, or an MDB2_Error objet.
*/
public function pruneBucket($oBucket, $oEnd, $oStart = null)
{
$sTableName = $oBucket->getBucketTableName();
if (!is_null($oStart)) {
OA::debug(' - Pruning the ' . $sTableName . ' table for data with operation interval start between ' . $oStart->format('%Y-%m-%d %H:%M:%S') . ' ' . $oStart->tz->getShortName() . ' and ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_DEBUG);
} else {
OA::debug(' - Pruning the ' . $sTableName . ' table for all data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_DEBUG);
}
$query = "\n DELETE FROM\n {$sTableName}\n WHERE\n interval_start <= " . DBC::makeLiteral($oEnd->format('%Y-%m-%d %H:%M:%S'));
if (!is_null($oStart)) {
$query .= "\n AND\n interval_start >= " . DBC::makeLiteral($oStart->format('%Y-%m-%d %H:%M:%S'));
}
$oDbh = OA_DB::singleton();
return $oDbh->exec($query);
}
示例14: raiseError
/**
* A method to invoke errors.
*
* @static
* @param mixed $message A string error message, or a {@link PEAR_Error} object.
* @param integer $type A custom message code - see the {@link setupConstants()} function.
* @param integer $behaviour Optional behaviour (i.e. PEAR_ERROR_DIE to halt on this error).
* @return PEAR_Error $error A (@link PEAR_Error} object.
*/
function raiseError($message, $type = null, $behaviour = null)
{
// If fatal
if ($behaviour == PEAR_ERROR_DIE) {
// Log fatal message here as execution will stop
$errorType = MAX::errorConstantToString($type);
if (!is_string($message)) {
$message = print_r($message, true);
}
OA::debug($type . ' :: ' . $message, PEAR_LOG_EMERG);
exit;
}
$error = PEAR::raiseError($message, $type, $behaviour);
return $error;
}
示例15: testCheckOperationIntervalValue
/**
* A method to test the checkOperationIntervalValue() method.
*
*/
function testCheckOperationIntervalValue()
{
OA::disableErrorHandling();
for ($i = -1; $i <= 61; $i++) {
$result = OX_OperationInterval::checkOperationIntervalValue($i);
if ($i == 1 || $i == 2 || $i == 3 || $i == 4 || $i == 5 || $i == 6 || $i == 10 || $i == 12 || $i == 15 || $i == 20 || $i == 30 || $i == 60) {
$this->assertTrue($result);
} else {
$this->assertTrue(PEAR::isError($result));
}
$result = OX_OperationInterval::checkOperationIntervalValue(120);
$this->assertTrue(PEAR::isError($result));
}
OA::enableErrorHandling();
}