1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
/**
|
5 |
|
|
* @file
|
6 |
|
|
* Enables your site to display dynamic content in a block.
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Implements hook_help().
|
11 |
|
|
*/
|
12 |
|
|
function ddblock_help($path, $arg) {
|
13 |
|
|
switch ($path) {
|
14 |
|
|
case "admin/help#ddblock":
|
15 |
|
|
$output = '<p>' . t('Display content dynamically in a block using the jQuery Cycle plugin and the jQuery UI plugin for easing') . '</p>';
|
16 |
|
|
$output .= '<p>' . t('There are three methods to provide content for a dynamic display block. An input folder with images, a node from a content type or by making an instance of any block to use the block content of the original block as content for the dynamic display block') . '</p>';
|
17 |
|
|
return $output;
|
18 |
|
|
}
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
/**
|
22 |
|
|
* add javascript and css files.
|
23 |
|
|
*/
|
24 |
|
|
function ddblock_init_js_css() {
|
25 |
|
|
// add jquery.ui
|
26 |
|
|
drupal_add_library('system', 'effects');
|
27 |
|
|
// get module path to dynamic display block module
|
28 |
|
|
$ddblock_path = drupal_get_path('module', 'ddblock');
|
29 |
|
|
|
30 |
|
|
//add jcycle plugin
|
31 |
|
|
// Don't load javascript unless libraries module is present.
|
32 |
|
|
if (module_exists('libraries')) {
|
33 |
|
|
// Load jQuery Cycle
|
34 |
|
|
$cycle_path = libraries_get_path('jquery.cycle');
|
35 |
|
|
if (!empty($cycle_path) && file_exists($cycle_path . '/jquery.cycle.all.min.js')) {
|
36 |
|
|
drupal_add_js($cycle_path . '/jquery.cycle.all.min.js');
|
37 |
|
|
}
|
38 |
|
|
elseif (!empty($cycle_path) && file_exists($cycle_path . '/jquery.cycle.all.js')) {
|
39 |
|
|
drupal_add_js($cycle_path . '/jquery.cycle.all.js');
|
40 |
|
|
}
|
41 |
|
|
}
|
42 |
|
|
// add json pack to parse json
|
43 |
|
|
drupal_add_js($ddblock_path . '/js/json2.pack.js');
|
44 |
|
|
|
45 |
|
|
// add ddblock js file
|
46 |
|
|
drupal_add_js($ddblock_path . '/js/ddblock.js');
|
47 |
|
|
|
48 |
|
|
// add Cascading style sheet
|
49 |
|
|
drupal_add_css($ddblock_path . '/css/ddblock.css');
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
|
|
* Implements hook_menu().
|
54 |
|
|
*/
|
55 |
|
|
function ddblock_menu() {
|
56 |
|
|
|
57 |
|
|
// add ddblock
|
58 |
|
|
$items['admin/structure/ddblock'] = array(
|
59 |
|
|
'title' => 'Dynamic display block',
|
60 |
|
|
'description' => 'Manage dynamic display blocks.',
|
61 |
|
|
'page callback' => 'drupal_get_form',
|
62 |
|
|
'page arguments' => array('ddblock_block_add_form'),
|
63 |
|
|
'access arguments' => array('administer dynamic display blocks'),
|
64 |
|
|
'type' => MENU_NORMAL_ITEM,
|
65 |
|
|
'file' => 'ddblock.admin.inc',
|
66 |
|
|
);
|
67 |
|
|
|
68 |
|
|
// list tab in settings page.
|
69 |
|
|
$items['admin/structure/ddblock/list'] = array(
|
70 |
|
|
'title' => 'List',
|
71 |
|
|
'page arguments' => array('ddblock_block_add_form'),
|
72 |
|
|
'access arguments' => array('administer dynamic display blocks'),
|
73 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
74 |
|
|
'weight' => -10,
|
75 |
|
|
);
|
76 |
|
|
|
77 |
|
|
// Settings tab in settings page.
|
78 |
|
|
$items['admin/structure/ddblock/settings'] = array(
|
79 |
|
|
'title' => 'Settings',
|
80 |
|
|
'page arguments' => array('ddblock_settings_form'),
|
81 |
|
|
'access arguments' => array('administer dynamic display blocks'),
|
82 |
|
|
'type' => MENU_LOCAL_TASK,
|
83 |
|
|
'weight' => 10,
|
84 |
|
|
'file' => 'ddblock.admin.inc',
|
85 |
|
|
);
|
86 |
|
|
|
87 |
|
|
// Edit dynamic display block.
|
88 |
|
|
$items['admin/structure/ddblock/edit/%'] = array(
|
89 |
|
|
'title' => 'Edit dynamic display block',
|
90 |
|
|
'page callback' => 'drupal_get_form',
|
91 |
|
|
'page arguments' => array('ddblock_block_edit_form', 4),
|
92 |
|
|
'access arguments' => array('administer dynamic display blocks'),
|
93 |
|
|
'type' => MENU_CALLBACK,
|
94 |
|
|
'file' => 'ddblock.admin.inc',
|
95 |
|
|
);
|
96 |
|
|
|
97 |
|
|
// Delete dynamic display block or instance.
|
98 |
|
|
$items['admin/structure/ddblock/delete/%'] = array(
|
99 |
|
|
'title' => 'Delete dynamic display block',
|
100 |
|
|
'page callback' => 'drupal_get_form',
|
101 |
|
|
'page arguments' => array('ddblock_block_confirm_delete_form', 4),
|
102 |
|
|
'access arguments' => array('administer dynamic display blocks'),
|
103 |
|
|
'type' => MENU_CALLBACK,
|
104 |
|
|
'file' => 'ddblock.admin.inc',
|
105 |
|
|
);
|
106 |
|
|
|
107 |
|
|
// Add ddblock instance.
|
108 |
|
|
$items['admin/structure/ddblock/instances'] = array(
|
109 |
|
|
'title' => 'Instances',
|
110 |
|
|
'description' => 'Create and delete instances of blocks.',
|
111 |
|
|
'page callback' => 'ddblock_instances',
|
112 |
|
|
'access callback' => 'user_access',
|
113 |
|
|
'access arguments' => array('administer blocks'),
|
114 |
|
|
'type' => MENU_LOCAL_TASK,
|
115 |
|
|
'weight' => -1,
|
116 |
|
|
);
|
117 |
|
|
|
118 |
|
|
// Ahah update nodes to choose of content type.
|
119 |
|
|
$items['ddblock/js/select_nodes'] = array(
|
120 |
|
|
'page callback' => 'ddblock_select_nodes_js',
|
121 |
|
|
'access arguments' => array('access content'),
|
122 |
|
|
'type' => MENU_CALLBACK,
|
123 |
|
|
);
|
124 |
|
|
|
125 |
|
|
$items['ddblock_mapping/js/%'] = array(
|
126 |
|
|
'page callback' => 'ddblock_mapping_js',
|
127 |
|
|
'page arguments' => array(2),
|
128 |
|
|
'access arguments' => array('access content'),
|
129 |
|
|
'type ' => MENU_CALLBACK,
|
130 |
|
|
);
|
131 |
|
|
|
132 |
|
|
// Ahah update available template sizes of themes.
|
133 |
|
|
// This block defines the path to which the AHAH call points.
|
134 |
|
|
// The path relays the call to a specific AHAH callback function.
|
135 |
|
|
$items['ddblock/js'] = array(
|
136 |
|
|
'page callback' => 'ddblock_select_template_ahah', // the AHAH callback function
|
137 |
|
|
'access callback' => TRUE,
|
138 |
|
|
'type' => MENU_CALLBACK,
|
139 |
|
|
);
|
140 |
|
|
|
141 |
|
|
return $items;
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
/**
|
145 |
|
|
* Implements hook_permission().
|
146 |
|
|
*/
|
147 |
|
|
function ddblock_permission() {
|
148 |
|
|
return array(
|
149 |
|
|
'administer dynamic display blocks' => array(
|
150 |
|
|
'title' => t('administer dynamic display blocks'),
|
151 |
|
|
'description' => t('Allow users to administer dynamic display blocks'),
|
152 |
|
|
),
|
153 |
|
|
'view dynamic display blocks' => array(
|
154 |
|
|
'title' => t('view dynamic display blocks'),
|
155 |
|
|
'description' => t('Allow users to view dynamic display blocks'),
|
156 |
|
|
),
|
157 |
|
|
);
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
/**
|
161 |
|
|
* Implements hook_block_info().
|
162 |
|
|
*/
|
163 |
|
|
function ddblock_block_info() {
|
164 |
|
|
$blocks = ddblock_get_blocks(NULL);
|
165 |
|
|
$list = array();
|
166 |
|
|
foreach ($blocks as $block) {
|
167 |
|
|
$list[$block->delta] = array(
|
168 |
|
|
'info' => check_plain($block->title),
|
169 |
|
|
'cache' => DRUPAL_NO_CACHE); // Don't cache blocks.
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
return $list;
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
/**
|
176 |
|
|
* Implements hook_block_configure().
|
177 |
|
|
*/
|
178 |
|
|
function ddblock_block_configure($delta = '') {
|
179 |
|
|
// if block is a ddblock instance invoke configure option of original block.
|
180 |
|
|
// with form_alter the ddblock settings are added.
|
181 |
|
|
$block = ddblock_get_blocks($delta);
|
182 |
|
|
if ($block->enabled == 1) {
|
183 |
|
|
$module = $block->module;
|
184 |
|
|
$delta_original = $block->delta_original;
|
185 |
|
|
return module_invoke($module, 'block_configure', $delta_original);
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
// if block is a ddblock invoke the block configure page.
|
189 |
|
|
return ddblock_block_configure_form($delta);
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
/**
|
193 |
|
|
* Implements hook_block_save().
|
194 |
|
|
*/
|
195 |
|
|
function ddblock_block_save($delta = '', $edit = array()) {
|
196 |
|
|
//all blocks are instances of ddblock.
|
197 |
|
|
$module = 'ddblock';
|
198 |
|
|
ddblock_set_configuration_settings($module, $delta, $edit);
|
199 |
|
|
$module = 'ddblock_cycle';
|
200 |
|
|
ddblock_set_cycle_configuration_settings($module, $delta, $edit);
|
201 |
|
|
if ($edit['input_type'] == 'instance' ) {
|
202 |
|
|
$module = 'ddblock_cycle';
|
203 |
|
|
ddblock_set_cycle_mapping_settings($module, $delta, $edit);
|
204 |
|
|
}
|
205 |
|
|
}
|
206 |
|
|
/**
|
207 |
|
|
* Implements hook_block_view().
|
208 |
|
|
*/
|
209 |
|
|
function ddblock_block_view($delta = '') {
|
210 |
|
|
$block = array();
|
211 |
|
|
|
212 |
|
|
//all blocks are instances of ddblock.
|
213 |
|
|
$module = 'ddblock';
|
214 |
|
|
|
215 |
|
|
if (user_access('view dynamic display blocks')) {
|
216 |
|
|
$block['subject'] = ddblock_subject($module, $delta);
|
217 |
|
|
$block['content'] = ddblock_content($module, $delta);
|
218 |
|
|
|
219 |
|
|
if (!empty($block['content'])) {
|
220 |
|
|
return $block;
|
221 |
|
|
}
|
222 |
|
|
}
|
223 |
|
|
return;
|
224 |
|
|
}
|
225 |
|
|
|
226 |
|
|
/**
|
227 |
|
|
* Return all or one dynamic display block.
|
228 |
|
|
*
|
229 |
|
|
* @param $delta
|
230 |
|
|
* Optional. Retreive a single block based on this delta. If none specified,
|
231 |
|
|
* all blocks are returned.
|
232 |
|
|
* @param $reset
|
233 |
|
|
* Optional. Boolean value to reset the interal cache of this function.
|
234 |
|
|
* @return
|
235 |
|
|
* array of dynamic display blocks.
|
236 |
|
|
*/
|
237 |
|
|
function ddblock_get_blocks($delta = NULL, $reset = FALSE) {
|
238 |
|
|
static $blocks;
|
239 |
|
|
|
240 |
|
|
if (!isset($blocks) || $reset) {
|
241 |
|
|
$blocks = array();
|
242 |
|
|
|
243 |
|
|
$sql = "SELECT * " .
|
244 |
|
|
"FROM {ddblock_block}";
|
245 |
|
|
$results = db_query($sql);
|
246 |
|
|
|
247 |
|
|
while ($block = $results->fetchObject()) {
|
248 |
|
|
$blocks[$block->delta] = $block;
|
249 |
|
|
}
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
return is_numeric($delta) ? $blocks[$delta] : $blocks;
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
/**
|
256 |
|
|
* Block configuration page of dynamic display block blocks added to standard block configuration page.
|
257 |
|
|
*
|
258 |
|
|
* @param $delta
|
259 |
|
|
* Blocknumber of the block.
|
260 |
|
|
*
|
261 |
|
|
* @return
|
262 |
|
|
* form with configuration settings.
|
263 |
|
|
*/
|
264 |
|
|
function ddblock_block_configure_form($delta) {
|
265 |
|
|
|
266 |
|
|
// get configuration settings
|
267 |
|
|
foreach (ddblock_get_configuration_settings('ddblock', $delta)->settings() as $key => $value) {
|
268 |
|
|
${$key} = $value;
|
269 |
|
|
}
|
270 |
|
|
// get configuration settings
|
271 |
|
|
foreach (ddblock_get_cycle_configuration_settings('ddblock_cycle', $delta)->settings() as $key => $value) {
|
272 |
|
|
${$key} = $value;
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
// get module path to dynamic display block module
|
276 |
|
|
$ddblock_path = drupal_get_path('module', 'ddblock');
|
277 |
|
|
// add ddblock js file
|
278 |
|
|
drupal_add_js($ddblock_path . '/js/ddblock.admin.js');
|
279 |
|
|
|
280 |
|
|
// Need this for AJAX.
|
281 |
|
|
$form['#cache'] = TRUE;
|
282 |
|
|
|
283 |
|
|
// show warning that cycle plugin is not installed.
|
284 |
|
|
$cycle_path = libraries_get_path('jquery.cycle');
|
285 |
|
|
if (empty($cycle_path) || !(file_exists($cycle_path . '/jquery.cycle.all.min.js') || file_exists($cycle_path . '/jquery.cycle.all.js'))) {
|
286 |
|
|
$form['no_cycle_js'] = array(
|
287 |
|
|
'#type' => 'item',
|
288 |
|
|
'#title' => 'Cycle plugin',
|
289 |
|
|
'#markup' => '<div style="color: red">' . t('You need to install the jQuery cycle plugin.<br />
|
290 |
|
|
Create a directory in sites/all/libraries called jquery.cycle, and then copy jquery.cycle.all.js or jquery.cycle.all.min.js into it.<br />
|
291 |
|
|
Latest version tested: 2.99<br />
|
292 |
|
|
You can find the plugin at !url.', array('!url' => l('http://malsup.com/jquery/cycle/download.html', 'http://malsup.com/jquery/cycle/download.html', array('attributes' => array('target' => '_blank'))))) . '</div>',
|
293 |
|
|
'#prefix' => '<div id="ddblock-no-cycle-js">',
|
294 |
|
|
'#suffix' => '</div>',
|
295 |
|
|
'#weight' => -11,
|
296 |
|
|
);
|
297 |
|
|
}
|
298 |
|
|
|
299 |
|
|
// content settings: what to use as content for the dynamic display block.
|
300 |
|
|
$form['content'] = array(
|
301 |
|
|
'#type' => 'fieldset',
|
302 |
|
|
'#collapsible' => TRUE,
|
303 |
|
|
'#title' => t('Content settings'),
|
304 |
|
|
'#prefix' => '<div id="ddblock-content-settings">',
|
305 |
|
|
'#suffix' => '</div>',
|
306 |
|
|
'#weight' => -1,
|
307 |
|
|
);
|
308 |
|
|
|
309 |
|
|
// input type settings
|
310 |
|
|
$options = array(
|
311 |
|
|
'images' => t('Image folder'),
|
312 |
|
|
'nodes' => t('Content type'),
|
313 |
|
|
);
|
314 |
|
|
$form['content']['input_type'] = array(
|
315 |
|
|
'#type' => 'select',
|
316 |
|
|
'#title' => t('Input type'),
|
317 |
|
|
'#default_value' => $input_type,
|
318 |
|
|
'#options' => $options,
|
319 |
|
|
'#multiple' => FALSE,
|
320 |
|
|
'#required' => TRUE,
|
321 |
|
|
'#description' => t("Input of the dynamic display block."),
|
322 |
|
|
'#weight' => -7,
|
323 |
|
|
);
|
324 |
|
|
|
325 |
|
|
// image folder settings.
|
326 |
|
|
$form['content']['image_folder'] = array(
|
327 |
|
|
'#type' => 'fieldset',
|
328 |
|
|
'#collapsible' => TRUE,
|
329 |
|
|
'#title' => t('Image folder settings'),
|
330 |
|
|
'#prefix' => '<div id="ddblock-image-folder-settings-wrapper">',
|
331 |
|
|
'#suffix' => '</div>',
|
332 |
|
|
'#weight' => -6,
|
333 |
|
|
);
|
334 |
|
|
|
335 |
|
|
$form['content']['image_folder']['folder'] = array(
|
336 |
|
|
'#type' => 'textfield',
|
337 |
|
|
'#title' => t('Image Folder'),
|
338 |
|
|
'#default_value' => $folder,
|
339 |
|
|
'#size' => 25,
|
340 |
|
|
'#maxlength' => 100,
|
341 |
|
|
'#required' => FALSE,
|
342 |
|
|
'#description' => t("The folder containing image files to be used as the content of dynamic display block. The folder is relative to the drupal files path in admin > settings > file-system. e.g. <strong>images/ddblock</strong>."),
|
343 |
|
|
);
|
344 |
|
|
|
345 |
|
|
$form['content']['image_folder']['ignore_files'] = array(
|
346 |
|
|
'#type' => 'textfield',
|
347 |
|
|
'#title' => t('Ignore files'),
|
348 |
|
|
'#default_value' => $ignore_files,
|
349 |
|
|
'#required' => FALSE,
|
350 |
|
|
'#description' => t("Ignore these files to be shown. e.g. ignore file with _thumbnail, _preview in the file_name.<br />
|
351 |
|
|
You can use a comma seprated list"),
|
352 |
|
|
);
|
353 |
|
|
|
354 |
|
|
$form['content']['image_folder']['max_image'] = array(
|
355 |
|
|
'#type' => 'textfield',
|
356 |
|
|
'#title' => t('Number of images'),
|
357 |
|
|
'#default_value' => $max_image,
|
358 |
|
|
'#required' => FALSE,
|
359 |
|
|
'#description' => t("The number of images to show in the block."),
|
360 |
|
|
);
|
361 |
|
|
|
362 |
|
|
// content type settings.
|
363 |
|
|
$form['content']['content_types'] = array(
|
364 |
|
|
'#type' => 'fieldset',
|
365 |
|
|
'#collapsible' => TRUE,
|
366 |
|
|
'#title' => t('Content type settings'),
|
367 |
|
|
'#prefix' => '<div id="ddblock-content-types-settings-wrapper">',
|
368 |
|
|
'#suffix' => '</div>',
|
369 |
|
|
'#weight' => -5,
|
370 |
|
|
);
|
371 |
|
|
|
372 |
|
|
// get possible content types from settings.
|
373 |
|
|
$node_types = variable_get('ddblock_node_type', array());
|
374 |
|
|
foreach ($node_types as $key => $value ) {
|
375 |
|
|
if ($value) {
|
376 |
|
|
$content_types[$key] = $value;
|
377 |
|
|
}
|
378 |
|
|
}
|
379 |
|
|
|
380 |
|
|
// add a none option to the content types to choose from.
|
381 |
|
|
$content_types['none'] = t("None");
|
382 |
|
|
|
383 |
|
|
$form['content']['content_types']['content_type'] = array(
|
384 |
|
|
'#type' => 'select',
|
385 |
|
|
'#title' => t('Content Type'),
|
386 |
|
|
'#default_value' => $content_type,
|
387 |
|
|
'#options' => $content_types,
|
388 |
|
|
'#description' => t("The nodes of the content type to be used as content of dynamic display block.<br />Only content types enabled in the settings tab of the ddblock module will show up here."),
|
389 |
|
|
'#attributes' => array('class' => array('content-type-select')),
|
390 |
|
|
'#ahah' => array(
|
391 |
|
|
'path' => 'ddblock/js/select_nodes',
|
392 |
|
|
'wrapper' => 'select-nodes-wrapper',
|
393 |
|
|
'effect' => 'slide',
|
394 |
|
|
),
|
395 |
|
|
);
|
396 |
|
|
|
397 |
|
|
ddblock_select_nodes_form($form, $content_type, $nodes);
|
398 |
|
|
|
399 |
|
|
$options = array(
|
400 |
|
|
'body' => t('Body'),
|
401 |
|
|
'teaser' => t('Teaser'),
|
402 |
|
|
);
|
403 |
|
|
$form['content']['content_types']['node_body_teaser'] = array(
|
404 |
|
|
'#type' => 'radios',
|
405 |
|
|
'#title' => t('Node content'),
|
406 |
|
|
'#default_value' => $node_body_teaser,
|
407 |
|
|
'#options' => $options,
|
408 |
|
|
'#multiple' => FALSE,
|
409 |
|
|
'#required' => TRUE,
|
410 |
|
|
'#description' => t("Show node body or teaser"),
|
411 |
|
|
);
|
412 |
|
|
|
413 |
|
|
|
414 |
|
|
// get image style options
|
415 |
|
|
$image_style_options = image_style_options(FALSE);
|
416 |
|
|
// if image styles exist make it possible to use image styles
|
417 |
|
|
if (is_array($image_style_options)) {
|
418 |
|
|
$image_style_options['none'] = 'None';
|
419 |
|
|
$image_style_slide_desc = t("Style options to use for slide image");
|
420 |
|
|
$image_style_pager_item_desc = t("Style options to use for pager-item image. Only for themes that use an image in the pager");
|
421 |
|
|
|
422 |
|
|
// Image style toggle
|
423 |
|
|
$form['block_settings']['image_style_toggle'] = array(
|
424 |
|
|
'#type' => 'checkbox',
|
425 |
|
|
'#title' => t('Use image styles'),
|
426 |
|
|
'#default_value' => $image_style_toggle,
|
427 |
|
|
'#required' => FALSE,
|
428 |
|
|
'#description' => t("Use image styles for images"),
|
429 |
|
|
'#weight' => -5,
|
430 |
|
|
);
|
431 |
|
|
|
432 |
|
|
// Image style settings.
|
433 |
|
|
$extra = (empty($image_style_toggle)) ? ' style="display:none"' : '';
|
434 |
|
|
$form['block_settings']['image_style'] = array(
|
435 |
|
|
'#type' => 'fieldset',
|
436 |
|
|
'#collapsible' => TRUE,
|
437 |
|
|
'#title' => t('Image styles settings'),
|
438 |
|
|
'#prefix' => '<div id="ddblock-image-style-settings-wrapper"' . $extra . '>',
|
439 |
|
|
'#suffix' => '</div>',
|
440 |
|
|
'#weight' => -4,
|
441 |
|
|
);
|
442 |
|
|
|
443 |
|
|
$form['block_settings']['image_style']['image_style_slide'] = array(
|
444 |
|
|
'#type' => 'select',
|
445 |
|
|
'#title' => t('Image style slide image'),
|
446 |
|
|
'#default_value' => $image_style_slide,
|
447 |
|
|
'#options' => $image_style_options,
|
448 |
|
|
'#multiple' => FALSE,
|
449 |
|
|
'#required' => FALSE,
|
450 |
|
|
'#description' => $image_style_slide_desc,
|
451 |
|
|
'#weight' => 1,
|
452 |
|
|
);
|
453 |
|
|
|
454 |
|
|
$form['block_settings']['image_style']['image_style_pager_item'] = array(
|
455 |
|
|
'#type' => 'select',
|
456 |
|
|
'#title' => t('Image style pager-item image'),
|
457 |
|
|
'#default_value' => $image_style_pager_item,
|
458 |
|
|
'#options' => $image_style_options,
|
459 |
|
|
'#multiple' => FALSE,
|
460 |
|
|
'#required' => FALSE,
|
461 |
|
|
'#description' => $image_style_pager_item_desc,
|
462 |
|
|
'#weight' => 2,
|
463 |
|
|
);
|
464 |
|
|
}
|
465 |
|
|
|
466 |
|
|
// content container settings.
|
467 |
|
|
$form['content']['content_container'] = array(
|
468 |
|
|
'#type' => 'fieldset',
|
469 |
|
|
'#collapsible' => TRUE,
|
470 |
|
|
'#title' => t('Content container settings'),
|
471 |
|
|
'#weight' => -4,
|
472 |
|
|
);
|
473 |
|
|
|
474 |
|
|
$form['content']['content_container']['container_basic'] = array(
|
475 |
|
|
'#type' => 'textfield',
|
476 |
|
|
'#title' => t('Content container'),
|
477 |
|
|
'#default_value' => $container_basic,
|
478 |
|
|
'#required' => FALSE,
|
479 |
|
|
'#description' => t("Container of the content to show, eg. div.slide, to show the content of slides."),
|
480 |
|
|
);
|
481 |
|
|
|
482 |
|
|
$form['content']['content_container']['overflow'] = array(
|
483 |
|
|
'#type' => 'checkbox',
|
484 |
|
|
'#title' => t('Overflow hidden'),
|
485 |
|
|
'#default_value' => $overflow,
|
486 |
|
|
'#required' => FALSE,
|
487 |
|
|
'#description' => t("Hide the overflow of the container"),
|
488 |
|
|
);
|
489 |
|
|
|
490 |
|
|
$form['content']['content_container']['height'] = array(
|
491 |
|
|
'#type' => 'textfield',
|
492 |
|
|
'#title' => t('Height'),
|
493 |
|
|
'#default_value' => $height,
|
494 |
|
|
'#required' => FALSE,
|
495 |
|
|
'#description' => t("Height of the content to show.<br /> This value is often higher as the image height"),
|
496 |
|
|
);
|
497 |
|
|
|
498 |
|
|
$form['content']['content_container']['width'] = array(
|
499 |
|
|
'#type' => 'textfield',
|
500 |
|
|
'#title' => t('Width'),
|
501 |
|
|
'#default_value' => $width,
|
502 |
|
|
'#required' => FALSE,
|
503 |
|
|
'#description' => t("Width of the content to show.<br />This value is often higher as the image widht"),
|
504 |
|
|
);
|
505 |
|
|
|
506 |
|
|
// Image settings.
|
507 |
|
|
$form['content']['images'] = array(
|
508 |
|
|
'#type' => 'fieldset',
|
509 |
|
|
'#collapsible' => TRUE,
|
510 |
|
|
'#title' => t('Image settings'),
|
511 |
|
|
'#description' => t('Set to 0 (zero) for both the height and the width to be able to use the original image size or image styles.<br />To show all the images the height and width of the content container must be bigger that the biggest image.'),
|
512 |
|
|
'#weight' => -3,
|
513 |
|
|
);
|
514 |
|
|
$form['content']['images']['image_height'] = array(
|
515 |
|
|
'#type' => 'textfield',
|
516 |
|
|
'#title' => t('Height'),
|
517 |
|
|
'#default_value' => $image_height,
|
518 |
|
|
'#required' => FALSE,
|
519 |
|
|
'#description' => t("Height of the image to show"),
|
520 |
|
|
);
|
521 |
|
|
|
522 |
|
|
$form['content']['images']['image_width'] = array(
|
523 |
|
|
'#type' => 'textfield',
|
524 |
|
|
'#title' => t('Width'),
|
525 |
|
|
'#default_value' => $image_width,
|
526 |
|
|
'#required' => FALSE,
|
527 |
|
|
'#description' => t("Width of the image to show"),
|
528 |
|
|
);
|
529 |
|
|
|
530 |
|
|
//wrapper for ddblock block settings
|
531 |
|
|
$form['block_settings']['#prefix'] = '<div id="ddblock-block-settings">';
|
532 |
|
|
$form['block_settings']['#suffix'] = '</div>';
|
533 |
|
|
|
534 |
|
|
$form['block_settings']['settings'] = array(
|
535 |
|
|
'#type' => 'fieldset',
|
536 |
|
|
'#collapsible' => TRUE,
|
537 |
|
|
'#title' => t('Settings'),
|
538 |
|
|
'#weight' => 11,
|
539 |
|
|
);
|
540 |
|
|
|
541 |
|
|
// transition effect settings
|
542 |
|
|
$options = _ddblock_get_effects();
|
543 |
|
|
$form['block_settings']['settings']['fx'] = array(
|
544 |
|
|
'#type' => 'select',
|
545 |
|
|
'#title' => t('Transition Effect'),
|
546 |
|
|
'#default_value' => $fx,
|
547 |
|
|
'#options' => $options,
|
548 |
|
|
'#multiple' => FALSE,
|
549 |
|
|
'#required' => TRUE,
|
550 |
|
|
'#description' => t("The transition effect between content.<br />(all for random effect per slide, none for no effect)<br />Multiple effects can be set in the Custom jQuery Cycle Plugin Settings."),
|
551 |
|
|
);
|
552 |
|
|
|
553 |
|
|
// speed settings
|
554 |
|
|
$options = drupal_map_assoc(array(0, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000));
|
555 |
|
|
|
556 |
|
|
$form['block_settings']['settings']['speed'] = array(
|
557 |
|
|
'#type' => 'select',
|
558 |
|
|
'#title' => t('Speed'),
|
559 |
|
|
'#default_value' => $speed,
|
560 |
|
|
'#options' => $options,
|
561 |
|
|
'#required' => TRUE,
|
562 |
|
|
'#description' => t("Speed of the transitions (1000 = 1 second, 0 = direct)."),
|
563 |
|
|
);
|
564 |
|
|
|
565 |
|
|
// timeout settings
|
566 |
|
|
$options = drupal_map_assoc(array(0, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000, 30000));
|
567 |
|
|
$form['block_settings']['settings']['timeout'] = array(
|
568 |
|
|
'#type' => 'select',
|
569 |
|
|
'#title' => t('Timeout'),
|
570 |
|
|
'#default_value' => $timeout,
|
571 |
|
|
'#options' => $options,
|
572 |
|
|
'#required' => TRUE,
|
573 |
|
|
'#description' => t("The time (in milliseconds) between transitions (1000 = 1 second, 0 to disable auto advance)."),
|
574 |
|
|
);
|
575 |
|
|
|
576 |
|
|
// order settings
|
577 |
|
|
$options = array(
|
578 |
|
|
'none' => t('None'),
|
579 |
|
|
'asc' => t('Ascending'),
|
580 |
|
|
'desc' => t('Descending'),
|
581 |
|
|
);
|
582 |
|
|
$form['block_settings']['settings']['order'] = array(
|
583 |
|
|
'#type' => 'radios',
|
584 |
|
|
'#title' => t('Sort Order'),
|
585 |
|
|
'#default_value' => $order,
|
586 |
|
|
'#options' => $options,
|
587 |
|
|
'#multiple' => FALSE,
|
588 |
|
|
'#required' => TRUE,
|
589 |
|
|
'#description' => t("The display order of the content. None for using the original content order."),
|
590 |
|
|
);
|
591 |
|
|
|
592 |
|
|
// pause settings
|
593 |
|
|
$form['block_settings']['settings']['pause'] = array(
|
594 |
|
|
'#type' => 'checkbox',
|
595 |
|
|
'#title' => t('Pause'),
|
596 |
|
|
'#default_value' => $pause,
|
597 |
|
|
'#description' => t("Enable users to pause the cycle by hovering on the content."),
|
598 |
|
|
);
|
599 |
|
|
|
600 |
|
|
// next settings
|
601 |
|
|
$form['block_settings']['settings']['next'] = array(
|
602 |
|
|
'#type' => 'checkbox',
|
603 |
|
|
'#title' => t('Next'),
|
604 |
|
|
'#default_value' => $next,
|
605 |
|
|
'#description' => t("Enable users to advanced to the next content by clicking on the content."),
|
606 |
|
|
);
|
607 |
|
|
|
608 |
|
|
// pager settings
|
609 |
|
|
$form['block_settings']['settings']['pager_toggle'] = array(
|
610 |
|
|
'#type' => 'checkbox',
|
611 |
|
|
'#title' => t('Use Pager'),
|
612 |
|
|
'#default_value' => $pager_toggle,
|
613 |
|
|
'#required' => FALSE,
|
614 |
|
|
'#description' => t("Use a pager to select slides"),
|
615 |
|
|
);
|
616 |
|
|
|
617 |
|
|
// show fields when using pager
|
618 |
|
|
$extra = (empty($pager_toggle)) ? ' style="display:none"' : '';
|
619 |
|
|
$form['block_settings']['settings']['pager_settings'] = array(
|
620 |
|
|
'#type' => 'fieldset',
|
621 |
|
|
'#collapsible' => TRUE,
|
622 |
|
|
'#collapsed' => FALSE,
|
623 |
|
|
'#prefix' => '<div id="ddblock-pager-settings-wrapper"' . $extra . '>',
|
624 |
|
|
'#suffix' => '</div>',
|
625 |
|
|
'#title' => t('Pager settings'),
|
626 |
|
|
);
|
627 |
|
|
|
628 |
|
|
$options = array(
|
629 |
|
|
'number-pager' => t('Number pager'),
|
630 |
|
|
'prev-next-pager' => t('Prev next pager'),
|
631 |
|
|
'image-pager' => t('Image pager'),
|
632 |
|
|
);
|
633 |
|
|
|
634 |
|
|
$form['block_settings']['settings']['pager_settings']['pager'] = array(
|
635 |
|
|
'#type' => 'select',
|
636 |
|
|
'#title' => t('Pager'),
|
637 |
|
|
'#default_value' => $pager,
|
638 |
|
|
'#options' => $options,
|
639 |
|
|
'#required' => TRUE,
|
640 |
|
|
'#description' => t("Add a pager to the block."),
|
641 |
|
|
);
|
642 |
|
|
|
643 |
|
|
$options = array(
|
644 |
|
|
'click' => t('Click'),
|
645 |
|
|
'mouseover' => t('Mouseover'),
|
646 |
|
|
);
|
647 |
|
|
|
648 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_event'] = array(
|
649 |
|
|
'#type' => 'select',
|
650 |
|
|
'#title' => t('Pager event'),
|
651 |
|
|
'#default_value' => $pager_event,
|
652 |
|
|
'#options' => $options,
|
653 |
|
|
'#required' => FALSE,
|
654 |
|
|
'#description' => t("The event on which the pager reacts."),
|
655 |
|
|
);
|
656 |
|
|
|
657 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_height'] = array(
|
658 |
|
|
'#type' => 'textfield',
|
659 |
|
|
'#title' => t('Height'),
|
660 |
|
|
'#default_value' => $pager_height,
|
661 |
|
|
'#required' => FALSE,
|
662 |
|
|
'#description' => t("Height of the pager"),
|
663 |
|
|
);
|
664 |
|
|
|
665 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_width'] = array(
|
666 |
|
|
'#type' => 'textfield',
|
667 |
|
|
'#title' => t('Width'),
|
668 |
|
|
'#default_value' => $pager_width,
|
669 |
|
|
'#required' => FALSE,
|
670 |
|
|
'#description' => t("Width of the pager"),
|
671 |
|
|
);
|
672 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_fast'] = array(
|
673 |
|
|
'#type' => 'checkbox',
|
674 |
|
|
'#title' => t('Fast Pager'),
|
675 |
|
|
'#default_value' => $pager_fast,
|
676 |
|
|
'#required' => FALSE,
|
677 |
|
|
'#description' => t("Use fast pager event when clicked or hovered."),
|
678 |
|
|
);
|
679 |
|
|
|
680 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_pause'] = array(
|
681 |
|
|
'#type' => 'checkbox',
|
682 |
|
|
'#title' => t('Pager pause'),
|
683 |
|
|
'#default_value' => $pager_pause,
|
684 |
|
|
'#required' => FALSE,
|
685 |
|
|
'#description' => t("Pause the slideshow when pager hovered."),
|
686 |
|
|
);
|
687 |
|
|
|
688 |
|
|
// prev/next pager settings.
|
689 |
|
|
$form['block_settings']['settings']['pager2'] = array(
|
690 |
|
|
'#type' => 'checkbox',
|
691 |
|
|
'#title' => t('Prev/Next Pager'),
|
692 |
|
|
'#default_value' => $pager2,
|
693 |
|
|
'#required' => FALSE,
|
694 |
|
|
'#description' => t("Add a previous/next pager."),
|
695 |
|
|
);
|
696 |
|
|
|
697 |
|
|
// show fields when using pager
|
698 |
|
|
$extra = (empty($pager2)) ? ' style="display:none"' : '';
|
699 |
|
|
$form['block_settings']['settings']['pager2_settings'] = array(
|
700 |
|
|
'#type' => 'fieldset',
|
701 |
|
|
'#collapsible' => TRUE,
|
702 |
|
|
'#collapsed' => FALSE,
|
703 |
|
|
'#prefix' => '<div id="ddblock-pager2-settings-wrapper"' . $extra . '>',
|
704 |
|
|
'#suffix' => '</div>',
|
705 |
|
|
'#title' => t('Prev/next pager settings'),
|
706 |
|
|
);
|
707 |
|
|
|
708 |
|
|
$options = array(
|
709 |
|
|
'click' => t('Click'),
|
710 |
|
|
'mouseover' => t('Mouseover'),
|
711 |
|
|
);
|
712 |
|
|
|
713 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_event'] = array(
|
714 |
|
|
'#type' => 'select',
|
715 |
|
|
'#title' => t('Pager event'),
|
716 |
|
|
'#default_value' => $pager2_event,
|
717 |
|
|
'#options' => $options,
|
718 |
|
|
'#required' => FALSE,
|
719 |
|
|
'#description' => t("The event on which the prev/next pager reacts."),
|
720 |
|
|
);
|
721 |
|
|
|
722 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_slide_prev'] = array(
|
723 |
|
|
'#type' => 'textfield',
|
724 |
|
|
'#title' => t('Prev text on slide'),
|
725 |
|
|
'#default_value' => $pager2_slide_prev,
|
726 |
|
|
'#size' => 30,
|
727 |
|
|
'#required' => FALSE,
|
728 |
|
|
'#description' => t("Caption for the prev pager on the slide.<br />Can also be empty if you use a background image to go to the previous slide."),
|
729 |
|
|
);
|
730 |
|
|
|
731 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_slide_next'] = array(
|
732 |
|
|
'#type' => 'textfield',
|
733 |
|
|
'#title' => t('Next text on slide'),
|
734 |
|
|
'#default_value' => $pager2_slide_next,
|
735 |
|
|
'#size' => 30,
|
736 |
|
|
'#required' => FALSE,
|
737 |
|
|
'#description' => t("Caption for the next pager on the slide.<br />Can also be empty if you use a background image to go to the next slide."),
|
738 |
|
|
);
|
739 |
|
|
|
740 |
|
|
// hide prev/next pager when no prev/next slide available
|
741 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_slide']['pager2_slide_hide'] = array(
|
742 |
|
|
'#type' => 'checkbox',
|
743 |
|
|
'#title' => t('Prev/Next Hide'),
|
744 |
|
|
'#default_value' => $pager2_slide_hide,
|
745 |
|
|
'#required' => FALSE,
|
746 |
|
|
'#description' => t("Hide Prev/Next Pager when no slide available."),
|
747 |
|
|
);
|
748 |
|
|
|
749 |
|
|
// custom jcycle plugin settings
|
750 |
|
|
// collapsed or not collapsed depending on value for custom settings.
|
751 |
|
|
if ($custom_jquery) {
|
752 |
|
|
$collapsed = FALSE;
|
753 |
|
|
}
|
754 |
|
|
else {
|
755 |
|
|
$collapsed = TRUE;
|
756 |
|
|
}
|
757 |
|
|
|
758 |
|
|
$form['block_settings']['settings']['custom'] = array(
|
759 |
|
|
'#type' => 'fieldset',
|
760 |
|
|
'#collapsible' => TRUE,
|
761 |
|
|
'#collapsed' => $collapsed,
|
762 |
|
|
'#title' => t('Custom jQuery Cycle Plugin Settings'),
|
763 |
|
|
'#weight' => 1,
|
764 |
|
|
'#description' => t('If you use custom jQuery options, they will override your other settings.'),
|
765 |
|
|
);
|
766 |
|
|
|
767 |
|
|
$form['block_settings']['settings']['custom']['custom_jquery'] = array(
|
768 |
|
|
'#type' => 'textarea',
|
769 |
|
|
'#title' => t('Custom Options'),
|
770 |
|
|
'#default_value' => $custom_jquery,
|
771 |
|
|
'#cols' => 60,
|
772 |
|
|
'#rows' => 10,
|
773 |
|
|
'#required' => FALSE,
|
774 |
|
|
'#description' => t('Use valid JSON syntax, with double quotes for key/and string value pairs.<br />The total script needs to be enclosed in curly brackets.<br />No comma allowed after the last statement like in an array.<br />e.g.<br />{"fx":"fade",<br />"startingSlide":2,<br />"autostop":1}'),
|
775 |
|
|
);
|
776 |
|
|
|
777 |
|
|
$form_state['redirect'] = 'admin/structure/ddblock/list';
|
778 |
|
|
|
779 |
|
|
return $form;
|
780 |
|
|
}
|
781 |
|
|
|
782 |
|
|
/**
|
783 |
|
|
* Build the node selection form element.
|
784 |
|
|
*
|
785 |
|
|
* This function is also called when generating a new set of options during the
|
786 |
|
|
* AJAX callback, so an array is returned that can be used to replace an existing
|
787 |
|
|
* form element.
|
788 |
|
|
*
|
789 |
|
|
* @param $form
|
790 |
|
|
* form to add elements to.
|
791 |
|
|
* @param $content_type
|
792 |
|
|
* selected content type.
|
793 |
|
|
* @param $nodes
|
794 |
|
|
* Existing nodes added to the block.
|
795 |
|
|
*
|
796 |
|
|
* @return
|
797 |
|
|
* form fields.
|
798 |
|
|
*/
|
799 |
|
|
function ddblock_select_nodes_form(&$form, $content_type, $nodes) {
|
800 |
|
|
// Wrapper for nodes select box.
|
801 |
|
|
$form['content']['content_types']['select_nodes'] = array(
|
802 |
|
|
'#type' => 'hidden',
|
803 |
|
|
'#value' => -1,
|
804 |
|
|
'#prefix' => '<div id="select-nodes-wrapper">',
|
805 |
|
|
);
|
806 |
|
|
// no content type selected (show text 'No content type selected').
|
807 |
|
|
if ($content_type == 'none') {
|
808 |
|
|
$form['content']['content_types']['select_nodes']['#prefix'] .= '<em>' . t('No content type selected.') . '</em>';
|
809 |
|
|
$form['content']['content_types']['select_nodes']['#suffix'] = '</div>';
|
810 |
|
|
|
811 |
|
|
unset($form['content']['content_types']['nodes']);
|
812 |
|
|
|
813 |
|
|
}
|
814 |
|
|
// add select box to select a node.
|
815 |
|
|
else {
|
816 |
|
|
if (user_access('administer dynamic display blocks')) {
|
817 |
|
|
|
818 |
|
|
// get all nodes of a content type which are not added yet to the block.
|
819 |
|
|
$options = _ddblock_get_content_type_nodes($content_type);
|
820 |
|
|
$form['content']['content_types']['nodes'] = array(
|
821 |
|
|
'#type' => 'select',
|
822 |
|
|
'#title' => t('Node'),
|
823 |
|
|
'#default_value' => $nodes,
|
824 |
|
|
'#description' => t('The node to show in the Dynamic display block'),
|
825 |
|
|
'#options' => $options,
|
826 |
|
|
'#attributes' => array('class' => array('content-type-select')),
|
827 |
|
|
'#suffix' => '</div>',
|
828 |
|
|
);
|
829 |
|
|
}
|
830 |
|
|
}
|
831 |
|
|
|
832 |
|
|
return $form;
|
833 |
|
|
}
|
834 |
|
|
|
835 |
|
|
/**
|
836 |
|
|
* Implements hook_form_alter().
|
837 |
|
|
*
|
838 |
|
|
* Used to add dynamic display block configuration settings to dynamic display block instances.
|
839 |
|
|
*/
|
840 |
|
|
function ddblock_form_alter(&$form, &$form_state, $form_id) {
|
841 |
|
|
$module = arg(4);
|
842 |
|
|
$delta = arg(5);
|
843 |
|
|
|
844 |
|
|
if ((isset($delta) && ($module == 'ddblock'))
|
845 |
|
|
&& (user_access('administer dynamic display blocks'))
|
846 |
|
|
&& (user_access('administer blocks'))
|
847 |
|
|
&& ($form_id == 'block_admin_configure')) {
|
848 |
|
|
|
849 |
|
|
// get original block_settings.
|
850 |
|
|
$block = ddblock_get_blocks($delta);
|
851 |
|
|
$module_original = $block->module;
|
852 |
|
|
$delta_original = $block->delta_original;
|
853 |
|
|
|
854 |
|
|
// check if module enabled in the dynamic display block settings.
|
855 |
|
|
$block_enabled = FALSE;
|
856 |
|
|
$blocks = ddblock_get_ddblock_enabled_module_blocks();
|
857 |
|
|
foreach ($blocks as $block) {
|
858 |
|
|
if (($block['module'] == $module_original) && ($block['delta'] == $delta_original)) {
|
859 |
|
|
$block_enabled = TRUE;
|
860 |
|
|
}
|
861 |
|
|
}
|
862 |
|
|
if ($block_enabled) {
|
863 |
|
|
if ($module_original == 'views') {
|
864 |
|
|
// block.module has a delta length limit of 32, but deltas in the views module can
|
865 |
|
|
// be longer because view names can be 32 and display IDs can also be 32.
|
866 |
|
|
// So for very long deltas, md5 hashes are used.
|
867 |
|
|
if (strlen($delta_original) == 32) {
|
868 |
|
|
$hashes = variable_get('views_block_hashes', array());
|
869 |
|
|
if (!empty($hashes[$delta_original])) {
|
870 |
|
|
$delta_original = $hashes[$delta_original];
|
871 |
|
|
}
|
872 |
|
|
}
|
873 |
|
|
list($view_name, $display_id) = explode('-', $delta_original);
|
874 |
|
|
// Load the view
|
875 |
|
|
if ($view = views_get_view($view_name)) {
|
876 |
|
|
if ($view->access($display_id)) {
|
877 |
|
|
// get the possible source fields form the view
|
878 |
|
|
$source_fields = array('none' => t('--None--'));
|
879 |
|
|
$display = $view->display[$display_id];
|
880 |
|
|
|
881 |
|
|
foreach ($display->handler->get_handlers('field') as $field => $handler) {
|
882 |
|
|
$format = isset($handler->options['format']) ? ' - ' . $handler->options['format'] : '';
|
883 |
|
|
if ($label = $handler->label()) {
|
884 |
|
|
$source_fields[$field] = $label . $format;
|
885 |
|
|
}
|
886 |
|
|
else {
|
887 |
|
|
$source_fields[$field] = $handler->ui_name() . $format;
|
888 |
|
|
}
|
889 |
|
|
}
|
890 |
|
|
}
|
891 |
|
|
}
|
892 |
|
|
}
|
893 |
|
|
|
894 |
|
|
// get module path to dynamic display block module
|
895 |
|
|
$ddblock_path = drupal_get_path('module', 'ddblock');
|
896 |
|
|
// add ddblock js file
|
897 |
|
|
drupal_add_js($ddblock_path . '/js/ddblock.admin.js');
|
898 |
|
|
drupal_add_js($ddblock_path . '/js/jquery.selectboxes.js');
|
899 |
|
|
|
900 |
|
|
// get configuration settings
|
901 |
|
|
foreach (ddblock_get_configuration_settings('ddblock', $delta)->settings() as $key => $value) {
|
902 |
|
|
${$key} = $value;
|
903 |
|
|
}
|
904 |
|
|
// get cycle configuration settings
|
905 |
|
|
foreach (ddblock_get_cycle_configuration_settings('ddblock_cycle', $delta)->settings() as $key => $value) {
|
906 |
|
|
${$key} = $value;
|
907 |
|
|
}
|
908 |
|
|
// get cycle mapping settings
|
909 |
|
|
foreach (ddblock_get_cycle_mapping_settings('ddblock_cycle', $delta)->settings() as $key => $value) {
|
910 |
|
|
${$key} = $value;
|
911 |
|
|
$mappings[$key]['target'] = $value['target'];
|
912 |
|
|
$mappings[$key]['source'] = $value['source'];
|
913 |
|
|
}
|
914 |
|
|
|
915 |
|
|
// set pager variable for javascript
|
916 |
|
|
$settings['ddblockCustomTemplate'] = array(
|
917 |
|
|
'pager' => $pager,
|
918 |
|
|
'pagerPosition' => $pager_position,
|
919 |
|
|
);
|
920 |
|
|
|
921 |
|
|
drupal_add_js($settings, array('type' => 'setting', 'scope' => JS_DEFAULT));
|
922 |
|
|
|
923 |
|
|
// hide fields when using advanced settings
|
924 |
|
|
$extra = (!empty($advanced)) ? ' style="display:none"' : '';
|
925 |
|
|
|
926 |
|
|
// show warning that cycle plugin is not installed.
|
927 |
|
|
$cycle_path = libraries_get_path('jquery.cycle');
|
928 |
|
|
if (empty($cycle_path) || !(file_exists($cycle_path . '/jquery.cycle.all.min.js') || file_exists($cycle_path . '/jquery.cycle.all.js'))) {
|
929 |
|
|
$form['no_cycle_js'] = array(
|
930 |
|
|
'#type' => 'item',
|
931 |
|
|
'#title' => 'Cycle plugin',
|
932 |
|
|
'#markup' => '<div style="color: red">' . t('You need to install the jQuery cycle plugin.<br />
|
933 |
|
|
Create a directory in sites/all/libraries called jquery.cycle, and then copy jquery.cycle.all.js or jquery.cycle.all.min.js into it.<br />
|
934 |
|
|
Latest version tested: 2.99<br />
|
935 |
|
|
You can find the plugin at !url.', array('!url' => l('http://malsup.com/jquery/cycle/download.html', 'http://malsup.com/jquery/cycle/download.html', array('attributes' => array('target' => '_blank'))))) . '</div>',
|
936 |
|
|
'#prefix' => '<div id="ddblock-no-cycle-js">',
|
937 |
|
|
'#suffix' => '</div>',
|
938 |
|
|
'#weight' => -16,
|
939 |
|
|
);
|
940 |
|
|
}
|
941 |
|
|
$form['module'] = array(
|
942 |
|
|
'#type' => 'hidden',
|
943 |
|
|
'#value' => $module,
|
944 |
|
|
);
|
945 |
|
|
$form['delta'] = array(
|
946 |
|
|
'#type' => 'value',
|
947 |
|
|
'#value' => $delta,
|
948 |
|
|
);
|
949 |
|
|
$form['input_type'] = array(
|
950 |
|
|
'#type' => 'hidden',
|
951 |
|
|
'#value' => 'instance',
|
952 |
|
|
);
|
953 |
|
|
|
954 |
|
|
$form['#attached']['css'] = array(
|
955 |
|
|
drupal_get_path('module', 'ddblock') . '/css/ddblock_instance_admin.css',
|
956 |
|
|
);
|
957 |
|
|
|
958 |
|
|
// widget setting: Enable the dynamic display block setting for this block.
|
959 |
|
|
$options = array(
|
960 |
|
|
'default' => t('Default'),
|
961 |
|
|
'cycle' => t('Cycleblock'),
|
962 |
|
|
);
|
963 |
|
|
|
964 |
|
|
//wrapper for ddblock instance settings
|
965 |
|
|
$form['block_settings']['#prefix'] = '<div id="ddblock-instance-settings">';
|
966 |
|
|
$form['block_settings']['#suffix'] = '</div>';
|
967 |
|
|
|
968 |
|
|
$form['block_settings']['widget'] = array(
|
969 |
|
|
'#type' => 'radios',
|
970 |
|
|
'#title' => t('Display Method'),
|
971 |
|
|
'#default_value' => $widget,
|
972 |
|
|
'#options' => $options,
|
973 |
|
|
'#required' => TRUE,
|
974 |
|
|
'#description' => t("Choose a way to display content."),
|
975 |
|
|
'#weight' => -12,
|
976 |
|
|
);
|
977 |
|
|
|
978 |
|
|
// advanced settings togg;e
|
979 |
|
|
$form['block_settings']['advanced'] = array(
|
980 |
|
|
'#type' => 'checkbox',
|
981 |
|
|
'#title' => t('Use advanced settings'),
|
982 |
|
|
'#default_value' => $advanced,
|
983 |
|
|
'#required' => FALSE,
|
984 |
|
|
'#description' => t("Use Custom templates and CSS (more flexible)"),
|
985 |
|
|
'#weight' => -11,
|
986 |
|
|
);
|
987 |
|
|
|
988 |
|
|
// select themes from [Theme_name]/custom/modules/ddblock
|
989 |
|
|
$path_to_themes = _ddblock_get_theme_path() . '/custom/modules/ddblock';
|
990 |
|
|
|
991 |
|
|
$dirs = _ddblock_dir_scan_directory($path_to_themes, '');
|
992 |
|
|
|
993 |
|
|
$options = array();
|
994 |
|
|
if (!empty($dirs)) {
|
995 |
|
|
asort($dirs);
|
996 |
|
|
foreach ($dirs as $dir) {
|
997 |
|
|
$options[$dir] = $dir;
|
998 |
|
|
}
|
999 |
|
|
}
|
1000 |
|
|
|
1001 |
|
|
$form['block_settings']['template'] = array(
|
1002 |
|
|
'#type' => 'select',
|
1003 |
|
|
'#title' => t('Slideshow theme layout'),
|
1004 |
|
|
'#default_value' => $template,
|
1005 |
|
|
'#options' => $options,
|
1006 |
|
|
'#multiple' => FALSE,
|
1007 |
|
|
'#required' => FALSE,
|
1008 |
|
|
'#prefix' => '<div id="ddblock-template-wrapper">',
|
1009 |
|
|
'#suffix' => '</div>',
|
1010 |
|
|
'#description' => t("Available slideshow themes are automatically detected form the folder custom/modules/ddblock.<br />
|
1011 |
|
|
A slideshow themes can only contain letters and numbers, no underscores and hyphens, etc.<br />
|
1012 |
|
|
The .tpl.php file used will become:ddblock-cycle-block-content--[THEMENAME].tpl.php"),
|
1013 |
|
|
'#weight' => -10,
|
1014 |
|
|
);
|
1015 |
|
|
|
1016 |
|
|
if (isset($form_state['values'])) {
|
1017 |
|
|
$form_state_values = $form_state['values'];
|
1018 |
|
|
}
|
1019 |
|
|
|
1020 |
|
|
$template = (isset($form_state_values['block_settings']['template'])) ? $form_state_values['block_settings']['template'] : $template;
|
1021 |
|
|
|
1022 |
|
|
$template_sizes = _ddblock_get_template_size($template);
|
1023 |
|
|
|
1024 |
|
|
// Since a #select element can't have it's own #submit handler, we have to create an extra
|
1025 |
|
|
// submit button to which we attach the correct callback function that's going to be called on a change
|
1026 |
|
|
// We'll hide this with '#access' => FALSE.
|
1027 |
|
|
$form['block_settings']['template_submit'] = array(
|
1028 |
|
|
'#type' => 'submit',
|
1029 |
|
|
'#value' => t('get template sizes'),
|
1030 |
|
|
'#submit' => array('ddblock_options_form_submit'),
|
1031 |
|
|
'#weight' => -8,
|
1032 |
|
|
// '#access'=> FALSE, // hide the button
|
1033 |
|
|
'#description' => t('Get the possible themesizes after selecting a theme'),
|
1034 |
|
|
);
|
1035 |
|
|
|
1036 |
|
|
// We define a <div> wrapper that contains the select box that needs to be refilled with data
|
1037 |
|
|
$form['block_settings']['template_size_wrapper'] = array(
|
1038 |
|
|
'#prefix' => '<div id="select-template-size-wrapper">',
|
1039 |
|
|
'#suffix' => '</div>',
|
1040 |
|
|
'#weight' => -9,
|
1041 |
|
|
);
|
1042 |
|
|
|
1043 |
|
|
// This is the actual select that needs to be refreshed depending on what happens in the 'template' select
|
1044 |
|
|
$form['block_settings']['template_size_wrapper']['template_size'] = array(
|
1045 |
|
|
'#type' => 'select',
|
1046 |
|
|
'#title' => t('Template size'),
|
1047 |
|
|
'#options' => $template_sizes,
|
1048 |
|
|
'#default_value' => $template_size,
|
1049 |
|
|
'#description' => t('The slideshow template_size css file to use'),
|
1050 |
|
|
// '#attributes' => array('class' => 'template-size-select'),
|
1051 |
|
|
'#prefix' => '<div id="select-template-size">',
|
1052 |
|
|
'#suffix' => '</div>',
|
1053 |
|
|
);
|
1054 |
|
|
|
1055 |
|
|
|
1056 |
|
|
// Wrapper in which to place both the mapped fields and the 'add mapping' form.
|
1057 |
|
|
$form['block_settings']['mapping_wrapper'] = array(
|
1058 |
|
|
'#weight' => -7,
|
1059 |
|
|
'#prefix' => '<div class="clear-block" id="ddblock-mapping-wrapper">',
|
1060 |
|
|
'#suffix' => '</div>',
|
1061 |
|
|
);
|
1062 |
|
|
|
1063 |
|
|
$form['block_settings']['mapping_wrapper']['helptext'] = array(
|
1064 |
|
|
'#type' => 'item',
|
1065 |
|
|
'#title' => t('Field mappings'),
|
1066 |
|
|
'#description' => t('In this part you map available fields to ddblock theme fields.<br />The ddblock theme fields are the target.<br />Source fields are fields available from your view.'),
|
1067 |
|
|
);
|
1068 |
|
|
|
1069 |
|
|
$form['block_settings']['mapping_wrapper']['headingtable'] = array(
|
1070 |
|
|
'#type' => 'item',
|
1071 |
|
|
'#title' => t('Target
|
1072 |
|
|
Source'),
|
1073 |
|
|
);
|
1074 |
|
|
|
1075 |
|
|
// Wrapper to display existing mappingss.
|
1076 |
|
|
$form['block_settings']['mapping_wrapper']['mappings'] = array(
|
1077 |
|
|
'#prefix' => '<div id="ddblock-mappings">',
|
1078 |
|
|
'#suffix' => '</div>',
|
1079 |
|
|
// '#theme' => 'ddblock_mappings_table',
|
1080 |
|
|
);
|
1081 |
|
|
|
1082 |
|
|
// Get number of mappings.
|
1083 |
|
|
$options = array();
|
1084 |
|
|
$mapping_count = empty($mappings) ? 0 : count($mappings);
|
1085 |
|
|
// Add the existing mappings to the form.
|
1086 |
|
|
for ($delta = 0; $delta < $mapping_count; $delta++) {
|
1087 |
|
|
$target = isset($mappings[$delta]['target']) ? $mappings[$delta]['target'] : '';
|
1088 |
|
|
$source = isset($mappings[$delta]['source']) ? $mappings[$delta]['source'] : '';
|
1089 |
|
|
// Display existing mappings using helper function ddblock_mapping_display_form().
|
1090 |
|
|
$form['block_settings']['mapping_wrapper']['mappings'][$delta] = ddblock_mapping_display_form($delta, $target, $source, $source_fields);
|
1091 |
|
|
}
|
1092 |
|
|
|
1093 |
|
|
if ($widget == 'default') {
|
1094 |
|
|
$collapsed = TRUE;
|
1095 |
|
|
}
|
1096 |
|
|
else {
|
1097 |
|
|
$collapsed = FALSE;
|
1098 |
|
|
}
|
1099 |
|
|
|
1100 |
|
|
// content settings: what to use as content for the dynamic display block.
|
1101 |
|
|
$form['block_settings']['settings'] = array(
|
1102 |
|
|
'#type' => 'fieldset',
|
1103 |
|
|
'#collapsible' => TRUE,
|
1104 |
|
|
'#collapsed' => $collapsed,
|
1105 |
|
|
'#title' => t('Dynamic display block settings'),
|
1106 |
|
|
'#weight' => 1,
|
1107 |
|
|
);
|
1108 |
|
|
|
1109 |
|
|
// content container settings.
|
1110 |
|
|
$form['block_settings']['content_container'] = array(
|
1111 |
|
|
'#type' => 'fieldset',
|
1112 |
|
|
'#collapsible' => TRUE,
|
1113 |
|
|
'#collapsed' => FALSE,
|
1114 |
|
|
'#title' => t('Content container settings'),
|
1115 |
|
|
'#weight' => -3,
|
1116 |
|
|
);
|
1117 |
|
|
|
1118 |
|
|
$form['block_settings']['content_container']['container_advanced'] = array(
|
1119 |
|
|
'#type' => 'textfield',
|
1120 |
|
|
'#title' => t('Content container'),
|
1121 |
|
|
'#default_value' => $container_advanced,
|
1122 |
|
|
'#required' => FALSE,
|
1123 |
|
|
'#size' => 30,
|
1124 |
|
|
'#description' => t("Container of the content to slide, eg. CSS selector img, to show images.<br />This can be any CSS selector containing a slide. e.g div.slide"),
|
1125 |
|
|
);
|
1126 |
|
|
|
1127 |
|
|
$form['block_settings']['content_container']['overflow'] = array(
|
1128 |
|
|
'#type' => 'checkbox',
|
1129 |
|
|
'#title' => t('Overflow hidden'),
|
1130 |
|
|
'#default_value' => $overflow,
|
1131 |
|
|
'#prefix' => '<div id="ddblock-advanced-content-container-overflow-wrapper"' . $extra . '>',
|
1132 |
|
|
'#suffix' => '</div>',
|
1133 |
|
|
'#required' => FALSE,
|
1134 |
|
|
'#description' => t("Hide the overflow of the container"),
|
1135 |
|
|
);
|
1136 |
|
|
|
1137 |
|
|
$form['block_settings']['content_container']['height'] = array(
|
1138 |
|
|
'#type' => 'textfield',
|
1139 |
|
|
'#title' => t('Container height'),
|
1140 |
|
|
'#default_value' => $height,
|
1141 |
|
|
'#prefix' => '<div id="ddblock-advanced-content-container-height-wrapper"' . $extra . '>',
|
1142 |
|
|
'#suffix' => '</div>',
|
1143 |
|
|
'#required' => FALSE,
|
1144 |
|
|
'#description' => t("Height of the content to show"),
|
1145 |
|
|
);
|
1146 |
|
|
|
1147 |
|
|
$form['block_settings']['content_container']['width'] = array(
|
1148 |
|
|
'#type' => 'textfield',
|
1149 |
|
|
'#title' => t('Container width'),
|
1150 |
|
|
'#default_value' => $width,
|
1151 |
|
|
'#prefix' => '<div id="ddblock-advanced-content-container-width-wrapper"' . $extra . '>',
|
1152 |
|
|
'#suffix' => '</div>',
|
1153 |
|
|
'#required' => FALSE,
|
1154 |
|
|
'#description' => t("Width of the content to show"),
|
1155 |
|
|
);
|
1156 |
|
|
|
1157 |
|
|
// Image settings.
|
1158 |
|
|
$form['block_settings']['images'] = array(
|
1159 |
|
|
'#type' => 'fieldset',
|
1160 |
|
|
'#collapsible' => TRUE,
|
1161 |
|
|
'#title' => t('Image settings'),
|
1162 |
|
|
'#prefix' => '<div id="ddblock-image-settings-wrapper"' . $extra . '>',
|
1163 |
|
|
'#suffix' => '</div>',
|
1164 |
|
|
'#weight' => -3,
|
1165 |
|
|
);
|
1166 |
|
|
|
1167 |
|
|
$form['block_settings']['images']['image_height'] = array(
|
1168 |
|
|
'#type' => 'textfield',
|
1169 |
|
|
'#title' => t('Image height'),
|
1170 |
|
|
'#default_value' => $image_height,
|
1171 |
|
|
'#required' => FALSE,
|
1172 |
|
|
'#description' => t("Height of the image to show"),
|
1173 |
|
|
);
|
1174 |
|
|
|
1175 |
|
|
$form['block_settings']['images']['image_width'] = array(
|
1176 |
|
|
'#type' => 'textfield',
|
1177 |
|
|
'#title' => t('Image width'),
|
1178 |
|
|
'#default_value' => $image_width,
|
1179 |
|
|
'#required' => FALSE,
|
1180 |
|
|
'#description' => t("Width of the image to show"),
|
1181 |
|
|
);
|
1182 |
|
|
|
1183 |
|
|
$options = _ddblock_get_effects();
|
1184 |
|
|
$form['block_settings']['settings']['fx'] = array(
|
1185 |
|
|
'#type' => 'select',
|
1186 |
|
|
'#title' => t('Transition Effect'),
|
1187 |
|
|
'#default_value' => $fx,
|
1188 |
|
|
'#options' => $options,
|
1189 |
|
|
'#multiple' => FALSE,
|
1190 |
|
|
'#required' => TRUE,
|
1191 |
|
|
'#description' => t("The transition effect between content.<br />(all for random effect per slide, none for no effect)<br />Multiple effects can be set in the Custom jQuery Cycle Plugin Settings."),
|
1192 |
|
|
);
|
1193 |
|
|
$options = _ddblock_get_easing_effects();
|
1194 |
|
|
$form['block_settings']['settings']['easing_out'] = array(
|
1195 |
|
|
'#type' => 'select',
|
1196 |
|
|
'#title' => t('Transition Effect'),
|
1197 |
|
|
'#default_value' => $easing_out,
|
1198 |
|
|
'#options' => $options,
|
1199 |
|
|
'#multiple' => FALSE,
|
1200 |
|
|
'#required' => TRUE,
|
1201 |
|
|
'#description' => t("The easing effect of the previous slide.<br />For easing effect examples, see: <a href=\"http://jqueryui.com/demos/effect/easing.html\" target=\"_blank\">easing demos</a>"),
|
1202 |
|
|
);
|
1203 |
|
|
$form['block_settings']['settings']['easing_in'] = array(
|
1204 |
|
|
'#type' => 'select',
|
1205 |
|
|
'#title' => t('Transition Effect'),
|
1206 |
|
|
'#default_value' => $easing_in,
|
1207 |
|
|
'#options' => $options,
|
1208 |
|
|
'#multiple' => FALSE,
|
1209 |
|
|
'#required' => TRUE,
|
1210 |
|
|
'#description' => t("The easing effect of the next slide.<br />For easing effect examples, see: <a href=\"http://jqueryui.com/demos/effect/easing.html\" target=\"_blank\">easing demos</a>"),
|
1211 |
|
|
);
|
1212 |
|
|
|
1213 |
|
|
$options = drupal_map_assoc(array(0, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000));
|
1214 |
|
|
$form['block_settings']['settings']['speed'] = array(
|
1215 |
|
|
'#type' => 'select',
|
1216 |
|
|
'#title' => t('Speed'),
|
1217 |
|
|
'#default_value' => $speed,
|
1218 |
|
|
'#options' => $options,
|
1219 |
|
|
'#required' => TRUE,
|
1220 |
|
|
'#description' => t("Speed of the transitions (1000 = 1 second, 0 = direct)."),
|
1221 |
|
|
);
|
1222 |
|
|
|
1223 |
|
|
$options = drupal_map_assoc(array(0, 250, 500, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000, 30000));
|
1224 |
|
|
$form['block_settings']['settings']['timeout'] = array(
|
1225 |
|
|
'#type' => 'select',
|
1226 |
|
|
'#title' => t('Timeout'),
|
1227 |
|
|
'#default_value' => $timeout,
|
1228 |
|
|
'#options' => $options,
|
1229 |
|
|
'#required' => TRUE,
|
1230 |
|
|
'#description' => t("The time (in milliseconds) between transitions (1000 = 1 second, 0 to disable auto advance)."),
|
1231 |
|
|
);
|
1232 |
|
|
|
1233 |
|
|
$options = array(
|
1234 |
|
|
'none' => t('None'),
|
1235 |
|
|
'asc' => t('Ascending'),
|
1236 |
|
|
'desc' => t('Descending'),
|
1237 |
|
|
'random' => t('Random'),
|
1238 |
|
|
);
|
1239 |
|
|
|
1240 |
|
|
$form['block_settings']['settings']['order'] = array(
|
1241 |
|
|
'#type' => 'select',
|
1242 |
|
|
'#title' => t('Sort Order'),
|
1243 |
|
|
'#default_value' => $order,
|
1244 |
|
|
'#options' => $options,
|
1245 |
|
|
'#multiple' => FALSE,
|
1246 |
|
|
'#required' => TRUE,
|
1247 |
|
|
'#description' => t("The display order of the content. None for using the original content order."),
|
1248 |
|
|
);
|
1249 |
|
|
|
1250 |
|
|
$form['block_settings']['settings']['pause'] = array(
|
1251 |
|
|
'#type' => 'checkbox',
|
1252 |
|
|
'#title' => t('Pause'),
|
1253 |
|
|
'#default_value' => $pause,
|
1254 |
|
|
'#description' => t("Enable users to pause the cycle by hovering on the content of the slideshow."),
|
1255 |
|
|
);
|
1256 |
|
|
|
1257 |
|
|
$form['block_settings']['settings']['next'] = array(
|
1258 |
|
|
'#type' => 'checkbox',
|
1259 |
|
|
'#title' => t('Next'),
|
1260 |
|
|
'#default_value' => $next,
|
1261 |
|
|
'#description' => t("Enable users to advanced to the next content by clicking on the content.<br />
|
1262 |
|
|
Note: When readmore button is used, don't enable this option."),
|
1263 |
|
|
);
|
1264 |
|
|
|
1265 |
|
|
$form['block_settings']['settings']['pager2'] = array(
|
1266 |
|
|
'#type' => 'checkbox',
|
1267 |
|
|
'#title' => t('Prev/Next Pager'),
|
1268 |
|
|
'#default_value' => $pager2,
|
1269 |
|
|
'#required' => FALSE,
|
1270 |
|
|
'#description' => t("Add a previous/next pager."),
|
1271 |
|
|
);
|
1272 |
|
|
|
1273 |
|
|
// pager settings.
|
1274 |
|
|
// show fields when using pager
|
1275 |
|
|
$extra = (empty($pager2)) ? ' style="display:none"' : '';
|
1276 |
|
|
$form['block_settings']['settings']['pager2_settings'] = array(
|
1277 |
|
|
'#type' => 'fieldset',
|
1278 |
|
|
'#collapsible' => TRUE,
|
1279 |
|
|
'#collapsed' => FALSE,
|
1280 |
|
|
'#prefix' => '<div id="ddblock-pager2-settings-wrapper"' . $extra . '>',
|
1281 |
|
|
'#suffix' => '</div>',
|
1282 |
|
|
'#title' => t('Prev/next pager settings'),
|
1283 |
|
|
);
|
1284 |
|
|
|
1285 |
|
|
$options = array(
|
1286 |
|
|
'click' => t('Click'),
|
1287 |
|
|
'mouseover' => t('Mouseover'),
|
1288 |
|
|
);
|
1289 |
|
|
|
1290 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_event'] = array(
|
1291 |
|
|
'#type' => 'select',
|
1292 |
|
|
'#title' => t('Pager event'),
|
1293 |
|
|
'#default_value' => $pager2_event,
|
1294 |
|
|
'#options' => $options,
|
1295 |
|
|
'#required' => FALSE,
|
1296 |
|
|
'#description' => t("The event on which the prev/next pager reacts."),
|
1297 |
|
|
);
|
1298 |
|
|
|
1299 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_slide_prev'] = array(
|
1300 |
|
|
'#type' => 'textfield',
|
1301 |
|
|
'#title' => t('Prev text on slide'),
|
1302 |
|
|
'#default_value' => $pager2_slide_prev,
|
1303 |
|
|
'#size' => 30,
|
1304 |
|
|
'#required' => FALSE,
|
1305 |
|
|
'#description' => t("Caption for the prev pager on the slide.<br />Can also be empty if you use a background image to go to the previous slide."),
|
1306 |
|
|
);
|
1307 |
|
|
|
1308 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_slide_next'] = array(
|
1309 |
|
|
'#type' => 'textfield',
|
1310 |
|
|
'#title' => t('Next text on slide'),
|
1311 |
|
|
'#default_value' => $pager2_slide_next,
|
1312 |
|
|
'#size' => 30,
|
1313 |
|
|
'#required' => FALSE,
|
1314 |
|
|
'#description' => t("Caption for the next pager on the slide.<br />Can also be empty if you use a background image to go to the next slide."),
|
1315 |
|
|
);
|
1316 |
|
|
|
1317 |
|
|
// hide prev/next pager when no prev/next slide available
|
1318 |
|
|
$form['block_settings']['settings']['pager2_settings']['pager2_slide']['pager2_slide_hide'] = array(
|
1319 |
|
|
'#type' => 'checkbox',
|
1320 |
|
|
'#title' => t('Prev/Next Hide'),
|
1321 |
|
|
'#default_value' => $pager2_slide_hide,
|
1322 |
|
|
'#required' => FALSE,
|
1323 |
|
|
'#description' => t("Hide Prev/Next Pager when no slide available."),
|
1324 |
|
|
);
|
1325 |
|
|
|
1326 |
|
|
// pager settings togg;e
|
1327 |
|
|
$form['block_settings']['settings']['pager_toggle'] = array(
|
1328 |
|
|
'#type' => 'checkbox',
|
1329 |
|
|
'#title' => t('Use Pager'),
|
1330 |
|
|
'#default_value' => $pager_toggle,
|
1331 |
|
|
'#required' => FALSE,
|
1332 |
|
|
'#description' => t("Use a pager to select slides"),
|
1333 |
|
|
);
|
1334 |
|
|
|
1335 |
|
|
// pager settings.
|
1336 |
|
|
//show fields when using pager
|
1337 |
|
|
$extra = (empty($pager_toggle)) ? ' style="display:none"' : '';
|
1338 |
|
|
$form['block_settings']['settings']['pager_settings'] = array(
|
1339 |
|
|
'#type' => 'fieldset',
|
1340 |
|
|
'#collapsible' => TRUE,
|
1341 |
|
|
'#collapsed' => FALSE,
|
1342 |
|
|
'#prefix' => '<div id="ddblock-pager-settings-wrapper"' . $extra . '>',
|
1343 |
|
|
'#suffix' => '</div>',
|
1344 |
|
|
'#title' => t('Pager settings'),
|
1345 |
|
|
);
|
1346 |
|
|
|
1347 |
|
|
$options = array(
|
1348 |
|
|
'none' => t('None'),
|
1349 |
|
|
'number-pager' => t('Number pager'),
|
1350 |
|
|
'prev-next-pager' => t('Prev next pager'),
|
1351 |
|
|
'custom-pager' => t('Custom pager'),
|
1352 |
|
|
'scrollable-pager' => t('Scrollable pager'),
|
1353 |
|
|
);
|
1354 |
|
|
|
1355 |
|
|
$form['block_settings']['settings']['pager_settings']['pager'] = array(
|
1356 |
|
|
'#type' => 'select',
|
1357 |
|
|
'#title' => t('Pager'),
|
1358 |
|
|
'#default_value' => $pager,
|
1359 |
|
|
'#options' => $options,
|
1360 |
|
|
'#required' => TRUE,
|
1361 |
|
|
'#description' => t("Type of pager to add."),
|
1362 |
|
|
);
|
1363 |
|
|
|
1364 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_height'] = array(
|
1365 |
|
|
'#type' => 'textfield',
|
1366 |
|
|
'#title' => t('Height'),
|
1367 |
|
|
'#default_value' => $pager_height,
|
1368 |
|
|
'#prefix' => '<div id="ddblock-pager-height-wrapper"' . $extra . '>',
|
1369 |
|
|
'#suffix' => '</div>',
|
1370 |
|
|
'#required' => FALSE,
|
1371 |
|
|
'#description' => t("Height of the pager"),
|
1372 |
|
|
);
|
1373 |
|
|
|
1374 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_width'] = array(
|
1375 |
|
|
'#type' => 'textfield',
|
1376 |
|
|
'#title' => t('Width'),
|
1377 |
|
|
'#default_value' => $pager_width,
|
1378 |
|
|
'#prefix' => '<div id="ddblock-pager-width-wrapper"' . $extra . '>',
|
1379 |
|
|
'#suffix' => '</div>',
|
1380 |
|
|
'#required' => FALSE,
|
1381 |
|
|
'#description' => t("Width of the pager"),
|
1382 |
|
|
);
|
1383 |
|
|
|
1384 |
|
|
$options = array(
|
1385 |
|
|
'top' => t('Top'),
|
1386 |
|
|
'right' => t('Right'),
|
1387 |
|
|
'bottom' => t('Bottom'),
|
1388 |
|
|
'left' => t('Left'),
|
1389 |
|
|
);
|
1390 |
|
|
|
1391 |
|
|
//show fields when using advanced settings
|
1392 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1393 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1394 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_position'] = array(
|
1395 |
|
|
'#type' => 'select',
|
1396 |
|
|
'#title' => t('Pager position'),
|
1397 |
|
|
'#default_value' => $pager_position,
|
1398 |
|
|
'#prefix' => '<div id="ddblock-pager-position-wrapper"' . $extra . '>',
|
1399 |
|
|
'#suffix' => '</div>',
|
1400 |
|
|
'#options' => $options,
|
1401 |
|
|
'#required' => FALSE,
|
1402 |
|
|
'#description' => t("Possible position for the pager.<br />The position must be supported by the template used to be effective."),
|
1403 |
|
|
);
|
1404 |
|
|
|
1405 |
|
|
$options = array(
|
1406 |
|
|
'click' => t('Click'),
|
1407 |
|
|
'mouseover' => t('Mouseover'),
|
1408 |
|
|
);
|
1409 |
|
|
//show fields when using advanced settings
|
1410 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1411 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1412 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_event'] = array(
|
1413 |
|
|
'#type' => 'select',
|
1414 |
|
|
'#title' => t('Pager event'),
|
1415 |
|
|
'#default_value' => $pager_event,
|
1416 |
|
|
'#prefix' => '<div id="ddblock-pager-event-wrapper"' . $extra . '>',
|
1417 |
|
|
'#suffix' => '</div>',
|
1418 |
|
|
'#options' => $options,
|
1419 |
|
|
'#required' => FALSE,
|
1420 |
|
|
'#description' => t("The event on which the pager reacts."),
|
1421 |
|
|
);
|
1422 |
|
|
|
1423 |
|
|
// disable click if pager is mouseover
|
1424 |
|
|
//show fields when using advanced settings
|
1425 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1426 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1427 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_disable_click'] = array(
|
1428 |
|
|
'#type' => 'checkbox',
|
1429 |
|
|
'#title' => t('Disable Pager click'),
|
1430 |
|
|
'#default_value' => $pager_disable_click,
|
1431 |
|
|
'#prefix' => '<div id="ddblock-pager-disable-click-wrapper"' . $extra . '>',
|
1432 |
|
|
'#suffix' => '</div>',
|
1433 |
|
|
'#required' => FALSE,
|
1434 |
|
|
'#description' => t("Disable pager click when pager event is mouseover."),
|
1435 |
|
|
);
|
1436 |
|
|
|
1437 |
|
|
//show fields when using advanced settings
|
1438 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1439 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1440 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_fast'] = array(
|
1441 |
|
|
'#type' => 'checkbox',
|
1442 |
|
|
'#title' => t('Fast Pager'),
|
1443 |
|
|
'#default_value' => $pager_fast,
|
1444 |
|
|
'#prefix' => '<div id="ddblock-pager-fast-wrapper"' . $extra . '>',
|
1445 |
|
|
'#suffix' => '</div>',
|
1446 |
|
|
'#required' => FALSE,
|
1447 |
|
|
'#description' => t("When pager is used to go to another slide, don't use the effect to go to the slide.<br />
|
1448 |
|
|
Use for quick selection of slides."),
|
1449 |
|
|
);
|
1450 |
|
|
|
1451 |
|
|
//show fields when using advanced settings
|
1452 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1453 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1454 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_pause'] = array(
|
1455 |
|
|
'#type' => 'checkbox',
|
1456 |
|
|
'#title' => t('Pager pause'),
|
1457 |
|
|
'#default_value' => $pager_pause,
|
1458 |
|
|
'#prefix' => '<div id="ddblock-pager-pause-wrapper"' . $extra . '>',
|
1459 |
|
|
'#suffix' => '</div>',
|
1460 |
|
|
'#required' => FALSE,
|
1461 |
|
|
'#description' => t("Pause the slideshow when the mouse is on the pager."),
|
1462 |
|
|
);
|
1463 |
|
|
|
1464 |
|
|
// prev_next_pager_loop - Only show prev if previous slide exist - Only show next if next slide exist
|
1465 |
|
|
//show fields when using advanced settings
|
1466 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1467 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1468 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_prev_next_loop'] = array(
|
1469 |
|
|
'#type' => 'checkbox',
|
1470 |
|
|
'#title' => t('Prev/next Pager loop'),
|
1471 |
|
|
'#default_value' => $pager_prev_next_loop,
|
1472 |
|
|
'#prefix' => '<div id="ddblock-pager-prev-next-loop-wrapper"' . $extra . '>',
|
1473 |
|
|
'#suffix' => '</div>',
|
1474 |
|
|
'#required' => FALSE,
|
1475 |
|
|
'#description' => t("Loop the next/prev pager. If disabled:<br />- Only show prev if previous slide exist<br />- Only show next if next slide exist"),
|
1476 |
|
|
);
|
1477 |
|
|
|
1478 |
|
|
// scrollable_pager_loop - Only show prev if previous slide exist - Only show next if next slide exist
|
1479 |
|
|
//show fields when using advanced settings
|
1480 |
|
|
$extra = (empty($advanced)) ? ' style="display:none"' : '';
|
1481 |
|
|
// if the checkbox: Use advanced settings is not checked, hide the advanced settings
|
1482 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_scrollable_loop'] = array(
|
1483 |
|
|
'#type' => 'checkbox',
|
1484 |
|
|
'#title' => t('Scrollable Pager show navigation'),
|
1485 |
|
|
'#default_value' => $pager_scrollable_loop,
|
1486 |
|
|
'#prefix' => '<div id="ddblock-pager-scrollable-loop-wrapper"' . $extra . '>',
|
1487 |
|
|
'#suffix' => '</div>',
|
1488 |
|
|
'#required' => FALSE,
|
1489 |
|
|
'#description' => t("Always show navigation items for scrollable pager. If disabled:<br />- Only show prev pager item when previous slide exist<br />- Only show next pager item when next slide exist"),
|
1490 |
|
|
);
|
1491 |
|
|
|
1492 |
|
|
$form['block_settings']['settings']['pager_settings']['nr_of_pager_items'] = array(
|
1493 |
|
|
'#type' => 'textfield',
|
1494 |
|
|
'#title' => t('Nr of pager items'),
|
1495 |
|
|
'#default_value' => $nr_of_pager_items,
|
1496 |
|
|
'#prefix' => '<div id="ddblock-nr-of-pager-items-wrapper">',
|
1497 |
|
|
'#suffix' => '</div>',
|
1498 |
|
|
'#required' => FALSE,
|
1499 |
|
|
'#size' => 30,
|
1500 |
|
|
'#description' => t("For Custom pager: Number of items in a row.<br />For Scrollable pager: Set this to the number of pager items visible at one time in the scrollable pager.<br />This setting will rule the functionality of the scrollable pager."),
|
1501 |
|
|
);
|
1502 |
|
|
|
1503 |
|
|
$form['block_settings']['settings']['pager_settings']['pager_container'] = array(
|
1504 |
|
|
'#type' => 'textfield',
|
1505 |
|
|
'#title' => t('Pager container'),
|
1506 |
|
|
'#default_value' => $pager_container,
|
1507 |
|
|
'#required' => FALSE,
|
1508 |
|
|
'#size' => 30,
|
1509 |
|
|
'#description' => t("Container of a pager-item, eg. CSS selector li.<br />This can be any CSS selector containing a pager-item. e.g .custom-pager-item<br />Most of the time this can be left at the default value."),
|
1510 |
|
|
);
|
1511 |
|
|
|
1512 |
|
|
$form['block_settings']['settings']['slide_text'] = array(
|
1513 |
|
|
'#type' => 'checkbox',
|
1514 |
|
|
'#title' => t('Use slide text'),
|
1515 |
|
|
'#default_value' => $slide_text,
|
1516 |
|
|
'#required' => FALSE,
|
1517 |
|
|
'#description' => t("Show slide text when available in content."),
|
1518 |
|
|
);
|
1519 |
|
|
|
1520 |
|
|
// if the checkbox: Use jQuery effects for text of a slide is not checked, hide the slide text settings
|
1521 |
|
|
$extra = (empty($slide_text)) ? ' style="display:none"' : '';
|
1522 |
|
|
$form['block_settings']['settings']['slide_text_settings'] = array(
|
1523 |
|
|
'#type' => 'fieldset',
|
1524 |
|
|
'#collapsible' => TRUE,
|
1525 |
|
|
'#title' => t('Slide text settings'),
|
1526 |
|
|
'#prefix' => '<div id="ddblock-slide-text-settings-wrapper"' . $extra . '>',
|
1527 |
|
|
'#suffix' => '</div>',
|
1528 |
|
|
);
|
1529 |
|
|
|
1530 |
|
|
// slide text container field.
|
1531 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_text_container'] = array(
|
1532 |
|
|
'#type' => 'textfield',
|
1533 |
|
|
'#title' => t('Slide text container'),
|
1534 |
|
|
'#default_value' => $slide_text_container,
|
1535 |
|
|
'#required' => FALSE,
|
1536 |
|
|
'#size' => 30,
|
1537 |
|
|
'#description' => t("Container of the slide text. Most of the time, can be left at default"),
|
1538 |
|
|
'#weight' => 5,
|
1539 |
|
|
);
|
1540 |
|
|
|
1541 |
|
|
$options = array(
|
1542 |
|
|
'top' => t('Top'),
|
1543 |
|
|
'right' => t('Right'),
|
1544 |
|
|
'bottom' => t('Bottom'),
|
1545 |
|
|
'left' => t('Left'),
|
1546 |
|
|
);
|
1547 |
|
|
|
1548 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_text_position'] = array(
|
1549 |
|
|
'#type' => 'select',
|
1550 |
|
|
'#title' => t('Slide text position'),
|
1551 |
|
|
'#default_value' => $slide_text_position,
|
1552 |
|
|
'#options' => $options,
|
1553 |
|
|
'#multiple' => FALSE,
|
1554 |
|
|
'#required' => FALSE,
|
1555 |
|
|
'#description' => t("Position of the slide text."),
|
1556 |
|
|
'#weight' => 4,
|
1557 |
|
|
);
|
1558 |
|
|
|
1559 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_text_jquery'] = array(
|
1560 |
|
|
'#type' => 'checkbox',
|
1561 |
|
|
'#title' => t('Use jQuery effects for text of a slide'),
|
1562 |
|
|
'#default_value' => $slide_text_jquery,
|
1563 |
|
|
'#required' => FALSE,
|
1564 |
|
|
'#description' => t("The jQuery effects will be added to the text in the Slide text container"),
|
1565 |
|
|
'#weight' => 6,
|
1566 |
|
|
);
|
1567 |
|
|
|
1568 |
|
|
//show fields when using jQuery effects for text of a slide
|
1569 |
|
|
$extra = (empty($slide_text_jquery)) ? ' style="display:none"' : '';
|
1570 |
|
|
// if the checkbox: jQuery effects for text of a slide is not checked, hide the advanced settings
|
1571 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery'] = array(
|
1572 |
|
|
'#type' => 'fieldset',
|
1573 |
|
|
'#collapsible' => TRUE,
|
1574 |
|
|
'#collapsed' => FALSE,
|
1575 |
|
|
'#prefix' => '<div id="ddblock-slide-jquery-settings-wrapper"' . $extra . '>',
|
1576 |
|
|
'#suffix' => '</div>',
|
1577 |
|
|
'#title' => t('Slide text jquery settings'),
|
1578 |
|
|
'#weight' => 7,
|
1579 |
|
|
);
|
1580 |
|
|
$easing_effect_options = _ddblock_get_easing_effects();
|
1581 |
|
|
$before_effect_options = array(
|
1582 |
|
|
'hide' => t('Basics - Hide'),
|
1583 |
|
|
'fadeOut' => t('Fading - Fade Out'),
|
1584 |
|
|
'slideUp' => t('Sliding - Slide Up'),
|
1585 |
|
|
);
|
1586 |
|
|
|
1587 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery']['slide_text_before_effect'] = array(
|
1588 |
|
|
'#type' => 'select',
|
1589 |
|
|
'#title' => t('Before effect'),
|
1590 |
|
|
'#default_value' => $slide_text_before_effect,
|
1591 |
|
|
'#options' => $before_effect_options,
|
1592 |
|
|
'#multiple' => FALSE,
|
1593 |
|
|
'#required' => FALSE,
|
1594 |
|
|
'#description' => t("The before event is before a slide is shown, here the slidetext of the
|
1595 |
|
|
previous slide will be hidden."),
|
1596 |
|
|
);
|
1597 |
|
|
|
1598 |
|
|
$speed_options = drupal_map_assoc(array(0, 250, 500, 1000, 2000, 3000, 4000, 5000));
|
1599 |
|
|
|
1600 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery']['slide_text_before_speed'] = array(
|
1601 |
|
|
'#type' => 'select',
|
1602 |
|
|
'#title' => t('Speed before effect'),
|
1603 |
|
|
'#default_value' => $slide_text_before_speed,
|
1604 |
|
|
'#options' => $speed_options,
|
1605 |
|
|
'#required' => FALSE,
|
1606 |
|
|
'#description' => t("Speed of the before effect (1000 = 1 second, 0 = direct)."),
|
1607 |
|
|
);
|
1608 |
|
|
|
1609 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery']['slide_text_before_easing'] = array(
|
1610 |
|
|
'#type' => 'select',
|
1611 |
|
|
'#title' => t('Before easing'),
|
1612 |
|
|
'#default_value' => $slide_text_before_easing,
|
1613 |
|
|
'#options' => $easing_effect_options,
|
1614 |
|
|
'#multiple' => FALSE,
|
1615 |
|
|
'#required' => FALSE,
|
1616 |
|
|
'#description' => t("Before easing effect of the slide text.<br />For easing effect examples, see: <a href=\"http://jqueryui.com/demos/effect/easing.html\" target=\"_blank\">easing demos</a>"),
|
1617 |
|
|
);
|
1618 |
|
|
|
1619 |
|
|
$after_effect_options = array(
|
1620 |
|
|
'show' => t('Basics - Show'),
|
1621 |
|
|
'fadeIn' => t('Fading - Fade In'),
|
1622 |
|
|
'slideDown' => t('Sliding - Slide Down'),
|
1623 |
|
|
);
|
1624 |
|
|
|
1625 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery']['slide_text_after_effect'] = array(
|
1626 |
|
|
'#type' => 'select',
|
1627 |
|
|
'#title' => t('After effect'),
|
1628 |
|
|
'#default_value' => $slide_text_after_effect,
|
1629 |
|
|
'#options' => $after_effect_options,
|
1630 |
|
|
'#multiple' => FALSE,
|
1631 |
|
|
'#required' => FALSE,
|
1632 |
|
|
'#description' => t("The after event is after a slide is shown, here the slidetext of the
|
1633 |
|
|
current slide will be shown."),
|
1634 |
|
|
);
|
1635 |
|
|
|
1636 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery']['slide_text_after_speed'] = array(
|
1637 |
|
|
'#type' => 'select',
|
1638 |
|
|
'#title' => t('Speed after effect'),
|
1639 |
|
|
'#default_value' => $slide_text_after_speed,
|
1640 |
|
|
'#options' => $speed_options,
|
1641 |
|
|
'#required' => FALSE,
|
1642 |
|
|
'#description' => t("Speed of the after effect (1000 = 1 second, 0 = direct)."),
|
1643 |
|
|
);
|
1644 |
|
|
|
1645 |
|
|
$form['block_settings']['settings']['slide_text_settings']['slide_jquery']['slide_text_after_easing'] = array(
|
1646 |
|
|
'#type' => 'select',
|
1647 |
|
|
'#title' => t('After easing'),
|
1648 |
|
|
'#default_value' => $slide_text_after_easing,
|
1649 |
|
|
'#options' => $easing_effect_options,
|
1650 |
|
|
'#multiple' => FALSE,
|
1651 |
|
|
'#required' => FALSE,
|
1652 |
|
|
'#description' => t("After easing effect of the slide text.<br />For easing effect examples, see: <a href=\"http://jqueryui.com/demos/effect/easing.html\" target=\"_blank\">easing demos</a>"),
|
1653 |
|
|
);
|
1654 |
|
|
|
1655 |
|
|
if ($custom_jquery) {
|
1656 |
|
|
$collapsed = FALSE;
|
1657 |
|
|
}
|
1658 |
|
|
else {
|
1659 |
|
|
$collapsed = TRUE;
|
1660 |
|
|
}
|
1661 |
|
|
$form['block_settings']['settings']['custom'] = array(
|
1662 |
|
|
'#type' => 'fieldset',
|
1663 |
|
|
'#collapsible' => TRUE,
|
1664 |
|
|
'#collapsed' => $collapsed,
|
1665 |
|
|
'#title' => t('Custom jQuery Cycle Plugin Settings'),
|
1666 |
|
|
'#description' => t('If you use custom jQuery options, they will override your other settings.'),
|
1667 |
|
|
);
|
1668 |
|
|
|
1669 |
|
|
$form['block_settings']['settings']['custom']['custom_jquery'] = array(
|
1670 |
|
|
'#type' => 'textarea',
|
1671 |
|
|
'#title' => t('Custom Options'),
|
1672 |
|
|
'#default_value' => $custom_jquery,
|
1673 |
|
|
'#cols' => 60,
|
1674 |
|
|
'#rows' => 10,
|
1675 |
|
|
'#required' => FALSE,
|
1676 |
|
|
'#description' => t('Use valid JSON syntax, with double quotes for key/and string value pairs.<br />The total script needs to be enclosed in curly brackets.<br />No comma allowed after the last statement like in an array.<br />e.g.<br />{"fx":"fade",<br />"startingSlide":2,<br />"autostop":1}'),
|
1677 |
|
|
);
|
1678 |
|
|
|
1679 |
|
|
$form_state['redirect'] = 'admin/structure/ddblock/list';
|
1680 |
|
|
}
|
1681 |
|
|
}
|
1682 |
|
|
}
|
1683 |
|
|
|
1684 |
|
|
/**
|
1685 |
|
|
* Submit block configuration settings.
|
1686 |
|
|
*/
|
1687 |
|
|
function ddblock_form_alter_submit($form, &$form_state) {
|
1688 |
|
|
// save the dynamic display block specific settings.
|
1689 |
|
|
$delta = $form_state['values']['delta'];
|
1690 |
|
|
$module = $form_state['values']['module'];
|
1691 |
|
|
ddblock_set_configuration_settings($module, $delta, $form_state['values']);
|
1692 |
|
|
|
1693 |
|
|
// Call the standard submit handler that saves the block settings.
|
1694 |
|
|
block_admin_configure_submit($form, $form_state);
|
1695 |
|
|
}
|
1696 |
|
|
|
1697 |
|
|
/**
|
1698 |
|
|
* return subject of block.
|
1699 |
|
|
*
|
1700 |
|
|
* @param $origin
|
1701 |
|
|
* Origin of the block.
|
1702 |
|
|
* @param $delta
|
1703 |
|
|
* Blocknumber of the block.
|
1704 |
|
|
*
|
1705 |
|
|
* @return
|
1706 |
|
|
* string with title of the block.
|
1707 |
|
|
*
|
1708 |
|
|
*/
|
1709 |
|
|
function ddblock_subject($origin, $delta) {
|
1710 |
|
|
return ddblock_get_block_title($origin, $delta);
|
1711 |
|
|
}
|
1712 |
|
|
|
1713 |
|
|
/**
|
1714 |
|
|
* Get contents of dynamic display block block.
|
1715 |
|
|
*/
|
1716 |
|
|
function ddblock_content($origin, $delta, $content = NULL, $teaser = NULL) {
|
1717 |
|
|
|
1718 |
|
|
// get configuration settings
|
1719 |
|
|
foreach (ddblock_get_configuration_settings('ddblock', $delta)->settings() as $key => $value) {
|
1720 |
|
|
${$key} = $value;
|
1721 |
|
|
}
|
1722 |
|
|
// get configuration settings
|
1723 |
|
|
foreach (ddblock_get_cycle_configuration_settings('ddblock_cycle', $delta)->settings() as $key => $value) {
|
1724 |
|
|
${$key} = $value;
|
1725 |
|
|
}
|
1726 |
|
|
|
1727 |
|
|
if (!empty($overflow)) {
|
1728 |
|
|
$overflow = 'hidden';
|
1729 |
|
|
}
|
1730 |
|
|
else {
|
1731 |
|
|
$overflow = 'visible';
|
1732 |
|
|
}
|
1733 |
|
|
|
1734 |
|
|
$container = $container_advanced;
|
1735 |
|
|
if ($template == 'none') {
|
1736 |
|
|
$container = $container_basic;
|
1737 |
|
|
// set imagecontainer height and width with jQuery
|
1738 |
|
|
$settings['ddblockImageContainer'][$delta] = array(
|
1739 |
|
|
'block' => $delta,
|
1740 |
|
|
'contentContainer' => $container,
|
1741 |
|
|
'imageContainerHeight' => $height,
|
1742 |
|
|
'imageContainerWidth' => $width,
|
1743 |
|
|
'setDimensions' => $template,
|
1744 |
|
|
);
|
1745 |
|
|
|
1746 |
|
|
// set image heigth and width with jQuery
|
1747 |
|
|
$settings['ddblockImages'][$delta] = array(
|
1748 |
|
|
'block' => $delta,
|
1749 |
|
|
'contentContainer' => $container,
|
1750 |
|
|
'imageHeight' => $image_height,
|
1751 |
|
|
'imageWidth' => $image_width,
|
1752 |
|
|
'setDimensions' => $template,
|
1753 |
|
|
);
|
1754 |
|
|
}
|
1755 |
|
|
|
1756 |
|
|
// get module path to dynamic display block module
|
1757 |
|
|
$ddblock_path = drupal_get_path('module', 'ddblock');
|
1758 |
|
|
|
1759 |
|
|
// get original block settings.
|
1760 |
|
|
$ddblock = ddblock_get_blocks($delta);
|
1761 |
|
|
$delta_original = $ddblock->delta_original;
|
1762 |
|
|
|
1763 |
|
|
$module_original = $ddblock->module;
|
1764 |
|
|
$ddblock_enabled = $ddblock->enabled;
|
1765 |
|
|
$view_name = '';
|
1766 |
|
|
$display_id = '';
|
1767 |
|
|
|
1768 |
|
|
if ($ddblock_enabled) {
|
1769 |
|
|
// get content from other blocks.
|
1770 |
|
|
$block = module_invoke($module_original, 'block_view', $delta_original);
|
1771 |
|
|
|
1772 |
|
|
if ($widget == 'default') {
|
1773 |
|
|
return ($block['content']);
|
1774 |
|
|
}
|
1775 |
|
|
else {
|
1776 |
|
|
if ($module_original == 'views') {
|
1777 |
|
|
if ($output == 'view_fields' ) {
|
1778 |
|
|
|
1779 |
|
|
foreach (ddblock_get_cycle_mapping_settings('ddblock_cycle', $delta)->settings() as $key => $value) {
|
1780 |
|
|
${$key} = $value;
|
1781 |
|
|
$mappings[$key]['target'] = $value['target'];
|
1782 |
|
|
$mappings[$key]['source'] = $value['source'];
|
1783 |
|
|
}
|
1784 |
|
|
|
1785 |
|
|
$output_type = 'view_fields';
|
1786 |
|
|
// block.module has a delta length limit of 32, but deltas in the views module can
|
1787 |
|
|
// be longer because view names can be 32 and display IDs can also be 32.
|
1788 |
|
|
// So for very long deltas, md5 hashes are used.
|
1789 |
|
|
if (strlen($delta_original) == 32) {
|
1790 |
|
|
$hashes = variable_get('views_block_hashes', array());
|
1791 |
|
|
if (!empty($hashes[$delta_original])) {
|
1792 |
|
|
$delta_original = $hashes[$delta_original];
|
1793 |
|
|
}
|
1794 |
|
|
}
|
1795 |
|
|
list($view_name, $display_id) = explode('-', $delta_original);
|
1796 |
|
|
|
1797 |
|
|
|
1798 |
|
|
// Load the view
|
1799 |
|
|
if ($view = views_get_view($view_name)) {
|
1800 |
|
|
if ($view->access($display_id)) {
|
1801 |
|
|
$view->preview($display_id);
|
1802 |
|
|
$content = $view->result;
|
1803 |
|
|
|
1804 |
|
|
// Remove empty mappings
|
1805 |
|
|
foreach ($mappings as $key => $value) {
|
1806 |
|
|
if (empty($value['target'])) {
|
1807 |
|
|
unset($mappings[$key]);
|
1808 |
|
|
}
|
1809 |
|
|
}
|
1810 |
|
|
|
1811 |
|
|
// create result array
|
1812 |
|
|
foreach ($content as $row_num => $result) {
|
1813 |
|
|
foreach ($view->field as $id => $field) {
|
1814 |
|
|
$field_output = $view->style_plugin->get_field($row_num, $id);
|
1815 |
|
|
foreach ($mappings as $mapping_key => $mapping_value) {
|
1816 |
|
|
if ($mapping_value['source'] == $id) {
|
1817 |
|
|
$mapping_target=$mapping_value['target'];
|
1818 |
|
|
$result_rows[$row_num][$mapping_target] = $field_output;
|
1819 |
|
|
}
|
1820 |
|
|
}
|
1821 |
|
|
}
|
1822 |
|
|
}
|
1823 |
|
|
$content = array();
|
1824 |
|
|
if (!empty($result_rows)) {
|
1825 |
|
|
$content = $result_rows;
|
1826 |
|
|
switch ($order) {
|
1827 |
|
|
case 'random':
|
1828 |
|
|
shuffle($content);
|
1829 |
|
|
break;
|
1830 |
|
|
case 'asc':
|
1831 |
|
|
asort($content);
|
1832 |
|
|
break;
|
1833 |
|
|
case 'desc':
|
1834 |
|
|
rsort($content);
|
1835 |
|
|
break;
|
1836 |
|
|
case 'none':
|
1837 |
|
|
break;
|
1838 |
|
|
}
|
1839 |
|
|
}
|
1840 |
|
|
}
|
1841 |
|
|
$view->destroy();
|
1842 |
|
|
}
|
1843 |
|
|
}
|
1844 |
|
|
else {
|
1845 |
|
|
$output_type = 'view_content';
|
1846 |
|
|
$content = $block['content']; //return $block['content'];
|
1847 |
|
|
}
|
1848 |
|
|
}
|
1849 |
|
|
else {
|
1850 |
|
|
$output_type = 'view_content';
|
1851 |
|
|
$content = $block['content'];
|
1852 |
|
|
}
|
1853 |
|
|
$nr_of_items = count($content);
|
1854 |
|
|
}
|
1855 |
|
|
}
|
1856 |
|
|
else {
|
1857 |
|
|
if ($input_type <> 'images') {
|
1858 |
|
|
$output_type = 'content_array';
|
1859 |
|
|
$content = _ddblock_get_content_array($content_type, $nodes, $node_body_teaser);
|
1860 |
|
|
$nr_of_items = 2;
|
1861 |
|
|
}
|
1862 |
|
|
else {
|
1863 |
|
|
// get content from image folderimages.
|
1864 |
|
|
$output_type = 'images';
|
1865 |
|
|
$imagepath = check_plain(file_default_scheme() . ':/' .
|
1866 |
|
|
'/' .
|
1867 |
|
|
$folder,
|
1868 |
|
|
file_default_scheme() . ':/');
|
1869 |
|
|
$content = _ddblock_get_image_array($imagepath, $order, $max_image, $ignore_files, $image_style_slide, $image_style_pager_item);
|
1870 |
|
|
$nr_of_items = count($content);
|
1871 |
|
|
}
|
1872 |
|
|
}
|
1873 |
|
|
|
1874 |
|
|
// set jquery cycle settings
|
1875 |
|
|
$settings['ddblockContent'][$delta] = array(
|
1876 |
|
|
'block' => $delta,
|
1877 |
|
|
'nrOfItems' => $nr_of_items,
|
1878 |
|
|
'setDimensions' => $template,
|
1879 |
|
|
'contentContainer' => $container,
|
1880 |
|
|
'custom' => $custom_jquery,
|
1881 |
|
|
'fx' => $fx,
|
1882 |
|
|
'easeOut' => $easing_out,
|
1883 |
|
|
'easeIn' => $easing_in,
|
1884 |
|
|
'speed' => $speed,
|
1885 |
|
|
'timeOut' => $timeout,
|
1886 |
|
|
'pause' => $pause,
|
1887 |
|
|
'next' => $next,
|
1888 |
|
|
'overflow' => $overflow,
|
1889 |
|
|
'pager' => $pager,
|
1890 |
|
|
'pagerPosition' => $pager_position,
|
1891 |
|
|
'pagerPrevNextLoop' => $pager_prev_next_loop,
|
1892 |
|
|
'pagerScrollableLoop' => $pager_scrollable_loop,
|
1893 |
|
|
'nrOfPagerItems' => $nr_of_pager_items,
|
1894 |
|
|
'pagerContainer' => $pager_container,
|
1895 |
|
|
'pagerEvent' => $pager_event,
|
1896 |
|
|
'pagerDisableClick' => $pager_disable_click,
|
1897 |
|
|
'pagerFast' => $pager_fast,
|
1898 |
|
|
'pagerPause' => $pager_pause,
|
1899 |
|
|
'pager2' => $pager2,
|
1900 |
|
|
'pager2Event' => $pager2_event,
|
1901 |
|
|
'pager2SlideHide' => $pager2_slide_hide,
|
1902 |
|
|
'slideText' => $slide_text,
|
1903 |
|
|
'slideTextjQuery' => $slide_text_jquery,
|
1904 |
|
|
'slideTextPosition' => $slide_text_position,
|
1905 |
|
|
'slideTextContainer' => $slide_text_container,
|
1906 |
|
|
'slideTextEffectBefore' => $slide_text_before_effect,
|
1907 |
|
|
'slideTextEffectBeforeSpeed' => $slide_text_before_speed,
|
1908 |
|
|
'slideTextEffectBeforeEasing' => $slide_text_before_easing,
|
1909 |
|
|
'slideTextEffectAfter' => $slide_text_after_effect,
|
1910 |
|
|
'slideTextEffectAfterSpeed' => $slide_text_after_speed,
|
1911 |
|
|
'slideTextEffectAfterEasing' => $slide_text_after_easing,
|
1912 |
|
|
'height' => $height,
|
1913 |
|
|
'width' => $width,
|
1914 |
|
|
);
|
1915 |
|
|
|
1916 |
|
|
ddblock_init_js_css();
|
1917 |
|
|
drupal_add_js($settings, array('type' => 'setting', 'scope' => JS_DEFAULT));
|
1918 |
|
|
|
1919 |
|
|
if (!empty($content)) {
|
1920 |
|
|
//use a settings array for template arguments which is more flexible
|
1921 |
|
|
$settings = array(
|
1922 |
|
|
'delta' => $delta,
|
1923 |
|
|
'image_style_pager_item' => $image_style_pager_item,
|
1924 |
|
|
'image_style_toggle' => $image_style_toggle,
|
1925 |
|
|
'image_style_slide' => $image_style_slide,
|
1926 |
|
|
'nr_of_items' => $nr_of_items,
|
1927 |
|
|
'nr_of_pager_items' => $nr_of_pager_items,
|
1928 |
|
|
'output_type' => $output_type,
|
1929 |
|
|
'pager_toggle' => $pager_toggle,
|
1930 |
|
|
'pager' => $pager,
|
1931 |
|
|
'pager_container' => $pager_container,
|
1932 |
|
|
'pager_event' => $pager_event,
|
1933 |
|
|
'pager_height' => $pager_height,
|
1934 |
|
|
'pager_position' => $pager_position,
|
1935 |
|
|
'pager_width' => $pager_width,
|
1936 |
|
|
'pager_scrollable_loop' => $pager_scrollable_loop,
|
1937 |
|
|
'pager2' => $pager2,
|
1938 |
|
|
'pager2_event' => $pager2_event,
|
1939 |
|
|
'pager2_slide_prev' => $pager2_slide_prev,
|
1940 |
|
|
'pager2_slide_next' => $pager2_slide_next,
|
1941 |
|
|
'pager2_slide_hide' => $pager2_slide_hide,
|
1942 |
|
|
'slide_text' => $slide_text,
|
1943 |
|
|
'slide_text_position' => $slide_text_position,
|
1944 |
|
|
'template' => $template,
|
1945 |
|
|
'template_size' => $template_size,
|
1946 |
|
|
'view_name' => $view_name,
|
1947 |
|
|
'view_display_id' => $display_id,
|
1948 |
|
|
'image_height' => $image_height,
|
1949 |
|
|
'image_width' => $image_width,
|
1950 |
|
|
);
|
1951 |
|
|
|
1952 |
|
|
|
1953 |
|
|
$block_content = theme('ddblock_cycle_block_content', array(
|
1954 |
|
|
'settings' => $settings,
|
1955 |
|
|
'content' => $content,
|
1956 |
|
|
)
|
1957 |
|
|
);
|
1958 |
|
|
return $block_content;
|
1959 |
|
|
}
|
1960 |
|
|
else {
|
1961 |
|
|
return FALSE;
|
1962 |
|
|
}
|
1963 |
|
|
}
|
1964 |
|
|
|
1965 |
|
|
// THEME FUNCTIONS.
|
1966 |
|
|
/**
|
1967 |
|
|
* Implements hook_theme().
|
1968 |
|
|
*/
|
1969 |
|
|
function ddblock_theme() {
|
1970 |
|
|
return array(
|
1971 |
|
|
'ddblock_cycle_block_content' => array(
|
1972 |
|
|
'template' => 'ddblock-cycle-block-content',
|
1973 |
|
|
'variables' => array(
|
1974 |
|
|
'settings' => NULL,
|
1975 |
|
|
'content' => NULL,
|
1976 |
|
|
),
|
1977 |
|
|
),
|
1978 |
|
|
'ddblock_cycle_pager_content' => array(
|
1979 |
|
|
'template' => 'ddblock-cycle-pager-content',
|
1980 |
|
|
'variables' => array(
|
1981 |
|
|
'pager_settings' => NULL,
|
1982 |
|
|
'content' => NULL,
|
1983 |
|
|
),
|
1984 |
|
|
),
|
1985 |
|
|
'ddblock_add_instance' => array(
|
1986 |
|
|
'variables' => array(
|
1987 |
|
|
'add_block_form' => NULL,
|
1988 |
|
|
'ddblock_instances' => NULL,
|
1989 |
|
|
),
|
1990 |
|
|
),
|
1991 |
|
|
'ddblock_mappings_table' => array(
|
1992 |
|
|
'variables' => array('form'),
|
1993 |
|
|
),
|
1994 |
|
|
);
|
1995 |
|
|
}
|
1996 |
|
|
|
1997 |
|
|
/**
|
1998 |
|
|
* Override or insert variables into the ddblock_cycle_block_content templates.
|
1999 |
|
|
*
|
2000 |
|
|
* @param $vars
|
2001 |
|
|
* An array of variables to pass to the theme template.
|
2002 |
|
|
*/
|
2003 |
|
|
function template_preprocess_ddblock_cycle_block_content(&$vars) {
|
2004 |
|
|
//symplify content settings
|
2005 |
|
|
$slider_settings['delta'] = $vars['settings']['delta'];
|
2006 |
|
|
$slider_settings['image_height'] = $vars['settings']['image_height'];
|
2007 |
|
|
$slider_settings['image_width'] = $vars['settings']['image_width'];
|
2008 |
|
|
$slider_settings['image_style_slide'] = $vars['settings']['image_style_slide'];
|
2009 |
|
|
$slider_settings['image_style_pager_item'] = $vars['settings']['image_style_pager_item'];
|
2010 |
|
|
$slider_settings['nr_of_items'] = $vars['settings']['nr_of_items'];
|
2011 |
|
|
$slider_settings['nr_of_pager_items'] = $vars['settings']['nr_of_pager_items'];
|
2012 |
|
|
$slider_settings['output_type'] = $vars['settings']['output_type'];
|
2013 |
|
|
$slider_settings['pager_toggle'] = $vars['settings']['pager_toggle'];
|
2014 |
|
|
$slider_settings['pager'] = $vars['settings']['pager'];
|
2015 |
|
|
$slider_settings['pager_height'] = $vars['settings']['pager_height'];
|
2016 |
|
|
$slider_settings['pager_width'] = $vars['settings']['pager_width'];
|
2017 |
|
|
$slider_settings['pager_position'] = $vars['settings']['pager_position'];
|
2018 |
|
|
$slider_settings['pager2'] = $vars['settings']['pager2'];
|
2019 |
|
|
$slider_settings['pager2_slide_prev'] = $vars['settings']['pager2_slide_prev'];
|
2020 |
|
|
$slider_settings['pager2_slide_next'] = $vars['settings']['pager2_slide_next'];
|
2021 |
|
|
$slider_settings['slide_text'] = $vars['settings']['slide_text'];
|
2022 |
|
|
$slider_settings['slide_text_position'] = $vars['settings']['slide_text_position'];
|
2023 |
|
|
if ($vars['settings']['slide_text_position'] == "top" || $vars['settings']['slide_text_position'] == "bottom") {
|
2024 |
|
|
$slider_settings['slide_direction'] = "horizontal";
|
2025 |
|
|
}
|
2026 |
|
|
else {
|
2027 |
|
|
$slider_settings['slide_direction'] = "vertical";
|
2028 |
|
|
}
|
2029 |
|
|
$slider_settings['template'] = $vars['settings']['template'];
|
2030 |
|
|
$slider_settings['template_size'] = $vars['settings']['template_size'];
|
2031 |
|
|
|
2032 |
|
|
$vars['ddblock_cycle_slider_settings'] = $slider_settings;
|
2033 |
|
|
|
2034 |
|
|
// pager content settings
|
2035 |
|
|
$pager_settings['delta'] = $vars['settings']['delta'];
|
2036 |
|
|
$pager_settings['nr_of_items'] = $vars['settings']['nr_of_items'];
|
2037 |
|
|
$pager_settings['nr_of_pager_items'] = $vars['settings']['nr_of_pager_items'];
|
2038 |
|
|
$pager_settings['output_type'] = $vars['settings']['output_type'];
|
2039 |
|
|
$pager_settings['pager'] = $vars['settings']['pager'];
|
2040 |
|
|
$pager_settings['pager_container'] = $vars['settings']['pager_container'];
|
2041 |
|
|
$pager_settings['pager_event'] = $vars['settings']['pager_event'];
|
2042 |
|
|
$pager_settings['pager_height'] = $vars['settings']['pager_height'];
|
2043 |
|
|
$pager_settings['pager_width'] = $vars['settings']['pager_width'];
|
2044 |
|
|
$pager_settings['pager_scrollable_loop'] = $vars['settings']['pager_scrollable_loop'];
|
2045 |
|
|
$pager_settings['pager2'] = $vars['settings']['pager2'];
|
2046 |
|
|
$pager_settings['pager2_event'] = $vars['settings']['pager2_event'];
|
2047 |
|
|
$pager_settings['pager2_slide_prev'] = $vars['settings']['pager2_slide_prev'];
|
2048 |
|
|
$pager_settings['pager2_slide_next'] = $vars['settings']['pager2_slide_next'];
|
2049 |
|
|
$pager_settings['pager2_slide_hide'] = $vars['settings']['pager2_slide_hide'];
|
2050 |
|
|
$pager_settings['image_style_pager_item'] = $vars['settings']['image_style_pager_item'];
|
2051 |
|
|
$pager_settings['pager_position'] = $vars['settings']['pager_position'];
|
2052 |
|
|
$pager_settings['template'] = $vars['settings']['template'];
|
2053 |
|
|
$pager_settings['view_name'] = $vars['settings']['view_name'];
|
2054 |
|
|
|
2055 |
|
|
$vars['pager_content'] = theme('ddblock_cycle_pager_content', array(
|
2056 |
|
|
'pager_settings' => $pager_settings,
|
2057 |
|
|
'content' => $vars['content'],
|
2058 |
|
|
)
|
2059 |
|
|
);
|
2060 |
|
|
|
2061 |
|
|
// additional candidate template files
|
2062 |
|
|
$vars['theme_hook_suggestions'][] = 'ddblock_cycle_block_content__' . $vars['settings']['template'];
|
2063 |
|
|
$vars['theme_hook_suggestions'][] = 'ddblock_cycle_block_content__' . $vars['settings']['delta'];
|
2064 |
|
|
}
|
2065 |
|
|
|
2066 |
|
|
/**
|
2067 |
|
|
* Override or insert variables into the ddblock_cycle_pager_content templates.
|
2068 |
|
|
*
|
2069 |
|
|
* @param $vars
|
2070 |
|
|
* An array of variables to pass to the theme template.
|
2071 |
|
|
*/
|
2072 |
|
|
function template_preprocess_ddblock_cycle_pager_content(&$vars) {
|
2073 |
|
|
$vars['ddblock_cycle_pager_settings'] = $vars['pager_settings'];
|
2074 |
|
|
|
2075 |
|
|
// additional candidate template files
|
2076 |
|
|
$vars['theme_hook_suggestions'][] = 'ddblock_cycle_pager_content__' . $vars['pager_settings']['template'];
|
2077 |
|
|
$vars['theme_hook_suggestions'][] = 'ddblock_cycle_pager_content__' . $vars['pager_settings']['delta'];
|
2078 |
|
|
}
|
2079 |
|
|
|
2080 |
|
|
// HELPER FUNCTIONS.
|
2081 |
|
|
/**
|
2082 |
|
|
* Get the configuration settings of a block.
|
2083 |
|
|
*
|
2084 |
|
|
* @param $origin
|
2085 |
|
|
* Origin of the block.
|
2086 |
|
|
* @param $delta
|
2087 |
|
|
* Blocknumber of the block.
|
2088 |
|
|
* @return
|
2089 |
|
|
* An associative array containing the configuration settings of the block.
|
2090 |
|
|
*/
|
2091 |
|
|
function ddblock_get_configuration_settings($origin, $delta) {
|
2092 |
|
|
return new ddblockConfigurationSettings(variable_get('ddblock_block_' . $origin . "_" . $delta . '_settings', array()));
|
2093 |
|
|
}
|
2094 |
|
|
|
2095 |
|
|
/**
|
2096 |
|
|
* Set the configuration settings of a block.
|
2097 |
|
|
*
|
2098 |
|
|
* @param $origin
|
2099 |
|
|
* Origin of the block.
|
2100 |
|
|
* @param $delta
|
2101 |
|
|
* Blocknumber of the block.
|
2102 |
|
|
* @param $edit
|
2103 |
|
|
* An associative array containing the configuration settings of the block.
|
2104 |
|
|
*
|
2105 |
|
|
* @return
|
2106 |
|
|
* none.
|
2107 |
|
|
*/
|
2108 |
|
|
function ddblock_set_configuration_settings($origin, $delta, $edit) {
|
2109 |
|
|
$configuration_settings = new ddblockConfigurationSettings($edit);
|
2110 |
|
|
|
2111 |
|
|
// set ouput to view_fields for advanced blocks otherwise output becomes view_content
|
2112 |
|
|
if ($configuration_settings->widget != 'default') {
|
2113 |
|
|
$configuration_settings->output = 'view_fields';
|
2114 |
|
|
}
|
2115 |
|
|
else {
|
2116 |
|
|
$configuration_settings->output = 'view_content';
|
2117 |
|
|
}
|
2118 |
|
|
variable_set('ddblock_block_' . $origin . '_' . $delta . '_settings', $configuration_settings->settings());
|
2119 |
|
|
}
|
2120 |
|
|
/**
|
2121 |
|
|
* Get the configuration settings of a cycle block.
|
2122 |
|
|
*
|
2123 |
|
|
* @param $origin
|
2124 |
|
|
* Origin of the block.
|
2125 |
|
|
* @param $delta
|
2126 |
|
|
* Blocknumber of the block.
|
2127 |
|
|
* @return
|
2128 |
|
|
* An associative array containing the configuration settings of the block.
|
2129 |
|
|
*/
|
2130 |
|
|
function ddblock_get_cycle_configuration_settings($origin, $delta) {
|
2131 |
|
|
return new ddblockCycleConfigurationSettings(variable_get('ddblock_block_' . $origin . "_" . $delta . '_cycle_settings', array()));
|
2132 |
|
|
}
|
2133 |
|
|
|
2134 |
|
|
/**
|
2135 |
|
|
* Set the configuration settings of a cycle block.
|
2136 |
|
|
*
|
2137 |
|
|
* @param $origin
|
2138 |
|
|
* Origin of the block.
|
2139 |
|
|
* @param $delta
|
2140 |
|
|
* Blocknumber of the block.
|
2141 |
|
|
* @param $edit
|
2142 |
|
|
* An associative array containing the configuration settings of the block.
|
2143 |
|
|
*
|
2144 |
|
|
* @return
|
2145 |
|
|
* none.
|
2146 |
|
|
*/
|
2147 |
|
|
function ddblock_set_cycle_configuration_settings($origin, $delta, $edit) {
|
2148 |
|
|
$configuration_settings = new ddblockCycleConfigurationSettings($edit);
|
2149 |
|
|
|
2150 |
|
|
// set pager to none if pager_toggle is unchecked
|
2151 |
|
|
if ($configuration_settings->pager_toggle == 0) {
|
2152 |
|
|
$configuration_settings->pager = 'none';
|
2153 |
|
|
}
|
2154 |
|
|
// set image_style-slide and image_style_pager_item to none if image_style_toggle is unchecked
|
2155 |
|
|
if ($configuration_settings->image_style_toggle == 0) {
|
2156 |
|
|
$configuration_settings->image_style_slide = 'none';
|
2157 |
|
|
$configuration_settings->image_style_pager_item = 'none';
|
2158 |
|
|
}
|
2159 |
|
|
variable_set('ddblock_block_' . $origin . '_' . $delta . '_cycle_settings', $configuration_settings->settings());
|
2160 |
|
|
}
|
2161 |
|
|
|
2162 |
|
|
/**
|
2163 |
|
|
* Get the mapping settings of a cycle block.
|
2164 |
|
|
*
|
2165 |
|
|
* @param $origin
|
2166 |
|
|
* Origin of the block.
|
2167 |
|
|
* @param $delta
|
2168 |
|
|
* Blocknumber of the block.
|
2169 |
|
|
* @return
|
2170 |
|
|
* An associative array containing the configuration settings of the block.
|
2171 |
|
|
*/
|
2172 |
|
|
function ddblock_get_cycle_mapping_settings($origin, $delta) {
|
2173 |
|
|
return new ddblockCycleMappingSettings(variable_get('ddblock_block_' . $origin . "_" . $delta . '_cycle_mapping_settings', array()));
|
2174 |
|
|
}
|
2175 |
|
|
|
2176 |
|
|
/**
|
2177 |
|
|
* Set the mapping settings of a cycle block.
|
2178 |
|
|
*
|
2179 |
|
|
* @param $origin
|
2180 |
|
|
* Origin of the block.
|
2181 |
|
|
* @param $delta
|
2182 |
|
|
* Blocknumber of the block.
|
2183 |
|
|
* @param $edit
|
2184 |
|
|
* An associative array containing the configuration settings of the block.
|
2185 |
|
|
*
|
2186 |
|
|
* @return
|
2187 |
|
|
* none.
|
2188 |
|
|
*/
|
2189 |
|
|
function ddblock_set_cycle_mapping_settings($origin, $delta, $edit) {
|
2190 |
|
|
$mapping_settings = new ddblockCycleMappingSettings($edit['block_settings']['mapping_wrapper']['mappings']);
|
2191 |
|
|
variable_set('ddblock_block_' . $origin . '_' . $delta . '_cycle_mapping_settings', $mapping_settings->settings());
|
2192 |
|
|
}
|
2193 |
|
|
|
2194 |
|
|
/**
|
2195 |
|
|
* Return available effect for the dynamic display block.
|
2196 |
|
|
*
|
2197 |
|
|
* @return
|
2198 |
|
|
* An associative array containing the available effect for the dynamic display block.
|
2199 |
|
|
*/
|
2200 |
|
|
function _ddblock_get_effects() {
|
2201 |
|
|
// effects.
|
2202 |
|
|
$_fx = array(
|
2203 |
|
|
'none' => t('none'),
|
2204 |
|
|
'all' => t('all'),
|
2205 |
|
|
'blindX' => t('blindX'),
|
2206 |
|
|
'blindY' => t('blindY'),
|
2207 |
|
|
'blindZ' => t('blindZ'),
|
2208 |
|
|
'cover' => t('cover'),
|
2209 |
|
|
'curtainX' => t('curtainX'),
|
2210 |
|
|
'curtainY' => t('curtainY'),
|
2211 |
|
|
'fade' => t('fade'),
|
2212 |
|
|
'fadeZoom' => t('fadeZoom'),
|
2213 |
|
|
'growX' => t('growX'),
|
2214 |
|
|
'growY' => t('growY'),
|
2215 |
|
|
'scrollUp' => t('scrollUp'),
|
2216 |
|
|
'scrollDown' => t('scrollDown'),
|
2217 |
|
|
'scrollLeft' => t('scrollLeft'),
|
2218 |
|
|
'scrollRight' => t('scrollRight'),
|
2219 |
|
|
'scrollHorz' => t('scrollHorz'),
|
2220 |
|
|
'scrollVert' => t('scrollVert'),
|
2221 |
|
|
'shuffle' => t('shuffle'),
|
2222 |
|
|
'slideX' => t('slideX'),
|
2223 |
|
|
'slideY' => t('slideY'),
|
2224 |
|
|
'toss' => t('toss'),
|
2225 |
|
|
'turnUp' => t('turnUp'),
|
2226 |
|
|
'turnDown' => t('turnDown'),
|
2227 |
|
|
'turnLeft' => t('turnLeft'),
|
2228 |
|
|
'turnRight' => t('turnRight'),
|
2229 |
|
|
'uncover' => t('uncover'),
|
2230 |
|
|
'wipe' => t('wipe'),
|
2231 |
|
|
'zoom' => t('zoom'),
|
2232 |
|
|
);
|
2233 |
|
|
|
2234 |
|
|
return $_fx;
|
2235 |
|
|
}
|
2236 |
|
|
|
2237 |
|
|
/**
|
2238 |
|
|
* Return available easing effect for the dynamic display block.
|
2239 |
|
|
*
|
2240 |
|
|
* @return
|
2241 |
|
|
* An associative array containing the available easing effect for the dynamic display block.
|
2242 |
|
|
*/
|
2243 |
|
|
function _ddblock_get_easing_effects() {
|
2244 |
|
|
// easing effects.
|
2245 |
|
|
$_easing_fx = array(
|
2246 |
|
|
'none' => '<none>',
|
2247 |
|
|
'linear' => 'linear',
|
2248 |
|
|
'swing' => 'swing',
|
2249 |
|
|
'easeInQuad' => 'easeInQuad',
|
2250 |
|
|
'easeOutQuad' => 'easeOutQuad',
|
2251 |
|
|
'easeInOutQuad' => 'easeInOutQuad',
|
2252 |
|
|
'easeInCubic' => 'easeInCubic',
|
2253 |
|
|
'easeOutCubic' => 'easeOutCubic',
|
2254 |
|
|
'easeInOutCubic' => 'easeInOutCubic',
|
2255 |
|
|
'easeInQuart' => 'easeInQuart',
|
2256 |
|
|
'easeOutQuart' => 'easeOutQuart',
|
2257 |
|
|
'easeInOutQuart' => 'easeInOutQuart',
|
2258 |
|
|
'easeInQuint' => 'easeInQuint',
|
2259 |
|
|
'easeOutQuint' => 'easeOutQuint',
|
2260 |
|
|
'easeInOutQuint' => 'easeInOutQuint',
|
2261 |
|
|
'easeInSine' => 'easeInSine',
|
2262 |
|
|
'easeOutSine' => 'easeOutSine',
|
2263 |
|
|
'easeInOutSine' => 'easeInOutSine',
|
2264 |
|
|
'easeInExpo' => 'easeInExpo',
|
2265 |
|
|
'easeOutExpo' => 'easeOutExpo',
|
2266 |
|
|
'easeInOutExpo' => 'easeInOutExpo',
|
2267 |
|
|
'easeInCirc' => 'easeInCirc',
|
2268 |
|
|
'easeOutCirc' => 'easeOutCirc',
|
2269 |
|
|
'easeInOutCirc' => 'easeInOutCirc',
|
2270 |
|
|
'easeInElastic' => 'easeInElastic',
|
2271 |
|
|
'easeOutElastic' => 'easeOutElastic',
|
2272 |
|
|
'easeInOutElastic' => 'easeInOutElastic',
|
2273 |
|
|
'easeInBack' => 'easeInBack',
|
2274 |
|
|
'easeOutBack' => 'easeOutBack',
|
2275 |
|
|
'easeInOutBack' => 'easeInOutBack',
|
2276 |
|
|
'easeInBounce' => 'easeInBounce',
|
2277 |
|
|
'easeOutBounce' => 'easeOutBounce',
|
2278 |
|
|
'easeInOutBounce' => 'easeInOutBounce',
|
2279 |
|
|
);
|
2280 |
|
|
|
2281 |
|
|
return $_easing_fx;
|
2282 |
|
|
}
|
2283 |
|
|
|
2284 |
|
|
/**
|
2285 |
|
|
* Get images from a directory.
|
2286 |
|
|
*
|
2287 |
|
|
* @param $imagepath
|
2288 |
|
|
* Path to the directoryory where the images are stored.
|
2289 |
|
|
* @param $order
|
2290 |
|
|
* The order in which to return the images.
|
2291 |
|
|
* @param $max_image
|
2292 |
|
|
* The maximum images to show in the slideshow.
|
2293 |
|
|
* @param $ignore_files
|
2294 |
|
|
* Comma seperated list of strings. When string exist in image file name, the image is ignored.
|
2295 |
|
|
* @return
|
2296 |
|
|
* An array containing the filenames of the images for the dynamic display block.
|
2297 |
|
|
*/
|
2298 |
|
|
function _ddblock_get_image_array($imagepath, $order, $max_image, $ignore_files, $image_style_slide, $image_style_pager_item) {
|
2299 |
|
|
|
2300 |
|
|
// only images jpg, jpeg, gif, png
|
2301 |
|
|
$mask = '/[a-zA-Z0-9\_\-\.\]\[]+\.(jpe?g|gif|png|JPE?G|GIF|PNG)$/';
|
2302 |
|
|
// ignore the following files
|
2303 |
|
|
$ignore = '/(\.\.?|CVS)$/';
|
2304 |
|
|
|
2305 |
|
|
// Finds all files that match a given mask in a given directory, files which match the ignore variable are excluded.
|
2306 |
|
|
$file_array = file_scan_directory($imagepath, $mask, array('nomask' => $ignore, 'callback' => $callback = 0, 'recurse' => $recurse = FALSE, 'key' => $key = 'filename', 'min_depth' => $min_depth = 0));
|
2307 |
|
|
|
2308 |
|
|
$file_names = array();
|
2309 |
|
|
|
2310 |
|
|
if (sizeof($file_array) > 0) {
|
2311 |
|
|
// Remove to file to ignore
|
2312 |
|
|
if (!empty($ignore_files)) {
|
2313 |
|
|
$ignore_strings = explode(',', $ignore_files);
|
2314 |
|
|
|
2315 |
|
|
$temp_file_array = array();
|
2316 |
|
|
foreach ($file_array as $value) {
|
2317 |
|
|
$ignore = FALSE;
|
2318 |
|
|
|
2319 |
|
|
foreach ($ignore_strings as $ignore_string ) {
|
2320 |
|
|
if (stristr($value->filename, $ignore_string)) {
|
2321 |
|
|
$ignore = TRUE;
|
2322 |
|
|
break;
|
2323 |
|
|
}
|
2324 |
|
|
}
|
2325 |
|
|
if (!$ignore) {
|
2326 |
|
|
$temp_file_array[] = $value;
|
2327 |
|
|
}
|
2328 |
|
|
}
|
2329 |
|
|
$file_array = $temp_file_array;
|
2330 |
|
|
}
|
2331 |
|
|
if (sizeof($file_array) > 0) {
|
2332 |
|
|
foreach ($file_array as $value) {
|
2333 |
|
|
if ($image_style_slide <> 'none') {
|
2334 |
|
|
$image_info = _ddblock_get_file_sizes($value->uri, $image_style_slide);
|
2335 |
|
|
$image = array(
|
2336 |
|
|
'title' => 'image',
|
2337 |
|
|
'path' => $value->uri,
|
2338 |
|
|
'alt' => 'image',
|
2339 |
|
|
'style_name' => $image_style_slide,
|
2340 |
|
|
'width' => $image_info['width'] . 'px',
|
2341 |
|
|
'height' => $image_info['height'] . 'px',
|
2342 |
|
|
);
|
2343 |
|
|
|
2344 |
|
|
$file_names['slide_image'][] = theme('image_style', $image);
|
2345 |
|
|
}
|
2346 |
|
|
else {
|
2347 |
|
|
$variables = array(
|
2348 |
|
|
'path' => $value->uri,
|
2349 |
|
|
'alt' => 'image',
|
2350 |
|
|
'title' => 'image',
|
2351 |
|
|
'width' => '100%',
|
2352 |
|
|
'height' => '100%',
|
2353 |
|
|
'attributes' => array(),
|
2354 |
|
|
);
|
2355 |
|
|
$file_names['slide_image'][] = '<img src="' . file_create_url($value->uri) . '" alt="image">';
|
2356 |
|
|
// $file_names['slide_image'][] = theme('image', $variables);
|
2357 |
|
|
}
|
2358 |
|
|
if ($image_style_pager_item <> 'none') {
|
2359 |
|
|
$image_info = _ddblock_get_file_sizes($value->uri, $image_style_pager_item);
|
2360 |
|
|
$image = array(
|
2361 |
|
|
'title' => 'image',
|
2362 |
|
|
'path' => $value->uri,
|
2363 |
|
|
'alt' => 'image',
|
2364 |
|
|
'style_name' => $image_style_pager_item,
|
2365 |
|
|
'width' => $image_info['width'] . 'px',
|
2366 |
|
|
'height' => $image_info['height'] . 'px',
|
2367 |
|
|
);
|
2368 |
|
|
$file_names['pager_image'][] = theme('image_style', $image);
|
2369 |
|
|
}
|
2370 |
|
|
else {
|
2371 |
|
|
$variables = array(
|
2372 |
|
|
'path' => $value->uri,
|
2373 |
|
|
'alt' => 'image',
|
2374 |
|
|
'title' => 'image',
|
2375 |
|
|
'width' => '55px',
|
2376 |
|
|
'height' => '55px',
|
2377 |
|
|
'attributes' => array(),
|
2378 |
|
|
);
|
2379 |
|
|
$file_names['pager_image'][] = theme('image', $variables);
|
2380 |
|
|
}
|
2381 |
|
|
}
|
2382 |
|
|
|
2383 |
|
|
switch ($order) {
|
2384 |
|
|
case 'random':
|
2385 |
|
|
shuffle($file_names);
|
2386 |
|
|
break;
|
2387 |
|
|
case 'asc':
|
2388 |
|
|
asort($file_names['slide_image']);
|
2389 |
|
|
asort($file_names['pager_image']);
|
2390 |
|
|
break;
|
2391 |
|
|
case 'desc':
|
2392 |
|
|
rsort($file_names['slide_image']);
|
2393 |
|
|
rsort($file_names['pager_image']);
|
2394 |
|
|
break;
|
2395 |
|
|
case 'none':
|
2396 |
|
|
break;
|
2397 |
|
|
}
|
2398 |
|
|
$file_names['slide_image'] = array_slice($file_names['slide_image'], 0, $max_image);
|
2399 |
|
|
$file_names['pager_image'] = array_slice($file_names['pager_image'], 0, $max_image);
|
2400 |
|
|
}
|
2401 |
|
|
}
|
2402 |
|
|
return $file_names;
|
2403 |
|
|
}
|
2404 |
|
|
|
2405 |
|
|
/**
|
2406 |
|
|
* Get content from a content type for the dynamic display block.
|
2407 |
|
|
*
|
2408 |
|
|
* @param $content_type
|
2409 |
|
|
* Content type to get the content from.
|
2410 |
|
|
* @param $nodes
|
2411 |
|
|
* The nodes to return.
|
2412 |
|
|
* @return
|
2413 |
|
|
* An array containing the teaser of nodes for the dynamic display block
|
2414 |
|
|
*/
|
2415 |
|
|
function _ddblock_get_content_array($content_type, $nodes, $node_body_teaser) {
|
2416 |
|
|
$sql = "SELECT nid " .
|
2417 |
|
|
"FROM {node} " .
|
2418 |
|
|
"WHERE status = 1 " .
|
2419 |
|
|
"AND type = :content_type " .
|
2420 |
|
|
"AND nid = :nodes";
|
2421 |
|
|
$results = db_query($sql, array(
|
2422 |
|
|
':content_type' => $content_type,
|
2423 |
|
|
':nodes' => $nodes)
|
2424 |
|
|
);
|
2425 |
|
|
$selected_nodes = array();
|
2426 |
|
|
$view_mode = ($node_body_teaser == 'teaser') ? 'teaser' : 'full';
|
2427 |
|
|
while ($obj = $results->fetchObject()) {
|
2428 |
|
|
$node = node_load($obj->nid);
|
2429 |
|
|
$content = node_view($node, $view_mode);
|
2430 |
|
|
$selected_nodes[] = drupal_render($content);
|
2431 |
|
|
}
|
2432 |
|
|
return $selected_nodes;
|
2433 |
|
|
}
|
2434 |
|
|
|
2435 |
|
|
function _ddblock_get_file_sizes($path, $style_name) {
|
2436 |
|
|
// theme_image() can only honor the $getsize parameter with local file paths.
|
2437 |
|
|
// The derivative image is not created until it has been requested so the file
|
2438 |
|
|
// may not yet exist, in this case we just fallback to the URL.
|
2439 |
|
|
$style_path = image_style_path($style_name, $path);
|
2440 |
|
|
if (!file_exists($style_path)) {
|
2441 |
|
|
$style_path = image_style_url($style_name, $path);
|
2442 |
|
|
}
|
2443 |
|
|
$image_info = image_get_info($style_path);
|
2444 |
|
|
|
2445 |
|
|
return $image_info;
|
2446 |
|
|
};
|
2447 |
|
|
|
2448 |
|
|
/**
|
2449 |
|
|
* Get node id's and titles of nodes of a content type.
|
2450 |
|
|
*
|
2451 |
|
|
* @param $content_type
|
2452 |
|
|
* Content type to get the content from.
|
2453 |
|
|
* @return
|
2454 |
|
|
* An array containing node id's and node titles.
|
2455 |
|
|
*/
|
2456 |
|
|
function _ddblock_get_content_type_nodes($content_type) {
|
2457 |
|
|
|
2458 |
|
|
$sql = "SELECT nid " .
|
2459 |
|
|
"FROM {node} " .
|
2460 |
|
|
"WHERE status=1 " .
|
2461 |
|
|
"AND type= :content_type";
|
2462 |
|
|
$results = db_query($sql, array(
|
2463 |
|
|
':content_type' => $content_type)
|
2464 |
|
|
);
|
2465 |
|
|
|
2466 |
|
|
$selected_nodes = array();
|
2467 |
|
|
while ($obj = $results->fetchObject()) {
|
2468 |
|
|
$node = node_load($obj->nid);
|
2469 |
|
|
$selected_nodes[$node->nid] = check_plain($node->title);
|
2470 |
|
|
}
|
2471 |
|
|
|
2472 |
|
|
return $selected_nodes;
|
2473 |
|
|
}
|
2474 |
|
|
|
2475 |
|
|
// AHAH CALLBACK FUNCTIONS
|
2476 |
|
|
|
2477 |
|
|
/**
|
2478 |
|
|
* AHAH callback to replace node select options.
|
2479 |
|
|
*
|
2480 |
|
|
* This function is called when the content type is changed. It updates the
|
2481 |
|
|
* cached form (configure form) and returns rendered output to be used to
|
2482 |
|
|
* replace the select containing the possible nodes in the newly selected content-type.
|
2483 |
|
|
*
|
2484 |
|
|
* @param $build_id
|
2485 |
|
|
* The form's build_id.
|
2486 |
|
|
* @param $ctid
|
2487 |
|
|
* A content type id from among those in the form's content type select.
|
2488 |
|
|
* @return
|
2489 |
|
|
* Prints the replacement HTML in JSON format.
|
2490 |
|
|
*/
|
2491 |
|
|
function ddblock_select_nodes_js() {
|
2492 |
|
|
// get the form_id to rebuild the form later.
|
2493 |
|
|
$form_id = $_POST['form_id'];
|
2494 |
|
|
|
2495 |
|
|
// get field settings from the form.
|
2496 |
|
|
$content_type = $_POST['content_type'];
|
2497 |
|
|
$nodes = $_POST['content_nodes'];
|
2498 |
|
|
|
2499 |
|
|
// get the form_build_id of the form to fetch the form from the cache_form table.
|
2500 |
|
|
$form_build_id = $_POST['form_build_id'];
|
2501 |
|
|
$form_state = array('submitted' => FALSE);
|
2502 |
|
|
|
2503 |
|
|
// Fetch the form from cache.
|
2504 |
|
|
$form = form_get_cache($form_build_id, $form_state);
|
2505 |
|
|
|
2506 |
|
|
// Get the new fields.
|
2507 |
|
|
ddblock_select_nodes_form($form, $content_type, $nodes);
|
2508 |
|
|
|
2509 |
|
|
// Store the form back in the cache.
|
2510 |
|
|
form_set_cache($form_build_id, $form, $form_state);
|
2511 |
|
|
|
2512 |
|
|
// Build and render the new select element, then return it in JSON format.
|
2513 |
|
|
$form_state = array();
|
2514 |
|
|
$form['#post'] = array();
|
2515 |
|
|
$form = form_builder($form_id, $form, $form_state);
|
2516 |
|
|
$output = drupal_render($form['content']['content_types']['content_type']);
|
2517 |
|
|
$output .= drupal_render($form['content']['content_types']['nodes']);
|
2518 |
|
|
$output .= drupal_render($form['content']['content_types']['select_nodes']);
|
2519 |
|
|
|
2520 |
|
|
// Don't call drupal_json(). ahah.js uses an iframe and
|
2521 |
|
|
// the header output by drupal_json() causes problems in some browsers.
|
2522 |
|
|
print drupal_json_encode(array('status' => TRUE, 'data' => $output));
|
2523 |
|
|
exit();
|
2524 |
|
|
}
|
2525 |
|
|
|
2526 |
|
|
/**
|
2527 |
|
|
* ddblock instances.
|
2528 |
|
|
*
|
2529 |
|
|
* Gives an overview of all dynamic display blocks instances to manage and to add a dynamic display block instance.
|
2530 |
|
|
*/
|
2531 |
|
|
function ddblock_instances() {
|
2532 |
|
|
|
2533 |
|
|
// Fetch "Add Instance" form.
|
2534 |
|
|
$form = drupal_get_form('ddblock_add_instance_form');
|
2535 |
|
|
|
2536 |
|
|
// Get an array of existing block instances.
|
2537 |
|
|
$block_instances = ddblock_get_block_instances(NULL, TRUE);
|
2538 |
|
|
|
2539 |
|
|
// theme the instances form.
|
2540 |
|
|
return theme('ddblock_add_instance', array('add_block_form' => $form, 'ddblock_instances' => $block_instances));
|
2541 |
|
|
}
|
2542 |
|
|
|
2543 |
|
|
/**
|
2544 |
|
|
* form to add a dynamic display block instance.
|
2545 |
|
|
*/
|
2546 |
|
|
function ddblock_add_instance_form($form, $form_state) {
|
2547 |
|
|
$form = array();
|
2548 |
|
|
$form['title'] = array(
|
2549 |
|
|
'#type' => 'textfield',
|
2550 |
|
|
'#title' => t('Instance Title'),
|
2551 |
|
|
'#maxlength' => 256,
|
2552 |
|
|
'#required' => TRUE,
|
2553 |
|
|
);
|
2554 |
|
|
|
2555 |
|
|
// Turn $blocks into form options of block types.
|
2556 |
|
|
$options = array();
|
2557 |
|
|
|
2558 |
|
|
//get possible content types from settings.
|
2559 |
|
|
$block_types = variable_get('ddblock_blocks', array());
|
2560 |
|
|
foreach ($block_types as $value ) {
|
2561 |
|
|
if ($value) {
|
2562 |
|
|
|
2563 |
|
|
//$option[0] contains module name, $option[1] contains delta, $option[2] contains block title,
|
2564 |
|
|
$option = explode(':', $value);
|
2565 |
|
|
|
2566 |
|
|
//If the block title contains colons, the value in $option[2] would
|
2567 |
|
|
//be incorrect. Any array elements > 3 also belong in the title, so if
|
2568 |
|
|
//they exist, loop through them and add them to the block title.
|
2569 |
|
|
$block_title = $option[2];
|
2570 |
|
|
for($i = 3; $i < count($option); $i++) {
|
2571 |
|
|
$block_title .= ":".$option[$i];
|
2572 |
|
|
}
|
2573 |
|
|
|
2574 |
|
|
$options[$option[0] . ':' . $option[1]] = $option[0] . ' - ' . $block_title;
|
2575 |
|
|
}
|
2576 |
|
|
}
|
2577 |
|
|
|
2578 |
|
|
$form['block'] = array(
|
2579 |
|
|
'#type' => 'select',
|
2580 |
|
|
'#title' => t('Block type'),
|
2581 |
|
|
'#options' => $options,
|
2582 |
|
|
'#required' => TRUE,
|
2583 |
|
|
);
|
2584 |
|
|
|
2585 |
|
|
$form['submit'] = array(
|
2586 |
|
|
'#type' => 'submit',
|
2587 |
|
|
'#value' => t('Add Instance'),
|
2588 |
|
|
);
|
2589 |
|
|
|
2590 |
|
|
return $form;
|
2591 |
|
|
}
|
2592 |
|
|
|
2593 |
|
|
/**
|
2594 |
|
|
* Return all or one dynamic display block instances.
|
2595 |
|
|
*
|
2596 |
|
|
* @param $delta
|
2597 |
|
|
* Optional. Retreive a single block based on this delta. If none specified,
|
2598 |
|
|
* all blocks are returned.
|
2599 |
|
|
* @param $reset
|
2600 |
|
|
* Optional. Boolean value to reset the interal cache of this function.
|
2601 |
|
|
* @return
|
2602 |
|
|
* array of dynamic display block.
|
2603 |
|
|
*/
|
2604 |
|
|
function ddblock_get_block_instances($delta = NULL, $reset = FALSE) {
|
2605 |
|
|
static $block_instances;
|
2606 |
|
|
|
2607 |
|
|
if (!isset($block_instances) || $reset) {
|
2608 |
|
|
$block_instances = array();
|
2609 |
|
|
$results = db_query("SELECT * FROM {ddblock_block} where enabled = 1");
|
2610 |
|
|
while ($block_instance = $results->fetchObject()) {
|
2611 |
|
|
$block_instances[$block_instance->delta] = $block_instance;
|
2612 |
|
|
}
|
2613 |
|
|
}
|
2614 |
|
|
|
2615 |
|
|
return is_numeric($delta) ? $block_instances[$delta] : $block_instances;
|
2616 |
|
|
}
|
2617 |
|
|
|
2618 |
|
|
/**
|
2619 |
|
|
* Add block instance to database from add_instance_form.
|
2620 |
|
|
*/
|
2621 |
|
|
function ddblock_add_instance_form_submit($form, &$form_state) {
|
2622 |
|
|
// Get the original block info.
|
2623 |
|
|
$original_block = explode(':', $form_state['values']['block']);
|
2624 |
|
|
// Create new delta for block instance.
|
2625 |
|
|
$result = $id = db_insert('ddblock_block')
|
2626 |
|
|
->fields(array(
|
2627 |
|
|
'title' => $form_state['values']['title'],
|
2628 |
|
|
'module' => $original_block[0],
|
2629 |
|
|
'delta_original' => $original_block[1],
|
2630 |
|
|
'enabled' => 1,
|
2631 |
|
|
))
|
2632 |
|
|
->execute();
|
2633 |
|
|
|
2634 |
|
|
drupal_set_message(t('Dynamic display block instance Added.'));
|
2635 |
|
|
$form_state['redirect'] = 'admin/structure/ddblock';
|
2636 |
|
|
return $form;
|
2637 |
|
|
}
|
2638 |
|
|
|
2639 |
|
|
|
2640 |
|
|
/**
|
2641 |
|
|
* Get title of a block by its module and delta.
|
2642 |
|
|
*/
|
2643 |
|
|
function ddblock_get_block_title($module, $delta) {
|
2644 |
|
|
$blocks = module_invoke($module, 'block_info');
|
2645 |
|
|
$title = $blocks[$delta]['info'];
|
2646 |
|
|
return $title;
|
2647 |
|
|
}
|
2648 |
|
|
|
2649 |
|
|
/**
|
2650 |
|
|
* Get the blocks which are enabled in the settings page of the dynamic display block module.
|
2651 |
|
|
*/
|
2652 |
|
|
function ddblock_get_ddblock_enabled_module_blocks() {
|
2653 |
|
|
|
2654 |
|
|
// get the saved block types which can be used as ddblock instances.
|
2655 |
|
|
$block_types = variable_get('ddblock_blocks', array());
|
2656 |
|
|
|
2657 |
|
|
// put the block types in an array.
|
2658 |
|
|
$blocks = array();
|
2659 |
|
|
$i = 0;
|
2660 |
|
|
foreach ($block_types as $value ) {
|
2661 |
|
|
if ($value) {
|
2662 |
|
|
//$option[0] contains module name, $option[1] contains delta, $option[2] contains block title.
|
2663 |
|
|
$option = explode(':', $value);
|
2664 |
|
|
$blocks[$i]['module'] = $option[0];
|
2665 |
|
|
$blocks[$i]['delta'] = $option[1];
|
2666 |
|
|
$i++;
|
2667 |
|
|
}
|
2668 |
|
|
}
|
2669 |
|
|
return $blocks;
|
2670 |
|
|
}
|
2671 |
|
|
|
2672 |
|
|
/**
|
2673 |
|
|
* Theme function for the "Block Instances" page.
|
2674 |
|
|
*/
|
2675 |
|
|
function theme_ddblock_add_instance($variables) {
|
2676 |
|
|
$add_block_form = $variables['add_block_form'];
|
2677 |
|
|
$block_instances = $variables['ddblock_instances'];
|
2678 |
|
|
|
2679 |
|
|
$output = '';
|
2680 |
|
|
$header = array(
|
2681 |
|
|
t('Title'),
|
2682 |
|
|
t('Original Module'),
|
2683 |
|
|
t('Original Block Title'),
|
2684 |
|
|
);
|
2685 |
|
|
$rows = array();
|
2686 |
|
|
if (!empty($block_instances)) {
|
2687 |
|
|
foreach ($block_instances as $row) {
|
2688 |
|
|
$title = ddblock_get_block_title($row->module, $row->delta_original);
|
2689 |
|
|
$rows[] = array(
|
2690 |
|
|
check_plain($row->title),
|
2691 |
|
|
$row->module,
|
2692 |
|
|
$title,
|
2693 |
|
|
);
|
2694 |
|
|
}
|
2695 |
|
|
}
|
2696 |
|
|
|
2697 |
|
|
$output .= '<p><h3>' . t('Manage Instances') . '</h3>' . theme('table', array('header' => $header, 'rows' => $rows)) . '</p>';
|
2698 |
|
|
|
2699 |
|
|
$output .= '<p><h3>' . t('Add Instance') . '</h3>' . drupal_render($add_block_form) . '</p>';
|
2700 |
|
|
return $output;
|
2701 |
|
|
}
|
2702 |
|
|
|
2703 |
|
|
/**
|
2704 |
|
|
* Custom sort based on info element of array.
|
2705 |
|
|
*/
|
2706 |
|
|
function ddblock_block_sort($a, $b) {
|
2707 |
|
|
return strcmp($a['module'] . $a['info'], $b['module'] . $b['info']);
|
2708 |
|
|
}
|
2709 |
|
|
|
2710 |
|
|
/**
|
2711 |
|
|
* Returns the path to actual site theme in use because path_to_theme is flaky.
|
2712 |
|
|
*/
|
2713 |
|
|
function _ddblock_get_theme_path() {
|
2714 |
|
|
// path_to_theme gives the path to the admin theme when a different one is used.
|
2715 |
|
|
// As a band-aid solution, this will pull the default theme out of the
|
2716 |
|
|
// database and use that. (got this from advanced_forum module, in this case always
|
2717 |
|
|
// use the default theme from database)
|
2718 |
|
|
static $theme_path;
|
2719 |
|
|
|
2720 |
|
|
if (!$theme_path) {
|
2721 |
|
|
$default_theme = variable_get('theme_default', 'garland');
|
2722 |
|
|
$theme_path = drupal_get_path('theme', $default_theme);
|
2723 |
|
|
}
|
2724 |
|
|
return $theme_path;
|
2725 |
|
|
}
|
2726 |
|
|
|
2727 |
|
|
function theme_ddblock_mappings_table($form) {
|
2728 |
|
|
$vars['header'] = array(t('Target'), t('Source'));
|
2729 |
|
|
$vars['rows'] = array();
|
2730 |
|
|
|
2731 |
|
|
foreach (element_children($form) as $key) {
|
2732 |
|
|
// No need to print the field title every time.
|
2733 |
|
|
unset(
|
2734 |
|
|
$form[$key]['target']['#title'],
|
2735 |
|
|
$form[$key]['source']['#title']
|
2736 |
|
|
);
|
2737 |
|
|
|
2738 |
|
|
// Build the table row.
|
2739 |
|
|
$row = array(
|
2740 |
|
|
'data' => array(
|
2741 |
|
|
array('data' => drupal_render($form[$key]['target']) . drupal_render($form[$key]['target']), 'class' => 'target'),
|
2742 |
|
|
array('data' => drupal_render($form[$key]['source']) . drupal_render($form[$key]['source']), 'class' => 'source'),
|
2743 |
|
|
),
|
2744 |
|
|
);
|
2745 |
|
|
|
2746 |
|
|
// Add additional attributes to the row, such as a class for this row.
|
2747 |
|
|
if (isset($form[$key]['#attributes'])) {
|
2748 |
|
|
$row = array_merge($row, $form[$key]['#attributes']);
|
2749 |
|
|
}
|
2750 |
|
|
$vars['rows'][] = $row;
|
2751 |
|
|
}
|
2752 |
|
|
|
2753 |
|
|
$output = theme('table', $vars);
|
2754 |
|
|
$output .= drupal_render($form);
|
2755 |
|
|
return $output;
|
2756 |
|
|
}
|
2757 |
|
|
|
2758 |
|
|
/**
|
2759 |
|
|
* Helper function to define populated form field elements for album track node form.
|
2760 |
|
|
*/
|
2761 |
|
|
function ddblock_mapping_display_form($delta, $target, $source, $source_fields) {
|
2762 |
|
|
|
2763 |
|
|
$form = array(
|
2764 |
|
|
'#tree' => TRUE,
|
2765 |
|
|
);
|
2766 |
|
|
|
2767 |
|
|
$form['target'] = array(
|
2768 |
|
|
'#type' => 'textfield',
|
2769 |
|
|
'#title' => t('Target'),
|
2770 |
|
|
'#weight' => 1,
|
2771 |
|
|
'#size' => 20,
|
2772 |
|
|
'#parents' => array('block_settings', 'mapping_wrapper', 'mappings', $delta, 'target'),
|
2773 |
|
|
'#default_value' => $target,
|
2774 |
|
|
'#prefix' => '<div class="ddblock-target">',
|
2775 |
|
|
'#suffix' => '</div>',
|
2776 |
|
|
|
2777 |
|
|
);
|
2778 |
|
|
|
2779 |
|
|
$form['source'] = array(
|
2780 |
|
|
'#type' => 'select',
|
2781 |
|
|
'#title' => t('Source'),
|
2782 |
|
|
'#weight' => 2,
|
2783 |
|
|
'#parents' => array('block_settings', 'mapping_wrapper', 'mappings', $delta, 'source'),
|
2784 |
|
|
'#default_value' => $source,
|
2785 |
|
|
'#size' => 1,
|
2786 |
|
|
'#options' => $source_fields,
|
2787 |
|
|
'#prefix' => '<div class="ddblock-source">',
|
2788 |
|
|
'#suffix' => '</div>',
|
2789 |
|
|
);
|
2790 |
|
|
|
2791 |
|
|
return $form;
|
2792 |
|
|
}
|
2793 |
|
|
|
2794 |
|
|
/**
|
2795 |
|
|
* This submit handler is hooked to the hidden submit button and is executed on the AHAH call
|
2796 |
|
|
*/
|
2797 |
|
|
function ddblock_options_form_submit($form, &$form_state) {
|
2798 |
|
|
unset($form_state['submit_handlers']);
|
2799 |
|
|
form_execute_handlers('submit', $form, $form_state);
|
2800 |
|
|
$form_state_values = $form_state['values'];
|
2801 |
|
|
$form_state['form_state_values'] = $form_state_values;
|
2802 |
|
|
$form_state['rebuild'] = TRUE;
|
2803 |
|
|
return $form_state_values;
|
2804 |
|
|
}
|
2805 |
|
|
|
2806 |
|
|
/**
|
2807 |
|
|
* Form validation
|
2808 |
|
|
*/
|
2809 |
|
|
function ddblock_options_form_validate($form, &$form_state) {
|
2810 |
|
|
if (!is_numeric($form_state['values']['block_settings']['settings']['pager_settings']['nr_of_pager_items'])) {
|
2811 |
|
|
form_error($form['block_settings']['settings']['pager_settings']['nr_of_pager_items'], t('!setting must be numeric!', array('!setting' => 'nr_of_pager_items')));
|
2812 |
|
|
}
|
2813 |
|
|
}
|
2814 |
|
|
|
2815 |
|
|
/**
|
2816 |
|
|
* Get theme sizes of a theme.
|
2817 |
|
|
*
|
2818 |
|
|
* @param $theme
|
2819 |
|
|
* Slidehsow theme.
|
2820 |
|
|
* @return
|
2821 |
|
|
* An array containing the theme sizes.
|
2822 |
|
|
*/
|
2823 |
|
|
function _ddblock_get_template_size($theme) {
|
2824 |
|
|
|
2825 |
|
|
$path_to_themes = _ddblock_get_theme_path() . '/custom/modules/ddblock/' . $theme;
|
2826 |
|
|
|
2827 |
|
|
$dirs = _ddblock_dir_scan_directory($path_to_themes, 'siz');
|
2828 |
|
|
|
2829 |
|
|
if (!empty($dirs)) {
|
2830 |
|
|
asort($dirs);
|
2831 |
|
|
foreach ($dirs as $dir) {
|
2832 |
|
|
$options[$dir] = $dir;
|
2833 |
|
|
}
|
2834 |
|
|
}
|
2835 |
|
|
else {
|
2836 |
|
|
$options['default'] = 'Default';
|
2837 |
|
|
}
|
2838 |
|
|
|
2839 |
|
|
return $options;
|
2840 |
|
|
}
|
2841 |
|
|
|
2842 |
|
|
/**
|
2843 |
|
|
* Get the sub directories, starting with the mapping string, of a directory.
|
2844 |
|
|
*
|
2845 |
|
|
* @param $dir
|
2846 |
|
|
* directory.
|
2847 |
|
|
* @param $mapping
|
2848 |
|
|
* the start characters of the directory
|
2849 |
|
|
* @return
|
2850 |
|
|
* An array of directories.
|
2851 |
|
|
*/
|
2852 |
|
|
function _ddblock_dir_scan_directory($dir, $mapping = '') {
|
2853 |
|
|
$dirs = array();
|
2854 |
|
|
$mask = '/[^0-9A-Za-z\-]/';
|
2855 |
|
|
if (is_dir($dir) && $handle = opendir($dir)) {
|
2856 |
|
|
while ($file = readdir($handle)) {
|
2857 |
|
|
// no current and previous directory
|
2858 |
|
|
if ($file[0] != '.') {
|
2859 |
|
|
if (is_dir("$dir/$file")) {
|
2860 |
|
|
//only alphanumeric dirs
|
2861 |
|
|
if (!preg_match($mask, $file)) {
|
2862 |
|
|
if (!empty($mapping)) {
|
2863 |
|
|
if (substr($file, 0, 3) == $mapping) {
|
2864 |
|
|
// add dir.
|
2865 |
|
|
$dirs[] = $file;
|
2866 |
|
|
}
|
2867 |
|
|
}
|
2868 |
|
|
else {
|
2869 |
|
|
// add dir.
|
2870 |
|
|
$dirs[] = $file;
|
2871 |
|
|
}
|
2872 |
|
|
}
|
2873 |
|
|
}
|
2874 |
|
|
}
|
2875 |
|
|
}
|
2876 |
|
|
closedir($handle);
|
2877 |
|
|
}
|
2878 |
|
|
|
2879 |
|
|
return $dirs;
|
2880 |
|
|
}
|