You are here

public function FeedsQueryPathParser::configFormValidate in Feeds QueryPath Parser 7

Same name and namespace in other branches
  1. 6 FeedsQueryPathParser.inc \FeedsQueryPathParser::configFormValidate()

Override parent::sourceFormValidate().

1 call to FeedsQueryPathParser::configFormValidate()
FeedsQueryPathParser::sourceFormValidate in ./FeedsQueryPathParser.inc
Override parent::sourceFormValidate().

File

./FeedsQueryPathParser.inc, line 276
Provides the class for FeedsQueryPathParser.

Class

FeedsQueryPathParser
@file

Code

public function configFormValidate(&$values) {
  $config = FALSE;
  $mappings = $this
    ->getOwnMappings();
  $doc = '<html></html>';
  if (isset($values['querypath'])) {
    $values = $values['querypath'];
    $config = TRUE;
  }
  $values['context'] = trim($values['context']);
  try {
    $this
      ->includeQueryPath();
    qp($doc, $values['context']);
  } catch (CSSParseException $e) {
    $elem = 'feeds][FeedsQueryPathParser][querypath][context';
    if ($config) {
      $elem = 'querypath][context';
    }
    form_set_error($elem, $e
      ->getMessage());
  }
  foreach ($values['sources'] as $key => &$query) {
    $query = trim($query);
    try {
      qp($doc, $query);
    } catch (CSSParseException $e) {

      // Check for variable substitution.
      $variable_present = FALSE;

      // Our variable substitution options can cause syntax errors, check
      // if we're doing that.
      foreach ($mappings as $target) {
        if (strpos($query, '{' . $target . '}') !== FALSE) {
          $variable_present = TRUE;
        }
      }
      if (!$variable_present) {
        $elem = 'feeds][FeedsQueryPathParser][querypath][sources][';
        if ($config) {
          $elem = 'querypath][sources][';
        }
        form_set_error($elem . $key, $e
          ->getMessage());
      }
    }
  }
}