You are here

function dfp_breakpoints_trim in Doubleclick for Publishers (DFP) 7.2

Same name and namespace in other branches
  1. 7 dfp.admin.inc \dfp_breakpoints_trim()

Helper function that takes a form_state['values'] and removes empty breakpoints.

1 call to dfp_breakpoints_trim()
dfp_breakpoints_form_validate in ./dfp.admin.inc
Validation function used by the breakpoints form.

File

./dfp.admin.inc, line 525
Admin forms and functinality for DFP ads.

Code

function dfp_breakpoints_trim(&$values, $parent = 'breakpoints') {
  foreach ($values as $key => &$val) {
    if ($key === $parent) {

      // We found the browser_size values.
      foreach ($val as $k => $v) {
        if (empty($val[$k]['browser_size']) && empty($val[$k]['ad_sizes'])) {
          unset($val[$k]);
        }
      }

      // Reset the array indexes to prevent wierd behavior caused by a
      // breakpoint being removed in the middle of the array.
      $val = array_values($val);
      break;
    }
    elseif (is_array($val)) {
      dfp_breakpoints_trim($val, $parent);
    }
  }
}