View source
<?php
function color_patterns($data = NULL) {
$files = array(
'modules/system/system.module',
'modules/system/system.admin.inc',
);
$actions['color'] = array(
PATTERNS_INFO => t('Setting color'),
PATTERNS_MODIFY => array(
'system_theme_settings',
),
PATTERNS_FILES => $files,
PATTERNS_EXPORT => array(
PATTERNS_EXPORT_ALL => 'color_patterns_export_all_color',
),
);
return $actions;
}
function color_patterns_export_all_color($args = NULL, &$result = NULL) {
$themes = system_rebuild_theme_data();
$result = array();
foreach ($themes as $voc) {
if (!empty($voc->info['hidden'])) {
continue;
}
if (color_get_info($voc->name)) {
$vocp = array(
'palette' => variable_get('color_' . $voc->name . '_palette', array()),
);
$data = array(
'tag' => 'color',
'theme' => $voc->name,
);
$data = array_merge($data, $vocp);
$current_scheme = variable_get('color_' . $voc->name . '_palette', array());
if (empty($current_scheme)) {
$scheme_name = array(
'scheme' => 'default',
);
$data = array_merge($data, $scheme_name);
}
$action = array(
PATTERNS_MODIFY => $data,
);
array_push($result, $action);
}
}
return $result;
}
function color_patterns_get_arguments($action, $tag, $form_id, &$loop = FALSE) {
$return = array();
$themes = system_rebuild_theme_data();
$loop = TRUE;
foreach ($themes as $voc) {
if (!empty($theme->info['hidden'])) {
continue;
}
if (color_get_info($voc->name)) {
array_push($return, array(
$voc->name,
));
}
}
return $return;
}
function color_patterns_prepare($action, $tag, &$data) {
if (!isset($data['scheme'])) {
$data['scheme'] = '';
}
return patterns_results();
}
function color_patterns_validate($action, $tag, &$data) {
$status = PATTERNS_SUCCESS;
$msg = '';
foreach ($data['palette'] as $key => $color) {
if (!preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color)) {
$msg = t('%name must be a valid hexadecimal CSS color value.', array(
'%name' => $data['palette'][$key],
));
break;
}
}
return patterns_results($status, $msg);
}
function color_patterns_build($action, $tag, &$data, $form_id) {
return patterns_results(PATTERNS_SUCCESS, t('Execution successful'), $data);
}
function color_patterns_params($action, $form_id, &$data, &$a) {
$result = array(
$data['theme'],
);
return patterns_results(PATTERNS_SUCCESS, t('Execution successful'), $result);
}
function color_patterns_cleanup($action, $tag, &$data) {
return patterns_results();
}
function color_patterns_callbacks($action, $tag, &$data) {
$desc = color_patterns();
$result = $desc[$tag][$action];
return patterns_results(PATTERNS_SUCCESS, t('Execution successful'), $result);
}