function system_patterns_prepare in Patterns 7
Same name and namespace in other branches
- 7.2 patterns_components/components/system.inc \system_patterns_prepare()
File
- patterns_components/
components/ system.inc, line 83
Code
function system_patterns_prepare($action, $tag, &$data) {
if ($tag == 'theme') {
if ($data['value']) {
$data['theme_default'] = $data['value'];
}
}
elseif ($tag == 'modules') {
// Make a <modules>modulename</modules> style tag work
if (is_string($data) || isset($data['value']) && !isset($data[0])) {
$data = array(
$data,
);
}
// Ensure proper data format for cases when <modules> tag contains
// only single <module> tag.
if (!empty($data['module']) && is_string($data['module'])) {
$data[0]['value'] = $data['module'];
unset($data['module']);
}
foreach ($data as &$item) {
// Ensure that modules with tags like <module>modulename</module>
// are represented as an array instead of a string
if (is_string($item)) {
$item = array(
'value' => $item,
);
}
}
// proccess alias for delete
if (isset($data['disable']) && !isset($data['delete'])) {
$data['delete'] = $data['disable'];
}
unset($data['disable']);
}
elseif ($tag == 'form') {
}
else {
switch ($tag) {
case 'variable':
// Turn <variable>value</variable> style tag function the same as <variables>
$tag = 'variables';
$data = array(
$data,
);
case 'variables':
// Make a <variables>modulename</variables> style tag work
if (!$data[0]) {
if ($data['variable'] && isset($data['variable'][0])) {
$data = $data['variable'];
unset($data['variable']);
}
elseif ($data['variable'] && isset($data['variable']['value'])) {
$data[0] = $data['variable'];
unset($data['variable']);
}
else {
$temp = $data;
$data[0] = $temp;
unset($data['id'], $data['value'], $data['delete']);
}
}
for ($i = 0, $total = count($data); $i < $total; $i++) {
$item =& $data[$i];
if (!isset($item['value']) && (!isset($item['delete']) || !$item['delete'])) {
$value = $item;
unset($value['name']);
$item = array(
'name' => $item['name'],
'value' => $value,
);
}
}
break;
}
}
// TODO: other tags
return patterns_results();
}