Issue #1230736 by Yukare: Make grouping of imagens in views work

parent 6500bd88
......@@ -263,59 +263,30 @@ function lightbox2_general_settings_form() {
'#default_value' => variable_get('lightbox2_page_list', ''),
);
// Define cck settings fieldset.
// Define grouping settings fieldset.
/* ------------------------------------ */
if ((module_exists('emfield') && module_exists('emimage')) || (module_exists('imagefield') && module_exists('imagecache'))) {
$form['cck_options'] = array(
'#type' => 'fieldset',
'#title' => t('CCK display settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$cck_options = array(
0 => t('No grouping'),
1 => t('Group by field name'),
2 => t('Group by node id'),
3 => t('Group by field name and node id'),
4 => t('Group all nodes and fields'),
);
// Add checkbox for emfield emimage grouping.
if (module_exists('emfield') && module_exists('emimage')) {
$form['cck_options']['lightbox2_image_ncck_group_node_id'] = array(
'#type' => 'select',
'#title' => t('Select Emfield Image grouping in Views'),
'#description' => t('By default, emfield images in views are grouped by the field name they appear in the view in. You can override that grouping here.'),
'#options' => $cck_options,
'#default_value' => variable_get('lightbox2_image_ncck_group_node_id', 1),
);
}
$form['group_options'] = array(
'#type' => 'fieldset',
'#title' => t('Group display settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Add checkbox for imagefield grouping.
if (module_exists('imagefield') && module_exists('imagecache')) {
$form['cck_options']['lightbox2_imagefield_group_node_id'] = array(
'#type' => 'select',
'#title' => t('Select Imagefield grouping in Views'),
'#description' => t('By default, imagefields in views are grouped by the field name they appear in the view in. You can override that grouping here.'),
'#options' => $cck_options,
'#default_value' => variable_get('lightbox2_imagefield_group_node_id', 1),
);
$form['cck_options']['lightbox2_imagefield_use_node_title'] = array(
'#type' => 'checkbox',
'#title' => t('Use node title as caption'),
'#description' => t('By default, the caption for imagefields is the image title text configured. If no title is configured, then the alt text will be used. This option allows you to override that and always display the node title as the image caption.'),
'#default_value' => variable_get('lightbox2_imagefield_use_node_title', FALSE),
);
$form['cck_options']['lightbox2_view_image_text'] = array(
'#type' => 'textfield',
'#title' => t('Text to view image'),
'#description' => t('This is the text that can appear when linking to the image using CCK imagefields.'),
'#default_value' => variable_get('lightbox2_view_image_text', 'View image'),
);
$group_options = array(
0 => t('No grouping'),
1 => t('Group by field name'),
2 => t('Group by node id'),
3 => t('Group by field name and node id'),
4 => t('Group all nodes and fields'),
);
}
}
$form['group_options']['lightbox2_image_group_node_id'] = array(
'#type' => 'select',
'#title' => t('Select Imagefield grouping in Views'),
'#description' => t('By default, imagefields in views are grouped by the field name they appear in the view in. You can override that grouping here.'),
'#options' => $group_options,
'#default_value' => variable_get('lightbox2_image_group_node_id', 1),
);
// Define advanced settings fieldset.
......
......@@ -25,6 +25,8 @@ function theme_lightbox2_image($variables) {
$path = $variables['path'];
$item = $variables['item'];
$image_style = $variables['image_style'];
$node_id = $variables['node_id'];
$field_name = $variables['field_name'];
if(!$variables["lightbox_style"]) {
$path['path'] = file_create_url($item['uri']);
......@@ -36,7 +38,32 @@ function theme_lightbox2_image($variables) {
$rel = 'lightbox';
// Grouping
$rel .= '[]';
$rel .= '[';
$group = variable_get('lightbox2_image_group_node_id', 1);
switch($group) {
// No groups
case '0':
dpm($group,'bla');
break;
// Group by field name
case '1':
$rel .= $field_name;
break;
// Group by node id
case '2':
$rel .= $node_id;
break;
// Group by field name and node id
case '3':
$rel .= $field_name . '_' . $node_id;
break;
// All nodes and fields in same group
case '4':
$rel .= 'group';
break;
}
$rel .= ']';
// Title Start
$rel .= '[' . $item['title'];
......
......@@ -946,12 +946,18 @@ function lightbox2_field_formatter_view($entity_type, $entity, $field, $instance
$pieces = explode('__', $display['type']);
$image_style = $pieces[2];
$lightbox_style = $pieces[3];
if($image_style == 'original') {
$image_style = NULL;
}
if($lightbox_style == 'original') {
$lightbox_style = NULL;
}
if ($entity_type == 'node') {
$node_id = $entity->nid;
}
foreach ($items as $delta => $item) {
$uri = array(
'path' => file_create_url($item['uri']),
......@@ -963,6 +969,8 @@ function lightbox2_field_formatter_view($entity_type, $entity, $field, $instance
'#image_style' => $image_style,
'#lightbox_style' => $lightbox_style,
'#path' => $uri,
'#node_id' => $node_id,
'#field_name' => $field['field_name'],
);
}
return($element);
......@@ -1010,6 +1018,8 @@ function lightbox2_theme($existing, $type, $theme, $path) {
'path' => NULL,
'image_style' => NULL,
'lightbox_style' => NULL,
'node_id' => NULL,
'field_name' => NULL,
),
//'variables' => array(),
);
......@@ -1531,7 +1541,7 @@ function lightbox2_views_api() {
}
function lightbox2_filter_xss() {
$allowed_tags = trim(variable_get('lightbox2_filter_xss_allowed_tags', 'p, br, a, em, strong, cite, code, ul, ol, li, dl, dt, dd, i'));
$allowed_tags = trim(variable_get('lightbox2_filter_xss_allowed_tags', 'p, br, a, em, strong, cite, code, ul, ol, li, dl, dt, dd, '));
$allowed_tags = (empty($allowed_tags) ? array() : preg_split('/[,\s]+/', $allowed_tags));
if (!empty($_POST['allowed_tags']) && $_POST['allowed_tags'] != 'undefined') {
$allowed_tags = explode(',', $_POST['allowed_tags']);
......
diff --git a/lightbox2.formatter.inc b/lightbox2.formatter.inc
index 7169410..a5b0e52 100644
--- a/lightbox2.formatter.inc
+++ b/lightbox2.formatter.inc
@@ -31,9 +31,26 @@ function theme_lightbox2_image($variables) {
} else {
$path['path'] = image_style_url($variables["lightbox_style"], $item['uri']);
}
+
+ // Lightbox type
+ $rel = 'lightbox';
+
+ // Grouping
+ $rel .= '[]';
+
+ // Title Start
+ $rel .= '[' . $item['title'];
+
+ // Download Link
+ if (user_access('download original image')) {
+ $rel .= '<p><a href="' . file_create_url($item['uri']) . '">' . variable_get('lightbox2_download_link_text', 'Download Original') . '</a></p>';
+ }
- $path['options']['attributes']['rel'] = 'lightbox';
- $path['options']['attributes']['title'] = $item['alt'];
+ // Title End
+ $rel .= ']';
+
+ $path['options']['attributes']['rel'] = $rel;
+ $path['options']['attributes']['title'] = $item['title'];
return theme('image_formatter', array( 'item' => $item, 'path' => $path, 'image_style' => $image_style ) );
}
diff --git a/lightbox2.module b/lightbox2.module
index a59de5c..d543c87 100644
--- a/lightbox2.module
+++ b/lightbox2.module
@@ -143,11 +143,13 @@ function lightbox2_help($path, $arg) {
function lightbox2_permission() {
return array(
'administer lightbox2' => array(
- 'title' =>t('Administer Lightbox2')
+ 'title' => t('Administer Lightbox2'),
+ 'description' => t('Allow the user administer Lightbox2 settings'),
),
'download original image' => array(
- 'title' => t('Download Original')
- )
+ 'title' => t('Download Original'),
+ 'description' => t('Create a link that allow the user download the original image'),
+ ),
);
}
@@ -1529,7 +1531,7 @@ function lightbox2_views_api() {
}
function lightbox2_filter_xss() {
- $allowed_tags = trim(variable_get('lightbox2_filter_xss_allowed_tags', 'p, br, a, em, strong, cite, code, ul, ol, li, dl, dt, dd'));
+ $allowed_tags = trim(variable_get('lightbox2_filter_xss_allowed_tags', 'p, br, a, em, strong, cite, code, ul, ol, li, dl, dt, dd, i'));
$allowed_tags = (empty($allowed_tags) ? array() : preg_split('/[,\s]+/', $allowed_tags));
if (!empty($_POST['allowed_tags']) && $_POST['allowed_tags'] != 'undefined') {
$allowed_tags = explode(',', $_POST['allowed_tags']);
Markdown is supported
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