1 | <?php
|
---|
2 |
|
---|
3 | load_plugin_textdomain('xpressme', 'wp-content/plugins/xpressme/language');
|
---|
4 |
|
---|
5 | class XPressME_Class{
|
---|
6 | var $pluginName = 'xpressme';
|
---|
7 | var $is_use_xoops_upload_path;
|
---|
8 | var $is_theme_sidebar_disp;
|
---|
9 | var $is_save_post_revision;
|
---|
10 | var $is_postnavi_title_disp;
|
---|
11 | var $is_left_postnavi_old;
|
---|
12 | var $old_post_link_text;
|
---|
13 | var $newer_post_link_text;
|
---|
14 | var $is_left_page_navi_old;
|
---|
15 | var $old_page_link_text;
|
---|
16 | var $newer_page_link_text;
|
---|
17 | var $is_author_view_count;
|
---|
18 | var $is_sql_debug;
|
---|
19 | var $groupe_role;
|
---|
20 | var $is_use_d3forum;
|
---|
21 | var $d3forum_module_dir;
|
---|
22 | var $d3forum_forum_id;
|
---|
23 | var $d3forum_external_link_format;
|
---|
24 | //constructor
|
---|
25 | function XPressME_Class()
|
---|
26 | {
|
---|
27 | global $xoops_db;
|
---|
28 |
|
---|
29 | $this->setdefault(); //not setting propaty load
|
---|
30 | $this->SettingValueRead();
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | function add_option_page()
|
---|
35 | {
|
---|
36 | add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
|
---|
37 | }
|
---|
38 |
|
---|
39 | function add_admin_head()
|
---|
40 | {
|
---|
41 | // add header text
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | //Set Default Value
|
---|
46 | function setDefault()
|
---|
47 | {
|
---|
48 | $this->is_use_xoops_upload_path = true;
|
---|
49 | $this->is_theme_sidebar_disp = true;
|
---|
50 | $this->is_save_post_revision = true;
|
---|
51 | $this->is_postnavi_title_disp = true;
|
---|
52 | $this->is_left_postnavi_old = true;
|
---|
53 | $this->old_post_link_text = __('Older Post', 'xpressme');
|
---|
54 | $this->newer_post_link_text = __('Newer Post', 'xpressme');
|
---|
55 | $this->is_left_page_navi_old = true;
|
---|
56 | $this->old_page_link_text = __('Older Entries', 'xpressme');
|
---|
57 | $this->newer_page_link_text = __('Newer Entries', 'xpressme');
|
---|
58 | $this->is_author_view_count = false;
|
---|
59 | $this->is_sql_debug = false;
|
---|
60 | $this->is_use_d3forum = false;
|
---|
61 | $this->d3forum_module_dir = '';
|
---|
62 | $this->d3forum_forum_id = '';
|
---|
63 | $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
|
---|
64 | $this->is_d3forum_flat = true;
|
---|
65 | $this->is_d3forum_desc = true;
|
---|
66 | $this->d3forum_views_num = 10;
|
---|
67 | }
|
---|
68 |
|
---|
69 | function SettingValueRead()
|
---|
70 | {
|
---|
71 | global $xoops_db;
|
---|
72 | $options = get_option('xpressme_option');
|
---|
73 | if (!$options) {
|
---|
74 | $this->setDefault();
|
---|
75 | $this->SettingValueWrite('add_new');
|
---|
76 | } else {
|
---|
77 | foreach ($options as $option_name => $option_value){
|
---|
78 | $this-> {$option_name} = $option_value;
|
---|
79 | }
|
---|
80 | }
|
---|
81 | if (!empty($xoops_db)) // at install trap
|
---|
82 | $this->GroupeRoleRead();
|
---|
83 | }
|
---|
84 |
|
---|
85 | // mode 0:add 1:update
|
---|
86 | function SettingValueWrite($mode)
|
---|
87 | {
|
---|
88 | $write_options = array (
|
---|
89 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
90 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ,
|
---|
91 | 'is_save_post_revision' => $this->is_save_post_revision ,
|
---|
92 | 'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
|
---|
93 | 'is_left_postnavi_old' => $this->is_left_postnavi_old ,
|
---|
94 | 'old_post_link_text' => $this->old_post_link_text ,
|
---|
95 | 'newer_post_link_text' => $this->newer_post_link_text,
|
---|
96 | 'is_left_page_navi_old' => $this->is_left_page_navi_old ,
|
---|
97 | 'old_page_link_text' => $this->old_page_link_text ,
|
---|
98 | 'newer_page_link_text' => $this->newer_page_link_text,
|
---|
99 | 'is_author_view_count' => $this->is_author_view_count,
|
---|
100 | 'is_sql_debug' => $this->is_sql_debug,
|
---|
101 | 'is_use_d3forum' => $this->is_use_d3forum,
|
---|
102 | 'd3forum_module_dir' => $this->d3forum_module_dir,
|
---|
103 | 'd3forum_forum_id' => $this->d3forum_forum_id,
|
---|
104 | 'd3forum_external_link_format' => $this->d3forum_external_link_format,
|
---|
105 | 'is_d3forum_flat' => $this->is_d3forum_flat,
|
---|
106 | 'is_d3forum_desc' => $this->is_d3forum_desc,
|
---|
107 | 'd3forum_views_num' =>$this->d3forum_views_num
|
---|
108 | );
|
---|
109 | if ($mode == 'add_new') {
|
---|
110 | add_option('xpressme_option', $write_options);
|
---|
111 | } else {
|
---|
112 | update_option("xpressme_option", $write_options);
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | function GroupeRoleRead() {
|
---|
117 | global $xoops_db;
|
---|
118 |
|
---|
119 | // table sync
|
---|
120 | $table = get_wp_prefix() . 'group_role';
|
---|
121 | $xoops_group = get_xoops_prefix() . 'groups';
|
---|
122 | $sql= "SELECT * FROM $table";
|
---|
123 | $before_groupes = $xoops_db->get_results($sql);
|
---|
124 |
|
---|
125 | $sql = "DELETE FROM $table";
|
---|
126 | $xoops_db->query($sql);
|
---|
127 |
|
---|
128 |
|
---|
129 | $sql= "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";
|
---|
130 | $groupes = $xoops_db->get_results($sql);
|
---|
131 | $insert_sql = '';
|
---|
132 | foreach ($groupes as $groupe) {
|
---|
133 | $role = '';
|
---|
134 | foreach ($before_groupes as $before_groupe) {
|
---|
135 | if ($groupe->groupid == $before_groupe->groupid) {
|
---|
136 | $role = $before_groupe->role;
|
---|
137 | $login_all = $before_groupe->login_all;
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | $insert_sql = "INSERT INTO $table ";
|
---|
142 | $insert_sql .= "(groupid , name , description , group_type , role , login_all) ";
|
---|
143 | $insert_sql .= "VALUES (";
|
---|
144 | $insert_sql .= $groupe->groupid . ', ';
|
---|
145 | $insert_sql .= "'" . $groupe->name . "' , ";
|
---|
146 | $insert_sql .= "'" . $groupe->description . "' , ";
|
---|
147 | $insert_sql .= "'" . $groupe->group_type . "' , ";
|
---|
148 | $insert_sql .= "'" . $role . "' , '";
|
---|
149 | $insert_sql .= $login_all . "')";
|
---|
150 | $xoops_db->query($insert_sql);
|
---|
151 | }
|
---|
152 |
|
---|
153 | $sql= "SELECT * FROM $table";
|
---|
154 |
|
---|
155 | $this->groupe_role = $xoops_db->get_results($sql);
|
---|
156 | $sql= "SELECT * FROM $table";
|
---|
157 | }
|
---|
158 |
|
---|
159 | function ReadPostData()
|
---|
160 | {
|
---|
161 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
162 | $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
|
---|
163 | $this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
|
---|
164 | $this->is_postnavi_title_disp = stripslashes(trim($_POST['ch_is_postnavi_title_disp']));
|
---|
165 | $this->is_left_postnavi_old = stripslashes(trim($_POST['ch_is_left_postnavi_old']));
|
---|
166 | $this->old_post_link_text = stripslashes($_POST['ch_old_post_link_text']);
|
---|
167 | if(empty($this->old_post_link_text)) $this->old_post_link_text = __('Older Post', 'xpressme');
|
---|
168 | $this->newer_post_link_text = stripslashes($_POST['ch_newer_post_link_text']);
|
---|
169 | if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('Newer Post', 'xpressme');
|
---|
170 | $this->is_left_page_navi_old = stripslashes(trim($_POST['ch_is_left_page_navi_old']));
|
---|
171 | $this->old_page_link_text = stripslashes($_POST['ch_old_page_link_text']);
|
---|
172 | if(empty($this->old_page_link_text)) $this->old_page_link_text = __('Older Entries', 'xpressme');
|
---|
173 | $this->newer_page_link_text = stripslashes($_POST['ch_newer_page_link_text']);
|
---|
174 | if(empty($this->newer_page_link_text)) $this->newer_page_link_text = __('Newer Entries', 'xpressme');
|
---|
175 | $this->is_author_view_count = stripslashes(trim($_POST['ch_is_author_view_count']));
|
---|
176 | $this->is_sql_debug = stripslashes(trim($_POST['ch_is_sql_debug']));
|
---|
177 | //d3forum
|
---|
178 | $d3forum_select = stripslashes(trim($_POST['ch_d3forum']));
|
---|
179 | if ($d3forum_select == 'none') {
|
---|
180 | $this->is_use_d3forum = false;
|
---|
181 | $this->d3forum_module_dir = '';
|
---|
182 | $this->d3forum_forum_id = '';
|
---|
183 | $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
|
---|
184 | } else {
|
---|
185 | $d3f_set = explode('|', $d3forum_select);
|
---|
186 | $this->is_use_d3forum = true;
|
---|
187 | $this->d3forum_module_dir = $d3f_set[1];
|
---|
188 | $this->d3forum_forum_id = $d3f_set[2];
|
---|
189 | $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
|
---|
190 | }
|
---|
191 | $this->is_d3forum_flat = stripslashes(trim($_POST['ch_d3forum_type']));
|
---|
192 | $this->is_d3forum_desc = stripslashes(trim($_POST['ch_d3forum_order']));
|
---|
193 | $this->d3forum_views_num = stripslashes(trim($_POST['ch_d3forum_view_num']));
|
---|
194 |
|
---|
195 | global $xoops_db;
|
---|
196 | $table = get_wp_prefix() . 'group_role';
|
---|
197 | // $sql= "SELECT * FROM $table";
|
---|
198 | // $this->groupe_role = $xoops_db->get_results($sql); // before Read
|
---|
199 |
|
---|
200 | foreach ($this->groupe_role as $groupe) {
|
---|
201 | $post_name = 'role_gid_' . $groupe->groupid;
|
---|
202 | $role = stripslashes(trim($_POST[$post_name]));
|
---|
203 | $post_name = 'login_all_gid_' . $groupe->groupid;
|
---|
204 | $login_all = stripslashes(trim($_POST[$post_name]));
|
---|
205 | if (empty($login_all)) $login_all = '0';
|
---|
206 | $groupe->role = $role;
|
---|
207 | $groupe->login_all = $login_all;
|
---|
208 | $update_sql = "UPDATE $table ";
|
---|
209 | $update_sql .= 'SET ';
|
---|
210 | $update_sql .= "role = '$role' , ";
|
---|
211 | $update_sql .= "login_all = $login_all ";
|
---|
212 | $update_sql .= "WHERE (groupid = '$groupe->groupid' )";
|
---|
213 | $xoops_db->query($update_sql);
|
---|
214 | }
|
---|
215 | }
|
---|
216 |
|
---|
217 | function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
|
---|
218 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
219 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
220 | $value = $this->{$option_name};
|
---|
221 | $ans_name = 'ch_' . $option_name;
|
---|
222 |
|
---|
223 | $form = "<tr>\n";
|
---|
224 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
225 | $form .= "<td>\n";
|
---|
226 | $form .= $this->yes_no_radio_option_sub($option_name,$yes,$no);
|
---|
227 | $form .= "</td>\n";
|
---|
228 | $form .= "</tr><tr>\n";
|
---|
229 |
|
---|
230 | return $form;
|
---|
231 |
|
---|
232 | }
|
---|
233 | function yes_no_radio_option_sub($option_name,$yes = '',$no= ''){
|
---|
234 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
235 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
236 | $value = $this->{$option_name};
|
---|
237 | $ans_name = 'ch_' . $option_name;
|
---|
238 |
|
---|
239 | if ($value){
|
---|
240 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
|
---|
241 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
|
---|
242 | }else{
|
---|
243 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
|
---|
244 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
|
---|
245 | }
|
---|
246 | return $form;
|
---|
247 | }
|
---|
248 |
|
---|
249 |
|
---|
250 | function text_option($option_name,$option_desc){
|
---|
251 | $value = $this->{$option_name};
|
---|
252 | $ans_name = 'ch_' . $option_name;
|
---|
253 |
|
---|
254 | $form = "<tr>\n";
|
---|
255 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
256 | $form .= "<td>\n";
|
---|
257 | $form .= $this->text_option_sub($option_name);
|
---|
258 | $form .= "</td>\n";
|
---|
259 | $form .= "</tr><tr>\n";
|
---|
260 |
|
---|
261 | return $form;
|
---|
262 |
|
---|
263 | }
|
---|
264 |
|
---|
265 | function text_option_sub($option_name){
|
---|
266 | $value = $this->{$option_name};
|
---|
267 | $ans_name = 'ch_' . $option_name;
|
---|
268 |
|
---|
269 | $form = '<label> <input name="'. $ans_name . '" type="text" size="25" maxlength="50" value="' . $value . '" /></label>'."\n";
|
---|
270 | return $form;
|
---|
271 |
|
---|
272 | }
|
---|
273 |
|
---|
274 |
|
---|
275 | function single_post_navi_option(){
|
---|
276 | $form = '';
|
---|
277 | $form .= '<tr><th><label for="single_page_navi">' .__('Single Post Navi Setting', 'xpressme') . '</label></th>';
|
---|
278 | $form .= "<td>\n";
|
---|
279 | $form .= "<table>\n";
|
---|
280 | $form .= "<tr>\n";
|
---|
281 |
|
---|
282 | $form .= "<td>" . __('Adjustment of Navi link display position','xpressme') . "</td>\n";
|
---|
283 | $form .= "<td>\n";
|
---|
284 | $form .= $this->yes_no_radio_option_sub('is_left_postnavi_old',
|
---|
285 | __("'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right",'xpressme'),
|
---|
286 | __("'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right",'xpressme')
|
---|
287 | );
|
---|
288 | $form .= "</td>\n";
|
---|
289 | $form .= "</tr>\n";
|
---|
290 |
|
---|
291 | $form .= "<tr>\n";
|
---|
292 | $form .= "<td>" . __('Select Display name of PostNavi Link','xpressme') . "</td>\n";
|
---|
293 | $form .= "<td>\n";
|
---|
294 | $form .= $this->yes_no_radio_option_sub('is_postnavi_title_disp',
|
---|
295 | __('Title of post','xpressme'),
|
---|
296 | __('Title of Navi','xpressme')
|
---|
297 | );
|
---|
298 | $form .= "</td>\n";
|
---|
299 | $form .= "</tr>\n";
|
---|
300 |
|
---|
301 | $form .= "<tr>\n";
|
---|
302 | $form .= "<td>" . __('Display Navi Title of Old Post Link','xpressme') . "</td>\n";
|
---|
303 | $form .= "<td>\n";
|
---|
304 | $form .= $this->text_option_sub('old_post_link_text');
|
---|
305 | $form .= "</td>\n";
|
---|
306 | $form .= "</tr>\n";
|
---|
307 |
|
---|
308 | $form .= "<tr>\n";
|
---|
309 | $form .= "<td>" . __('Display Navi Title of Newer Post Link','xpressme') . "</td>\n";
|
---|
310 | $form .= "<td>\n";
|
---|
311 | $form .= $this->text_option_sub('newer_post_link_text');
|
---|
312 | $form .= "</td>\n";
|
---|
313 | $form .= "</tr>\n";
|
---|
314 |
|
---|
315 | $form .= "</table></td></tr>\n";
|
---|
316 | return $form;
|
---|
317 |
|
---|
318 | }
|
---|
319 |
|
---|
320 | function posts_page_navi_option(){
|
---|
321 | $form = '';
|
---|
322 | $form .= '<tr><th><label for="posts_page_navi">' .__('Posts List Page Navi Setting', 'xpressme') . '</label></th>';
|
---|
323 | $form .= "<td>\n";
|
---|
324 | $form .= "<table>\n";
|
---|
325 | $form .= "<tr>\n";
|
---|
326 |
|
---|
327 | $form .= "<td>" . __('Adjustment of Navi link display position','xpressme') . "</td>\n";
|
---|
328 | $form .= "<td>\n";
|
---|
329 | $form .= $this->yes_no_radio_option_sub('is_left_page_navi_old',
|
---|
330 | __("'Old Page Link' is displayed in the left, and 'Newer Page Link' is displayed in the right",'xpressme'),
|
---|
331 | __("'Newer Page Link' is displayed in the left, and 'Old Page Link' is displayed in the right",'xpressme')
|
---|
332 | );
|
---|
333 | $form .= "</td>\n";
|
---|
334 | $form .= "</tr>\n";
|
---|
335 |
|
---|
336 | $form .= "<tr>\n";
|
---|
337 | $form .= "<td>" . __('Display Navi Title of Old Page Link','xpressme') . "</td>\n";
|
---|
338 | $form .= "<td>\n";
|
---|
339 | $form .= $this->text_option_sub('old_page_link_text');
|
---|
340 | $form .= "</td>\n";
|
---|
341 | $form .= "</tr>\n";
|
---|
342 |
|
---|
343 | $form .= "<tr>\n";
|
---|
344 | $form .= "<td>" . __('Display Navi Title of Newer Page Link','xpressme') . "</td>\n";
|
---|
345 | $form .= "<td>\n";
|
---|
346 | $form .= $this->text_option_sub('newer_page_link_text');
|
---|
347 | $form .= "</td>\n";
|
---|
348 | $form .= "</tr>\n";
|
---|
349 |
|
---|
350 | $form .= "</table></td></tr>\n";
|
---|
351 | return $form;
|
---|
352 |
|
---|
353 | }
|
---|
354 |
|
---|
355 | function groupe_role_option(){
|
---|
356 | global $wp_roles , $xoops_db;
|
---|
357 |
|
---|
358 | $form = '';
|
---|
359 | $form .= '<tr><th><label for="role">' .__('Role Setting at Login', 'xpressme') . '</label></th>';
|
---|
360 | $form .= '<td>';
|
---|
361 | $form .= "<table>\n";
|
---|
362 | $form .= '<tr><td>' . __('XOOPS Groupe', 'xpressme') . '</td><td>' . __('WordPress Role', 'xpressme') . '</td><td>' . __('Role is set at each login', 'xpressme') . "</td></tr>\n";
|
---|
363 | foreach ($this->groupe_role as $groupe) {
|
---|
364 | $form .= "<tr>";
|
---|
365 | $form .= "<td> $groupe->name </td>";
|
---|
366 | $form .= "<td>\n" . '<select name="role_gid_'.$groupe->groupid . '" id="role_gid_' . $groupe->groupid . '">' . "\n";
|
---|
367 | $role_list = '';
|
---|
368 | $group_has_role = false;
|
---|
369 |
|
---|
370 | $select_value = $groupe->role;
|
---|
371 |
|
---|
372 |
|
---|
373 |
|
---|
374 | foreach($wp_roles->role_names as $role => $name) {
|
---|
375 | $name = translate_with_context($name);
|
---|
376 | if ( $role == $select_value) {
|
---|
377 | $selected = ' selected="selected"';
|
---|
378 | $group_has_role = true;
|
---|
379 | } else {
|
---|
380 | $selected = '';
|
---|
381 | }
|
---|
382 | if ($groupe->group_type != 'Admin' || !empty($selected)) {
|
---|
383 | $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>\n";
|
---|
384 | }
|
---|
385 | }
|
---|
386 | if ($groupe->group_type != 'Admin') {
|
---|
387 | if ( $group_has_role ) {
|
---|
388 | $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
389 | $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
390 | } else {
|
---|
391 | if ($select_value == 'default'){
|
---|
392 | $role_list .= '<option value="default" selected="selected">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
393 | $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
394 | } else {
|
---|
395 | $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
396 | $role_list .= '<option value="" selected="selected">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
397 | }
|
---|
398 | }
|
---|
399 | }
|
---|
400 | $form .= $role_list . "</select>\n</td>";
|
---|
401 | if ($groupe->login_all){
|
---|
402 | $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1" checked ></td>';
|
---|
403 | } else {
|
---|
404 | $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1"></td>';
|
---|
405 | }
|
---|
406 | $form .= "</tr>\n";
|
---|
407 | }
|
---|
408 | $form .= "</table></td></tr>\n";
|
---|
409 | return $form;
|
---|
410 |
|
---|
411 | }
|
---|
412 |
|
---|
413 | function d3forum_option($do_message = ''){
|
---|
414 | global $xoops_db;
|
---|
415 |
|
---|
416 | $d3frum_list = array();
|
---|
417 | $module_dir_path = get_xoops_root_path();
|
---|
418 |
|
---|
419 | $forum_list = '<select name="ch_d3forum">' . "\n";
|
---|
420 |
|
---|
421 | if ($this->is_use_d3forum != true)
|
---|
422 | $selected = ' selected="selected"';
|
---|
423 | else
|
---|
424 | $selected = '';
|
---|
425 | $forum_list .= '<option value="none"' . $selected . '>' . __('Do Not Comment Integration.', 'xpressme') . "</option>\n";
|
---|
426 |
|
---|
427 | // Form making for forum selection of D3forum
|
---|
428 | $modules_table = get_xoops_prefix() .'modules';
|
---|
429 | $sql = "SELECT mid,name,isactive,dirname FROM $modules_table WHERE isactive = 1";
|
---|
430 | $modules = $xoops_db->get_results($sql);
|
---|
431 | foreach ($modules as $module) {
|
---|
432 | $file_path = $module_dir_path . '/modules/' . $module->dirname . '/mytrustdirname.php';
|
---|
433 | if (! file_exists($file_path)) continue;
|
---|
434 | $array_files = file($file_path);
|
---|
435 | // It is checked whether there is character string "$mytrustdirname ='d3forum'"in the file.
|
---|
436 | foreach ($array_files as $aeey_file){
|
---|
437 | if( preg_match( "/\s*(mytrustdirname)\s*(=)\s*([\"'])(d3forum)([\"'])/", $aeey_file ) ) {
|
---|
438 | $forums_tb = get_xoops_prefix() . $module->dirname . '_forums';
|
---|
439 | $cat_tb = get_xoops_prefix() . $module->dirname . '_categories';
|
---|
440 | $sql= "SELECT * FROM $forums_tb LEFT JOIN $cat_tb ON $forums_tb.cat_id = $cat_tb.cat_id";
|
---|
441 | $forums = $xoops_db->get_results($sql);
|
---|
442 | foreach ($forums as $forum) {
|
---|
443 | if (($module->dirname == $this->d3forum_module_dir) && ($forum->forum_id == $this->d3forum_forum_id))
|
---|
444 | $selected = ' selected="selected"';
|
---|
445 | else
|
---|
446 | $selected = '';
|
---|
447 | $forum_div = 'forum|' . $module->dirname . '|' . $forum->forum_id;
|
---|
448 | $forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)";
|
---|
449 | $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
|
---|
450 | }
|
---|
451 | break;
|
---|
452 | }
|
---|
453 | }
|
---|
454 | $forum_list .= '<br>';
|
---|
455 | }
|
---|
456 | $forum_list .= '</select>' . "\n";
|
---|
457 |
|
---|
458 | $form = '<tr>' . "\n";
|
---|
459 | $form .= '<th><label for="d3forum">' .__('Comment integration with D3Forum', 'xpressme') . '</label></th>' . "\n";
|
---|
460 | $form .= "<td>\n";
|
---|
461 | $form .= __('Select the forum of D3Forum that does the comment integration from the following lists.', 'xpressme') ."<br />\n";
|
---|
462 | $form .= $forum_list."\n";
|
---|
463 | $form .= '<br /><br />';
|
---|
464 | if ($this->is_use_d3forum) $disible = ''; else $disible = 'disabled';
|
---|
465 | $form .= __('Select the Type of display of D3Forum comment.', 'xpressme') . " \n&emsp";
|
---|
466 | if ($this->is_d3forum_flat){
|
---|
467 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='1' checked='checked' />" . __('Flat','xpressme') ."</label>\n";
|
---|
468 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='0' />". __('Threaded','xpressme') . "</label>\n";
|
---|
469 | }else{
|
---|
470 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='1' />" . __('Flat','xpressme') . "</label>\n";
|
---|
471 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='0' checked='checked' />". __('Threaded','xpressme') ."</label>\n";
|
---|
472 | }
|
---|
473 | $form .= '<br />';
|
---|
474 | $form .= __('Select the order of display of D3Forum comment.', 'xpressme') . " \n&emsp";
|
---|
475 | if ($this->is_d3forum_desc){
|
---|
476 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='1' checked='checked' />" . __('DESC','xpressme') ."</label>\n";
|
---|
477 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='0' />". __('ASC','xpressme') . "</label>\n";
|
---|
478 | }else{
|
---|
479 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='1' />" . __('DESC','xpressme') . "</label>\n";
|
---|
480 | $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='0' checked='checked' />". __('ASC','xpressme') ."</label>\n";
|
---|
481 | }
|
---|
482 | $form .= '<br />';
|
---|
483 | $form .= __('Number of displays of D3Forum comments.', 'xpressme') ." \n";
|
---|
484 | $form .= '&emsp<label> <input name="ch_d3forum_view_num" type="text" size="3" maxlength="3" value="' . $this->d3forum_views_num . '" /></label>'."\n";
|
---|
485 |
|
---|
486 | $form .= '<div class="submit">'."\n";
|
---|
487 | $form .= __('The import and the export between Wordpress Comments and the D3Forum Posts can be done. ', 'xpressme') ."<br />\n";
|
---|
488 | $form .= '<input type="submit" value= "' . __('Export to D3Forum', 'xpressme') . '" name="export_d3f" ' . $disible . ' >' ."\n";
|
---|
489 | $form .= '<input type="submit" value= "' . __('Import from D3Forum', 'xpressme') . '" name="inport_d3f" ' . $disible . ' >' ."<br />\n";
|
---|
490 | $form .= '</div>'."\n";
|
---|
491 | if (!empty($do_message)){
|
---|
492 | $form .= '<div>' . $do_message . '</div>';
|
---|
493 | }
|
---|
494 | $form .= "</td>\n";
|
---|
495 | $form .= "</tr><tr>\n";
|
---|
496 | return $form;
|
---|
497 | }
|
---|
498 |
|
---|
499 | function option_page()
|
---|
500 | {
|
---|
501 | $do_message ='';
|
---|
502 | if (!empty($_POST['submit_update'])) {
|
---|
503 | $this->ReadPostData();
|
---|
504 | $this->SettingValueWrite('update');
|
---|
505 | } else if (isset($_POST['submit_reset'])) {
|
---|
506 | $this->fck_setDefault();
|
---|
507 | $this->SettingValueWrite('update');
|
---|
508 | } else if (isset($_POST['export_d3f'])) {
|
---|
509 | $do_message = 'export(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
|
---|
510 | $do_message .= wp_to_d3forum($this->d3forum_forum_id, $this->d3forum_module_dir);
|
---|
511 | $do_message .= '....END';
|
---|
512 | } else if (isset($_POST['inport_d3f'])) {
|
---|
513 | $do_message = 'Import(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
|
---|
514 | $do_message .= d3forum_to_wp($this->d3forum_forum_id, $this->d3forum_module_dir);
|
---|
515 | $do_message .= '....END';
|
---|
516 | }
|
---|
517 |
|
---|
518 | echo '<div class="wrap">'."\n";
|
---|
519 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
520 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
|
---|
521 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
522 | echo '<table class="form-table">'."\n";
|
---|
523 | echo $this->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
524 | __('Media Upload Base Path','xpressme'),
|
---|
525 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
526 | __('USE WordPress BASE_PATH','xpressme')
|
---|
527 | );
|
---|
528 | echo $this->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
529 | __('Thema Sidebar Display','xpressme'),
|
---|
530 | __('YES','xpressme'),
|
---|
531 | __('NO','xpressme')
|
---|
532 | );
|
---|
533 | echo $this->yes_no_radio_option('is_save_post_revision',
|
---|
534 | __('The change tracking of the post is preserved','xpressme'),
|
---|
535 | __('YES','xpressme'),
|
---|
536 | __('NO','xpressme')
|
---|
537 | );
|
---|
538 |
|
---|
539 | echo $this->single_post_navi_option();
|
---|
540 | echo $this->posts_page_navi_option();
|
---|
541 |
|
---|
542 |
|
---|
543 | echo $this->yes_no_radio_option('is_author_view_count',
|
---|
544 | __('Is the posts author views counted?','xpressme'),
|
---|
545 | __('YES','xpressme'),
|
---|
546 | __('NO','xpressme')
|
---|
547 | );
|
---|
548 | echo $this->yes_no_radio_option('is_sql_debug',
|
---|
549 | __('Is SQL debugging window displayed?','xpressme'),
|
---|
550 | __('YES','xpressme'),
|
---|
551 | __('NO','xpressme')
|
---|
552 | );
|
---|
553 |
|
---|
554 | echo $this->groupe_role_option();
|
---|
555 |
|
---|
556 | echo $this->d3forum_option($do_message);
|
---|
557 | // $this->is_use_xoops_upload_path_html();
|
---|
558 | echo "</table>\n";
|
---|
559 |
|
---|
560 | echo '<p class="submit">'."\n";
|
---|
561 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
562 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
563 | echo "</p>\n";
|
---|
564 |
|
---|
565 | echo "</form>\n" ;
|
---|
566 | echo "</div>\n";
|
---|
567 | }
|
---|
568 |
|
---|
569 | function xpress_upload_filter($uploads)
|
---|
570 | {
|
---|
571 | global $xoops_config;
|
---|
572 | if ($this->is_use_xoops_upload_path){
|
---|
573 | $wordpress_dir = ABSPATH ;
|
---|
574 | $xoops_dir = $xoops_config->xoops_upload_path . '/';
|
---|
575 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
576 | $xoops_upload_url = $xoops_config->xoops_upload_url;
|
---|
577 |
|
---|
578 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
579 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
580 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
581 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
582 | }
|
---|
583 | return $uploads;
|
---|
584 | }
|
---|
585 |
|
---|
586 | // SQL DEBUG TEST
|
---|
587 | function is_sql_debug_permission()
|
---|
588 | {
|
---|
589 | global $current_user;
|
---|
590 |
|
---|
591 | if (!is_object($current_user)) return false;
|
---|
592 | if ($this->is_sql_debug && ($current_user->user_level >= 10))
|
---|
593 | return true;
|
---|
594 | else
|
---|
595 | return false;
|
---|
596 | }
|
---|
597 |
|
---|
598 | function xpress_sql_debug($query_strings)
|
---|
599 | {
|
---|
600 | if ($this->is_sql_debug_permission()){
|
---|
601 | if (empty($GLOBALS['XPress_SQL_Query'])) $GLOBALS['XPress_SQL_Query'] = '';
|
---|
602 | $GLOBALS['XPress_SQL_Query'] .= $query_strings . '<br />';
|
---|
603 | }
|
---|
604 | return $query_strings;
|
---|
605 | }
|
---|
606 |
|
---|
607 | function displayDebugLog()
|
---|
608 | {
|
---|
609 | if ($this->is_sql_debug_permission()){
|
---|
610 | $content = '';
|
---|
611 | $content .= '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />';
|
---|
612 | $content .= '<meta http-equiv="content-language" content="'._LANGCODE.'" />' ;
|
---|
613 | $content .= '<title>XPressME SQL DEBUG</title>' ;
|
---|
614 | $content .= '</head><body>';
|
---|
615 | $content .= $GLOBALS['XPress_SQL_Query'];
|
---|
616 | $content .= '<div style="text-align:center;"><input class="formButton" value="CLOSE" type="button" onclick="javascript:window.close();" /></div></body></html>';
|
---|
617 |
|
---|
618 | echo '<script type="text/javascript">
|
---|
619 | <!--//
|
---|
620 | xpress_debug_window = window.open("", "xpress_debug", "width=680 , height=600 ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no");
|
---|
621 | xpress_debug_window.document.clear();
|
---|
622 | xpress_debug_window.focus();
|
---|
623 | ';
|
---|
624 | $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
|
---|
625 | foreach ($lines as $line) {
|
---|
626 | echo 'xpress_debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
|
---|
627 | }
|
---|
628 | echo '
|
---|
629 | xpress_debug_window.document.close();
|
---|
630 | //-->
|
---|
631 | </script>';
|
---|
632 | }
|
---|
633 | }
|
---|
634 |
|
---|
635 | function set_d3forum_external_link_format()
|
---|
636 | {
|
---|
637 | global $xoops_db;
|
---|
638 | /* var $is_use_d3forum;
|
---|
639 | var $d3forum_module_dir;
|
---|
640 | var $d3forum_forum_id;
|
---|
641 | var $d3forum_external_link_format;
|
---|
642 | if ($this->$is_use_d3forum){
|
---|
643 | $content = '';
|
---|
644 | $content .= '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />';
|
---|
645 | $content .= '<meta http-equiv="content-language" content="'._LANGCODE.'" />' ;
|
---|
646 | $content .= '<title>XPressME SQL DEBUG</title>' ;
|
---|
647 | $content .= '</head><body>';
|
---|
648 | $content .= $GLOBALS['XPress_SQL_Query'];
|
---|
649 | $content .= '<div style="text-align:center;"><input class="formButton" value="CLOSE" type="button" onclick="javascript:window.close();" /></div></body></html>';
|
---|
650 |
|
---|
651 | echo '<script type="text/javascript">
|
---|
652 | <!--//
|
---|
653 | xpress_debug_window = window.open("", "xpress_debug", "width=680 , height=600 ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no");
|
---|
654 | xpress_debug_window.document.clear();
|
---|
655 | xpress_debug_window.focus();
|
---|
656 | ';
|
---|
657 | $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
|
---|
658 | foreach ($lines as $line) {
|
---|
659 | echo 'xpress_debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
|
---|
660 | }
|
---|
661 | echo '
|
---|
662 | xpress_debug_window.document.close();
|
---|
663 | //-->
|
---|
664 | </script>';
|
---|
665 | }
|
---|
666 | */
|
---|
667 | }
|
---|
668 |
|
---|
669 | }
|
---|
670 | ?> |
---|