You are here

function google_admanager_update_6300 in DFP Small Business (Google Ad Manager) 6.3

Convert the ad zones to the new format.

File

./google_admanager.install, line 124
Install, update and uninstall functions for the google_admanager module.

Code

function google_admanager_update_6300() {
  $ret = array();
  $list = variable_get('google_admanager_ad_slots', array());
  $slots = array();
  if (!is_array($list)) {
    $list = str_replace(array(
      "\r",
      "\t",
      "\0",
      "\v",
      " ",
    ), '', $list);
    foreach (explode("\n", $list) as $name) {
      if (preg_match('/(\\d+)[x\\*](\\d+)(_.*|)$/', $name, $match)) {
        $width = $match[1];
        $height = $match[2];
      }
      else {
        $width = $height = '';
      }
      $slots[] = array(
        'name' => $name,
        'height' => $height,
        'width' => $width,
      );
    }
    variable_set('google_admanager_ad_slots', $slots);
  }
  return $ret;
}