| 1 |
<?php |
<?php |
| 2 |
|
//$Id$ |
| 3 |
|
|
| 4 |
/*------------- Drupal Hooks ---------------*/ |
/*------------- Drupal Hooks ---------------*/ |
| 5 |
|
/** |
| 6 |
|
* implementation of hook_help() |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
function imagefield_gallery_help($section) { |
function imagefield_gallery_help($section) { |
| 10 |
switch ($section) { |
switch ($section) { |
| 11 |
case 'admin/help#imagefield_gallery': |
case 'admin/help#imagefield_gallery': |
| 12 |
$output = '<p>'. t('Imagefield Gallery is specifically designed to make theming and displaying imagefield images easy. The following administrative links will help you manage your imagefield galleries. Currently the system is made up of a single module that handles all the needs of the lightbox2 mechanism and a fancy themable display. Before the 1.0 version is released, this will be broken into multipl modules, one as a framework for the other. The framework will ultimately support multiple gallery types, allowing other contributors to write their own gallery extensions, and the lightbox2 mechanism will serve as a template module for others wishing to create their own contributions.') .'</p>'; |
$output = '<p>'. t('Imagefield Gallery is specifically designed to make theming and displaying imagefield images easy. The following administrative links will help you manage your imagefield galleries.') .'</p>'; |
| 13 |
|
$output .= '<p>'. t('Imagefield Gallery is currently made up of two separate modules. The first is the imagefield_gallery module which does nothing on its own. The second is the imagefield_gallery_lightbox2 module. This module allows you to create galleries of images on a node that has an imagefield on it. Imagefield_gallery is designed to work with nodes that have only one imagefield, it does not currently work with nodes that have more than one imagefield. Results cannot be garunteed in these situations. For best results set your imagefield to be a multi-value imagefield and then use the links below to administrate the look of your gallery. Imagefield_gallery works on a node by node basis, so you can set completely different css settings on nodes, even if they share the same gallery type, and same imagefield!') .'</p>'; |
| 14 |
return $output; |
return $output; |
| 15 |
} |
} |
| 16 |
} |
} |
| 17 |
|
|
| 18 |
|
/** |
| 19 |
|
* implementation of hook_menu() |
| 20 |
|
*/ |
| 21 |
|
|
| 22 |
function imagefield_gallery_menu($may_cache) { |
function imagefield_gallery_menu($may_cache) { |
| 23 |
$items = array(); |
$items = array(); |
| 24 |
|
|
| 45 |
return $items; |
return $items; |
| 46 |
} |
} |
| 47 |
|
|
| 48 |
|
/** |
| 49 |
|
* implementation of hook_nodeapi() |
| 50 |
|
* imagefield_gallery_nodeapi() is open for other gallery modules to hook into |
| 51 |
|
* this can be accomplished through a simple naming convention i.e. in the cased |
| 52 |
|
* of the lightbox2 gallery type, the function was named theme_imagefield_gallery_lightbox2 |
| 53 |
|
* This naming convention is set via the imagefield_gallery_lightbox2_settings function. |
| 54 |
|
* All hooks through out these modules use the same convention. |
| 55 |
|
*/ |
| 56 |
|
|
| 57 |
function imagefield_gallery_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { |
function imagefield_gallery_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { |
| 58 |
$types = imagefield_gallery_nodetypes(); |
switch ($op) { |
| 59 |
$var = variable_get('imagefield_gallery', array()); |
case 'view': |
| 60 |
foreach($types as $type) { |
$types = imagefield_gallery_nodetypes(); |
| 61 |
if ($var[$type['type']]['gallery'] != 'none' && !empty($var[$type['type']]['gallery'])) { |
$var = variable_get('imagefield_gallery', array()); |
| 62 |
if ($node->type == $type['type']) { |
foreach ($types as $type) { |
| 63 |
switch ($op) { |
if ($var[$type['type']]['gallery'] != 'none' && !empty($var[$type['type']]['gallery'])) { |
| 64 |
case 'view': |
if ($node->type == $type['type']) { |
| 65 |
$node->content[$type['name']] = array( |
$gallery_func = 'imagefield_gallery_'. imagefield_gallery_gallery_type($type['type']); |
| 66 |
'#value' => theme('imagefield_gallery_lightbox2', $node->$type['name'], $node->nid, $node->type), |
$node->content[$type['name']] = array( |
| 67 |
'#weight' => $node->content[$type['name']]['#weight'], |
'#value' => theme($gallery_func, $node->$type['name'], $node), |
| 68 |
); |
'#weight' => $node->content[$type['name']]['#weight'], |
| 69 |
break; |
); |
| 70 |
|
break; |
| 71 |
} |
} |
| 72 |
} |
} |
| 73 |
} |
} |
| 76 |
|
|
| 77 |
/*------------- Form & Misc Functions ---------------*/ |
/*------------- Form & Misc Functions ---------------*/ |
| 78 |
|
|
| 79 |
|
/** |
| 80 |
|
* implementation of imagefield_gallery_gallery_type() |
| 81 |
|
* @param $type |
| 82 |
|
* node type returns a gallery type. |
| 83 |
|
*/ |
| 84 |
|
|
| 85 |
|
function imagefield_gallery_gallery_type($type) { |
| 86 |
|
$var = variable_get('imagefield_gallery', array()); |
| 87 |
|
$gallery = is_array($var[$type]) ? $var[$type]['gallery'] : $var[$type]; |
| 88 |
|
return $gallery; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
/** |
| 92 |
|
* implementation of imagefield_gallery_nodetypes() |
| 93 |
|
* returns an array of node types with imagefields attached and what |
| 94 |
|
* those fields are named. |
| 95 |
|
*/ |
| 96 |
|
|
| 97 |
function imagefield_gallery_nodetypes() { |
function imagefield_gallery_nodetypes() { |
| 98 |
$types = content_types(); |
$types = content_types(); |
| 99 |
$i = 0; |
$i = 0; |
| 100 |
$nt = array(); |
$nt = array(); |
| 101 |
foreach($types as $type) { |
foreach ($types as $type) { |
| 102 |
foreach($type['fields'] as $field) { |
foreach ($type['fields'] as $field) { |
| 103 |
if($field['type'] == 'image') { |
if ($field['type'] == 'image') { |
| 104 |
$nt[$i]['type'] = $type['type']; |
$nt[$i]['type'] = $type['type']; |
| 105 |
$nt[$i]['name'] = $field['field_name']; |
$nt[$i]['name'] = $field['field_name']; |
| 106 |
$i++; |
$i++; |
| 110 |
return $nt; |
return $nt; |
| 111 |
} |
} |
| 112 |
|
|
| 113 |
|
/** |
| 114 |
|
* implementation of imagefield_gallery_get_imagecache_presets() |
| 115 |
|
* returns an array of imagecache presets with a none option |
| 116 |
|
* included. |
| 117 |
|
*/ |
| 118 |
|
|
| 119 |
|
function imagefield_gallery_get_imagecache_presets() { |
| 120 |
|
$cache = array( |
| 121 |
|
'none' => t('No Preset'), |
| 122 |
|
); |
| 123 |
|
$caches = _imagecache_get_presets(); |
| 124 |
|
foreach ($caches as $id => $name) { |
| 125 |
|
$cache[$id] = $name; |
| 126 |
|
} |
| 127 |
|
return $cache; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
/** |
| 131 |
|
* implementation of imagefield_gallery_get_gallery_types() |
| 132 |
|
* returns an array of gallery types where the imagefield_gallery_hook_settings |
| 133 |
|
* function exists. This doesn't actually fire off the |
| 134 |
|
* imagefield_gallery_hook_settings function, it's just checking |
| 135 |
|
* to make sure it exists before including it's options in the array |
| 136 |
|
*/ |
| 137 |
|
|
| 138 |
|
function imagefield_gallery_get_gallery_types() { |
| 139 |
|
$options = array(); |
| 140 |
|
$options['none'] = t('No Gallery'); |
| 141 |
|
$galleries = variable_get('imagefield_gallery_galleries', array()); |
| 142 |
|
foreach ($galleries as $key => $gallery) { |
| 143 |
|
if (function_exists('imagefield_gallery_'. $key .'_settings')) { |
| 144 |
|
$options[$key] = $gallery; |
| 145 |
|
} |
| 146 |
|
} |
| 147 |
|
return $options; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
/** |
| 151 |
|
* implementation of imagefield_gallery_content_types_submit() |
| 152 |
|
* $form_values should already be checked and scrubbed at this point |
| 153 |
|
* so we're just saving each type within the imagefield_gallery |
| 154 |
|
* variable. Doing it this way should eliminate anything that is |
| 155 |
|
* not tied to a node type. |
| 156 |
|
*/ |
| 157 |
|
|
| 158 |
function imagefield_gallery_content_types_submit($form_id, $form_values) { |
function imagefield_gallery_content_types_submit($form_id, $form_values) { |
| 159 |
$types = imagefield_gallery_nodetypes(); |
$types = imagefield_gallery_nodetypes(); |
| 160 |
$var = array(); |
$var = array(); |
| 161 |
foreach($types as $type) { |
foreach ($types as $type) { |
| 162 |
if (is_array($form_values[$type['type']])) { |
if (is_array($form_values[$type['type']])) { |
| 163 |
$var[$type['type']] = $form_values[$type['type']]; |
$var[$type['type']] = $form_values[$type['type']]; |
| 164 |
} |
} |
| 169 |
variable_set('imagefield_gallery', $var); |
variable_set('imagefield_gallery', $var); |
| 170 |
} |
} |
| 171 |
|
|
| 172 |
|
/** |
| 173 |
|
* implementation of imagefield_gallery_hook_content_types() |
| 174 |
|
* this function actually checks for the existance of other |
| 175 |
|
* functions that can hook into it and includes their forms |
| 176 |
|
* into itself as well. This allows for each gallery type |
| 177 |
|
* module to have it's own custom admin interface for selecting |
| 178 |
|
* imagecache presets or whatever you may need. |
| 179 |
|
*/ |
| 180 |
|
|
| 181 |
function imagefield_gallery_content_types() { |
function imagefield_gallery_content_types() { |
| 182 |
$types = imagefield_gallery_nodetypes(); |
$types = imagefield_gallery_nodetypes(); |
| 183 |
$cache = array( |
$cache = imagefield_gallery_get_imagecache_presets(); |
|
'none' => t('No Preset'), |
|
|
); |
|
|
$caches = _imagecache_get_presets(); |
|
|
foreach ($caches as $id => $name) { |
|
|
$cache[$id] = $name; |
|
|
} |
|
| 184 |
$var = variable_get('imagefield_gallery', array()); |
$var = variable_get('imagefield_gallery', array()); |
| 185 |
$form = array(); |
$form = array(); |
| 186 |
|
|
| 187 |
foreach($types as $type){ |
if (!$types) { |
| 188 |
if($var[$type['type']]['gallery'] == 'none' || empty($var[$type['type']]['gallery'])) { |
drupal_set_message('None of your content types have any imagefields associated with them.', 'error'); |
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
foreach ($types as $type) { |
| 192 |
|
if ($var[$type['type']]['gallery'] == 'none' || empty($var[$type['type']]['gallery'])) { |
| 193 |
$form[$type['type']] = array( |
$form[$type['type']] = array( |
| 194 |
'#type' => 'select', |
'#type' => 'select', |
| 195 |
'#title' => t('@type gallery type', array('@type' => $type['type'])), |
'#title' => t('@type gallery type', array('@type' => $type['type'])), |
| 196 |
'#default_value' => isset($var[$type['type']]['gallery']) ? $var[$type['type']]['gallery'] : 'none', |
'#default_value' => isset($var[$type['type']]['gallery']) ? $var[$type['type']]['gallery'] : 'none', |
| 197 |
'#options' => array( |
'#options' => imagefield_gallery_get_gallery_types(), |
|
'none' => t('No Gallery'), |
|
|
'lightbox' => t('Lightbox'), |
|
|
), |
|
| 198 |
'#description' => t('Please select the gallery style you would like for the @type content type.', array('@type' => $type['type'])), |
'#description' => t('Please select the gallery style you would like for the @type content type.', array('@type' => $type['type'])), |
| 199 |
'#tree' => TRUE, |
'#tree' => TRUE, |
| 200 |
); |
); |
| 201 |
} |
} |
| 202 |
else { |
else { |
| 203 |
$form[$type['type']] = array( |
$form_func = 'imagefield_gallery_'. $var[$type['type']]['gallery'] .'_content_types'; |
| 204 |
'#type' => 'fieldset', |
if (function_exists($form_func)) { |
| 205 |
'#title' => t('@type settings', array('@type' => $type['type'])), |
$form = $form_func($form, $var, $type, $cache); |
| 206 |
'#collapsible' => FALSE, |
} |
|
'#description' => t('Please select the gallery style you would like for the @type content type.', array('@type' => $type['type'])), |
|
|
'#tree' => TRUE, |
|
|
); |
|
|
$form[$type['type']]['gallery'] = array( |
|
|
'#type' => 'select', |
|
|
'#title' => t('@type gallery type', array('@type' => $type['type'])), |
|
|
'#default_value' => isset($var[$type['type']]['gallery']) ? $var[$type['type']]['gallery'] : 'none', |
|
|
'#options' => array( |
|
|
'none' => t('No Gallery'), |
|
|
'lightbox' => t('Lightbox'), |
|
|
), |
|
|
'#tree' => TRUE, |
|
|
); |
|
|
$form[$type['type']]['images'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t($type['type'] .' image settings'), |
|
|
'#collapsible' => FALSE, |
|
|
'#description' => t('Select the imagecache settings you would like to use (if any) for the @type content type', array('@type' => $type['type'])), |
|
|
'#tree' => TRUE, |
|
|
); |
|
|
$form[$type['type']]['images']['thumbnail'] = array( |
|
|
'#type' => 'select', |
|
|
'#title' => t($type['type'] .' thumbnail'), |
|
|
'#default_value' => isset($var[$type['type']]['images']['thumbnail']) ? $var[$type['type']]['images']['thumbnail'] : 'none', |
|
|
'#options' => $cache, |
|
|
'#tree' => TRUE, |
|
|
); |
|
|
$form[$type['type']]['images']['preview'] = array( |
|
|
'#type' => 'select', |
|
|
'#title' => t($type['type'] .' preview'), |
|
|
'#default_value' => isset($var[$type['type']]['images']['preview']) ? $var[$type['type']]['images']['preview'] : 'none', |
|
|
'#options' => $cache, |
|
|
'#tree' => TRUE, |
|
|
); |
|
| 207 |
} |
} |
| 208 |
} |
} |
| 209 |
return system_settings_form($form); |
return system_settings_form($form); |
| 210 |
} |
} |
| 211 |
|
|
| 212 |
|
/** |
| 213 |
|
* implementation of imagefield_gallery_hook_content_types_validate() |
| 214 |
|
* custom validate functions are all checked for existance and then |
| 215 |
|
* called via the typical naming convention. This allows for gallery |
| 216 |
|
* type modules to have independent validation for whatever forms |
| 217 |
|
* they may implement in the content types admin. |
| 218 |
|
*/ |
| 219 |
|
|
| 220 |
function imagefield_gallery_content_types_validate($form_id, $form_values, $form) { |
function imagefield_gallery_content_types_validate($form_id, $form_values, $form) { |
| 221 |
$types = imagefield_gallery_nodetypes(); |
$types = imagefield_gallery_nodetypes(); |
| 222 |
foreach ($types as $type) { |
foreach ($types as $type) { |
| 223 |
if (is_array($form_values[$type['type']]) && $form_values[$type['type']]['gallery'] != 'none') { |
$validate_func = 'imagefield_gallery_'. imagefield_gallery_gallery_type($type['type']) .'_content_types_validate'; |
| 224 |
if ($form_values[$type['type']]['images']['thumbnail'] == 'none' || $form_values[$type['type']]['images']['preview'] == 'none') { |
if (function_exists($validate_func)) { |
| 225 |
form_set_error('', t('You must select an imagecache setting for the @type content type!', array('@type' => $type['type']))); |
$validate_func($form_id, $form_values, $form); |
|
} |
|
| 226 |
} |
} |
| 227 |
} |
} |
| 228 |
if (!is_file(file_directory_path() .'/imagefield_gallery/gallery.css')) { |
if (!is_file(file_directory_path() .'/imagefield_gallery/gallery.css')) { |
| 230 |
} |
} |
| 231 |
} |
} |
| 232 |
|
|
| 233 |
|
/** |
| 234 |
|
* implementation of imagefield_gallery_hook_admin() |
| 235 |
|
* default implementation of this is to be paired with |
| 236 |
|
* the css functions of this module, as such this function |
| 237 |
|
* is intended to have an admin interface that will save |
| 238 |
|
* values for use inside a css sheet. Look at the |
| 239 |
|
* imagefield_gallery_lightbox2_admin() function for |
| 240 |
|
* more obvious details. |
| 241 |
|
*/ |
| 242 |
|
|
| 243 |
function imagefield_gallery_admin() { |
function imagefield_gallery_admin() { |
| 244 |
drupal_set_title('Imagefield Gallery Administration Page'); |
drupal_set_title('Imagefield Gallery Administration Page'); |
| 245 |
$form = array(); |
$form = array(); |
| 246 |
|
$types = imagefield_gallery_nodetypes(); |
| 247 |
$form['general'] = array( |
if (!$types) { |
| 248 |
'#type' => 'fieldset', |
drupal_set_message('None of your content types have any imagefields associated with them.', 'error'); |
|
'#title' => t('Thumbnail Attributes'), |
|
|
'#collapsible' => FALSE, |
|
|
'#description' => t('Set the width and height, in pixels, you desire your thumbnails to be.'), |
|
|
); |
|
|
$form['general']['width'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Thumbnail Width'), |
|
|
'#size' => 10, |
|
|
'#maxlength' => 4, |
|
|
'#default_value' => variable_get('thumbnail_width', 100), |
|
|
'#required' => TRUE, |
|
|
); |
|
|
$form['general']['height'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Thumbnail Height'), |
|
|
'#size' => 10, |
|
|
'#maxlength' => 4, |
|
|
'#default_value' => variable_get('thumbnail_height', 100), |
|
|
'#required' => TRUE, |
|
|
); |
|
|
$form['general']['margins'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t('Margin Attributes'), |
|
|
'#collapsible' => TRUE, |
|
|
'#collapsed' => TRUE, |
|
|
); |
|
|
$form['general']['margins']['top'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Top Margin'), |
|
|
'#default_value' => variable_get('thumbnail_top', '10'), |
|
|
'#size' => '5', |
|
|
'#maxlength' => 3, |
|
|
'#required' => TRUE, |
|
|
); |
|
|
$form['general']['margins']['right'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Right Margin'), |
|
|
'#default_value' => variable_get('thumbnail_right', '10'), |
|
|
'#size' => '5', |
|
|
'#maxlength' => 3, |
|
|
'#required' => TRUE, |
|
|
); |
|
|
$form['general']['margins']['bottom'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Bottom Margin'), |
|
|
'#default_value' => variable_get('thumbnail_bottom', '10'), |
|
|
'#size' => '5', |
|
|
'#maxlength' => 3, |
|
|
'#required' => TRUE, |
|
|
); |
|
|
$form['general']['margins']['left'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Left Margin'), |
|
|
'#default_value' => variable_get('thumbnail_left', '10'), |
|
|
'#size' => '5', |
|
|
'#maxlength' => 3, |
|
|
'#required' => TRUE, |
|
|
); |
|
|
|
|
|
$form['border'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t('Border Attributes'), |
|
|
'#collapsible' => TRUE, |
|
|
'#collapsed' => TRUE, |
|
|
); |
|
|
if (module_exists('colorpicker')) { |
|
|
$form['border']['color_style'] = array( |
|
|
'#type' => 'colorpicker', |
|
|
'#title' => t('Border Color Picker'), |
|
|
); |
|
|
|
|
|
$form['border']['color_style_textfield'] = array( |
|
|
'#type' => 'colorpicker_textfield', |
|
|
'#title' => t('Border Color'), |
|
|
'#default_value' => variable_get('color_style_textfield', '#ffffff'), |
|
|
'#colorpicker' => 'color_style', |
|
|
); |
|
| 249 |
} |
} |
| 250 |
else { |
foreach ($types as $type) { |
| 251 |
$form['border']['color_style_textfield'] = array( |
$form_func = 'imagefield_gallery_'. imagefield_gallery_gallery_type($type['type']) .'_admin'; |
| 252 |
'#type' => 'textfield', |
if (function_exists($form_func)) { |
| 253 |
'#title' => t('Border Color'), |
$form[] = $form_func($type['type']); |
| 254 |
'#default_value' => variable_get('color_style_textfield', '#ffffff'), |
} |
|
'#size' => '8', |
|
|
'#maxlength' => 7, |
|
|
'#description' => t('Please insert a color in hexidecimal value. Do NOT forget the #.'), |
|
|
'#required' => TRUE, |
|
|
); |
|
|
drupal_set_message('Installation of the colorpicker module will make your overal experience much more pleasent.'); |
|
| 255 |
} |
} |
|
$form['border']['border_style'] = array( |
|
|
'#type' => 'select', |
|
|
'#title' => t('Border Style'), |
|
|
'#default_value' => variable_get('border_style', 'none'), |
|
|
'#options' => array( |
|
|
'none' => t('No Border'), |
|
|
'hidden' => t('Hidden'), |
|
|
'dotted' => t('Dotted'), |
|
|
'dashed' => t('Dashed'), |
|
|
'solid' => t('Solid'), |
|
|
'double' => t('Double'), |
|
|
'groove' => t('Groove'), |
|
|
'ridge' => t('Ridge'), |
|
|
'inset' => t('Inset'), |
|
|
'outset' => t('Outset'), |
|
|
), |
|
|
'#description' => t('Select the border style you would like.') |
|
|
); |
|
|
$form['border']['border_width'] = array( |
|
|
'#type' => 'select', |
|
|
'#title' => t('Border Width'), |
|
|
'#default_value' => variable_get('border_width', '1px'), |
|
|
'#options' => array( |
|
|
'0' => t('No Border'), |
|
|
'1px' => t('1 Pixel'), |
|
|
'2px' => t('2 Pixels'), |
|
|
'3px' => t('3 Pixels'), |
|
|
'4px' => t('4 Pixels'), |
|
|
'5px' => t('5 Pixels'), |
|
|
'6px' => t('6 Pixels'), |
|
|
'7px' => t('7 Pixels'), |
|
|
'8px' => t('8 Pixels'), |
|
|
'9px' => t('9 Pixels'), |
|
|
'10px' => t('10 Pixels'), |
|
|
), |
|
|
'#description' => t('The Number of pixels wide you would like your border to be.'), |
|
|
); |
|
| 256 |
return system_settings_form($form); |
return system_settings_form($form); |
| 257 |
} |
} |
| 258 |
|
|
| 259 |
|
/** |
| 260 |
|
* implementation of imagefield_gallery_hook_admin_validate() |
| 261 |
|
* a validation hook for the imagefield_gallery_hook_admin |
| 262 |
|
* function |
| 263 |
|
*/ |
| 264 |
|
|
| 265 |
|
function imagefield_gallery_admin_validate($form_id, $form_values, $form) { |
| 266 |
|
$types = imagefield_gallery_nodetypes(); |
| 267 |
|
foreach ($types as $type) { |
| 268 |
|
$validate_func = 'imagefield_gallery_'. imagefield_gallery_gallery_type($type['type']) .'_admin_validate'; |
| 269 |
|
if (function_exists($validate_func)) { |
| 270 |
|
$validate_func($form_id, $form_values, $form); |
| 271 |
|
} |
| 272 |
|
} |
| 273 |
|
} |
| 274 |
|
|
| 275 |
|
/** |
| 276 |
|
* implementation of imagefield_gallery_hook_admin_submit() |
| 277 |
|
* allows for each individual gallery type module to submit |
| 278 |
|
* their own values properly. This function doesn't do |
| 279 |
|
* any submission on its own, so each gallery type must have |
| 280 |
|
* it's own submission function. This is required for |
| 281 |
|
* the admin hook. |
| 282 |
|
* imagefield_gallery_build_css() also gets called at the |
| 283 |
|
* end of this as the css file will need rebuilding after |
| 284 |
|
* submission in each case. |
| 285 |
|
*/ |
| 286 |
|
|
| 287 |
function imagefield_gallery_admin_submit($form_id, $form_values) { |
function imagefield_gallery_admin_submit($form_id, $form_values) { |
| 288 |
variable_set('thumbnail_width', $form_values['width']); |
$types = imagefield_gallery_nodetypes(); |
| 289 |
variable_set('thumbnail_height', $form_values['height']); |
foreach ($types as $type) { |
| 290 |
variable_set('color_style_textfield', $form_values['color_style_textfield']); |
$submit_func = 'imagefield_gallery_'. imagefield_gallery_gallery_type($type['type']) .'_admin_submit'; |
| 291 |
variable_set('border_style', $form_values['border_style']); |
if (function_exists($submit_func)) { |
| 292 |
variable_set('border_width', $form_values['border_width']); |
$submit_func($form_id, $form_values); |
| 293 |
variable_set('thumbnail_top', $form_values['top']); |
} |
| 294 |
variable_set('thumbnail_right', $form_values['right']); |
} |
|
variable_set('thumbnail_bottom', $form_values['bottom']); |
|
|
variable_set('thumbnail_left', $form_values['left']); |
|
| 295 |
imagefield_gallery_build_css(); |
imagefield_gallery_build_css(); |
| 296 |
} |
} |
| 297 |
|
|
| 298 |
|
/** |
| 299 |
|
* implementation of imagefield_gallery_build_css() |
| 300 |
|
* creates a css file |
| 301 |
|
* calls theme_imagefield_gallery_css_render |
| 302 |
|
*/ |
| 303 |
|
|
| 304 |
function imagefield_gallery_build_css() { |
function imagefield_gallery_build_css() { |
| 305 |
$file = 'gallery.css'; |
$file = 'gallery.css'; |
| 306 |
$csspath = file_directory_path() .'/imagefield_gallery'; |
$csspath = file_directory_path() .'/imagefield_gallery'; |
| 309 |
} |
} |
| 310 |
} |
} |
| 311 |
|
|
| 312 |
/* ---------- Theme Functions ----------- */ |
/** |
| 313 |
|
* implementation of imagefield_gallery_hook_css_render() |
| 314 |
function theme_imagefield_gallery_lightbox2($images = array(), $nid, $type) { |
* calls gallery type css_render theme functions and passes |
| 315 |
$output = ''; |
* in the type of node so that the css can be generated on |
| 316 |
$count = count($images); |
* a per node basis, allowing node types that may use the |
| 317 |
$var = variable_get('imagefield_gallery', array()); |
* same gallery type to still have unique styling on a node |
| 318 |
if ($count) { |
* type by node type basis. |
| 319 |
$i = 0; |
*/ |
|
if (is_file(file_directory_path() .'/imagefield_gallery/gallery.css')) { |
|
|
drupal_add_css(file_directory_path() .'/imagefield_gallery/gallery.css'); |
|
|
} |
|
|
else { |
|
|
imagefield_gallery_build_css(); |
|
|
drupal_add_css(file_directory_path() .'/imagefield_gallery/gallery.css'); |
|
|
} |
|
|
|
|
|
$output .= '<span class="gallery_text">'. t('Click the images below for bigger versions:') .'</span>'; |
|
|
$output .= '<div class="gallery_box">'; |
|
|
while ($i < $count) { |
|
|
|
|
|
$thumbnail = _imagecache_preset_load($var[$type]['images']['thumbnail']); |
|
|
$preview = _imagecache_preset_load($var[$type]['images']['preview']); |
|
|
$imagecache_path = base_path() . file_directory_path() .'/imagecache/'. $preview .'/'. $images[$i]['filepath']; |
|
|
$output .= '<div class="image_field_thumbnail">'; |
|
|
$output .= '<a href="'. $imagecache_path .'" rel="lightbox['. $nid .']">'; |
|
|
$output .= theme('imagecache', $thumbnail, $images[$i]['filepath']); |
|
|
$output .= '</a>'; |
|
|
$output .= '</div>'; |
|
|
$i++; |
|
|
|
|
|
} |
|
|
|
|
|
$output .= '<div class="clear_both"></div>'; |
|
|
$output .= '</div>'; |
|
|
|
|
|
|
|
|
} |
|
|
return $output; |
|
|
} |
|
| 320 |
|
|
| 321 |
function theme_imagefield_gallery_css_render() { |
function theme_imagefield_gallery_css_render() { |
| 322 |
$output = " |
$output = " |
| 324 |
edits made to this file will be overwritten the next time any configuration changes |
edits made to this file will be overwritten the next time any configuration changes |
| 325 |
are made via the admin. If you'd like to alter the contents of this file, check |
are made via the admin. If you'd like to alter the contents of this file, check |
| 326 |
theme_imagefield_gallery_css_render() in the imagefield_gallery.module file. */ |
theme_imagefield_gallery_css_render() in the imagefield_gallery.module file. */ |
| 327 |
/* ----- general ------------------------------------------------------------------- */ |
"; |
| 328 |
|
$types = imagefield_gallery_nodetypes(); |
| 329 |
|
foreach ($types as $type) { |
| 330 |
div.gallery_box { |
$theme_func = 'theme_imagefield_gallery_'. imagefield_gallery_gallery_type($type['type']) .'_css_render'; |
| 331 |
width:100%; |
if (function_exists($theme_func)) { |
| 332 |
clear:both; |
$output .= $theme_func($type['type']); |
| 333 |
display:block; |
} |
| 334 |
} |
} |
|
|
|
|
/* ----- thumbnails ---------------------------------------------------------------- */ |
|
|
|
|
|
div.image_field_thumbnail { |
|
|
display: inline; |
|
|
float: left; |
|
|
overflow: hidden;\n"; |
|
|
$output .= theme('imagefield_gallery_css_margins'); |
|
|
$output .= theme('imagefield_gallery_css_borders'); |
|
|
$output .= theme('imagefield_gallery_css_width'); |
|
|
$output .= theme('imagefield_gallery_css_height'); |
|
|
$output .= "} |
|
|
|
|
|
div.clear_both { |
|
|
clear: both; |
|
|
}"; |
|
| 335 |
return $output; |
return $output; |
| 336 |
} |
} |
|
|
|
|
function theme_imagefield_gallery_css_margins() { |
|
|
return ' margin:'. variable_get('thumbnail_top', 10) .'px '. variable_get('thumbnail_right', 10) .'px '. variable_get('thumbnail_bottom', 10) .'px '. variable_get('thumbnail_left', 10) .'px;'."\n"; |
|
|
} |
|
|
|
|
|
function theme_imagefield_gallery_css_borders() { |
|
|
return ' border:'. variable_get('border_width', '1px') .' '. variable_get('border_style', 'none') .' '. variable_get('color_style_textfield', '#ffffff') .';'."\n"; |
|
|
} |
|
|
|
|
|
function theme_imagefield_gallery_css_width() { |
|
|
return ' width: '. variable_get('thumbnail_width', 100) .'px;'."\n"; |
|
|
} |
|
|
|
|
|
function theme_imagefield_gallery_css_height() { |
|
|
return ' height: '. variable_get('thumbnail_height', 100) .'px;'."\n"; |
|
|
} |
|