| 1 |
<?php
|
| 2 |
// $Id: imagepicker.admin.inc,v 1.7 2008/09/04 22:55:44 hutch Exp $
|
| 3 |
// $Name: HEAD $
|
| 4 |
|
| 5 |
/**
|
| 6 |
* @file
|
| 7 |
* admin settings functions
|
| 8 |
*/
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Menu callback; presents the settings form for imagepicker
|
| 12 |
*/
|
| 13 |
function imagepicker_admin_settings() {
|
| 14 |
|
| 15 |
// default settings
|
| 16 |
$form['imagepicker_settings'] = array(
|
| 17 |
'#type' => 'fieldset',
|
| 18 |
'#title' => t('Set imagepicker settings'),
|
| 19 |
'#collapsible' => TRUE,
|
| 20 |
'#collapsed' => FALSE,
|
| 21 |
);
|
| 22 |
$form['imagepicker_settings']['imagepicker_default_browser_thumbnail_size'] = array(
|
| 23 |
'#type' => 'textfield',
|
| 24 |
'#title' => t('Default Browser Thumbnail Size'),
|
| 25 |
'#size' => 10,
|
| 26 |
'#required' => TRUE,
|
| 27 |
'#default_value' => variable_get('imagepicker_default_browser_thumbnail_size', 100),
|
| 28 |
'#description' => t('Configure the default browser thumbnail size'),
|
| 29 |
);
|
| 30 |
$node_types = node_get_types('names');
|
| 31 |
$form['imagepicker_settings']['imagepicker_node_types_enabled'] = array(
|
| 32 |
'#type' => 'checkboxes',
|
| 33 |
'#title' => t('Node Types'),
|
| 34 |
'#description' => t('Set the node types you want to enable Imagepicker for.'),
|
| 35 |
'#default_value' => variable_get('imagepicker_node_types_enabled', array_keys($node_types)),
|
| 36 |
'#options' => $node_types,
|
| 37 |
);
|
| 38 |
if (module_exists('comment')) {
|
| 39 |
$form['imagepicker_settings']['imagepicker_comment_enabled'] = array(
|
| 40 |
'#type' => 'checkbox',
|
| 41 |
'#title' => t('Comments'),
|
| 42 |
'#return_value' => 1,
|
| 43 |
'#default_value' => variable_get('imagepicker_comment_enabled', 0),
|
| 44 |
'#description' => t('Setting this option enables Imagepicker in comments.'),
|
| 45 |
);
|
| 46 |
}
|
| 47 |
$form['imagepicker_settings']['imagepicker_default_pagelink'] = array(
|
| 48 |
'#type' => 'checkbox',
|
| 49 |
'#title' => t('Show return link in page'),
|
| 50 |
'#return_value' => 1,
|
| 51 |
'#default_value' => variable_get('imagepicker_default_pagelink', 1),
|
| 52 |
'#description' => t('Setting this option will add a link back to the thumbnail when using the page option. Uses javascript history(back).'),
|
| 53 |
);
|
| 54 |
$form['imagepicker_settings']['imagepicker_account_enabled'] = array(
|
| 55 |
'#type' => 'checkbox',
|
| 56 |
'#title' => t('Imagepicker in My Account'),
|
| 57 |
'#return_value' => 1,
|
| 58 |
'#default_value' => variable_get('imagepicker_account_enabled', 1),
|
| 59 |
'#description' => t('Setting this option enables Imagepicker in My Account.'),
|
| 60 |
);
|
| 61 |
// default options
|
| 62 |
$form['imagepicker_defaults'] = array(
|
| 63 |
'#type' => 'fieldset',
|
| 64 |
'#title' => t('Set imagepicker defaults'),
|
| 65 |
'#collapsible' => TRUE,
|
| 66 |
'#collapsed' => FALSE,
|
| 67 |
);
|
| 68 |
$form['imagepicker_defaults']['imagepicker_default_thumbnail_size'] = array(
|
| 69 |
'#type' => 'textfield',
|
| 70 |
'#title' => t('Default Thumbnail Size'),
|
| 71 |
'#size' => 10,
|
| 72 |
'#required' => TRUE,
|
| 73 |
'#default_value' => variable_get('imagepicker_default_thumbnail_size', 100),
|
| 74 |
'#description' => t('Configure the default thumbnail size'),
|
| 75 |
);
|
| 76 |
$form['imagepicker_defaults']['imagepicker_default_scale'] = array(
|
| 77 |
'#type' => 'textfield',
|
| 78 |
'#title' => t('Default Scale'),
|
| 79 |
'#size' => 10,
|
| 80 |
'#required' => FALSE,
|
| 81 |
'#default_value' => variable_get('imagepicker_default_scale', ''),
|
| 82 |
'#description' => t('Configure the default scale. leave empty for no default scale'),
|
| 83 |
);
|
| 84 |
// insert settings
|
| 85 |
$form['imagepicker_insert_defaults'] = array(
|
| 86 |
'#type' => 'fieldset',
|
| 87 |
'#title' => t('Set imagepicker insert defaults'),
|
| 88 |
'#collapsible' => TRUE,
|
| 89 |
'#collapsed' => FALSE,
|
| 90 |
'#description' => ''
|
| 91 |
);
|
| 92 |
$showoptions = array('full' => t('Full size'), 'thumb' => t('Thumbnail'), 'title' => t('Title'));
|
| 93 |
$linkoptions = array('none' => t('None'), 'file' => t('File'), 'page' => t('Page') );
|
| 94 |
if (module_exists('lightbox2') && variable_get('imagepicker_lightbox2_enable', 1) ) {
|
| 95 |
$linkoptions['lightbox'] = t('Lightbox');
|
| 96 |
}
|
| 97 |
$alignoptions = array('none' => t('None'), 'fleft' => t('Float Left'), 'fright' => t('Float right'));
|
| 98 |
$form['imagepicker_insert_defaults']['imagepicker_insert_defaults_align'] = array(
|
| 99 |
'#type' => 'radios',
|
| 100 |
'#title' => t('Align'),
|
| 101 |
'#default_value' => 'none',
|
| 102 |
'#options' => $alignoptions,
|
| 103 |
'#description' => '',
|
| 104 |
'#default_value' => variable_get('imagepicker_insert_defaults_align', 'none'),
|
| 105 |
);
|
| 106 |
$form['imagepicker_insert_defaults']['imagepicker_insert_defaults_show'] = array(
|
| 107 |
'#type' => 'radios',
|
| 108 |
'#id' => 'show',
|
| 109 |
'#title' => t('Show'),
|
| 110 |
'#default_value' => 'full',
|
| 111 |
'#options' => $showoptions,
|
| 112 |
'#description' => '',
|
| 113 |
'#default_value' => variable_get('imagepicker_insert_defaults_show', 'full'),
|
| 114 |
);
|
| 115 |
$form['imagepicker_insert_defaults']['imagepicker_insert_defaults_link'] = array(
|
| 116 |
'#type' => 'radios',
|
| 117 |
'#title' => t('Link'),
|
| 118 |
'#default_value' => 'none',
|
| 119 |
'#options' => $linkoptions,
|
| 120 |
'#description' => '',
|
| 121 |
'#default_value' => variable_get('imagepicker_insert_defaults_link', 'none'),
|
| 122 |
);
|
| 123 |
// alignment settings
|
| 124 |
$form['imagepicker_align'] = array(
|
| 125 |
'#type' => 'fieldset',
|
| 126 |
'#title' => t('Image alignment settings'),
|
| 127 |
'#collapsible' => TRUE,
|
| 128 |
'#collapsed' => FALSE,
|
| 129 |
);
|
| 130 |
$form['imagepicker_align']['imagepicker_default_align_show'] = array(
|
| 131 |
'#type' => 'checkbox',
|
| 132 |
'#title' => t('Show Alignment options'),
|
| 133 |
'#return_value' => 1,
|
| 134 |
'#default_value' => variable_get('imagepicker_default_align_show', 1),
|
| 135 |
'#description' => t('Unsetting this option will remove the alignment options from the insert page.'),
|
| 136 |
);
|
| 137 |
$form['imagepicker_align']['imagepicker_default_fleft'] = array(
|
| 138 |
'#type' => 'textfield',
|
| 139 |
'#title' => t('Default Float left code'),
|
| 140 |
'#size' => 25,
|
| 141 |
'#maxlength' => 50,
|
| 142 |
'#required' => TRUE,
|
| 143 |
'#default_value' => variable_get('imagepicker_default_fleft', 'style="float: left"'),
|
| 144 |
'#description' => t('Configure the default code used for float left styling.'),
|
| 145 |
);
|
| 146 |
$form['imagepicker_align']['imagepicker_default_fright'] = array(
|
| 147 |
'#type' => 'textfield',
|
| 148 |
'#title' => t('Default Float right code'),
|
| 149 |
'#size' => 25,
|
| 150 |
'#maxlength' => 50,
|
| 151 |
'#required' => TRUE,
|
| 152 |
'#default_value' => variable_get('imagepicker_default_fright', 'style="float: right"'),
|
| 153 |
'#description' => t('Configure the default code used for float right styling.'),
|
| 154 |
);
|
| 155 |
if (module_exists('lightbox2')) {
|
| 156 |
// lightbox2 integration
|
| 157 |
$form['imagepicker_lightbox2'] = array(
|
| 158 |
'#type' => 'fieldset',
|
| 159 |
'#title' => t('Lightbox integration'),
|
| 160 |
'#collapsible' => TRUE,
|
| 161 |
'#collapsed' => FALSE,
|
| 162 |
);
|
| 163 |
$form['imagepicker_lightbox2']['imagepicker_lightbox2_enable'] = array(
|
| 164 |
'#type' => 'checkbox',
|
| 165 |
'#title' => t('Enable Lightbox2 in Imagepicker'),
|
| 166 |
'#return_value' => 1,
|
| 167 |
'#default_value' => variable_get('imagepicker_lightbox2_enable', 1),
|
| 168 |
'#description' => t('Unsetting this option will disable Lightbox2 in Imagepicker.'),
|
| 169 |
);
|
| 170 |
$form['imagepicker_lightbox2']['imagepicker_lightbox2_insert'] = array(
|
| 171 |
'#type' => 'textfield',
|
| 172 |
'#title' => t('Default Lightbox insert'),
|
| 173 |
'#size' => 15,
|
| 174 |
'#maxlength' => 30,
|
| 175 |
'#required' => TRUE,
|
| 176 |
'#default_value' => variable_get('imagepicker_lightbox2_insert', 'lightbox'),
|
| 177 |
'#description' => t('Configure the default code inserted into the "rel" attribute.'),
|
| 178 |
);
|
| 179 |
}
|
| 180 |
// advanced settings
|
| 181 |
$form['imagepicker_advanced'] = array(
|
| 182 |
'#type' => 'fieldset',
|
| 183 |
'#title' => t('Advanced imagepicker settings'),
|
| 184 |
'#description' => t('You can alter the default styling of the iframe here,<br />useful if the iframe is not fitting in with your theme.'),
|
| 185 |
'#collapsible' => TRUE,
|
| 186 |
'#collapsed' => TRUE,
|
| 187 |
);
|
| 188 |
$form['imagepicker_advanced']['imagepicker_advanced_iframe_width'] = array(
|
| 189 |
'#type' => 'textfield',
|
| 190 |
'#title' => t('Iframe width'),
|
| 191 |
'#description' => t('Configure the iframe width. This can be a number or a percentage, eg 400 or 100%'),
|
| 192 |
'#size' => 10,
|
| 193 |
'#required' => TRUE,
|
| 194 |
'#default_value' => variable_get('imagepicker_advanced_iframe_width', "100%"),
|
| 195 |
);
|
| 196 |
$form['imagepicker_advanced']['imagepicker_advanced_iframe_height'] = array(
|
| 197 |
'#type' => 'textfield',
|
| 198 |
'#title' => t('Iframe height'),
|
| 199 |
'#description' => t('Configure the iframe height. This must be a number, eg 500'),
|
| 200 |
'#size' => 10,
|
| 201 |
'#required' => TRUE,
|
| 202 |
'#default_value' => variable_get('imagepicker_advanced_iframe_height', "500"),
|
| 203 |
);
|
| 204 |
$form['imagepicker_advanced']['imagepicker_advanced_iframe_border'] = array(
|
| 205 |
'#type' => 'textfield',
|
| 206 |
'#title' => t('Iframe border'),
|
| 207 |
'#description' => t('Configure the iframe border. This can be a number, eg 0 or 1, or a css entry such as 1px solid #808080'),
|
| 208 |
'#size' => 25,
|
| 209 |
'#required' => TRUE,
|
| 210 |
'#default_value' => variable_get('imagepicker_advanced_iframe_border', "0"),
|
| 211 |
);
|
| 212 |
$form['imagepicker_advanced']['imagepicker_advanced_browser_columns'] = array(
|
| 213 |
'#type' => 'textfield',
|
| 214 |
'#title' => t('Browser columns'),
|
| 215 |
'#description' => t('Configure the number of columns in the image browser. This must be a number, 0 for normal wraparound'),
|
| 216 |
'#size' => 10,
|
| 217 |
'#required' => TRUE,
|
| 218 |
'#default_value' => variable_get('imagepicker_advanced_browser_columns', 0),
|
| 219 |
);
|
| 220 |
$form['imagepicker_advanced']['imagepicker_advanced_browser_page'] = array(
|
| 221 |
'#type' => 'textfield',
|
| 222 |
'#title' => t('Images per page'),
|
| 223 |
'#description' => t('Configure the number of images shown per page in the image browser. This must be a number, 0 for no paging'),
|
| 224 |
'#size' => 10,
|
| 225 |
'#required' => TRUE,
|
| 226 |
'#default_value' => variable_get('imagepicker_advanced_browser_page', 20),
|
| 227 |
);
|
| 228 |
$form['imagepicker_advanced']['imagepicker_advanced_collapsed'] = array(
|
| 229 |
'#type' => 'checkbox',
|
| 230 |
'#title' => t('Fieldset state'),
|
| 231 |
'#return_value' => 1,
|
| 232 |
'#default_value' => variable_get('imagepicker_advanced_collapsed', 0),
|
| 233 |
'#description' => t('Setting this option will collapse the fieldset the iframe is in by default.'),
|
| 234 |
);
|
| 235 |
$form['imagepicker_advanced']['imagepicker_use_full_url'] = array(
|
| 236 |
'#type' => 'checkbox',
|
| 237 |
'#title' => t('Use full url'),
|
| 238 |
'#return_value' => 1,
|
| 239 |
'#default_value' => variable_get('imagepicker_use_full_url', 1),
|
| 240 |
'#description' => t('Setting this option will make imagepicker use a full url to the image being inserted, unsetting it will use an absolute path.<br />This is useful if you are developing a site with a different url than the production site will be on.'),
|
| 241 |
);
|
| 242 |
$form['imagepicker_advanced']['imagepicker_show_browse_order_form'] = array(
|
| 243 |
'#type' => 'checkbox',
|
| 244 |
'#title' => t('Show the order select box in the browser'),
|
| 245 |
'#return_value' => 1,
|
| 246 |
'#default_value' => variable_get('imagepicker_show_browse_order_form', 1),
|
| 247 |
'#description' => t(''),
|
| 248 |
);
|
| 249 |
$orderlist = array(
|
| 250 |
'img_id DESC' => t('Newest first'),
|
| 251 |
'img_id ASC' => t('Newest last'),
|
| 252 |
'img_date DESC' => t('Edited first'),
|
| 253 |
'img_date ASC' => t('Edited last'),
|
| 254 |
'img_name' => t('By name'),
|
| 255 |
);
|
| 256 |
$form['imagepicker_advanced']['imagepicker_default_browser_order'] = array(
|
| 257 |
'#type' => 'select',
|
| 258 |
'#default_value' => variable_get('imagepicker_default_browser_order', 'img_id DESC'),
|
| 259 |
'#options' => $orderlist,
|
| 260 |
'#title' => t('Default order'),
|
| 261 |
'#description' => t('The default order used to sort the browser. This will be applied wether or not the select box is visible'),
|
| 262 |
);
|
| 263 |
|
| 264 |
return system_settings_form($form);
|
| 265 |
}
|
| 266 |
|
| 267 |
/**
|
| 268 |
* Validate form
|
| 269 |
*/
|
| 270 |
function imagepicker_admin_settings_validate($form_id, $form_state) {
|
| 271 |
if (! drupal_strlen($form_state['values']['imagepicker_default_thumbnail_size'])) {
|
| 272 |
form_set_error('imagepicker_default_thumbnail_size', t('You must fill in the Thumbnail field'));
|
| 273 |
}
|
| 274 |
if (! is_numeric($form_state['values']['imagepicker_default_thumbnail_size'])) {
|
| 275 |
form_set_error('imagepicker_default_thumbnail_size', t('The Thumbnail field must be a number'));
|
| 276 |
}
|
| 277 |
if (! drupal_strlen($form_state['values']['imagepicker_default_browser_thumbnail_size'])) {
|
| 278 |
form_set_error('imagepicker_default_browser_thumbnail_size', t('You must fill in the Browser Thumbnail field'));
|
| 279 |
}
|
| 280 |
if (! is_numeric($form_state['values']['imagepicker_default_browser_thumbnail_size'])) {
|
| 281 |
form_set_error('imagepicker_default_browser_thumbnail_size', t('The Browser Thumbnail field must be a number'));
|
| 282 |
}
|
| 283 |
if (drupal_strlen($form_state['values']['imagepicker_default_scale']) && ! is_numeric($form_state['values']['imagepicker_default_scale'])) {
|
| 284 |
form_set_error('imagepicker_default_scale', t('The Scale field must be a number'));
|
| 285 |
}
|
| 286 |
if (! drupal_strlen($form_state['values']['imagepicker_default_fleft'])) {
|
| 287 |
form_set_error('imagepicker_default_fleft', t('You must fill in the Left alignment field'));
|
| 288 |
}
|
| 289 |
if (! drupal_strlen($form_state['values']['imagepicker_default_fright'])) {
|
| 290 |
form_set_error('imagepicker_default_fright', t('You must fill in the Right alignment field'));
|
| 291 |
}
|
| 292 |
if (! is_numeric($form_state['values']['imagepicker_advanced_iframe_height'])) {
|
| 293 |
form_set_error('imagepicker_advanced_iframe_height', t('The Iframe height must be a number'));
|
| 294 |
}
|
| 295 |
if (! drupal_strlen($form_state['values']['imagepicker_advanced_iframe_width'])) {
|
| 296 |
form_set_error('imagepicker_advanced_iframe_width', t('You must fill in the Iframe width'));
|
| 297 |
}
|
| 298 |
if (! drupal_strlen($form_state['values']['imagepicker_advanced_iframe_border'])) {
|
| 299 |
form_set_error('imagepicker_advanced_iframe_border', t('You must fill in the Iframe border'));
|
| 300 |
}
|
| 301 |
if (! drupal_strlen($form_state['values']['imagepicker_insert_defaults_align'])) {
|
| 302 |
form_set_error('imagepicker_insert_defaults_align', t('You must fill in the default align field'));
|
| 303 |
}
|
| 304 |
if (! drupal_strlen($form_state['values']['imagepicker_insert_defaults_show'])) {
|
| 305 |
form_set_error('imagepicker_insert_defaults_show', t('You must fill in the default show field'));
|
| 306 |
}
|
| 307 |
if (! drupal_strlen($form_state['values']['imagepicker_insert_defaults_link'])) {
|
| 308 |
form_set_error('imagepicker_insert_defaults_link', t('You must fill in the default link field'));
|
| 309 |
}
|
| 310 |
if ($form_values['imagepicker_show_browse_order_form'] != 1) {
|
| 311 |
variable_del('imagepicker_browser_order');
|
| 312 |
}
|
| 313 |
}
|