1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Export interface plugin
|
6 |
|
|
*
|
7 |
|
|
* @author Mathew Winstone <mwinstone@coldfrontlabs.ca>
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
/**
|
12 |
|
|
* Define this Export UI plugin.
|
13 |
|
|
*/
|
14 |
|
|
$plugin = array(
|
15 |
|
|
'schema' => 'flexslider_optionset', // As defined in hook_schema().
|
16 |
|
|
'access' => 'administer flexslider', // Define a permission users must have to access these pages.
|
17 |
|
|
|
18 |
|
|
// Define the menu item.
|
19 |
|
|
'menu' => array(
|
20 |
|
|
'menu prefix' => 'admin/config/media',
|
21 |
|
|
'menu item' => 'flexslider',
|
22 |
|
|
'menu title' => 'FlexSlider',
|
23 |
|
|
'menu description' => 'Administer FlexSlider presets.',
|
24 |
|
|
),
|
25 |
|
|
|
26 |
|
|
// Define user interface texts.
|
27 |
|
|
'title singular' => t('optionset'),
|
28 |
|
|
'title plural' => t('optionsets'),
|
29 |
|
|
'title singular proper' => t('FlexSlider optionset'),
|
30 |
|
|
'title plural proper' => t('FlexSlider optionsets'),
|
31 |
|
|
|
32 |
|
|
// Define the names of the functions that provide the add/edit forms.
|
33 |
|
|
'form' => array(
|
34 |
|
|
'settings' => 'flexslider_ctools_export_ui_form',
|
35 |
|
|
'validate' => 'flexslider_ctools_export_ui_form_validate',
|
36 |
|
|
'submit' => 'flexslider_ctools_export_ui_form_submit',
|
37 |
|
|
),
|
38 |
|
|
);
|
39 |
|
|
|
40 |
|
|
/**
|
41 |
|
|
* Export UI form
|
42 |
|
|
*/
|
43 |
|
|
function flexslider_ctools_export_ui_form(&$form, &$form_state) {
|
44 |
|
|
// Load the admin form include
|
45 |
|
|
module_load_include('inc', 'flexslider', 'flexslider.admin');
|
46 |
|
|
|
47 |
|
|
// Make optionset reference in form_state
|
48 |
|
|
$form_state['optionset'] = &$form_state['item'];
|
49 |
|
|
|
50 |
|
|
// Load the configuration form
|
51 |
|
|
$form = drupal_retrieve_form('flexslider_form_optionset_edit', $form_state);
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
|
|
* Validation handler
|
56 |
|
|
*/
|
57 |
|
|
function flexslider_ctools_export_ui_form_validate(&$form, &$form_state) {
|
58 |
|
|
// @todo
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
/**
|
62 |
|
|
* Submit handler
|
63 |
|
|
*/
|
64 |
|
|
function flexslider_ctools_export_ui_form_submit(&$form, &$form_state) {
|
65 |
|
|
// Edit the reference to $form_state['optionset'] which will in turn
|
66 |
|
|
// reference $form_state['item'] which is what CTools is looking for.
|
67 |
|
|
$optionset = &$form_state['optionset'];
|
68 |
|
|
$optionset->title = $form_state['values']['title'];
|
69 |
|
|
|
70 |
|
|
// Assign the values to the option set
|
71 |
|
|
$optionset->options = _flexslider_optionset_defaults();
|
72 |
|
|
|
73 |
|
|
// Save all the values for the optionset
|
74 |
|
|
foreach ($optionset->options as $key => $value) {
|
75 |
|
|
if (array_key_exists($key, $form_state['values'])) {
|
76 |
|
|
$optionset->options[$key] = $form_state['values'][$key];
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
} |