You are here

function dfp_breakpoint_form_validate in Doubleclick for Publishers (DFP) 7

Same name and namespace in other branches
  1. 7.2 dfp.admin.inc \dfp_breakpoint_form_validate()

Validation function used by an individual breakpoint in the breakpoints form.

1 string reference to 'dfp_breakpoint_form_validate'
_dfp_breakpoint_form in ./dfp.admin.inc
Helper form builder for an individual breakpoint.

File

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

Code

function dfp_breakpoint_form_validate($element, &$form_state) {
  if (empty($element['browser_size']['#value']) && !empty($element['ad_sizes']['#value'])) {
    form_error($element['browser_size'], t('The browser size cannot be empty if ad size(s) exists.'));
  }
  elseif (!empty($element['browser_size']['#value']) && empty($element['ad_sizes']['#value'])) {
    form_error($element['ad_sizes'], t('The ad size(s) cannot be empty if a browser size exists. If you wish to suppress an ad slot for a given browser size, you can enter "!none" in the ad size(s) field.', array(
      '!none' => htmlspecialchars('<none>'),
    )));
  }
  if (!empty($element['browser_size']['#value']) && !empty($element['ad_sizes']['#value'])) {
    if (preg_match('/[^x|0-9]/', $element['browser_size']['#value'])) {
      form_error($element['browser_size'], t('The browser size can only contain numbers and the character x.'));
    }
    elseif ($element['ad_sizes']['#value'] != '<none>' && preg_match('/[^x|,|0-9]/', $element['ad_sizes']['#value'])) {
      form_error($element['ad_sizes'], t('The ad size(s) string can only contain numbers, the character x and commas (unless it is the special keyword "!none").', array(
        '!none' => htmlspecialchars('<none>'),
      )));
    }
  }
}