Commit 647f0ebd authored by frjo's avatar frjo
Browse files

#768614: Some cleaning up of the Thickbox port and preparation for new features.

parent 502fff33
......@@ -93,7 +93,7 @@ function colorbox_admin_settings() {
$form['colorbox_custom_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Custom settings'),
'#title' => t('Style and Custom settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
......
......@@ -28,26 +28,7 @@
* Implementation of hook_uninstall().
*/
function colorbox_uninstall() {
variable_del('colorbox_auto_image_nodes');
variable_del('colorbox_compression_type');
variable_del('colorbox_custom_settings_activate');
variable_del('colorbox_form');
variable_del('colorbox_imagecache_preset');
variable_del('colorbox_imagefield_gallery');
variable_del('colorbox_login_custom');
variable_del('colorbox_login_form');
variable_del('colorbox_login');
variable_del('colorbox_opacity');
variable_del('colorbox_pages');
variable_del('colorbox_path');
variable_del('colorbox_slideshow');
variable_del('colorbox_style');
variable_del('colorbox_text_close');
variable_del('colorbox_text_current');
variable_del('colorbox_text_next');
variable_del('colorbox_text_previous');
variable_del('colorbox_transition_speed');
variable_del('colorbox_transition_type');
db_query("DELETE FROM {variable} WHERE name LIKE 'colorbox_%'");
}
/**
......
......@@ -25,7 +25,7 @@ function colorbox_theme() {
if (module_exists('imagecache')) {
foreach (imagecache_presets() as $preset) {
$theme['colorbox_formatter_'. $preset['presetname'] .'][colorbox'] = array(
$theme['colorbox_formatter_'. $preset['presetname'] .'__colorbox'] = array(
'function' => 'theme_colorbox_formatter_imagefield',
'arguments' => array('element' => NULL),
'file' => 'colorbox.theme.inc',
......@@ -65,7 +65,7 @@ function colorbox_menu() {
);
$items['colorbox/form'] = array(
'title' => 'Form',
'page callback' => 'colorbox_form',
'page callback' => 'colorbox_form_page',
'page arguments' => array(2),
'access callback' => 'user_access',
'access arguments' => array('access content'),
......@@ -80,13 +80,13 @@ function colorbox_menu() {
*/
function colorbox_login() {
$form_id = variable_get('colorbox_login_form', '') == 'custom' ? variable_get('colorbox_login_custom', 'user_login') : variable_get('colorbox_login_form', 'user_login');
colorbox_form($form_id);
colorbox_form_page($form_id);
}
/**
* Menu callback for colorbox_form.
* Menu callback for colorbox_form_page.
*/
function colorbox_form($form_id) {
function colorbox_form_page($form_id) {
$GLOBALS['devel_shutdown'] = FALSE; // Prevent devel module from spewing.
$form = drupal_get_form($form_id);
if (!empty($form)) {
......@@ -128,7 +128,6 @@ function _colorbox_doheader() {
$path = drupal_get_path('module', 'colorbox');
$style = variable_get('colorbox_style', 'default');
switch ($style) {
case 'default':
drupal_add_css($path .'/colorbox.css');
......@@ -156,7 +155,7 @@ function _colorbox_doheader() {
$js_settings = array(
'transition' => 'elastic',
'speed' => 350,
'opacity' => '0.9',
'opacity' => '0.85',
'slideshow' => FALSE,
'current' => t('{current} of {total}'),
'previous' => t('« Prev'),
......@@ -223,13 +222,14 @@ function colorbox_link_alter(&$links, $node) {
/**
* Implementation of hook_field_formatter_info().
*
* Adds certain colorbox+imagecache formatters to CCK image fields if imagefield.module and imagecache.module exist.
*/
function colorbox_field_formatter_info() {
$formatters = array();
if (module_exists('imagefield') && module_exists('imagecache')) {
foreach (imagecache_presets() as $preset) {
$formatters[$preset['presetname'] .'][colorbox'] = array(
$formatters[$preset['presetname'] .'__colorbox'] = array(
'label' => t('Colorbox: @preset image', array('@preset' => $preset['presetname'])),
'field types' => array('image', 'filefield'),
);
......
......@@ -20,7 +20,7 @@ function theme_colorbox_formatter_imagefield($element) {
return;
}
if (!empty($element['#item']['fid']) && isset($element['#item']['nid']) && $node = node_load($element['#item']['nid'])) {
if (!empty($element['#item']['fid']) && isset($element['#item']['nid'])) {
$item = $element['#item'];
if (is_string($item['data'])) {
......@@ -39,18 +39,19 @@ function theme_colorbox_formatter_imagefield($element) {
$item['data']['title'] = $item['data']['alt'];
}
else {
$node = node_load($item['nid']);
$item['data']['title'] = $node->title;
}
}
// Shorten the title when it is too long or it will look bad.
if ((variable_get('colorbox_style', 'default') != 'default') && (drupal_strlen($item['data']['title']) > 75)) {
// Shorten the title for the example styles when necessary.
$style = variable_get('colorbox_style', 'default');
if ((strpos($style, 'colorbox/example') !== FALSE) && (drupal_strlen($item['data']['title']) > 75)) {
$item['data']['title'] = drupal_substr($item['data']['title'], 0, 70) .'...';
}
// Build the gallery id.
$nid = $item['nid'] ? $item['nid'] : ($node->nid ? $node->nid : '');
$nid = $item['nid'] ? $item['nid'] : 'nid';
switch (variable_get('colorbox_imagefield_gallery', 1)) {
case 0:
$gallery_id = 'all';
......@@ -65,7 +66,8 @@ function theme_colorbox_formatter_imagefield($element) {
$gallery_id = $nid .'-'. $item['fid'];
break;
}
list($namespace, $presetname) = explode('][', $element['#formatter'], 2);
list($namespace, $modulename) = explode('__', $element['#formatter'], 2);
if ($preset = imagecache_preset_by_name($namespace)) {
return theme('colorbox_imagefield', $namespace, $item['filepath'], $item['data']['alt'], $item['data']['title'], $gallery_id, $element['#field_name']);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment