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 | var $is_content_excerpt;
|
---|
25 | var $ascii_judged_rate;
|
---|
26 | var $excerpt_length_word;
|
---|
27 | var $excerpt_length_character;
|
---|
28 | var $more_link_text;
|
---|
29 | var $viewer_type;
|
---|
30 | var $is_multi_user;
|
---|
31 | var $meta_keyword_type;
|
---|
32 | var $meta_description_type;
|
---|
33 | var $meta_robot_type;
|
---|
34 | //constructor
|
---|
35 | function XPressME_Class()
|
---|
36 | {
|
---|
37 | global $xoops_db;
|
---|
38 |
|
---|
39 | $this->setdefault(); //not setting propaty load
|
---|
40 | $this->SettingValueRead();
|
---|
41 | }
|
---|
42 |
|
---|
43 | //Set Default Value
|
---|
44 | function setDefault()
|
---|
45 | {
|
---|
46 | $this->is_use_xoops_upload_path = true;
|
---|
47 | $this->is_theme_sidebar_disp = false;
|
---|
48 | $this->is_save_post_revision = true;
|
---|
49 | $this->is_postnavi_title_disp = true;
|
---|
50 | $this->is_left_postnavi_old = true;
|
---|
51 | $this->old_post_link_text = __('Older Post', 'xpressme');
|
---|
52 | $this->newer_post_link_text = __('Newer Post', 'xpressme');
|
---|
53 | $this->is_left_page_navi_old = true;
|
---|
54 | $this->old_page_link_text = __('Older Entries', 'xpressme');
|
---|
55 | $this->newer_page_link_text = __('Newer Entries', 'xpressme');
|
---|
56 | $this->is_author_view_count = false;
|
---|
57 | $this->is_sql_debug = false;
|
---|
58 | $this->is_use_d3forum = false;
|
---|
59 | $this->d3forum_module_dir = '';
|
---|
60 | $this->d3forum_forum_id = '';
|
---|
61 | $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
|
---|
62 | $this->is_d3forum_flat = true;
|
---|
63 | $this->is_d3forum_desc = true;
|
---|
64 | $this->d3forum_views_num = 10;
|
---|
65 | $this->is_content_excerpt = true;
|
---|
66 | $this->ascii_judged_rate = 90;
|
---|
67 | $this->excerpt_length_word = 40;
|
---|
68 | $this->excerpt_length_character = 120;
|
---|
69 | $this->more_link_text = __('more', 'xpressme');
|
---|
70 | $this->viewer_type = 'xoops';
|
---|
71 | $this->is_multi_user = false;
|
---|
72 | $this->meta_keyword_type = 'xoops';
|
---|
73 | $this->meta_description_type = 'xoops';
|
---|
74 | $this->meta_robot_type = 'xoops';
|
---|
75 | }
|
---|
76 |
|
---|
77 | function SettingValueRead()
|
---|
78 | {
|
---|
79 | global $xoops_db;
|
---|
80 | $options = get_option('xpressme_option');
|
---|
81 | if (!$options) {
|
---|
82 | $this->setDefault();
|
---|
83 | $this->SettingValueWrite('add_new');
|
---|
84 | } else {
|
---|
85 | foreach ($options as $option_name => $option_value){
|
---|
86 | $this-> {$option_name} = $option_value;
|
---|
87 | }
|
---|
88 | }
|
---|
89 | if (!empty($xoops_db)) // at install trap
|
---|
90 | $this->GroupeRoleRead();
|
---|
91 | }
|
---|
92 |
|
---|
93 | // mode 0:add 1:update
|
---|
94 | function SettingValueWrite($mode)
|
---|
95 | {
|
---|
96 | $write_options = array (
|
---|
97 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
98 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ,
|
---|
99 | 'is_save_post_revision' => $this->is_save_post_revision ,
|
---|
100 | 'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
|
---|
101 | 'is_left_postnavi_old' => $this->is_left_postnavi_old ,
|
---|
102 | 'old_post_link_text' => $this->old_post_link_text ,
|
---|
103 | 'newer_post_link_text' => $this->newer_post_link_text,
|
---|
104 | 'is_left_page_navi_old' => $this->is_left_page_navi_old ,
|
---|
105 | 'old_page_link_text' => $this->old_page_link_text ,
|
---|
106 | 'newer_page_link_text' => $this->newer_page_link_text,
|
---|
107 | 'is_author_view_count' => $this->is_author_view_count,
|
---|
108 | 'is_sql_debug' => $this->is_sql_debug,
|
---|
109 | 'is_use_d3forum' => $this->is_use_d3forum,
|
---|
110 | 'd3forum_module_dir' => $this->d3forum_module_dir,
|
---|
111 | 'd3forum_forum_id' => $this->d3forum_forum_id,
|
---|
112 | 'd3forum_external_link_format' => $this->d3forum_external_link_format,
|
---|
113 | 'is_d3forum_flat' => $this->is_d3forum_flat,
|
---|
114 | 'is_d3forum_desc' => $this->is_d3forum_desc,
|
---|
115 | 'd3forum_views_num' =>$this->d3forum_views_num,
|
---|
116 | 'is_content_excerpt' => $this->is_content_excerpt,
|
---|
117 | 'ascii_judged_rate' => $this->ascii_judged_rate,
|
---|
118 | 'excerpt_length_word' => $this->excerpt_length_word,
|
---|
119 | 'excerpt_length_character' => $this->excerpt_length_character,
|
---|
120 | 'more_link_text' => $this->more_link_text,
|
---|
121 | 'viewer_type' => $this->viewer_type,
|
---|
122 | 'is_multi_user' => $this->is_multi_user,
|
---|
123 | 'meta_keyword_type' => $this->meta_keyword_type,
|
---|
124 | 'meta_description_type' => $this->meta_description_type,
|
---|
125 | 'meta_robot_type' => $this->meta_robot_type
|
---|
126 | );
|
---|
127 | if ($mode == 'add_new') {
|
---|
128 | add_option('xpressme_option', $write_options);
|
---|
129 | } else {
|
---|
130 | update_option("xpressme_option", $write_options);
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | function GroupeRoleRead() {
|
---|
135 | global $xoops_db;
|
---|
136 |
|
---|
137 | // table sync
|
---|
138 | $table = get_wp_prefix() . 'group_role';
|
---|
139 | $xoops_group = get_xoops_prefix() . 'groups';
|
---|
140 | $xoops_group_permission = get_xoops_prefix() . 'group_permission';
|
---|
141 |
|
---|
142 | $module_id = get_xpress_modid();
|
---|
143 |
|
---|
144 | $sql= "SELECT * FROM $table";
|
---|
145 | $before_groupes = $xoops_db->get_results($sql);
|
---|
146 |
|
---|
147 | $sql = "DELETE FROM $table";
|
---|
148 | $xoops_db->query($sql);
|
---|
149 |
|
---|
150 | $sql = "SELECT * FROM $xoops_group_permission WHERE gperm_itemid = $module_id";
|
---|
151 | $gperms = $xoops_db->get_results($sql);
|
---|
152 |
|
---|
153 | $sql = "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";
|
---|
154 | $groupes = $xoops_db->get_results($sql);
|
---|
155 | $insert_sql = '';
|
---|
156 | foreach ($groupes as $groupe) {
|
---|
157 | $parmsql = "SELECT * FROM $xoops_group_permission WHERE gperm_itemid = $module_id AND gperm_groupid = $groupe->groupid";
|
---|
158 | $gperms = $xoops_db->get_results($parmsql);
|
---|
159 | $parmission = '';
|
---|
160 | foreach ($gperms as $gperm) {
|
---|
161 | $parmission = $gperm->gperm_name;
|
---|
162 | if ($parmission == 'module_admin') break;
|
---|
163 | }
|
---|
164 |
|
---|
165 | if (!empty($parmission)){
|
---|
166 | $role = '';
|
---|
167 | foreach ($before_groupes as $before_groupe) {
|
---|
168 | if ($groupe->groupid == $before_groupe->groupid) {
|
---|
169 | $role = $before_groupe->role;
|
---|
170 | $login_all = $before_groupe->login_all;
|
---|
171 | }
|
---|
172 | }
|
---|
173 | if ($parmission == 'module_admin') $role = 'administrator';
|
---|
174 |
|
---|
175 | $insert_sql = "INSERT INTO $table ";
|
---|
176 | $insert_sql .= "(groupid , name , description , group_type , role , login_all) ";
|
---|
177 | $insert_sql .= "VALUES (";
|
---|
178 | $insert_sql .= $groupe->groupid . ', ';
|
---|
179 | $insert_sql .= "'" . $groupe->name . "' , ";
|
---|
180 | $insert_sql .= "'" . $groupe->description . "' , ";
|
---|
181 | $insert_sql .= "'" . $parmission . "' , ";
|
---|
182 | $insert_sql .= "'" . $role . "' , '";
|
---|
183 | $insert_sql .= $login_all . "')";
|
---|
184 | $xoops_db->query($insert_sql);
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 | $sql= "SELECT * FROM $table";
|
---|
189 |
|
---|
190 | $this->groupe_role = $xoops_db->get_results($sql);
|
---|
191 | $sql= "SELECT * FROM $table";
|
---|
192 | }
|
---|
193 |
|
---|
194 | function ReadPostData($post_data = null)
|
---|
195 | {
|
---|
196 | global $xoops_db;
|
---|
197 |
|
---|
198 | foreach ( (array) $post_data as $index_key => $value ){
|
---|
199 | if (preg_match('/^ch_/',$index_key)){ // case ch_
|
---|
200 | $indedx = preg_replace('/^ch_/', '', $index_key);
|
---|
201 | $set_value = stripslashes(trim($value));
|
---|
202 | // post d3forum
|
---|
203 | if ($indedx === 'd3forum') {
|
---|
204 | if ($value == 'none'){
|
---|
205 | $this->is_use_d3forum = false;
|
---|
206 | $this->d3forum_module_dir = '';
|
---|
207 | $this->d3forum_forum_id = '';
|
---|
208 | $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
|
---|
209 | } else {
|
---|
210 | $d3f_set = explode('|', $value);
|
---|
211 | $this->is_use_d3forum = true;
|
---|
212 | $this->d3forum_module_dir = $d3f_set[1];
|
---|
213 | $this->d3forum_forum_id = $d3f_set[2];
|
---|
214 | $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
|
---|
215 | }
|
---|
216 | } else { //post other
|
---|
217 | if(empty($set_value)){
|
---|
218 | switch ($indedx) {
|
---|
219 | case 'old_post_link_text':
|
---|
220 | $set_value = __('Older Post', 'xpressme');
|
---|
221 | break;
|
---|
222 | case 'newer_post_link_text':
|
---|
223 | $set_value = __('Newer Post', 'xpressme');
|
---|
224 | break;
|
---|
225 | case 'old_page_link_text':
|
---|
226 | $set_value = __('Older Entries', 'xpressme');
|
---|
227 | break;
|
---|
228 | case 'newer_page_link_text':
|
---|
229 | $set_value = __('Newer Entries', 'xpressme');
|
---|
230 | break;
|
---|
231 | default:
|
---|
232 | }
|
---|
233 | }
|
---|
234 | $this->$indedx = $value;
|
---|
235 | }
|
---|
236 | } // end of case 'ch_'
|
---|
237 | } // end of loop
|
---|
238 |
|
---|
239 | global $xoops_db;
|
---|
240 | $table = get_wp_prefix() . 'group_role';
|
---|
241 | // $sql= "SELECT * FROM $table";
|
---|
242 | // $this->groupe_role = $xoops_db->get_results($sql); // before Read
|
---|
243 |
|
---|
244 | foreach ($this->groupe_role as $groupe) {
|
---|
245 | $post_role_gid = 'role_gid_' . $groupe->groupid;
|
---|
246 | $login_all_gid = 'login_all_gid_' . $groupe->groupid;
|
---|
247 | if (isset($post_data[$post_role_gid])){
|
---|
248 | $role = stripslashes(trim($post_data[$post_role_gid]));
|
---|
249 | $login_all = stripslashes(trim($post_data[$login_all_gid]));
|
---|
250 | if (empty($login_all)) $login_all = '0';
|
---|
251 | $groupe->role = $role;
|
---|
252 | $groupe->login_all = $login_all;
|
---|
253 | $update_sql = "UPDATE $table ";
|
---|
254 | $update_sql .= 'SET ';
|
---|
255 | $update_sql .= "role = '$role' , ";
|
---|
256 | $update_sql .= "login_all = $login_all ";
|
---|
257 | $update_sql .= "WHERE (groupid = '$groupe->groupid' )";
|
---|
258 | $xoops_db->query($update_sql);
|
---|
259 | }
|
---|
260 | }
|
---|
261 | }
|
---|
262 |
|
---|
263 | function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
|
---|
264 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
265 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
266 | $value = $this->{$option_name};
|
---|
267 | $ans_name = 'ch_' . $option_name;
|
---|
268 |
|
---|
269 | $form = "<tr>\n";
|
---|
270 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
271 | $form .= "<td>\n";
|
---|
272 | $form .= $this->yes_no_radio_option_sub($option_name,$yes,$no);
|
---|
273 | $form .= "</td>\n";
|
---|
274 | $form .= "</tr>\n";
|
---|
275 |
|
---|
276 | return $form;
|
---|
277 |
|
---|
278 | }
|
---|
279 | function yes_no_radio_option_sub($option_name,$yes = '',$no= ''){
|
---|
280 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
281 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
282 | $value = $this->{$option_name};
|
---|
283 | $ans_name = 'ch_' . $option_name;
|
---|
284 |
|
---|
285 | if ($value){
|
---|
286 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
|
---|
287 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
|
---|
288 | }else{
|
---|
289 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
|
---|
290 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
|
---|
291 | }
|
---|
292 | return $form;
|
---|
293 | }
|
---|
294 |
|
---|
295 |
|
---|
296 | function text_option($option_name,$option_desc){
|
---|
297 | $value = $this->{$option_name};
|
---|
298 | $ans_name = 'ch_' . $option_name;
|
---|
299 |
|
---|
300 | $form = "<tr>\n";
|
---|
301 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
302 | $form .= "<td>\n";
|
---|
303 | $form .= $this->text_option_sub($option_name);
|
---|
304 | $form .= "</td>\n";
|
---|
305 | $form .= "</tr>\n";
|
---|
306 |
|
---|
307 | return $form;
|
---|
308 |
|
---|
309 | }
|
---|
310 |
|
---|
311 | function text_option_sub($option_name){
|
---|
312 | $value = $this->{$option_name};
|
---|
313 | $ans_name = 'ch_' . $option_name;
|
---|
314 |
|
---|
315 | $form = '<label> <input name="'. $ans_name . '" type="text" size="25" maxlength="50" value="' . $value . '" /></label>'."\n";
|
---|
316 | return $form;
|
---|
317 |
|
---|
318 | }
|
---|
319 |
|
---|
320 |
|
---|
321 | function single_post_navi_option(){
|
---|
322 | $form = '';
|
---|
323 | $form .= '<tr><th><label for="single_page_navi">' .__('Single Post Navi Setting', 'xpressme') . '</label></th>';
|
---|
324 | $form .= "<td>\n";
|
---|
325 | $form .= "<table>\n";
|
---|
326 | $form .= "<tr>\n";
|
---|
327 |
|
---|
328 | $form .= "<td>" . __('Adjustment of Navi link display position','xpressme') . "</td>\n";
|
---|
329 | $form .= "<td>\n";
|
---|
330 | $form .= $this->yes_no_radio_option_sub('is_left_postnavi_old',
|
---|
331 | __("'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right",'xpressme'),
|
---|
332 | __("'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right",'xpressme')
|
---|
333 | );
|
---|
334 | $form .= "</td>\n";
|
---|
335 | $form .= "</tr>\n";
|
---|
336 |
|
---|
337 | $form .= "<tr>\n";
|
---|
338 | $form .= "<td>" . __('Select Display name of PostNavi Link','xpressme') . "</td>\n";
|
---|
339 | $form .= "<td>\n";
|
---|
340 | $form .= $this->yes_no_radio_option_sub('is_postnavi_title_disp',
|
---|
341 | __('Title of post','xpressme'),
|
---|
342 | __('Title of Navi','xpressme')
|
---|
343 | );
|
---|
344 | $form .= "</td>\n";
|
---|
345 | $form .= "</tr>\n";
|
---|
346 |
|
---|
347 | $form .= "<tr>\n";
|
---|
348 | $form .= "<td>" . __('Display Navi Title of Old Post Link','xpressme') . "</td>\n";
|
---|
349 | $form .= "<td>\n";
|
---|
350 | $form .= $this->text_option_sub('old_post_link_text');
|
---|
351 | $form .= "</td>\n";
|
---|
352 | $form .= "</tr>\n";
|
---|
353 |
|
---|
354 | $form .= "<tr>\n";
|
---|
355 | $form .= "<td>" . __('Display Navi Title of Newer Post Link','xpressme') . "</td>\n";
|
---|
356 | $form .= "<td>\n";
|
---|
357 | $form .= $this->text_option_sub('newer_post_link_text');
|
---|
358 | $form .= "</td>\n";
|
---|
359 | $form .= "</tr>\n";
|
---|
360 |
|
---|
361 | $form .= "</table></td></tr>\n";
|
---|
362 | return $form;
|
---|
363 |
|
---|
364 | }
|
---|
365 |
|
---|
366 | function posts_page_navi_option(){
|
---|
367 | $form = '';
|
---|
368 | $form .= '<tr><th><label for="posts_page_navi">' .__('Posts List Page Navi Setting', 'xpressme') . '</label></th>';
|
---|
369 | $form .= "<td>\n";
|
---|
370 | $form .= "<table>\n";
|
---|
371 | $form .= "<tr>\n";
|
---|
372 |
|
---|
373 | $form .= "<td>" . __('Adjustment of Navi link display position','xpressme') . "</td>\n";
|
---|
374 | $form .= "<td>\n";
|
---|
375 | $form .= $this->yes_no_radio_option_sub('is_left_page_navi_old',
|
---|
376 | __("'Old Page Link' is displayed in the left, and 'Newer Page Link' is displayed in the right",'xpressme'),
|
---|
377 | __("'Newer Page Link' is displayed in the left, and 'Old Page Link' is displayed in the right",'xpressme')
|
---|
378 | );
|
---|
379 | $form .= "</td>\n";
|
---|
380 | $form .= "</tr>\n";
|
---|
381 |
|
---|
382 | $form .= "<tr>\n";
|
---|
383 | $form .= "<td>" . __('Display Navi Title of Old Page Link','xpressme') . "</td>\n";
|
---|
384 | $form .= "<td>\n";
|
---|
385 | $form .= $this->text_option_sub('old_page_link_text');
|
---|
386 | $form .= "</td>\n";
|
---|
387 | $form .= "</tr>\n";
|
---|
388 |
|
---|
389 | $form .= "<tr>\n";
|
---|
390 | $form .= "<td>" . __('Display Navi Title of Newer Page Link','xpressme') . "</td>\n";
|
---|
391 | $form .= "<td>\n";
|
---|
392 | $form .= $this->text_option_sub('newer_page_link_text');
|
---|
393 | $form .= "</td>\n";
|
---|
394 | $form .= "</tr>\n";
|
---|
395 |
|
---|
396 | $form .= "</table></td></tr>\n";
|
---|
397 | return $form;
|
---|
398 |
|
---|
399 | }
|
---|
400 |
|
---|
401 | function groupe_role_option(){
|
---|
402 | global $wp_roles , $xoops_db;
|
---|
403 |
|
---|
404 | $form = '';
|
---|
405 | $form .= '<tr><th><label for="role">' .__('Role Setting at Login', 'xpressme') . '</label></th>';
|
---|
406 | $form .= '<td>';
|
---|
407 | $form .= "<table>\n";
|
---|
408 | $form .= '<tr><td>' . __('XOOPS Groupe', 'xpressme') . '</td><td>' . __('WordPress Role', 'xpressme') . '</td><td>' . __('Role is set at each login', 'xpressme') . "</td></tr>\n";
|
---|
409 | foreach ($this->groupe_role as $groupe) {
|
---|
410 | $form .= "<tr>";
|
---|
411 | $form .= "<td> $groupe->name </td>";
|
---|
412 | $form .= "<td>\n" . '<select name="role_gid_'.$groupe->groupid . '" id="role_gid_' . $groupe->groupid . '">' . "\n";
|
---|
413 | $role_list = '';
|
---|
414 | $group_has_role = false;
|
---|
415 |
|
---|
416 | $select_value = $groupe->role;
|
---|
417 |
|
---|
418 |
|
---|
419 |
|
---|
420 | foreach($wp_roles->role_names as $role => $name) {
|
---|
421 | $name = translate_with_context($name);
|
---|
422 | if ( $role == $select_value) {
|
---|
423 | $selected = ' selected="selected"';
|
---|
424 | $group_has_role = true;
|
---|
425 | } else {
|
---|
426 | $selected = '';
|
---|
427 | }
|
---|
428 | if ($groupe->group_type != 'module_admin'|| !empty($selected)) {
|
---|
429 | $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>\n";
|
---|
430 | }
|
---|
431 | }
|
---|
432 | if ($groupe->group_type != 'module_admin') {
|
---|
433 | if ( $group_has_role ) {
|
---|
434 | $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
435 | $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
436 | } else {
|
---|
437 | if ($select_value == 'default'){
|
---|
438 | $role_list .= '<option value="default" selected="selected">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
439 | $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
440 | } else {
|
---|
441 | $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
442 | $role_list .= '<option value="" selected="selected">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
443 | }
|
---|
444 | }
|
---|
445 | }
|
---|
446 | $form .= $role_list . "</select>\n</td>";
|
---|
447 | if ($groupe->login_all){
|
---|
448 | $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1" checked ></td>';
|
---|
449 | } else {
|
---|
450 | $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1"></td>';
|
---|
451 | }
|
---|
452 | $form .= "</tr>\n";
|
---|
453 | }
|
---|
454 | $form .= "</table></td></tr>\n";
|
---|
455 | return $form;
|
---|
456 |
|
---|
457 | }
|
---|
458 |
|
---|
459 | function d3forum_option($do_message = ''){
|
---|
460 | global $xoops_db,$xoops_config;
|
---|
461 |
|
---|
462 | $d3frum_list = array();
|
---|
463 | $module_dir_path = get_xoops_root_path();
|
---|
464 |
|
---|
465 | $forum_list = '<select name="ch_d3forum">' . "\n";
|
---|
466 |
|
---|
467 | if ($this->is_use_d3forum != true)
|
---|
468 | $selected = ' selected="selected"';
|
---|
469 | else
|
---|
470 | $selected = '';
|
---|
471 |
|
---|
472 | if ($xoops_config->is_wpmu) {
|
---|
473 | $forum_list .= '<option value="none"' . $selected . '>' . __('WordPress MU cannot integrate the comments.', 'xpressme') . "</option>\n";
|
---|
474 | } else {
|
---|
475 | $forum_list .= '<option value="none"' . $selected . '>' . __('Do Not Comment Integration.', 'xpressme') . "</option>\n";
|
---|
476 |
|
---|
477 | // Form making for forum selection of D3forum
|
---|
478 | $modules_table = get_xoops_prefix() .'modules';
|
---|
479 | $sql = "SELECT mid,name,isactive,dirname FROM $modules_table WHERE isactive = 1";
|
---|
480 | $modules = $xoops_db->get_results($sql);
|
---|
481 | foreach ($modules as $module) {
|
---|
482 | $file_path = $module_dir_path . '/modules/' . $module->dirname . '/mytrustdirname.php';
|
---|
483 | if (! file_exists($file_path)) continue;
|
---|
484 | $array_files = file($file_path);
|
---|
485 | // It is checked whether there is character string "$mytrustdirname ='d3forum'"in the file.
|
---|
486 | foreach ($array_files as $aeey_file){
|
---|
487 | if( preg_match( "/\s*(mytrustdirname)\s*(=)\s*([\"'])(d3forum)([\"'])/", $aeey_file ) ) {
|
---|
488 | $forums_tb = get_xoops_prefix() . $module->dirname . '_forums';
|
---|
489 | $cat_tb = get_xoops_prefix() . $module->dirname . '_categories';
|
---|
490 | $sql= "SELECT * FROM $forums_tb LEFT JOIN $cat_tb ON $forums_tb.cat_id = $cat_tb.cat_id";
|
---|
491 | $forums = $xoops_db->get_results($sql);
|
---|
492 | foreach ($forums as $forum) {
|
---|
493 | if (($module->dirname == $this->d3forum_module_dir) && ($forum->forum_id == $this->d3forum_forum_id))
|
---|
494 | $selected = ' selected="selected"';
|
---|
495 | else
|
---|
496 | $selected = '';
|
---|
497 | $forum_div = 'forum|' . $module->dirname . '|' . $forum->forum_id;
|
---|
498 | $forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)";
|
---|
499 | $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
|
---|
500 | }
|
---|
501 | break;
|
---|
502 | }
|
---|
503 | }
|
---|
504 | $forum_list .= '<br>';
|
---|
505 | }
|
---|
506 | }
|
---|
507 | $forum_list .= '</select>' . "\n";
|
---|
508 |
|
---|
509 | $form = '<tr>' . "\n";
|
---|
510 | $form .= '<th><label for="d3forum">' .__('Comment integration with D3Forum', 'xpressme') . '</label></th>' . "\n";
|
---|
511 | $form .= "<td>\n";
|
---|
512 | $form .= __('Select the forum of D3Forum that does the comment integration from the following lists.', 'xpressme') ."<br />\n";
|
---|
513 | $form .= $forum_list."\n";
|
---|
514 | $form .= '<br /><br />';
|
---|
515 | if ($this->is_use_d3forum) $disible = ''; else $disible = 'disabled';
|
---|
516 | $form .= __('Select the Type of display of D3Forum comment.', 'xpressme') . " \n&emsp";
|
---|
517 | if ($this->is_d3forum_flat){
|
---|
518 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='1' checked='checked' />" . __('Flat','xpressme') ."</label>\n";
|
---|
519 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='0' />". __('Threaded','xpressme') . "</label>\n";
|
---|
520 | }else{
|
---|
521 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='1' />" . __('Flat','xpressme') . "</label>\n";
|
---|
522 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='0' checked='checked' />". __('Threaded','xpressme') ."</label>\n";
|
---|
523 | }
|
---|
524 | $form .= '<br />';
|
---|
525 | $form .= __('Select the order of display of D3Forum comment.', 'xpressme') . " \n&emsp";
|
---|
526 | if ($this->is_d3forum_desc){
|
---|
527 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='1' checked='checked' />" . __('DESC','xpressme') ."</label>\n";
|
---|
528 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='0' />". __('ASC','xpressme') . "</label>\n";
|
---|
529 | }else{
|
---|
530 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='1' />" . __('DESC','xpressme') . "</label>\n";
|
---|
531 | $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='0' checked='checked' />". __('ASC','xpressme') ."</label>\n";
|
---|
532 | }
|
---|
533 | $form .= '<br />';
|
---|
534 | $form .= __('Number of displays of D3Forum comments.', 'xpressme') ." \n";
|
---|
535 | $form .= '&emsp<label> <input name="ch_d3forum_views_num" type="text" size="3" maxlength="3" value="' . $this->d3forum_views_num . '" /></label>'."\n";
|
---|
536 |
|
---|
537 | $form .= '<div class="submit">'."\n";
|
---|
538 | $form .= __('The import and the export between Wordpress Comments and the D3Forum Posts can be done. ', 'xpressme') ."<br />\n";
|
---|
539 | $form .= '<input type="submit" value= "' . __('Export to D3Forum', 'xpressme') . '" name="export_d3f" ' . $disible . ' >' ."\n";
|
---|
540 | $form .= '<input type="submit" value= "' . __('Import from D3Forum', 'xpressme') . '" name="inport_d3f" ' . $disible . ' >' ."<br />\n";
|
---|
541 | $form .= '</div>'."\n";
|
---|
542 | if (!empty($do_message)){
|
---|
543 | $form .= '<div>' . $do_message . '</div>';
|
---|
544 | }
|
---|
545 | $form .= "</td>\n";
|
---|
546 | $form .= "</tr><tr>\n";
|
---|
547 | return $form;
|
---|
548 | }
|
---|
549 |
|
---|
550 | function excerpt_option(){
|
---|
551 | $form = '';
|
---|
552 | $form .= '<tr><th><label for="excerpt">' .__('Contents Excerpt Setting', 'xpressme') . '</label></th>';
|
---|
553 | $form .= "<td>\n";
|
---|
554 | $form .= "<table>\n";
|
---|
555 | $form .= "<tr>\n";
|
---|
556 |
|
---|
557 | $form .= "<td>" . __('Is the excerpt display done with the archive of contents?','xpressme') . "</td>\n";
|
---|
558 | $form .= "<td>\n";
|
---|
559 | $form .= $this->yes_no_radio_option_sub('is_content_excerpt');
|
---|
560 | $form .= "</td>\n";
|
---|
561 | $form .= "</tr>\n";
|
---|
562 |
|
---|
563 | $form .= "<tr>\n";
|
---|
564 | $form .= "<td>" . __('When ASCII character more than the set ratio is included, it is judged ASCII contents. ','xpressme') . "</td>\n";
|
---|
565 | $form .= "<td>\n";
|
---|
566 | $form .= $this->text_option_sub('ascii_judged_rate');
|
---|
567 | $form .= "</td>\n";
|
---|
568 | $form .= "</tr>\n";
|
---|
569 |
|
---|
570 | $form .= "<tr>\n";
|
---|
571 | $form .= "<td>" . __('Excerpt length of word for ASCII contents','xpressme') . "</td>\n";
|
---|
572 | $form .= "<td>\n";
|
---|
573 | $form .= $this->text_option_sub('excerpt_length_word');
|
---|
574 | $form .= "</td>\n";
|
---|
575 | $form .= "</tr>\n";
|
---|
576 |
|
---|
577 | $form .= "<tr>\n";
|
---|
578 | $form .= "<td>" . __('Excerpt length of character for multibyte contents','xpressme') . "</td>\n";
|
---|
579 | $form .= "<td>\n";
|
---|
580 | $form .= $this->text_option_sub('excerpt_length_character');
|
---|
581 | $form .= "</td>\n";
|
---|
582 | $form .= "</tr>\n";
|
---|
583 |
|
---|
584 | $form .= "<tr>\n";
|
---|
585 | $form .= "<td>" . __('More Link Text (Is not displayed for the blank.)','xpressme') . "</td>\n";
|
---|
586 | $form .= "<td>\n";
|
---|
587 | $form .= $this->text_option_sub('more_link_text');
|
---|
588 | $form .= "</td>\n";
|
---|
589 | $form .= "</tr>\n";
|
---|
590 |
|
---|
591 | $form .= "</table></td></tr>\n";
|
---|
592 | return $form;
|
---|
593 | }
|
---|
594 |
|
---|
595 | function viewer_type_option(){
|
---|
596 | $form = "<tr>\n";
|
---|
597 | $form .= '<th><label for="viewer_type">' .__('Display Mode Setting', 'xpressme') . '</label></th>';
|
---|
598 | $form .= "<td>\n";
|
---|
599 |
|
---|
600 | $form .= __('Select the XPressME Display Mode.', 'xpressme') ."\n";
|
---|
601 | $form .= '<select name="ch_viewer_type">' . "\n";
|
---|
602 |
|
---|
603 | $form .= '<option value="xoops" ';
|
---|
604 | if ($this->viewer_type == 'xoops') $form .= ' selected="selected"';
|
---|
605 | $form .= '>'.__('Xoops Mode', 'xpressme') ."</option>\n";
|
---|
606 |
|
---|
607 | $form .= '<option value="wordpress" ';
|
---|
608 | if ($this->viewer_type == 'wordpress') $form .= ' selected="selected"';
|
---|
609 | $form .= '>'.__('WordPress Mode', 'xpressme') ."</option>\n";
|
---|
610 |
|
---|
611 | $form .= '<option value="user_select" ';
|
---|
612 | if ($this->viewer_type == 'user_select') $form .= ' selected="selected"';
|
---|
613 | $form .= '>'.__('User select', 'xpressme') ."</option>\n";
|
---|
614 |
|
---|
615 | $form .= "</select><br />\n";
|
---|
616 |
|
---|
617 | $form .= "</td></tr>\n";
|
---|
618 | return $form;
|
---|
619 | }
|
---|
620 |
|
---|
621 | function header_meta_option(){
|
---|
622 | $form = "<tr>\n";
|
---|
623 | $form .= '<th><label for="header_type">' .__('Header Meta Option', 'xpressme') . '</label></th>';
|
---|
624 | $form .= "<td>\n";
|
---|
625 | $form .= "<table>\n";
|
---|
626 | $form .= "<tr>\n";
|
---|
627 |
|
---|
628 | $form .= "<td>" . __('Select the Header keyword.', 'xpressme') . "</td>\n";
|
---|
629 | $form .= "<td>\n";
|
---|
630 | $form .= '<select name="ch_meta_keyword_type">' . "\n";
|
---|
631 | $form .= '<option value="xoops" ';
|
---|
632 | if ($this->meta_keyword_type == 'xoops') $form .= ' selected="selected"';
|
---|
633 | $form .= '>'.__('Xoops KeyWord', 'xpressme') ."</option>\n";
|
---|
634 | $form .= '<option value="wordpress" ';
|
---|
635 | if ($this->meta_keyword_type == 'wordpress') $form .= ' selected="selected"';
|
---|
636 | $form .= '>'.__('WordPress KeyWord', 'xpressme') ."</option>\n";
|
---|
637 | $form .= '<option value="wordpress_xoops" ';
|
---|
638 | if ($this->meta_keyword_type == 'wordpress_xoops') $form .= ' selected="selected"';
|
---|
639 | $form .= '>'.__('WordPress & Xoops KeyWord', 'xpressme') ."</option>\n";
|
---|
640 | $form .= "</select><br />\n";
|
---|
641 | $form .= "</td>\n";
|
---|
642 | $form .= "</tr>\n";
|
---|
643 |
|
---|
644 | $form .= "<tr>\n";
|
---|
645 | $form .= "<td>" . __('Select the Header Description.', 'xpressme') . "</td>\n";
|
---|
646 | $form .= "<td>\n";
|
---|
647 | $form .= '<select name="ch_meta_description_type">' . "\n";
|
---|
648 | $form .= '<option value="xoops" ';
|
---|
649 | if ($this->meta_description_type == 'xoops') $form .= ' selected="selected"';
|
---|
650 | $form .= '>'.__('Xoops Description', 'xpressme') ."</option>\n";
|
---|
651 | $form .= '<option value="wordpress" ';
|
---|
652 | if ($this->meta_description_type == 'wordpress') $form .= ' selected="selected"';
|
---|
653 | $form .= '>'.__('WordPress Description', 'xpressme') ."</option>\n";
|
---|
654 | $form .= '<option value="wordpress_xoops" ';
|
---|
655 | if ($this->meta_description_type == 'wordpress_xoops') $form .= ' selected="selected"';
|
---|
656 | $form .= '>'.__('WordPress & Xoops Description', 'xpressme') ."</option>\n";
|
---|
657 | $form .= "</select><br />\n";
|
---|
658 | $form .= "</td>\n";
|
---|
659 | $form .= "</tr>\n";
|
---|
660 |
|
---|
661 | $form .= "<tr>\n";
|
---|
662 | $form .= "<td>" . __('Select the Header Robots Index.', 'xpressme') . "</td>\n";
|
---|
663 | $form .= "<td>\n";
|
---|
664 | $form .= '<select name="ch_meta_robot_type">' . "\n";
|
---|
665 | $form .= '<option value="xoops" ';
|
---|
666 | if ($this->meta_robot_type == 'xoops') $form .= ' selected="selected"';
|
---|
667 | $form .= '>'.__('Xoops Robots Index', 'xpressme') ."</option>\n";
|
---|
668 | $form .= '<option value="wordpress" ';
|
---|
669 | if ($this->meta_robot_type == 'wordpress') $form .= ' selected="selected"';
|
---|
670 | $form .= '>'.__('WordPress Robots Index', 'xpressme') ."</option>\n";
|
---|
671 | $form .= "</select><br />\n";
|
---|
672 | $form .= "</td>\n";
|
---|
673 | $form .= "</tr>\n";
|
---|
674 |
|
---|
675 | $form .= "</table>\n";
|
---|
676 |
|
---|
677 | $form .= "</tr>\n";
|
---|
678 | return $form;
|
---|
679 | }
|
---|
680 |
|
---|
681 | function xpress_upload_filter($uploads)
|
---|
682 | {
|
---|
683 | global $xoops_config;
|
---|
684 | if ($this->is_use_xoops_upload_path){
|
---|
685 | $wordpress_dir = ABSPATH ;
|
---|
686 | $xoops_dir = $xoops_config->xoops_upload_path . '/';
|
---|
687 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
688 | $xoops_upload_url = $xoops_config->xoops_upload_url;
|
---|
689 |
|
---|
690 | @rmdir($uploads[path]); //remove wordpress side uploads_dir
|
---|
691 |
|
---|
692 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
693 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
694 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
695 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
696 |
|
---|
697 | // Make sure we have an uploads dir
|
---|
698 | if ( ! wp_mkdir_p( $uploads[path] ) ) {
|
---|
699 | $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads[path] );
|
---|
700 | return array( 'error' => $message );
|
---|
701 | }
|
---|
702 | }
|
---|
703 | return $uploads;
|
---|
704 | }
|
---|
705 |
|
---|
706 | // SQL DEBUG TEST
|
---|
707 | function is_sql_debug_permission()
|
---|
708 | {
|
---|
709 | global $current_user;
|
---|
710 |
|
---|
711 | if (!is_object($current_user)) return false;
|
---|
712 | if ($this->is_sql_debug && ($current_user->user_level >= 10))
|
---|
713 | return true;
|
---|
714 | else
|
---|
715 | return false;
|
---|
716 | }
|
---|
717 |
|
---|
718 | function xpress_sql_debug($query_strings)
|
---|
719 | {
|
---|
720 | if ($this->is_sql_debug_permission()){
|
---|
721 | if (empty($GLOBALS['XPress_SQL_Query'])) $GLOBALS['XPress_SQL_Query'] = '';
|
---|
722 | $GLOBALS['XPress_SQL_Query'] .= $query_strings . '<br /><br />';
|
---|
723 | }
|
---|
724 | return $query_strings;
|
---|
725 | }
|
---|
726 |
|
---|
727 | function displayDebugLog()
|
---|
728 | {
|
---|
729 | if ($this->is_sql_debug_permission()){
|
---|
730 | $content = '';
|
---|
731 | $content .= '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />';
|
---|
732 | $content .= '<meta http-equiv="content-language" content="'._LANGCODE.'" />' ;
|
---|
733 | $content .= '<title>XPressME SQL DEBUG</title>' ;
|
---|
734 | $content .= '</head><body>';
|
---|
735 | $content .= $GLOBALS['XPress_SQL_Query'];
|
---|
736 | $content .= '<div style="text-align:center;"><input class="formButton" value="CLOSE" type="button" onclick="javascript:window.close();" /></div></body></html>';
|
---|
737 |
|
---|
738 | echo '<script type="text/javascript">
|
---|
739 | <!--//
|
---|
740 | 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");
|
---|
741 | xpress_debug_window.document.clear();
|
---|
742 | xpress_debug_window.focus();
|
---|
743 | ';
|
---|
744 | $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
|
---|
745 | foreach ($lines as $line) {
|
---|
746 | echo 'xpress_debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
|
---|
747 | }
|
---|
748 | echo '
|
---|
749 | xpress_debug_window.document.close();
|
---|
750 | //-->
|
---|
751 | </script>';
|
---|
752 | }
|
---|
753 | }
|
---|
754 | }
|
---|
755 | ?> |
---|