Projet

Général

Profil

Paste
Télécharger (5,61 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views_slideshow / views_slideshow.api.php @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Hooks provided by Views Slideshow.
6
 */
7

    
8
/**
9
 * @addtogroup hooks
10
 * @{
11
 */
12

    
13
/**
14
 * Define the type of the slideshow (eg.: cycle, imageflow, ddblock).
15
 *
16
 * @return array
17
 *   Associative array of slideshow type and its information.
18
 */
19
function hook_views_slideshow_slideshow_info() {
20
  $options = array(
21
    'views_slideshow_cycle' => array(
22
      'name' => t('Cycle'),
23
      'accepts' => array(
24
        'goToSlide',
25
        'nextSlide',
26
        'pause',
27
        'play',
28
        'previousSlide',
29
      ),
30
      'calls' => array(
31
        'transitionBegin',
32
        'transitionEnd',
33
        'goToSlide',
34
        'pause',
35
        'play',
36
        'nextSlide',
37
        'previousSlide',
38
      ),
39
    ),
40
  );
41
  return $options;
42
}
43

    
44
/**
45
 * Define form fields to be displayed in the views settings form.
46
 *
47
 * These fields would help configure your slideshow type.
48
 */
49
function hook_views_slideshow_slideshow_type_form(&$form, &$form_state, &$view) {
50
  $form['views_slideshow_cycle']['effect'] = array(
51
    '#type' => 'select',
52
    '#title' => t('Effect'),
53
    '#options' => $effects,
54
    '#default_value' => $view->options['views_slideshow_cycle']['effect'],
55
    '#description' => t('The transition effect that will be used to change between images. Not all options below may be relevant depending on the effect. !link', array('!link' => l(t('Follow this link to see examples of each effect.'), 'http://jquery.malsup.com/cycle/browser.html', array('attributes' => array('target' => '_blank'))))),
56
  );
57
}
58

    
59
/**
60
 * Set default values for options specified in hook_views_slideshow_type_form.
61
 *
62
 * @return array
63
 *   Associative array of slideshow type name and options.
64
 */
65
function hook_views_slideshow_option_definition() {
66
  $options['views_slideshow_cycle'] = array(
67
    'contains' => array(
68
      // Transition.
69
      'effect' => array('default' => 'fade'),
70
      'transition_advanced' => array('default' => 0),
71
      'timeout' => array('default' => 5000),
72
      'speed' => array('default' => 700),
73
      'delay' => array('default' => 0),
74
      'sync' => array('default' => 1),
75
      'random' => array('default' => 0),
76
    ),
77
  );
78
  return $options;
79
}
80

    
81
/**
82
 * Form validation callback for the slideshow settings.
83
 */
84
function hook_views_slideshow_options_form_validate(&$form, &$form_state, &$view) {
85
  if (!is_numeric($form_state['values']['style_options']['views_slideshow_cycle']['speed'])) {
86
    form_error($form['views_slideshow_cycle']['speed'], t('!setting must be numeric!', array('!setting' => 'Speed')));
87
  }
88
  if (!is_numeric($form_state['values']['style_options']['views_slideshow_cycle']['timeout'])) {
89
    form_error($form['views_slideshow_cycle']['timeout'], t('!setting must be numeric!', array('!setting' => 'Timeout')));
90
  }
91
  if (!is_numeric($form_state['values']['style_options']['views_slideshow_cycle']['remember_slide_days'])) {
92
    form_error($form['views_slideshow_cycle']['remember_slide_days'], t('!setting must be numeric!', array('!setting' => 'Slide days')));
93
  }
94
}
95

    
96
/**
97
 * Form submission callback for the slideshow settings.
98
 */
99
function hook_views_slideshow_options_form_submit($form, &$form_state) {
100
  // Act on option submission.
101
}
102

    
103
/**
104
 * Define slideshow skins to be available to the end user.
105
 */
106
function hook_views_slideshow_skin_info() {
107
  return array(
108
    'default' => array(
109
      'name' => t('Default'),
110
    ),
111
  );
112
}
113

    
114
/**
115
 * Define new widgets (pagers, controls, counters).
116
 *
117
 * Available events for accepts and calls
118
 *  - pause
119
 *  - play
120
 *  - nextSlide
121
 *  - previousSlide
122
 *  - goToSlide
123
 *  - transitionBegin
124
 *  - transitionEnd.
125
 *
126
 * @return array
127
 *   Array keyed by the widget names.
128
 */
129
function hook_views_slideshow_widget_info() {
130
  return array(
131
    'views_slideshow_pager' => array(
132
      'name' => t('Pager'),
133
      'accepts' => array(
134
        'transitionBegin' => array('required' => TRUE),
135
        'goToSlide' => array(),
136
        'previousSlide' => array(),
137
        'nextSlide' => array(),
138
      ),
139
      'calls' => array(
140
        'goToSlide',
141
        'pause',
142
        'play',
143
      ),
144
    ),
145
    'views_slideshow_controls' => array(
146
      'name' => t('Controls'),
147
      'accepts' => array(
148
        'pause' => array('required' => TRUE),
149
        'play' => array('required' => TRUE),
150
      ),
151
      'calls' => array(
152
        'nextSlide',
153
        'pause',
154
        'play',
155
        'previousSlide',
156
      ),
157
    ),
158
    'views_slideshow_slide_counter' => array(
159
      'name' => t('Slide Counter'),
160
      'accepts' => array(
161
        'transitionBegin' => array('required' => TRUE),
162
        'goToSlide' => array(),
163
        'previousSlide' => array(),
164
        'nextSlide' => array(),
165
      ),
166
      'calls' => array(),
167
    ),
168
  );
169
}
170

    
171
/**
172
 * Form fields to be added for a specific widget type.
173
 *
174
 * Example of a widget type would be views_slideshow_pager
175
 * or views_slideshow_slide_counter.
176
 */
177
function INSERT_WIDGET_TYPE_HERE_views_slideshow_widget_form_options(&$form, $form_state, $view, $defaults, $dependency) {
178
}
179

    
180
/**
181
 * Hook called by the pager widget to configure it, the fields that should be shown.
182
 */
183
function hook_views_slideshow_widget_pager_info($view) {
184
}
185

    
186
/**
187
 * Hook called by the pager widget to add form items.
188
 */
189
function INSERT_WIDGET_TYPE_HERE_views_slideshow_widget_pager_form_options(&$form, &$form_state, &$view, $defaults, $dependency) {
190
}
191

    
192
/**
193
 * Hook called by the controls widget to configure it, the fields that should be shown.
194
 */
195
function hook_views_slideshow_widget_controls_info($view) {
196
}
197

    
198
/**
199
 * Hook called by the controls widget to add form items.
200
 */
201
function INSERT_WIDGET_TYPE_HERE_views_slideshow_widget_controls_form_options(&$form, &$form_state, &$view, $defaults, $dependency) {
202
}
203

    
204
/**
205
 * @} End of "addtogroup hooks".
206
 */