function factory($class, $aAd = null, $data = null) { if (class_exists($class)) { $ad = new $class(); if (is_null($data)) { $data = $this->data; } if (is_null($aAd)) { $ad->active = true; $ad->name = OX_Tools::generate_name($ad->network_name); } else { $ad->name = $aAd['name']; $ad->id = $aAd['id']; $ad->active = $aAd['active']; $aProperties = Advman_Tools::get_properties_from_array($aAd); $ad->p = $aProperties; } if (empty($data['networks'][$class])) { $ad->np = $ad->get_network_property_defaults(); } else { $ad->np = $data['networks'][$class]; } return $ad; } else { return false; } }
function adsensem_upgrade_ad_settings(&$data) { $ads = array(); foreach ($data['ads'] as $id => $ad) { $ad['id'] = $id; if (!isset($ad['name'])) { $base = 'ad'; if (!empty($ad['class'])) { $class = $ad['class']; $tmp = new $class(); $base = $tmp->network_name; } $ad['name'] = OX_Tools::generate_name($base); } // add active if (!isset($ad['active'])) { $ad['active'] = true; } // remove title if (isset($ad['title'])) { unset($ad['title']); } // Make sure that any settings under 'color-url' are now under 'color-link' if (!empty($ad['color-url']) && empty($ad['color-link'])) { $ad['color-link'] = $ad['color-url']; } unset($ad['color-url']); // Set the OpenX Market if (!isset($ad['openx-market'])) { $ad['openx-market'] = false; } // Set the OpenX Market CPM if (!isset($ad['openx-market-cpm'])) { $ad['openx-market-cpm'] = '0.20'; } // Set the Weight if (!isset($ad['weight'])) { $ad['weight'] = '1'; } // Changed the 'hide link url' field to 'status' (for cj ads) if (isset($ad['hide-link-url'])) { $ad['status'] = $ad['hide-link-url']; unset($ad['hide-link-url']); } // Make sure width and height are correct if (empty($ad['width']) || empty($ad['height'])) { $format = $ad['adformat']; if (!empty($format) && $format != 'custom') { list($width, $height, $null) = split('[x]', $format); $ad['width'] = $width; $ad['height'] = $height; } } // Make sure that there is ad code if (empty($ad['code'])) { Advman_Upgrade::_get_code($ad); } // remove some variables... $aVars = array('codemethod', 'networkName', 'shortName', 'url'); foreach ($aVars as $var) { if (isset($ad[$var])) { unset($ad[$var]); } } $ads[$id] = $ad; } $data['ads'] = $ads; }