Projet

Général

Profil

Révision a60304ed

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/flexslider/theme/flexslider.theme.inc
10 10
/**
11 11
 * Default theme implementation for flexslider_list
12 12
 */
13
function theme_flexslider_list(&$vars) {
13
function theme_flexslider_list(&$variables) {
14 14
  // Reference configuration variables
15
  $optionset = &$vars['settings']['optionset'];
16
  $items = &$vars['items'];
17
  $attributes = &$vars['settings']['attributes'];
18
  $type = &$vars['settings']['type'];
15
  $optionset = &$variables['settings']['optionset'];
16
  $items = &$variables['items'];
17
  $attributes = &$variables['settings']['attributes'];
18
  $type = &$variables['settings']['type'];
19 19
  $output = '';
20 20

  
21 21
  // Build the list
22 22
  if (!empty($items)) {
23 23
    $output .= "<$type" . drupal_attributes($attributes) . '>';
24
    foreach ($items as $i => $item) {
24
    foreach ($items as $item) {
25 25

  
26 26
      $caption = '';
27 27
      if (!empty($item['caption'])) {
......
45 45
/**
46 46
 * Default theme implementation for flexslider_list_item
47 47
 */
48
function theme_flexslider_list_item(&$vars) {
49
  return '<li' . drupal_attributes($vars['settings']['attributes']) . '>' . $vars['item'] . $vars['caption'] . "</li>\n";
48
function theme_flexslider_list_item(&$variables) {
49
  return '<li' . drupal_attributes($variables['settings']['attributes']) . '>' . $variables['item'] . $variables['caption'] . "</li>\n";
50 50
}
51 51

  
52 52
/**
53
 * Template preprocess handler for 'flexslider' theme.
53
 * Prepares variables for flexslider templates.
54
 *
55
 * @see flexslider.tpl.php.
54 56
 */
55
function template_process_flexslider(&$vars) {
57
function template_process_flexslider(&$variables) {
56 58

  
57 59
  // Reference configuration variables
58
  $optionset = &$vars['settings']['optionset'];
59
  $settings = &$vars['settings'];
60
  $items = &$vars['items'];
60
  $optionset = &$variables['settings']['optionset'];
61
  $settings = &$variables['settings'];
62
  $items = &$variables['items'];
61 63

  
62 64
  // Set the default container type
63 65
  if (empty($settings['type'])) {
......
100 102
  // Add the flexslider class to be namespaced
101 103
  $attributes['class'][] = 'flexslider';
102 104

  
105
  // Add the optionset name as a class to the container.
106
  $attributes['class'][] = 'optionset-' . drupal_html_class($optionset->name);
107

  
108
  // Add the image style name as a class to the container.
109
  if (!empty($settings['image_style'])) {
110
    $attributes['class'][] = 'imagestyle-' . drupal_html_class($settings['image_style']);
111
  }
112

  
103 113
  // Add the attributes to the settings array.
104 114
  $settings['attributes'] = $attributes;
105 115

  
106 116
  // Finally, add the configuration to the page
107
  flexslider_add($vars['settings']['attributes']['id'], $vars['settings']['optionset']);
117
  flexslider_add($variables['settings']['attributes']['id'], $variables['settings']['optionset']);
108 118
}
109 119

  
110 120
/**
111
 * Process function for flexslider_list_item
121
 * Prepares variables for flexslider list templates.
122
 *
123
 * @see flexslider-list.tpl.php.
112 124
 */
113
function template_process_flexslider_list(&$vars) {
125
function template_process_flexslider_list(&$variables) {
114 126
  // Reset the list of attributes
115
  $vars['settings']['attributes'] = array(
127
  $variables['settings']['attributes'] = array(
116 128
    // @todo find a way to detect the outter container class if possible
117 129
    'class' => array('slides'),
118 130
  );
......
120 132
}
121 133

  
122 134
/**
123
 * Process function for flexslider_list_item
135
 * Prepares variables for flexslider list item templates.
136
 *
137
 * @see flexslider-list-item.tpl.php.
124 138
 */
125
function template_process_flexslider_list_item(&$vars) {
139
function template_process_flexslider_list_item(&$variables) {
126 140
  // Reset the list of attributes
127
  $vars['settings']['attributes'] = array();
141
  $variables['settings']['attributes'] = array();
128 142

  
129 143
  // Reference configuration variables
130
  $item = &$vars['item'];
131
  $settings = &$vars['settings'];
132
  $caption = &$vars['caption'];
133
  $attributes = &$vars['settings']['attributes'];
144
  $item = &$variables['item'];
145
  $settings = &$variables['settings'];
146
  $caption = &$variables['caption'];
147
  $attributes = &$variables['settings']['attributes'];
134 148

  
135 149
  // Generated thumbnail support
136 150
  if (isset($settings['optionset']->options['controlNav']) and $settings['optionset']->options['controlNav'] === "thumbnails") {
137 151
    // If the thumbnails are enabled in the option set, scan for the first img
138 152
    // tag and extract the src attribute to set as the thumbnail data
139 153
    $src = array();
140
    preg_match("<img.+?src=[\"'](.+?)[\"'].+?>", $item, $src);
154
    preg_match("/<img.+?src=[\"'](.+?)[\"'].+?>/", $item, $src);
141 155

  
142 156
    if (!empty($src[1])) {
143 157
      $attributes['data-thumb'] = $src[1];
144 158
    }
159

  
160
    // Let's also get the alt attribute to apply to thumbnails.
161
    // This only works in library version 2.6+.
162
    $alt = array();
163
    preg_match("/<img.+?alt=[\"'](.*?)[\"'].+?>/", $item, $alt);
164

  
165
    if (!empty($alt)) {
166
      $attributes['data-thumb-alt'] = $alt[1];
167
    }
145 168
  }
146 169

  
147 170
  if (isset($settings['optionset']->options['thumbCaptions']) and $settings['optionset']->options['thumbCaptions'] and !empty($caption)) {
148 171
    $attributes['data-thumbcaption'] = $caption;
149 172
    // Prevent captions from appearing in the slider as well
150 173
    if (isset($settings['optionset']->options['thumbCaptionsBoth']) and FALSE === $settings['optionset']->options['thumbCaptionsBoth']) {
151
      $caption = '';      
174
      $caption = '';
152 175
    }
153 176
  }
154 177

  

Formats disponibles : Unified diff