本文整理汇总了PHP中OX_Component类的典型用法代码示例。如果您正苦于以下问题:PHP OX_Component类的具体用法?PHP OX_Component怎么用?PHP OX_Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OX_Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Method that is called on settings form submission
* Error messages are appended to the 0 index of the array
*
* @return boolean
*/
function validate(&$aErrorMessage)
{
// Store current values from config
// overwrite it by tested ones
$storeSettings = array();
if (isset($GLOBALS['oxMemcached_memcachedServers'])) {
$storeSettings['memcachedServers'] = $GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedServers'];
$GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedServers'] = $GLOBALS['oxMemcached_memcachedServers'];
}
if (isset($GLOBALS['oxMemcached_memcachedExpireTime'])) {
$storeSettings['memcachedExpireTime'] = $GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedExpireTime'];
$GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedExpireTime'] = $GLOBALS['oxMemcached_memcachedExpireTime'];
}
// Use memcached plugin getStatus function to validate
$oPlgOxMemcached =& OX_Component::factory('deliveryCacheStore', 'oxMemcached', 'oxMemcached');
$result = $oPlgOxMemcached->getStatus();
if ($result !== true) {
$aErrorMessage[0] = $result;
$result = false;
}
// Restore config values
foreach ($storeSettings as $key => $value) {
$GLOBALS['_MAX']['CONF']['oxMemcached'][$key] = $value;
}
return $result;
}
示例2: insert
/**
* Handle all necessary operations when new agency is created
*
* @see DB_DataObject::insert()
*/
function insert()
{
// Create account first
$result = $this->createAccount(OA_ACCOUNT_MANAGER, $this->name);
if (!$result) {
return $result;
}
// Store data to create a user
if (!empty($this->username) && !empty($this->password)) {
$aUser = array('contact_name' => $this->contact, 'email_address' => $this->email, 'username' => $this->username, 'password' => $this->password, 'default_account_id' => $this->account_id);
}
$agencyid = parent::insert();
if (!$agencyid) {
return $agencyid;
}
// Create user if needed
// Is this even required anymore?
if (!empty($aUser)) {
$this->createUser($aUser);
}
// Execute any components which have registered at the afterAgencyCreate hook
$aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterAgencyCreate');
foreach ($aPlugins as $i => $id) {
if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
$obj->afterAgencyCreate($agencyid);
}
}
return $agencyid;
}
示例3: testGetName
function testGetName()
{
$oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'City');
$oPlugin->init(array());
// Assume it is called in the production after talking to Andrew
$this->assertEqual('Geo - Country / City', $oPlugin->displayName);
}
示例4: test_compile
function test_compile()
{
$oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'Continent');
$oPlugin->init(array('data' => 'EU', 'comparison' => '!~'));
$this->_assertResourceData();
$result = $oPlugin->compile();
$this->assertEqual("MAX_checkGeo_Continent('eu,yu,gb,uk,ua,ch,se,sj,es,si,sk,sm,ru,ro,pt,pl,no,nl,mc,md,mt,mk,lu,lt,li,lv,it,ie,is,hu,va,gr,gi,de,ge,fx,fr,fi,fo,ee,dk,cz,cy,hr,bg,ba,be,by,at,am,ad,al', '!~')", $result);
}
示例5: __construct
/**
* Constructor
*/
function __construct()
{
$this->oCacheStorePlugin =& OX_Component::factoryByComponentIdentifier($GLOBALS['_MAX']['CONF']['delivery']['cacheStorePlugin']);
// Do not use Plugin if it's not enabled
if ($this->oCacheStorePlugin->enabled === false) {
$this->oCacheStorePlugin = false;
}
}
示例6: test_oxMemcached_class
function test_oxMemcached_class()
{
if (extension_loaded('memcache')) {
$oComponent =& OX_Component::factory('deliveryCacheStore', 'oxMemcached', 'oxMemcached');
$this->_assertClass($oComponent, 'deliveryCacheStore', 'oxMemcached', 'oxMemcached');
} else {
$this->skip("memcache extension not available");
}
}
示例7: testCompile
function testCompile()
{
$oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'Region');
$rawData = 'GB|T5,T7';
$oPlugin->init(array('data' => $rawData, 'comparison' => '=='));
$this->assertEqual('MAX_checkGeo_Region(\'gb|t5,t7\', \'==\')', $oPlugin->compile());
$this->assertEqual($rawData, $oPlugin->getData());
$oPlugin->init(array('data' => array('GB', 'T5', 'T7'), 'comparison' => '=='));
$this->assertEqual('MAX_checkGeo_Region(\'gb|t5,t7\', \'==\')', $oPlugin->compile());
}
示例8: testCompile
function testCompile()
{
$oPlugin =& OX_Component::factory('deliveryLimitations', 'Site', 'Channel');
$oPlugin->init(array('data' => '21', 'comparison' => '=='));
$this->assertEqual("(MAX_checkSite_Channel('21', '=='))", $oPlugin->compile());
$oPlugin->init(array('data' => '21,43', 'comparison' => '=='));
$this->assertEqual("(MAX_checkSite_Channel('21', '==') && MAX_checkSite_Channel('43', '=='))", $oPlugin->compile());
$oPlugin->init(array('data' => '21,43', 'comparison' => '=~'));
$this->assertEqual("(MAX_checkSite_Channel('21', '=~') || MAX_checkSite_Channel('43', '=~'))", $oPlugin->compile());
$oPlugin->init(array('data' => '21,43', 'comparison' => '!~'));
$this->assertEqual("!(MAX_checkSite_Channel('21', '!~') || MAX_checkSite_Channel('43', '!~'))", $oPlugin->compile());
}
示例9:
/**
* A factory method to return the appropriate
* OA_Maintenance_Priority_DeliveryLimitation_Common
* subclass object (one of OA_Maintenance_Priority_DeliveryLimitation_Date,
* OA_Maintenance_Priority_DeliveryLimitation_Day,
* OA_Maintenance_Priority_DeliveryLimitation_Empty or
* OA_Maintenance_Priority_DeliveryLimitation_Hour), depending on the data
* provided.
*
* @static
* @param array $aDeliveryLimitation An array containing the details of a delivery limitation
* associated with an ad. For example:
* array(
* [ad_id] => 1
* [logical] => and
* [type] => Time:Hour
* [comparison] => ==
* [data] => 1,7,18,23
* [executionorder] => 1
* )
* @return object OA_Maintenance_Priority_DeliveryLimitation_Common
*/
function &factory($aDeliveryLimitation)
{
// Load plugins if not already in cache
if (!isset(self::$aPlugins)) {
self::$aPlugins = OX_Component::getComponents('deliveryLimitations', null, false);
}
// Return instance of the MPE DL class
if (isset(self::$aPlugins[$aDeliveryLimitation['type']])) {
return self::$aPlugins[$aDeliveryLimitation['type']]->getMpeClassInstance($aDeliveryLimitation);
}
// Unknown plugin? Return the empty MPE DL class
return new OA_Maintenance_Priority_DeliveryLimitation_Empty($aDeliveryLimitation);
}
示例10: _findDisplayableReports
/**
* A private method to find all report plugins with can be executed
* by the current user.
*
* @access private
* @return array An array of all the plugins that the user has
* access to excute, indexed by the plugin type.
*/
function _findDisplayableReports()
{
$aDisplayablePlugins = array();
// Get all the report plugins.
$aPlugins = OX_Component::getComponents('reports');
// Check the user's authorization level
foreach ($aPlugins as $pluginType => $oPlugin) {
if (!$oPlugin->isAllowedToExecute()) {
continue;
}
$aDisplayablePlugins[$pluginType] = $oPlugin;
}
return $aDisplayablePlugins;
}
示例11: test_genericHtml_class
function test_genericHtml_class()
{
// test the class implementation
$oComponent =& OX_Component::factory('bannerTypeHtml', 'demoBannerTypeHtml', 'demoHtml');
// common extension methods
$this->_assertClass($oComponent, 'bannerTypeHtml', 'demoBannerTypeHtml', 'demoHtml');
// plugin-specific methods
$this->assertTrue(method_exists($oComponent, '_buildHtmlTemplate'), $sender . ' missing method _buildHtmlTemplate');
$this->assertTrue(method_exists($oComponent, 'exportData'), $sender . ' missing method exportData');
// generate test data
$doBanners = OA_Dal::factoryDO('banners');
$oDG = new DataGenerator();
$oDG->setData('banners', array('ext_bannertype' => array($oComponent->getComponentIdentifier())));
$aIds = $oDG->generate($doBanners, 5, false);
$aFields = $aVariables = array();
// test the processForm method
// this method joins the banners and banners_demo tables
// by creating a banners_demo record where
// banners_demo.banners_demo_id = banners.bannerid
foreach ($aIds as $i => $bannerId) {
$aFields['description'] = 'description_' . $bannerId;
$this->assertTrue($oComponent->processForm(true, $bannerId, $aFields, $aVariables));
$doBannersDemo = OA_Dal::factoryDO('banners_demo');
$doBannersDemo->banners_demo_id = $bannerId;
$this->assertTrue($doBannersDemo->find(true));
$this->assertEqual($doBannersDemo->banners_demo_desc, $aFields['description']);
}
// test the exportData method
$aTables = $oComponent->exportData();
$this->assertIsA($aTables, 'array');
$this->assertEqual(count($aTables), 2);
$prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
$pattern = '/' . $prefix . 'z_' . $oComponent->component . '[\\d]{8}_[\\d]{6}' . $prefix . 'banners/';
$this->assertPattern($pattern, $aTables[0]);
$pattern = '/' . $prefix . 'z_' . $oComponent->component . '[\\d]{8}_[\\d]{6}' . $prefix . 'banners_demo/';
$this->assertPattern($pattern, $aTables[1]);
$oDbh = OA_DB::singleton();
$query = "SELECT * FROM " . $oDbh->quoteIdentifier($aTables[0]);
$aResult = $oDbh->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
foreach ($aResult as $i => $aFrom) {
$this->assertEqual($aFrom['bannerid'], $aIds[$i]);
}
$query = "SELECT * FROM " . $oDbh->quoteIdentifier($aTables[1]);
$aResult = $oDbh->queryAll($query, null, MDB2_FETCHMODE_ASSOC);
foreach ($aResult as $i => $aFrom) {
$this->assertEqual($aFrom['banners_demo_id'], $aIds[$i]);
}
}
示例12: run
/**
* A method to run distributed maintenance.
*/
function run()
{
if (empty($GLOBALS['_MAX']['CONF']['lb']['enabled'])) {
OA::debug('Distributed stats disabled, not running Maintenance Distributed Engine', PEAR_LOG_INFO);
return;
}
if (!empty($GLOBALS['_MAX']['CONF']['rawDatabase'])) {
$GLOBALS['_MAX']['CONF']['database'] = $GLOBALS['_MAX']['CONF']['rawDatabase'] + $GLOBALS['_MAX']['CONF']['database'];
OA::debug('rawDatabase functionality is being used, switching settings', PEAR_LOG_INFO);
}
$oLock =& OA_DB_AdvisoryLock::factory();
if (!$oLock->get(OA_DB_ADVISORYLOCK_DISTRIBUTED)) {
OA::debug('Maintenance Distributed Engine Already Running', PEAR_LOG_INFO);
return;
}
OA::debug('Running Maintenance Distributed Engine', PEAR_LOG_INFO);
// Attempt to increase PHP memory
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance'));
// Ensure the current time is registered with the OA_ServiceLocator
$oServiceLocator =& OA_ServiceLocator::instance();
$oNow =& $oServiceLocator->get('now');
if (!$oNow) {
// Record the current time, and register with the OA_ServiceLocator
$oNow = new Date();
$oServiceLocator->register('now', $oNow);
}
OA::debug(' - Current time is ' . $oNow->format('%Y-%m-%d %H:%M:%S') . ' ' . $oNow->tz->getShortName(), PEAR_LOG_DEBUG);
// Get the components of the deliveryLog extension
$aBuckets = OX_Component::getComponents('deliveryLog');
// Copy buckets' records with "interval_start" up to and including previous OI start,
// and then prune the data processed
$aPreviousOperationIntervalDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oNow);
OA::debug(' - Will process data for all operation intervals before and up to start', PEAR_LOG_DEBUG);
OA::debug(' time of ' . $aPreviousOperationIntervalDates['start']->format('%Y-%m-%d %H:%M:%S') . ' ' . $aPreviousOperationIntervalDates['start']->tz->getShortName(), PEAR_LOG_DEBUG);
foreach ($aBuckets as $sBucketName => $oBucketClass) {
if ($oBucketClass->testStatisticsMigration($oBucketClass->getStatisticsMigration())) {
$oBucketClass->processBucket($aPreviousOperationIntervalDates['start']);
$oBucketClass->pruneBucket($aPreviousOperationIntervalDates['start']);
} else {
OA::debug(' - Skipping ' . $sBucketName, PEAR_LOG_DEBUG);
}
}
$oLock->release();
OA::debug('Maintenance Distributed Engine Completed', PEAR_LOG_INFO);
}
示例13: buildForm
/**
* Append type-specific form elements to the base form
*
* @param object &$form
* @param array &$row
*/
function buildForm(&$form, &$row)
{
$form->setAttribute("onSubmit", "return max_formValidateHtml(this.banner)");
$header = $form->createElement('header', 'header_html', $GLOBALS['strHTMLBanner'] . " - banner code");
$header->setAttribute('icon', 'icon-banner-html.gif');
$form->addElement($header);
$adPlugins = OX_Component::getComponents('3rdPartyServers');
$adPluginsNames = OX_Component::callOnComponents($adPlugins, 'getName');
$adPluginsList = array();
$adPluginsList[''] = $GLOBALS['strAdserverTypeGeneric'];
$adPluginsList['none'] = $GLOBALS['strDoNotAlterHtml'];
foreach ($adPluginsNames as $adPluginKey => $adPluginName) {
$adPluginsList[$adPluginKey] = $adPluginName;
}
$htmlG['textarea'] = $form->createElement('textarea', 'htmltemplate', null, array('class' => 'code', 'cols' => '45', 'rows' => '10', 'wrap' => 'off', 'dir' => 'ltr', 'style' => 'width:550px;'));
$aSelectAttributes = array('id' => 'adserver', 'style' => 'margin-left: 15px;width:230px');
$htmlG['select'] = HTML_QuickForm::createElement('select', 'adserver', $GLOBALS['strAlterHTML'], $adPluginsList, $aSelectAttributes);
$form->addGroup($htmlG, 'html_banner_g', null, array("<br>", ""), false);
$form->addElement('advcheckbox', 'iframe_friendly', $GLOBALS['strIframeFriendly']);
if ($row['bannerid'] && ($row['url'] || $row['target'])) {
// The "url" and "target" elements remain as part of the form definition
// for HTML banners only for existing banners that have either
// url or target already set.
$form->addElement('header', 'header_b_links', "Banner link");
$form->addElement('text', 'url', $GLOBALS['strURL']);
$form->addElement('text', 'target', $GLOBALS['strTarget']);
}
$form->addElement('header', 'header_b_display', 'Banner display');
$sizeG['width'] = $form->createElement('text', 'width', $GLOBALS['strWidth'] . ":");
$sizeG['width']->setSize(5);
$sizeG['height'] = $form->createElement('text', 'height', $GLOBALS['strHeight'] . ":");
$sizeG['height']->setSize(5);
if (!empty($row['bannerid'])) {
$sizeG['height']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");');
$sizeG['width']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");');
}
$form->addGroup($sizeG, 'size', $GLOBALS['strSize'], " ", false);
$form->addElement('hidden', 'ext_bannertype', $this->getComponentIdentifier());
//validation rules
$translation = new OX_Translation();
$widthRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strWidth'])), 'required');
$heightRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strHeight'])), 'required');
$numericRule = array($GLOBALS['strNumericField'], 'numeric');
$form->addGroupRule('size', array('width' => array($widthRequiredRule, $numericRule), 'height' => array($heightRequiredRule, $numericRule)));
}
示例14: locateComponents
/**
* A private method to locate and instantiate all components that
* use the deliveryLog extension, and are in installed plugins, storing
* them in an array, grouped by the component's destination statistics
* table -- this will provide all of the plugin components that use
* the deliveryLog extension (i.e. have bucket-based delivery data that
* needs to be migrated to statistics tables), grouped by the detsination
* statistics tables (so that all components that have data migrated to
* the same table can be migrated in the one call).
*
* @access private
* @return array An array of plugins components, as described above.
*/
private function locateComponents()
{
$aSummariseComponents = array();
foreach ($this->aPackages as $aPluginInfo) {
foreach ($aPluginInfo['contents'] as $aContents) {
if ($aContents['extends'] == 'deliveryLog') {
foreach ($aContents['components'] as $aComponent) {
$oComponent =& OX_Component::factory('deliveryLog', $aContents['name'], $aComponent['name']);
if ($oComponent->enabled) {
$destinationTable = $oComponent->getStatisticsTableName();
$aSummariseComponents[$destinationTable][get_class($oComponent)] = $oComponent;
}
}
}
}
}
return $aSummariseComponents;
}
示例15: staticGetAuthPlugin
/**
* Returns authentication plugin
*
* @static
* @param string $authType
* @return Plugins_Authentication
*/
static function staticGetAuthPlugin()
{
static $authPlugin;
static $authPluginType;
if (!isset($authPlugin) || $authPluginType != $authType) {
$aConf = $GLOBALS['_MAX']['CONF'];
if (!empty($aConf['authentication']['type'])) {
$authType = $aConf['authentication']['type'];
$authPlugin = OX_Component::factoryByComponentIdentifier($authType);
}
if (!$authPlugin) {
// Fall back to internal
$authType = 'none';
$authPlugin = new Plugins_Authentication();
}
if (!$authPlugin) {
OA::debug('Error while including authentication plugin and unable to fallback', PEAR_LOG_ERR);
}
$authPluginType = $authType;
}
return $authPlugin;
}