Project

General

Profile

Revision 6135231a

Added by Assos Assos over 5 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/lightbox2/lightbox2.module
708 708
    'force_show_nav' => variable_get('lightbox2_force_show_nav', FALSE),
709 709
    'show_caption' => variable_get('lightbox2_show_caption', TRUE),
710 710
    'loop_items' => variable_get('lightbox2_loop_items', FALSE),
711
    'node_link_text' => check_plain(variable_get('lightbox2_node_link_text', 'View Image Details')),
711
    'node_link_text' => check_plain(t(variable_get('lightbox2_node_link_text', 'View Image Details'))),
712 712
    'node_link_target' => variable_get('lightbox2_node_link_target', FALSE),
713
    'image_count' => check_plain(variable_get('lightbox2_image_count_str', 'Image !current of !total')),
714
    'video_count' => check_plain(variable_get('lightbox2_video_count_str', 'Video !current of !total')),
715
    'page_count' => check_plain(variable_get('lightbox2_page_count_str', 'Page !current of !total')),
713
    'image_count' => check_plain(t(variable_get('lightbox2_image_count_str', 'Image !current of !total'))),
714
    'video_count' => check_plain(t(variable_get('lightbox2_video_count_str', 'Video !current of !total'))),
715
    'page_count' => check_plain(t(variable_get('lightbox2_page_count_str', 'Page !current of !total'))),
716 716
    'lite_press_x_close' => t('press !x to close', array('!x' => '<a href="#" onclick="hideLightbox(); return FALSE;"><kbd>x</kbd></a>')),
717 717
    'download_link_text' => '',
718 718
    'enable_login' => $enable_login,
......
749 749
    'iframe_border' => (int)variable_get('lightbox2_frame_border', 1),
750 750
    // Video settings.
751 751
    'enable_video' => $enable_video,
752
    'useragent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '',
752 753
  );
753 754
  if ($enable_video) {
754 755
    $js_settings['flvPlayer'] = url(check_plain(trim(variable_get('lightbox2_flv_player_path', 'flvplayer.swf'), '/')));
......
757 758

  
758 759
  // Only supply these if the user has the correct permissions.
759 760
  if (user_access('download original image') && user_access('view original images')) {
760
    $js_settings['download_link_text'] = check_plain(variable_get('lightbox2_download_link_text', 'Download Original'));
761
    $js_settings['download_link_text'] = check_plain(t(variable_get('lightbox2_download_link_text', 'Download Original')));
761 762
  }
762 763

  
763 764
  drupal_add_js(array('lightbox2' => $js_settings), array( 'type' => 'setting' ) );
......
786 787
    }
787 788
    //drupal_add_js($path .'/js/prototype.js', array( 'scope' => $js_location, 'cache' => false ) );
788 789
    //drupal_add_js($path .'/js/scriptaculous.js', array( 'scope' => $js_location, 'cache' => false ) );
789
    drupal_add_js($path . '/js/lightbox.js', array( 'scope' => $js_location , 'cache' => FALSE) );
790
    drupal_add_js($path . '/js/lightbox.js', array( 'scope' => $js_location));
790 791

  
791 792
  }
792 793
  // Lightbox Lite.
......
797 798
  }
798 799
}
799 800

  
801
/**
802
 * Helper function for image styles.
803
 */
804
function lightbox2_image_styles() {
805
  $image_styles=array('0'=>'original');
806
  $tmp=image_styles();
807
  foreach($tmp as $style) {
808
    $image_styles[$style['name']] = $style['name'];
809
  }
810
  return $image_styles;
811
}
812

  
813
/**
814
 * Helper function for possible fields to display as the caption.
815
 */
816
function lightbox2_image_fields() {
817
  $fields = array(
818
    'hidden' => t('Hidden'),
819
    'title' => t('File title'),
820
    'filename' => t('Filename'),
821
  );
822
  foreach(field_info_instances("file", "image") as $field) {
823
    $fields[$field['field_name']] = $field['label'];
824
  }
825
  return $fields;
826
}
827

  
828
/**
829
 * Helper function for possible lightbox styles.
830
 */
831
function lightbox2_lightbox_types() {
832
    return array(
833
      'lightbox' => t('Single lightbox'),
834
      'lightshow' => t('Lightshow'),
835
    );
836
}
837

  
838
/**
839
 * Implements hook_field_formatter_settings_form().
840
 */
841
function lightbox2_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
842
  $display = $instance['display'][$view_mode];
843
  $settings = $display['settings'];
844

  
845
  $form = array();
846

  
847
  $form['type'] = array(
848
    '#title' => t('Lightbox type'),
849
    '#type' => 'select',
850
    '#options' => lightbox2_lightbox_types(),
851
    '#default_value' => $settings['type'],
852
  );
853
  $form['image_style'] = array(
854
    '#title' => t('Image style'),
855
    '#description' => t('The thumbnail to display as a link for the lightbox.'),
856
    '#type' => 'select',
857
    '#options' => lightbox2_image_styles(),
858
    '#default_value' => $settings['image_style'],
859
  );
860
  $form['lightbox_style'] = array(
861
    '#title' => t('Lightbox style'),
862
    '#description' => t('The image style to show inside the lightbox.'),
863
    '#type' => 'select',
864
    '#options' => lightbox2_image_styles(),
865
    '#default_value' => $settings['lightbox_style'],
866
  );
