You are here

function panels_node_content_edit_validate in Panels 6.2

Validate a node.

1 string reference to 'panels_node_content_edit_validate'
panels_node_panels_content_types in panels_node_content/panels_node_content.module
Implementation of hook_panels_content_types()

File

panels_node_content/panels_node_content.module, line 190
panels_node_content.module

Code

function panels_node_content_edit_validate($form, &$form_state) {
  if (!$form_state['values']['validate_me']) {
    return;
  }
  $nid = $form_state['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"), $nid));
  }
  else {
    $node = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE LOWER(n.title) = LOWER('%s')"), $nid));
  }
  if ($node) {
    $form_state['values']['nid'] = $node->nid;
  }
  if (!($node || preg_match('/^[@%]\\d+$/', $nid))) {
    form_error($form['nid'], t('Invalid node'));
  }
}