You are here

function panels_image_edit_validate in Image 5.2

Validate a image.

1 string reference to 'panels_image_edit_validate'
image_image_panels_content_types in content_types/image.inc
Callback function to supply a list of content types.

File

content_types/image.inc, line 140

Code

function panels_image_edit_validate($form, $form_values) {
  if (!$form_values['validate_me']) {
    return;
  }
  $nid = $form_values['nid'];
  $preg_matches = array();
  $match = preg_match('/\\[nid: (\\d+)\\]/', $nid, $preg_matches);
  if (!$match) {
    $match = preg_match('/^nid: (\\d+)/', $nid, $preg_matches);
  }
  if ($match) {
    $nid = $preg_matches[1];
  }
  if (is_numeric($nid)) {
    $node = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.type = 'image'"), $nid));
  }
  else {
    $node = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE LOWER(n.title) = LOWER('%s') AND n.type = 'image'"), $nid));
  }
  if ($node) {
    form_set_value($form['nid'], $node->nid);
  }
  if (!($node || preg_match('/^[@%]\\d+$/', $nid))) {
    form_error($form['nid'], t('Invalid image'));
  }
}