867

  
868
  $form['caption'] = array(
869
    '#title' => t('Caption field'),
870
    '#description' => t('The field to use as a caption.'),
871
    '#type' => 'select',
872
    '#options' => lightbox2_image_fields(),
873
    '#default_value' => $settings['caption'],
874
  );
875

  
876
  return $form;
877
}
878
/**
879
 * Implements hook_field_formatter_settings_summary().
880
 */
881
function lightbox2_field_formatter_settings_summary($field, $instance, $view_mode) {
882
  $display = $instance['display'][$view_mode];
883
  $settings = $display['settings'];
884

  
885
  $image_styles = lightbox2_image_styles();
886
  $fields = lightbox2_image_fields();
887
  $types = lightbox2_lightbox_types();
888

  
889
  $summary = '';
890

  
891
  if(isset($settings['caption']) && isset($settings['type']) && isset($settings['image_style']) && isset($settings['lightbox_style'])) {
892
    $summary .= '<strong>'.t('Caption field') . '</strong>: ' . $fields[$settings['caption']] . '<br/>';
893
    $summary .= '<strong>'.t('Display') . '</strong>: ' ;
894
    $summary .= $types[$settings['type']];
895
    $summary .= ': ';
896
    $summary .= $image_styles[$settings['image_style']];
897
    $summary .= ' => ';
898
    $summary .= $image_styles[$settings['lightbox_style']];
899
  } else {
900
    $summary = 'Title - Lightbox: original => original';
901
  }
902

  
903

  
904
  return $summary;
905
}
906

  
800 907
/**
801 908
 * Implementation of hook_field_formatter_info().
802 909
 *
......
807 914
function lightbox2_field_formatter_info() {
808 915
  $formatters = array();
809 916
  if (module_exists('image')) {
810
    $image = $lightbox = image_styles();
811
    $types = array('lightbox', 'lightshow');
812
    foreach ($types as $type) {
813
      foreach ($image as $image_key => $image_value ) {
814
        $formatters['lightbox2__' . $type . '__' . $image_key . '__original'] = array(
815
          'label' => 'Lightbox2: ' . $type . ': ' . $image_key . '->original',
816
          'field types' => array('image'),
817
        );
818
        foreach ($lightbox as $lightbox_key => $lightbox_value ) {
819
          $formatters['lightbox2__' . $type . '__' . $image_key . "__" . $lightbox_key] = array(
820
            'label' => 'Lightbox2: ' . $type . ': ' . $image_key . '->' . $lightbox_key,
821
            'field types' => array('image'),
822
          );
823
        }
824
      }
825
    }
917
    $formatters['lightbox2'] = array(
918
      'label' => 'Lightbox2',
919
      'field types' => array('image'),
920
      'settings' => array(
921
          'type' => 'lightbox',
922
          'image_style' => 'original',
923
          'lightbox_style' => 'original',
924
          'caption' => 'hidden',
925
      ),
926
    );
826 927
  }
827 928
  return $formatters;
828 929
  /*
......
946 1047
 */
947 1048
function lightbox2_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
948 1049
  $element = array();
949
  $pieces = explode('__', $display['type']);
950
  $lightbox_type = $pieces[1];
951
  $image_style = $pieces[2];
952
  $lightbox_style = $pieces[3];
1050
  $settings = $display["settings"];
1051
  $lightbox_type = $settings['type'];
1052
  $image_style = $settings['image_style'];
1053
  $lightbox_style = $settings['lightbox_style'];
953 1054

  
954 1055
  if ($image_style == 'original') {
955 1056
    $image_style = NULL;
......
958 1059
    $lightbox_style = NULL;
959 1060
  }
960 1061

  
961
  if ($entity_type == 'node') {
962
    $node_id = $entity->nid;
963
  }
1062
  $wrapper = entity_metadata_wrapper($entity_type, $entity);
964 1063

  
965 1064
  foreach ($items as $delta => $item) {
966 1065
    $uri = array(
......
974 1073
      '#image_style' => $image_style,
975 1074
      '#lightbox_style' => $lightbox_style,
976 1075
      '#path' => $uri,
977
      '#node_id' => $node_id,
1076
      '#node_id' => $wrapper->getIdentifier(),
978 1077
      '#field_name' => $field['field_name'],
1078
      '#caption' => $settings['caption'],
979 1079
    );
980 1080
  }
981 1081
  return ($element);
......
1026 1126
      'lightbox_style' => NULL,
1027 1127
      'node_id' => NULL,
1028 1128
      'field_name' => NULL,
1129
      'caption' => NULL,
1029 1130
     ),
1030 1131
    //'variables' => array(),
1031 1132
  );
......
1309 1410
  return array(
1310 1411
    'lightbox2_iframe' => array(
1311 1412
      'suitability callback' => 'lightbox2_check_filefield_extension',
1312
      'title' => t('Lightbox2 iframe'),
1413
      'label' => t('Lightbox2 iframe'),
1313 1414
      'description' => t('Displays all kinds of files in a popup lightbox in an iframe.'),
1314 1415
    ),
1315 1416
    'lightbox2_image' => array(
1316 1417
      'suitability callback' => 'lightbox2_check_filefield_image_extension',
1317
      'title' => t('Lightbox2 image'),
1418
      'label' => t('Lightbox2 image'),
1318 1419
      'description' => t('Displays image files in a popup lightbox.'),
1319 1420
    ),
1320 1421
  );

Also available in: Unified diff