You are here

function pathauto_patterns_prepare in Patterns 7.2

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

File

patterns_components/components/pathauto.inc, line 142

Code

function pathauto_patterns_prepare($action, $tag, &$data = NULL) {
  $datacopy = $data;
  if ($tag == "pathauto_patterns" || $tag == "pathauto_steeing") {
    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 ($tag == "url_alias") {
      if ($action == PATTERNS_DELETE) {
        if (isset($data['pid'])) {
          $data['path']['pid'] = $data['pid'];
        }
        $data['values']['confirm'] = 1;
      }
      if ($action == PATTERNS_MODIFY) {
        if (!isset($data['pid'])) {
        	if(isset($data['language'])){
            	 $alias= _pathauto_existing_alias_data($data['source'],$data['language']);
            }else{
            	$alias= _pathauto_existing_alias_data($data['source']);
            }
          if($alias)
           $data['pid'] =$alias->pid;
        }
      }
    }*/

  // 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;
  }
  return patterns_results();
}