Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views_slideshow / views_slideshow.api.php @ 31a5a6d6

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Hooks provided by Views Slideshow.
6
 */
7
8
/**
9 c73bc8d8 Assos Assos
 * @defgroup vss_hooks Hooks
10 85ad3d82 Assos Assos
 * @{
11 c73bc8d8 Assos Assos
 * Hooks for modules to implement to extend or modify Views Slideshow.
12
 *
13
 * Allows modules to create actual slideshow implementations or add
14
 * widgets such as pagers.
15
 *
16
 * @see contrib\views_slideshow_simple_pager\views_slideshow_simple_pager.module
17
 * @see https://api.drupal.org/api/drupal/includes%21module.inc/group/hooks/7.x
18 85ad3d82 Assos Assos
 */
19
20
/**
21
 * Define the type of the slideshow (eg.: cycle, imageflow, ddblock).
22
 *
23 a2bb1a14 Assos Assos
 * @return array
24
 *   Associative array of slideshow type and its information.
25 85ad3d82 Assos Assos
 */
26
function hook_views_slideshow_slideshow_info() {
27
  $options = array(
28
    'views_slideshow_cycle' => array(
29
      'name' => t('Cycle'),
30
      'accepts' => array(
31
        'goToSlide',
32
        'nextSlide',
33
        'pause',
34
        'play',
35
        'previousSlide',
36
      ),
37
      'calls' => array(
38
        'transitionBegin',
39
        'transitionEnd',
40
        'goToSlide',
41
        'pause',
42
        'play',
43
        'nextSlide',
44
        'previousSlide',
45
      ),
46
    ),
47
  );
48
  return $options;
49
}
50
51
/**
52
 * Define form fields to be displayed in the views settings form.
53 a2bb1a14 Assos Assos
 *
54 85ad3d82 Assos Assos
 * These fields would help configure your slideshow type.
55
 */
56
function hook_views_slideshow_slideshow_type_form(&$form, &$form_state, &$view) {
57
  $form['views_slideshow_cycle']['effect'] = array(
58
    '#type' => 'select',
59
    '#title' => t('Effect'),
60
    '#options' => $effects,
61
    '#default_value' => $view->options['views_slideshow_cycle']['effect'],
62 a2bb1a14 Assos Assos
    '#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'))))),
63 85ad3d82 Assos Assos
  );
64
}
65
66
/**
67 a2bb1a14 Assos Assos
 * Set default values for options specified in hook_views_slideshow_type_form.
68 85ad3d82 Assos Assos
 *
69 a2bb1a14 Assos Assos
 * @return array
70
 *   Associative array of slideshow type name and options.
71 85ad3d82 Assos Assos
 */
72
function hook_views_slideshow_option_definition() {
73
  $options['views_slideshow_cycle'] = array(
74
    'contains' => array(
75 a2bb1a14 Assos Assos
      // Transition.
76 85ad3d82 Assos Assos
      'effect' => array('default' => 'fade'),
77
      'transition_advanced' => array('default' => 0),
78
      'timeout' => array('default' => 5000),
79 a2bb1a14 Assos Assos
      'speed' => array('default' => 700),
80 85ad3d82 Assos Assos
      'delay' => array('default' => 0),
81
      'sync' => array('default' => 1),
82
      'random' => array('default' => 0),
83 a2bb1a14 Assos Assos
    ),
84 85ad3d82 Assos Assos
  );
85
  return $options;
86
}
87
88
/**
89
 * Form validation callback for the slideshow settings.
90
 */
91
function hook_views_slideshow_options_form_validate(&$form, &$form_state, &$view) {
92
  if (!is_numeric($form_state['values']['style_options']['views_slideshow_cycle']['speed'])) {
93 0ece262b Assos Assos
    form_error($form['views_slideshow_cycle']['speed'], t('!setting must be numeric!', array('!setting' => 'Speed')));
94 85ad3d82 Assos Assos
  }
95
  if (!is_numeric($form_state['values']['style_options']['views_slideshow_cycle']['timeout'])) {
96 0ece262b Assos Assos
    form_error($form['views_slideshow_cycle']['timeout'], t('!setting must be numeric!', array('!setting' => 'Timeout')));
97 85ad3d82 Assos Assos
  }
98
  if (!is_numeric($form_state['values']['style_options']['views_slideshow_cycle']['remember_slide_days'])) {
99 0ece262b Assos Assos
    form_error($form['views_slideshow_cycle']['remember_slide_days'], t('!setting must be numeric!', array('!setting' => 'Slide days')));
100 85ad3d82 Assos Assos
  }
101
}
102
103
/**
104
 * Form submission callback for the slideshow settings.
105
 */
