This repository was archived by the owner on Jul 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjqueryui.php
More file actions
230 lines (207 loc) · 7.08 KB
/
Copy pathjqueryui.php
File metadata and controls
230 lines (207 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* A Zenphoto plugin for jQuery UI
* Experimental plugin
*
* The plugin does two things:
* - Load jQuery on the front end. This does not load the Zenphoto core 1.9.x one but its own newer 1.10.x version.
* - Provides content macros to insert an accordion or tabs within the normal description or content fields
* (experimental, conflicts with TinyMCE)
*
* @author Malte Müller (acrylian) <info@maltem.de>
* @copyright 2014 Malte Müller
* @license GPL v3 or later
* @package plugins
* @subpackage misc
*/
$plugin_is_filter = 9|THEME_PLUGIN|ADMIN_PLUGIN;
$plugin_description = gettext('A plugin to either load jQuery UI and also enable macros for accordion and tabs.');
$plugin_author = 'Malte Müller (acrylian)';
$plugin_version = '1.0.0';
$option_interface = 'jqueryui';
global $_zp_gallery, $_zp_gallery_page;
if (getOption('jqueryui_'.$_zp_gallery->getCurrentTheme().'_'.stripSuffix($_zp_gallery_page))) {
zp_register_filter('theme_head','jqueryui::jqueryuiJS');
}
zp_register_filter('content_macro','jqueryui::macros');
class jqueryui {
/**
* class instantiation function
*/
function __construct() {
setOptionDefault('jqueryui_theme', 'ui-lightness');
}
function getOptionsSupported() {
$themes = $this->getUIThemes();
/*
The option definitions are stored in a multidimensional array. There are several predefine option types.
Options types are the same for plugins and themes.
*/
$options = array(
gettext('jQuery UI theme') => array('key' => 'jqueryui_theme', 'type' => OPTION_TYPE_SELECTOR,
'selections' => $themes,
'desc' => gettext("Select the theme to use. Place custom skin within the root plugins folder. See plugin documentation for more info."))
);
foreach (getThemeFiles(array('404.php','themeoptions.php','theme_description.php')) as $theme=>$scripts) {
$list = array();
foreach ($scripts as $script) {
$list[$script] = 'jqueryui_'.$theme.'_'.stripSuffix($script);
}
$opts[$theme] = array('key' => 'jqueryui_'.$theme.'_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
'checkboxes' => $list,
'desc' => gettext('The scripts for which jQuery UI should be loaded.')
);
}
$options = array_merge($options, $opts);
return $options;
}
/**
* Gets the skin names and css files
*
*/
function getUIThemes() {
$all_skins = array();
$default_skins_dir = SERVERPATH.'/'.USER_PLUGIN_FOLDER.'/jqueryui/themes';
$user_skins_dir = SERVERPATH.'/'.USER_PLUGIN_FOLDER.'/jqueryui/themes';
$filestoignore = array( '.', '..','.DS_Store','Thumbs.db','.htaccess','.svn');
$skins = array_diff(scandir($default_skins_dir),array_merge($filestoignore));
$default_skins = $this->getUIThemeCSS($skins,$default_skins_dir);
$skins2 = @array_diff(scandir($user_skins_dir),array_merge($filestoignore));
if(is_array($skins2)) {
$user_skins = $this->getUIThemeCSS($skins2,$user_skins_dir);
//echo "<pre>";print_r($user_skins);echo "</pre>";
$default_skins = array_merge($default_skins,$user_skins);
}
return $default_skins;
}
/**
* Gets the css files for a skin. Helper function for getUIThemes().
*
*/
function getUIThemeCSS($skins,$dir) {
$skin_css = array();
foreach($skins as $skin) {
$css = safe_glob($dir.'/'.$skin.'/jquery-ui.min.css');
if($css) {
$skin_css = array_merge($skin_css,array($skin => $css[0])); // a skin should only have one css file so we just use the first found
}
}
return $skin_css;
}
/**
* Adds the jQuery calls to the theme head via filter
*/
static function jqueryuiJS() {
$skin = getOption('jqueryui_theme');
if(file_exists($skin)) {
$skin = str_replace(SERVERPATH,WEBPATH,$skin); //replace SERVERPATH as that does not work as a CSS link
} else {
$skin = WEBPATH.'/'.USER_PLUGIN_FOLDER.'/jqueryui/themes/ui-lightness/jquery-ui.min.css';
}
?>
<script type="text/javascript" src="<?php echo FULLWEBPATH.'/'.USER_PLUGIN_FOLDER; ?>/jqueryui/jquery-ui.min.js"></script>
<link href="<?php echo $skin; ?>" rel="stylesheet" type="text/css" />
<script>
$(function() {
$(".ui-accordion").accordion();
$(".ui-tabs").tabs();
});
</script>
<?php
}
static function macros($macros) {
/* accordion macros */
$macros['UIACC'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'<div class="ui-accordion" style="display: block">',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening div element for a jQuery UI accordion wrapper. Pass a class name as %1 or just empty.')
);
$macros['UIACC_END'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'</div>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the closing div element for a jQuery UI accordion wrapper.')
);
$macros['UIACC_HL'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'<h3>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening h3 element for a jQuery UI accordion element header.')
);
$macros['UIACC_HL_END'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'</h3>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the closing h3 element for a jQuery UI accordion element header.')
);
$macros['UIACC_EL'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'<div>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening div element for a jQuery UI accordion element content.')
);
$macros['UIACC_EL_END'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'</div>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening div element for a jQuery UI accordion element content.')
);
/* tabs macros */
$macros['UITABS'] = array(
'class'=>'function',
'params'=> array('string','array'),
'value'=>'jqueryui::getUITabsStart',
'owner'=>'jqueryui',
'desc'=>gettext('Something')
);
$macros['UITAB'] = array(
'class'=>'function',
'params'=> array('string'),
'value'=>'jqueryui::getUITabStart',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening wrapper for the tab content. Pass the tab number as %1')
);
$macros['UITAB_END'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'</div>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening wrapper for the tab content. The number of these must match those set with the main wrapper.')
);
$macros['UITABS_END'] = array(
'class'=>'constant',
'params'=> array(),
'value'=>'</div>',
'owner'=>'jqueryui',
'desc'=>gettext('Provides the opening div element for a jQuery UI accordion element content.')
);
return $macros;
}
static function getUITabsStart($id,$tabs) {
global $tabid;
$tabid = $id;
//print_r($tabs);
$content = '<div style="display:block" id="'.$id.'" class="ui-tabs">';
$count = '';
$content .= '<ul>';
foreach($tabs as $key=>$tab) {
$count++;
$content .= '<li><a href="#'.$id.'-'.$count.'">tab</a></li>';
}
$content .= '</ul>';
return $content;
}
static function getUITabStart($number) {
global $tabid;
$content = '<div id="'.$tabid.'-'.$number.'">';
return $content;
}
} // class end
?>