pathauto.inc in Patterns 6
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('Pathauto: Configure pathauto settings'),
);
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];
}
elseif ($key == 'taxonomy' && strpos($i, 'vid_') === 0) {
$new = $key . '_' . str_replace('vid_', '', $i) . '_pattern';
}
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 && $key != 'reset') {
$data[$new] = $value;
unset($data[$key]);
}
}
break;
case 'pre-validate':
break;
case 'form_id':
module_load_include('inc', 'pathauto', 'pathauto.admin');
return 'pathauto_admin_settings';
break;
case 'build':
if ($data['reset']) {
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'pathauto_%'");
while ($var = db_fetch_array($result)) {
variable_del($var['name']);
}
cache_clear_all('variables', 'cache');
return;
}
return $data;
break;
case 'validate':
break;
case 'params':
break;
case 'cleanup':
unset($_POST['op']);
break;
}
}