pathauto.inc in Patterns 5
File
components/pathauto.inc
View source
<?php
function pathauto_patterns($op, $id = null, &$data = null) {
switch ($op) {
case 'tags':
return array(
'pathauto',
);
break;
case 'actions':
return array(
'pathauto_admin_settings' => t('Setup pathauto'),
);
break;
case 'summary':
return t('Setup pathauto urls');
break;
case 'prepare':
foreach ($data as $key => $value) {
if (is_array($value)) {
$mappings = array(
'default' => 'pattern',
);
$skip = array(
'bulkupdate',
'applytofeeds',
);
foreach ($value as $i => $v) {
if (in_array($i, $skip)) {
$new = $key . '_' . $i;
}
else {
if (array_key_exists($i, $mappings)) {
$new = $key . '_' . $mappings[$i];
}
else {
$new = $key . '_' . $i . '_pattern';
}
}
$data[$new] = $v;
unset($data[$key][$i]);
}
unset($data[$key]);
}
}
$mappings = array(
'update' => 'update_action',
);
foreach ($data as $key => $value) {
if (array_key_exists($key, $mappings)) {
$new = $mappings[$key];
}
else {
$new = 'pathauto_' . $key;
}
if (strpos($key, 'pathauto_') === FALSE) {
$data[$new] = $value;
unset($data[$key]);
}
}
break;
case 'pre-validate':
break;
case 'form_id':
return 'pathauto_admin_settings';
break;
case 'build':
if ($data['reset']) {
foreach ($data as $key => $value) {
$data[$key] = '';
}
unset($data['reset']);
}
return $data;
break;
case 'validate':
break;
case 'params':
break;
case 'reverse':
$data['reset'] = true;
break;
case 'cleanup':
unset($_POST['op']);
break;
}
}