You are here

function pathauto_patterns_prepare in Patterns 7

Same name and namespace in other branches
  1. 7.2 patterns_components/components/pathauto.inc \pathauto_patterns_prepare()

File

patterns_components/components/pathauto.inc, line 60

Code

function pathauto_patterns_prepare($action, $tag, &$data = NULL) {

  // dirty fix for the null/0/false/'' problem
  if (isset($data['pathauto_verbose']) && $data['pathauto_verbose'] === 0) {
    $data['pathauto_verbose'] = NULL;
  }
  if (isset($data['pathauto_reduce_ascii']) && $data['pathauto_reduce_ascii'] === 0) {
    $data['pathauto_reduce_ascii'] = NULL;
  }
  $datacopy = $data;
  if ($tag == "pathauto_patterns" || $tag == "pathauto") {
    foreach ($datacopy as $key => $value) {
      if (strpos($key, 'pathauto') !== FALSE) {
        continue;
      }
      if (is_array($value)) {
        if ($key != "update") {
          foreach ($value as $i => $v) {
            $new = 'pathauto_' . $i . '_' . $key;
            $data[$new] = $v;
            unset($data[$key][$i]);
          }
          unset($data[$key]);
        }
        elseif ($key == "update") {
          foreach ($value as $i => $v) {
            $new = $i . '_pathauto_bulk_update_batch_process';
            if ($v == 1) {
              $data[$key][$new] = $new;
            }
            unset($data[$key][$i]);
          }
        }
      }
      elseif (substr($key, 0, 9) != 'pathauto_') {
        $new = 'pathauto_' . $key;
        $data[$new] = $value;
        unset($data[$key]);
      }
    }
  }
  elseif ($tag == "url_alias") {
    if ($action == PATTERNS_DELETE) {
      if (isset($data['pid'])) {
        $data['path']['pid'] = $data['pid'];
      }
      $data['values']['confirm'] = 1;
    }
  }
  return patterns_results();
}