function OX_Delivery_Common_hook($hookName, $aParams = array(), $functionName = '') { $return = null; if (!empty($functionName)) { $aParts = explode(':', $functionName); if (count($aParts) === 3) { $functionName = OX_Delivery_Common_getFunctionFromComponentIdentifier($functionName, $hookName); } if (function_exists($functionName)) { $return = call_user_func_array($functionName, $aParams); } } else { if (!empty($GLOBALS['_MAX']['CONF']['deliveryHooks'][$hookName])) { $return = array(); $hooks = explode('|', $GLOBALS['_MAX']['CONF']['deliveryHooks'][$hookName]); foreach ($hooks as $identifier) { $functionName = OX_Delivery_Common_getFunctionFromComponentIdentifier($identifier, $hookName); if (function_exists($functionName)) { OX_Delivery_logMessage('calling on ' . $functionName, 7); $return[$identifier] = call_user_func_array($functionName, $aParams); } } } } return $return; }
function OX_Delivery_Common_hook($hookName, $aParams = array(), $functionName = '') { $return = null; // When a $functionname is passed in we use that function/component-identifier and execute the hook if (!empty($functionName)) { // Right now, we're allowing either a plain function to be executed, or a component-identifier // we may remove the ability to pass a plain function in the future $aParts = explode(':', $functionName); if (count($aParts) === 3) { $functionName = OX_Delivery_Common_getFunctionFromComponentIdentifier($functionName, $hookName); } if (function_exists($functionName)) { $return = call_user_func_array($functionName, $aParams); } } else { // When no $functionName is passed in, we execute all components which are registered for this hook if (!empty($GLOBALS['_MAX']['CONF']['deliveryHooks'][$hookName])) { $return = array(); $hooks = explode('|', $GLOBALS['_MAX']['CONF']['deliveryHooks'][$hookName]); foreach ($hooks as $identifier) { $functionName = OX_Delivery_Common_getFunctionFromComponentIdentifier($identifier, $hookName); if (function_exists($functionName)) { $return[$identifier] = call_user_func_array($functionName, $aParams); } } } } return $return; }
function _adSelectCommon($aAds, $context, $source, $richMedia) { OX_Delivery_Common_hook('preAdSelect', array(&$aAds, &$context, &$source, &$richMedia)); if (!empty($aAds['ext_adselection'])) { $adSelectFunction = OX_Delivery_Common_getFunctionFromComponentIdentifier($aAds['ext_adselection'], 'adSelect'); } if (empty($adSelectFunction) || !function_exists($adSelectFunction)) { $adSelectFunction = '_adSelect'; } if (!empty($aAds['count_active'])) { if (isset($aAds['zone_companion']) && isset($context)) { foreach ($context as $contextEntry) { if (isset($contextEntry['==']) && preg_match('/^companionid:/', $contextEntry['=='])) { if ($aLinkedAd = _adSelectInnerLoop($adSelectFunction, $aAds, $context, $source, $richMedia, true)) { return $aLinkedAd; } } } } $aLinkedAd = _adSelectInnerLoop($adSelectFunction, $aAds, $context, $source, $richMedia); if (is_array($aLinkedAd)) { return $aLinkedAd; } } return false; }
function _getAdRenderFunction($aBanner, $richMedia = true) { $functionName = false; if (!empty($aBanner['ext_bannertype'])) { return OX_Delivery_Common_getFunctionFromComponentIdentifier($aBanner['ext_bannertype'], 'adRender'); } else { switch ($aBanner['contenttype']) { case 'gif': case 'jpeg': case 'png': $functionName = '_adRenderImage'; break; case 'swf': if ($richMedia) { $functionName = '_adRenderFlash'; } else { $functionName = '_adRenderImage'; } break; case 'txt': $functionName = '_adRenderText'; break; default: switch ($aBanner['type']) { case 'html': $functionName = '_adRenderHtml'; break; case 'url': // External banner without a recognised content type - assume image... $functionName = '_adRenderImage'; break; case 'txt': $functionName = '_adRenderText'; break; default: $functionName = '_adRenderHtml'; break; } break; } } return $functionName; }