1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Abstract Base class for a sweaver plugin.
|
6
|
*
|
7
|
* Public methods:
|
8
|
*
|
9
|
* - sweaver_init().
|
10
|
* Add initial logic, can be various tasks or preparation of data.
|
11
|
* - sweaver_menu().
|
12
|
* Add menu items.
|
13
|
* - sweaver_menu_callback().
|
14
|
* Menu callback.
|
15
|
* - sweaver_menu_callback_validate().
|
16
|
* Validator for the menu callback.
|
17
|
* - sweaver_menu_callback_submit().
|
18
|
* Menu callback submit.
|
19
|
* - sweaver_theme().
|
20
|
* Add theme registry items.
|
21
|
* - sweaver_dependencies().
|
22
|
* Define dependencies.
|
23
|
* - sweaver_objects_alter().
|
24
|
* Alter the sweaver object.
|
25
|
* - sweaver_form_css_js().
|
26
|
* Loads and includes extra javascript and css files.
|
27
|
* - sweaver_form_render().
|
28
|
* Renders the frontend manipulation form.
|
29
|
* - sweaver_form().
|
30
|
* Loads the frontend manipulation form for the plugin.
|
31
|
* - sweaver_form_submit().
|
32
|
* Submit handler that can perform extra save actions if needed.
|
33
|
* - [callback_method]
|
34
|
* Swappable method that can be implemented and invoked.
|
35
|
*/
|
36
|
abstract class sweaver_plugin {
|
37
|
|
38
|
/**
|
39
|
* Helper function render the popups.
|
40
|
*/
|
41
|
protected function sweaver_popups_render(&$vars, &$form, $name) {
|
42
|
foreach ($form[$name]['form']['#popups'] as $key => $form_key) {
|
43
|
$vars['sweaver_popup'] .= drupal_render($form[$name]['form'][$form_key]);
|
44
|
}
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* Init function.
|
49
|
*/
|
50
|
public function sweaver_init() {
|
51
|
// Initial things to do.
|
52
|
}
|
53
|
|
54
|
/**
|
55
|
* Preprocess page function.
|
56
|
*/
|
57
|
public function sweaver_preprocess_page(&$vars) {
|
58
|
// Initial things to do.
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* Sweaver dependencies.
|
63
|
*/
|
64
|
public function sweaver_dependencies() {
|
65
|
return array();
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* Sweaver objects alter.
|
70
|
*/
|
71
|
public function sweaver_objects_alter(&$objects) {
|
72
|
// Alter the objects if you want to.
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* Images handler.
|
77
|
*/
|
78
|
public function sweaver_images_handler(&$images) {
|
79
|
// Handles image. Is this neccessary here?
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* Menu registry.
|
84
|
*/
|
85
|
public function sweaver_menu(&$weight, $page_arguments, $base) {
|
86
|
// Hook method to add sweaver menu items.
|
87
|
return array();
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* Menu callback.
|
92
|
*/
|
93
|
public function sweaver_menu_callback() {
|
94
|
// Add in some menu links or tabs.
|
95
|
}
|
96
|
|
97
|
/**
|
98
|
* Menu callback validate.
|
99
|
*/
|
100
|
public function sweaver_menu_callback_validate($form, &$form_state) {
|
101
|
// Handles image. Is this neccessary here?
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* Menu callback submit.
|
106
|
*/
|
107
|
public function sweaver_menu_callback_submit($form, &$form_state) {
|
108
|
// Handles image. Is this neccessary here?
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* Theme registry.
|
113
|
*/
|
114
|
public function sweaver_theme() {
|
115
|
// Adds to the theme registry.
|
116
|
return array();
|
117
|
}
|
118
|
|
119
|
/**
|
120
|
* Sweaver css and js.
|
121
|
*/
|
122
|
public function sweaver_form_css_js(&$inline_settings) {
|
123
|
// Load some extra javascript and/or css files.
|
124
|
}
|
125
|
|
126
|
/**
|
127
|
* Sweaver form.
|
128
|
*/
|
129
|
public function sweaver_form() {
|
130
|
// create a managing form.
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* Sweaver submit handler.
|
135
|
*/
|
136
|
public function sweaver_form_submit($form, &$form_state) {
|
137
|
// Submit handler for the managing form.
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* Return false to not show editor.
|
142
|
*/
|
143
|
public function show_editor() {
|
144
|
}
|
145
|
|
146
|
/**
|
147
|
* Return true to allow access and false to deny.
|
148
|
*/
|
149
|
public function sweaver_menu_access_callback($args) {
|
150
|
}
|
151
|
|
152
|
/**
|
153
|
* Sweaver form render.
|
154
|
*/
|
155
|
public function sweaver_form_render(&$vars, &$form, $plugin) {
|
156
|
$name = $plugin['name'];
|
157
|
if (isset($form[$name])) {
|
158
|
|
159
|
if (isset($form[$name]['form']['#popups'])) {
|
160
|
$this->sweaver_popups_render($vars, $form, $name);
|
161
|
}
|
162
|
|
163
|
if (isset($form[$name]['#tab_name'])) {
|
164
|
$vars['tabs'][$name]['#tab_name'] = $form[$name]['#tab_name'];
|
165
|
}
|
166
|
$vars['tabs_data'][$name]['#tab_description'] = $form[$name]['#tab_description'];
|
167
|
$vars['tabs_data'][$name]['content'] = drupal_render($form[$name]['form']);
|
168
|
}
|
169
|
}
|
170
|
|
171
|
}
|
172
|
|