| 1 |
<?php |
<?php |
| 2 |
// $Id: image_cycle.module,v 1.2 2008/12/29 22:36:42 boombatower Exp $ |
// $Id: image_cycle.module,v 1.3 2009/05/01 02:42:35 boombatower Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Create an image slideshow from images in a gallery using the jQuery Cycle plugin. |
* Create an image slideshow from images in a gallery using the jQuery Cycle plugin. |
| 62 |
$form['image_cycle']['effect'] = array( |
$form['image_cycle']['effect'] = array( |
| 63 |
'#type' => 'select', |
'#type' => 'select', |
| 64 |
'#title' => t('Effect'), |
'#title' => t('Effect'), |
| 65 |
|
'#description' => t('Please note that the available effects will depend on which version of the jQuery Cycle Plugin ' . |
| 66 |
|
'is installed.'), |
| 67 |
'#options' => array( |
'#options' => array( |
| 68 |
'blindX', |
'blindX', |
| 69 |
'blindY', |
'blindY', |
| 99 |
$form['image_cycle']['parameters'] = array( |
$form['image_cycle']['parameters'] = array( |
| 100 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 101 |
'#title' => t('Parameters'), |
'#title' => t('Parameters'), |
| 102 |
'#description' => t('Custom parameters to pass with the effect. Place each parameter on a line in the format KEY:VALUE.' . |
'#description' => t('Custom parameters to pass with the effect. Place each parameter on a line in the format KEY:VALUE. ' . |
| 103 |
'Leave blank for default effect settings.'), |
'Leave blank for default effect settings. ' . |
| 104 |
|
'See the <a href="@reference">jQuery Cycle Plugin - Option Reference</a> for a list options and an ' . |
| 105 |
|
'explaination of what they do.', |
| 106 |
|
array('@reference' => 'http://malsup.com/jquery/cycle/options.html')), |
| 107 |
'#default_value' => '', |
'#default_value' => '', |
| 108 |
); |
); |
| 109 |
|
|
| 110 |
|
// Implode paramters. |
| 111 |
$parameters = variable_get('image_cycle_parameters_' . $form['vid']['#value'], array()); |
$parameters = variable_get('image_cycle_parameters_' . $form['vid']['#value'], array()); |
| 112 |
foreach ($parameters as $key => $value) { |
foreach ($parameters as $key => $value) { |
| 113 |
$form['image_cycle']['parameters']['#default_value'] .= "$key: $value\n"; |
$form['image_cycle']['parameters']['#default_value'] .= "$key: $value\n"; |
| 116 |
$form['image_cycle']['css'] = array( |
$form['image_cycle']['css'] = array( |
| 117 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 118 |
'#title' => t('CSS'), |
'#title' => t('CSS'), |
| 119 |
'#description' => t('Custom CSS for the slideshow. The images will be encapsulated by <em>image_cycle_pictures</em>.'), |
'#description' => t('Custom CSS for the slideshow. The images will be encapsulated by <em>div.image_cycle_pictures</em>.'), |
| 120 |
'#default_value' => variable_get('image_cycle_css_' . $form['vid']['#value'], '') |
'#default_value' => variable_get('image_cycle_css_' . $form['vid']['#value'], '') |
| 121 |
); |
); |
| 122 |
} |
} |
| 128 |
function image_cycle_gallery_submit($form, &$form_state) { |
function image_cycle_gallery_submit($form, &$form_state) { |
| 129 |
variable_set('image_cycle_effect_' . $form_state['values']['vid'], $form_state['values']['image_cycle']['effect']); |
variable_set('image_cycle_effect_' . $form_state['values']['vid'], $form_state['values']['image_cycle']['effect']); |
| 130 |
|
|
| 131 |
|
// Explode parameters by line and key => value pair. |
| 132 |
$parameters_input = explode("\n", $form_state['values']['image_cycle']['parameters']); |
$parameters_input = explode("\n", $form_state['values']['image_cycle']['parameters']); |
| 133 |
$parameters = array(); |
$parameters = array(); |
| 134 |
foreach ($parameters_input as $parameter) { |
foreach ($parameters_input as $parameter) { |
| 156 |
$css = variable_get('image_cycle_css_' . $term->vid, ''); |
$css = variable_get('image_cycle_css_' . $term->vid, ''); |
| 157 |
|
|
| 158 |
$out = ''; |
$out = ''; |
| 159 |
// drupal_set_title($term->name); TODO |
drupal_set_title($term->name); |
| 160 |
drupal_add_js(drupal_get_path('module', 'image_cycle') . '/jquery.cycle.js'); |
drupal_add_js(drupal_get_path('module', 'image_cycle') . '/jquery.cycle.js'); |
| 161 |
if ($css) { |
if ($css) { |
| 162 |
$out .= '<style>' . $css . '</style>'; |
$out .= '<style>' . $css . '</style>'; |