| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar_color.inc,v 1.1.2.7 2008/10/05 21:08:57 quicksketch Exp $ |
// $Id: fivestar_color.inc,v 1.1.2.8 2009/04/10 18:20:59 quicksketch Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 21 |
'#description' => t('A custom color widget must be selected to choose colors. Only the selected widget will be previewed.'), |
'#description' => t('A custom color widget must be selected to choose colors. Only the selected widget will be previewed.'), |
| 22 |
); |
); |
| 23 |
|
|
| 24 |
|
$disabled = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE; |
| 25 |
|
if ($disabled) { |
| 26 |
|
$form['#description'] = t('Custom colors are only supported when the <a href="!url">download method</a> is set to public.', array('!url' => url('admin/settings/file-system'))); |
| 27 |
|
} |
| 28 |
|
|
| 29 |
// Create the list of available schemes. |
// Create the list of available schemes. |
| 30 |
$options = array( |
$options = array( |
| 31 |
'#fff633,#f5d000,#d2e7f9,#027AC6,#cccccc,#dfdfdf' => t('Blue Lagoon (default)'), |
'#fff633,#f5d000,#d2e7f9,#027AC6,#cccccc,#dfdfdf' => t('Blue Lagoon (default)'), |
| 54 |
'#title' => t('Color display'), |
'#title' => t('Color display'), |
| 55 |
'#options' => array('default' => t('Default display'), 'solid' => t('Solid color'), 'gradient' => t('Gradient')), |
'#options' => array('default' => t('Default display'), 'solid' => t('Solid color'), 'gradient' => t('Gradient')), |
| 56 |
'#default_value' => variable_get('fivestar_color_type', 'solid'), |
'#default_value' => variable_get('fivestar_color_type', 'solid'), |
| 57 |
|
'#access' => !$disabled, |
| 58 |
); |
); |
| 59 |
|
|
| 60 |
// Add scheme selector. |
// Add scheme selector. |
| 63 |
'#title' => t('Color set'), |
'#title' => t('Color set'), |
| 64 |
'#options' => $options, |
'#options' => $options, |
| 65 |
'#default_value' => isset($options[$scheme_default]) ? $scheme_default : '', |
'#default_value' => isset($options[$scheme_default]) ? $scheme_default : '', |
| 66 |
|
'#access' => !$disabled, |
| 67 |
); |
); |
| 68 |
|
|
| 69 |
// Add palette fields. |
// Add palette fields. |
| 77 |
'matte' => t('Matte color'), |
'matte' => t('Matte color'), |
| 78 |
); |
); |
| 79 |
|
|
| 80 |
$form['fivestar_colors']['#tree'] = TRUE; |
$form['fivestar_colors'] = array( |
| 81 |
$form['fivestar_colors']['#theme'] = 'fivestar_color_palette'; |
'#tree' => TRUE, |
| 82 |
|
'#access' => !$disabled, |
| 83 |
|
); |
| 84 |
foreach ($names as $key => $name) { |
foreach ($names as $key => $name) { |
| 85 |
$form['fivestar_colors'][$key] = array( |
$form['fivestar_colors'][$key] = array( |
| 86 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 90 |
); |
); |
| 91 |
} |
} |
| 92 |
|
|
| 93 |
|
if ($disabled) { |
| 94 |
|
$form['fivestar_color_type']['#value'] = 'default'; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
return $form; |
return $form; |
| 98 |
} |
} |
| 99 |
|
|
| 101 |
* Theme color form. |
* Theme color form. |
| 102 |
*/ |
*/ |
| 103 |
function theme_fivestar_color_form($form) { |
function theme_fivestar_color_form($form) { |
| 104 |
|
if ($form['#access'] == FALSE) { |
| 105 |
|
return ''; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
// Add Farbtastic color picker. |
// Add Farbtastic color picker. |
| 109 |
drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE); |
drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE); |
| 110 |
drupal_add_js(drupal_get_path('module', 'fivestar') .'/js/fivestar-color.js'); |
drupal_add_js(drupal_get_path('module', 'fivestar') .'/js/fivestar-color.js'); |