106
function hook_views_slideshow_options_form_submit($form, &$form_state) {
107
  // Act on option submission.
108
}
109
110
/**
111
 * Define slideshow skins to be available to the end user.
112
 */
113
function hook_views_slideshow_skin_info() {
114
  return array(
115
    'default' => array(
116
      'name' => t('Default'),
117
    ),
118
  );
119
}
120
121
/**
122
 * Define new widgets (pagers, controls, counters).
123
 *
124
 * Available events for accepts and calls
125
 *  - pause
126
 *  - play
127
 *  - nextSlide
128
 *  - previousSlide
129
 *  - goToSlide
130
 *  - transitionBegin
131 a2bb1a14 Assos Assos
 *  - transitionEnd.
132 85ad3d82 Assos Assos
 *
133 a2bb1a14 Assos Assos
 * @return array
134
 *   Array keyed by the widget names.
135 85ad3d82 Assos Assos
 */
136
function hook_views_slideshow_widget_info() {
137
  return array(
138
    'views_slideshow_pager' => array(
139
      'name' => t('Pager'),
140
      'accepts' => array(
141
        'transitionBegin' => array('required' => TRUE),
142 a2bb1a14 Assos Assos
        'goToSlide' => array(),
143
        'previousSlide' => array(),
144
        'nextSlide' => array(),
145 85ad3d82 Assos Assos
      ),
146
      'calls' => array(
147
        'goToSlide',
148
        'pause',
149
        'play',
150
      ),
151
    ),
152
    'views_slideshow_controls' => array(
153
      'name' => t('Controls'),
154
      'accepts' => array(
155
        'pause' => array('required' => TRUE),
156
        'play' => array('required' => TRUE),
157
      ),
158
      'calls' => array(
159
        'nextSlide',
160
        'pause',
161
        'play',
162
        'previousSlide',
163
      ),
164
    ),
165
    'views_slideshow_slide_counter' => array(
166
      'name' => t('Slide Counter'),
167
      'accepts' => array(
168
        'transitionBegin' => array('required' => TRUE),
169 a2bb1a14 Assos Assos
        'goToSlide' => array(),
170
        'previousSlide' => array(),
171
        'nextSlide' => array(),
172 85ad3d82 Assos Assos
      ),
173
      'calls' => array(),
174
    ),
175
  );
176
}
177
178
/**
179 a2bb1a14 Assos Assos
 * Form fields to be added for a specific widget type.
180
 *
181
 * Example of a widget type would be views_slideshow_pager
182
 * or views_slideshow_slide_counter.
183 85ad3d82 Assos Assos
 */
184
function INSERT_WIDGET_TYPE_HERE_views_slideshow_widget_form_options(&$form, $form_state, $view, $defaults, $dependency) {
185
}
186
187
/**
188
 * Hook called by the pager widget to configure it, the fields that should be shown.
189
 */
190
function hook_views_slideshow_widget_pager_info($view) {
191
}
192
193
/**
194
 * Hook called by the pager widget to add form items.
195
 */
196
function INSERT_WIDGET_TYPE_HERE_views_slideshow_widget_pager_form_options(&$form, &$form_state, &$view, $defaults, $dependency) {
197
}
198
199
/**
200
 * Hook called by the controls widget to configure it, the fields that should be shown.
201
 */
202
function hook_views_slideshow_widget_controls_info($view) {
203
}
204
205
/**
206
 * Hook called by the controls widget to add form items.
207
 */
208
function INSERT_WIDGET_TYPE_HERE_views_slideshow_widget_controls_form_options(&$form, &$form_state, &$view, $defaults, $dependency) {
209
}
210
211
/**
212 c73bc8d8 Assos Assos
 * @} End of "defgroup vss_hooks".
213 85ad3d82 Assos Assos
 */