XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php @ 252

Last change on this file since 252 was 252, checked in by toemon, 15 years ago

WordPressME2.0.11への対応,(ブロック周りは未完)

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