patterns.inc in Patterns 5
File
components/patterns.inc
View source
<?php
function patterns_patterns($op, $id = null, &$data = null) {
switch ($op) {
case 'tags':
return array(
'pattern',
);
break;
case 'actions':
return array(
'patterns_enable_pattern' => t('Enable pattern'),
'patterns_disable_pattern' => t('Disable pattern'),
);
break;
case 'summary':
if ($id == 'patterns_enable_pattern') {
return t('Enabling pattern %pattern', array(
'%pattern' => $data,
));
}
else {
return t('Disabling pattern %pattern', array(
'%pattern' => $data['value'],
));
}
break;
case 'prepare':
break;
case 'pre-validate':
break;
case 'form_id':
$status = db_result(db_query('SELECT status FROM {patterns} WHERE name = "%s"', $data['value']));
if ($data['delete']) {
if ($status) {
return 'patterns_disable_pattern';
}
else {
return;
}
}
else {
if (!$status) {
return 'patterns_enable_pattern';
}
else {
return;
}
}
break;
case 'build':
$data['op'] = t('Confirm');
$data['confirm'] = 1;
return $data;
break;
case 'validate':
if (!patterns_get_pattern($data['value'])) {
return t('Invalid pattern');
}
break;
case 'params':
$pattern = patterns_get_pattern($data['value']);
return $pattern->pid;
break;
case 'reverse':
if ($data['delete']) {
unset($data['delete']);
}
else {
$data['delete'] = true;
}
return $data;
break;
}
}