XPressME Integration Kit

Trac

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

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

#14 マルチユーザーモードの実装

File size: 30.9 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        //constructor
32        function XPressME_Class()
33        {
34                global $xoops_db;
35               
36                $this->setdefault();    //not setting propaty load
37                $this->SettingValueRead();
38        }
39
40
41        function add_option_page()
42        {
43                add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
44        }
45       
46        function add_admin_head()
47        {
48                // add header text
49        }
50
51       
52                //Set Default Value     
53        function setDefault()
54        {
55                $this->is_use_xoops_upload_path = true;
56                $this->is_theme_sidebar_disp = false;
57                $this->is_save_post_revision = true;
58                $this->is_postnavi_title_disp = true;
59                $this->is_left_postnavi_old = true;
60                $this->old_post_link_text = __('Older Post', 'xpressme');
61                $this->newer_post_link_text = __('Newer Post', 'xpressme');
62                $this->is_left_page_navi_old = true;
63                $this->old_page_link_text = __('Older Entries', 'xpressme');
64                $this->newer_page_link_text = __('Newer Entries', 'xpressme');
65                $this->is_author_view_count = false;
66                $this->is_sql_debug = false;
67                $this->is_use_d3forum = false;
68                $this->d3forum_module_dir = '';
69                $this->d3forum_forum_id = '';
70                $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
71                $this->is_d3forum_flat = true;
72                $this->is_d3forum_desc = true;
73                $this->d3forum_views_num = 10;
74                $this->is_content_excerpt = true;
75                $this->ascii_judged_rate = 90;
76                $this->excerpt_length_word = 40;
77                $this->excerpt_length_character = 120;
78                $this->more_link_text = __('more', 'xpressme');
79                $this->viewer_type = 'xoops';
80                $this->is_multi_user = false;
81
82        }
83       
84        function SettingValueRead()
85        {
86                global $xoops_db;
87                $options = get_option('xpressme_option');
88                if (!$options) {
89                        $this->setDefault();
90                        $this->SettingValueWrite('add_new');
91                } else {
92                        foreach ($options as $option_name => $option_value){
93                                $this-> {$option_name} = $option_value;
94                        }
95                }
96                if (!empty($xoops_db))  // at install trap
97                        $this->GroupeRoleRead();
98        }
99       
100                // mode 0:add  1:update
101        function SettingValueWrite($mode)
102        {
103                $write_options = array (
104                        'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
105                        'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ,
106                        'is_save_post_revision' => $this->is_save_post_revision ,
107                        'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
108                        'is_left_postnavi_old' => $this->is_left_postnavi_old ,
109                        'old_post_link_text' => $this->old_post_link_text ,
110                        'newer_post_link_text' => $this->newer_post_link_text,
111                        'is_left_page_navi_old' => $this->is_left_page_navi_old ,
112                        'old_page_link_text' => $this->old_page_link_text ,
113                        'newer_page_link_text' => $this->newer_page_link_text,
114                        'is_author_view_count' => $this->is_author_view_count,
115                        'is_sql_debug' => $this->is_sql_debug,
116                        'is_use_d3forum' =>     $this->is_use_d3forum,
117                        'd3forum_module_dir' => $this->d3forum_module_dir,
118                        'd3forum_forum_id' => $this->d3forum_forum_id,
119                        'd3forum_external_link_format' => $this->d3forum_external_link_format,
120                        'is_d3forum_flat' => $this->is_d3forum_flat,
121                        'is_d3forum_desc' => $this->is_d3forum_desc,
122                        'd3forum_views_num' =>$this->d3forum_views_num,
123                        'is_content_excerpt' => $this->is_content_excerpt,
124                        'ascii_judged_rate' => $this->ascii_judged_rate,
125                        'excerpt_length_word' => $this->excerpt_length_word,
126                        'excerpt_length_character' => $this->excerpt_length_character,
127                        'more_link_text' => $this->more_link_text,
128                        'viewer_type' => $this->viewer_type,
129                        'is_multi_user' => $this->is_multi_user
130                );
131                if ($mode == 'add_new') {
132                        add_option('xpressme_option', $write_options);
133                } else {                       
134                        update_option("xpressme_option", $write_options);
135                }
136        }
137       
138        function GroupeRoleRead() {
139                global $xoops_db;
140               
141                // table sync
142                $table = get_wp_prefix() . 'group_role';
143                $xoops_group = get_xoops_prefix() . 'groups';
144                $xoops_group_permission = get_xoops_prefix() . 'group_permission';
145               
146                $module_id = get_xpress_modid();
147               
148                $sql=  "SELECT * FROM $table";
149                $before_groupes = $xoops_db->get_results($sql);
150               
151                $sql = "DELETE FROM $table";
152                $xoops_db->query($sql);
153               
154                $sql =  "SELECT *  FROM $xoops_group_permission WHERE gperm_itemid = $module_id";
155                $gperms = $xoops_db->get_results($sql);
156               
157                $sql =  "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";
158                $groupes = $xoops_db->get_results($sql);
159                $insert_sql = '';
160                foreach ($groupes as $groupe) {
161                        $parmsql =  "SELECT *  FROM $xoops_group_permission WHERE gperm_itemid = $module_id AND gperm_groupid = $groupe->groupid";
162                        $gperms = $xoops_db->get_results($parmsql);
163                        $parmission = '';
164                        foreach ($gperms as $gperm) {
165                                $parmission = $gperm->gperm_name;
166                                if ($parmission == 'module_admin') break;
167                        }
168                       
169                        if (!empty($parmission)){
170                                $role = '';
171                                foreach ($before_groupes as $before_groupe) {
172                                        if ($groupe->groupid == $before_groupe->groupid) {
173                                                $role = $before_groupe->role;
174                                                $login_all = $before_groupe->login_all;
175                                        }
176                                }
177                                if ($parmission == 'module_admin') $role = 'administrator';
178                               
179                                $insert_sql  = "INSERT INTO  $table ";
180                                $insert_sql .= "(groupid , name , description , group_type , role , login_all) ";
181                                $insert_sql .= "VALUES (";
182                                $insert_sql .= $groupe->groupid . ', ';
183                                $insert_sql .= "'" . $groupe->name . "' , ";
184                                $insert_sql .= "'" . $groupe->description . "' , ";
185                                $insert_sql .= "'" . $parmission . "' , ";
186                                $insert_sql .= "'" . $role . "' , '";
187                                $insert_sql .= $login_all . "')";
188                                $xoops_db->query($insert_sql);
189                        }
190                }
191               
192                $sql=  "SELECT * FROM $table";
193               
194                $this->groupe_role =  $xoops_db->get_results($sql);
195                        $sql=  "SELECT * FROM $table"; 
196        }
197       
198        function ReadPostData()
199        {
200                $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
201                $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
202                $this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
203                $this->is_postnavi_title_disp = stripslashes(trim($_POST['ch_is_postnavi_title_disp']));
204                $this->is_left_postnavi_old = stripslashes(trim($_POST['ch_is_left_postnavi_old']));
205                $this->old_post_link_text = stripslashes($_POST['ch_old_post_link_text']);
206                if(empty($this->old_post_link_text)) $this->old_post_link_text = __('Older Post', 'xpressme');
207                $this->newer_post_link_text = stripslashes($_POST['ch_newer_post_link_text']);
208                if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('Newer Post', 'xpressme');
209                $this->is_left_page_navi_old = stripslashes(trim($_POST['ch_is_left_page_navi_old']));
210                $this->old_page_link_text = stripslashes($_POST['ch_old_page_link_text']);
211                if(empty($this->old_page_link_text)) $this->old_page_link_text = __('Older Entries', 'xpressme');
212                $this->newer_page_link_text = stripslashes($_POST['ch_newer_page_link_text']);
213                if(empty($this->newer_page_link_text)) $this->newer_page_link_text = __('Newer Entries', 'xpressme');
214                $this->is_author_view_count = stripslashes(trim($_POST['ch_is_author_view_count']));
215                $this->is_sql_debug = stripslashes(trim($_POST['ch_is_sql_debug']));
216                //d3forum
217                $d3forum_select = stripslashes(trim($_POST['ch_d3forum']));
218                if ($d3forum_select == 'none') {
219                        $this->is_use_d3forum = false;
220                        $this->d3forum_module_dir = '';
221                        $this->d3forum_forum_id = '';
222                        $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
223                } else {
224                        $d3f_set = explode('|', $d3forum_select);
225                        $this->is_use_d3forum = true;
226                        $this->d3forum_module_dir = $d3f_set[1];
227                        $this->d3forum_forum_id = $d3f_set[2];
228                        $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
229                }
230                $this->is_d3forum_flat = stripslashes(trim($_POST['ch_d3forum_type']));
231                $this->is_d3forum_desc = stripslashes(trim($_POST['ch_d3forum_order']));
232                $this->d3forum_views_num = stripslashes(trim($_POST['ch_d3forum_view_num']));
233               
234                $this->is_content_excerpt = stripslashes(trim($_POST['ch_is_content_excerpt']));
235                $this->ascii_judged_rate = stripslashes(trim($_POST['ch_ascii_judged_rate']));
236                $this->excerpt_length_word = stripslashes(trim($_POST['ch_excerpt_length_word']));
237                $this->excerpt_length_character = stripslashes(trim($_POST['ch_excerpt_length_character']));
238                $this->more_link_text = stripslashes(trim($_POST['ch_more_link_text']));
239                $this->viewer_type = stripslashes(trim($_POST['ch_viewer_type']));
240                $this->is_multi_user = stripslashes(trim($_POST['ch_is_multi_user']));
241                global $xoops_db;
242                $table = get_wp_prefix() . 'group_role';       
243//              $sql=  "SELECT * FROM $table"; 
244//              $this->groupe_role =  $xoops_db->get_results($sql);  // before Read
245               
246                foreach ($this->groupe_role as $groupe) {
247                        $post_name = 'role_gid_' . $groupe->groupid;
248                        $role = stripslashes(trim($_POST[$post_name]));
249                        $post_name = 'login_all_gid_' . $groupe->groupid;
250                        $login_all = stripslashes(trim($_POST[$post_name]));
251                        if (empty($login_all)) $login_all = '0';
252                        $groupe->role = $role;
253                        $groupe->login_all = $login_all;
254                        $update_sql  = "UPDATE  $table ";
255                        $update_sql .= 'SET ';
256                        $update_sql .= "role  = '$role' , ";
257                        $update_sql .= "login_all  = $login_all ";
258                        $update_sql .= "WHERE (groupid = '$groupe->groupid' )";
259                        $xoops_db->query($update_sql);                 
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;
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                $forum_list .= '<option value="none"' . $selected . '>' . __('Do Not Comment Integration.', 'xpressme') . "</option>\n";
472
473                // Form making for forum selection of D3forum
474                $modules_table = get_xoops_prefix() .'modules';
475                $sql = "SELECT mid,name,isactive,dirname FROM $modules_table WHERE isactive = 1";
476                $modules = $xoops_db->get_results($sql);
477                foreach ($modules as $module) {
478                        $file_path = $module_dir_path . '/modules/' . $module->dirname . '/mytrustdirname.php';                 
479                        if (! file_exists($file_path)) continue;
480                        $array_files = file($file_path);
481                        // It is checked whether there is character string "$mytrustdirname ='d3forum'"in the file.
482                        foreach ($array_files as $aeey_file){
483                                if( preg_match( "/\s*(mytrustdirname)\s*(=)\s*([\"'])(d3forum)([\"'])/", $aeey_file ) ) {
484                                        $forums_tb = get_xoops_prefix() . $module->dirname . '_forums';
485                                        $cat_tb = get_xoops_prefix() . $module->dirname . '_categories';
486                                        $sql= "SELECT * FROM $forums_tb LEFT JOIN $cat_tb ON $forums_tb.cat_id = $cat_tb.cat_id";
487                                        $forums = $xoops_db->get_results($sql);
488                                        foreach ($forums as $forum) {
489                                                if (($module->dirname == $this->d3forum_module_dir) &&  ($forum->forum_id == $this->d3forum_forum_id))
490                                                        $selected = ' selected="selected"';
491                                                else
492                                                        $selected = '';
493                                                $forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id;
494                                                $forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)";
495                                                $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
496                                        }
497                                        break;
498                                }
499                        }
500                        $forum_list .= '<br>';                 
501                }
502                $forum_list .= '</select>' . "\n";
503
504                $form  = '<tr>' . "\n";
505                $form .= '<th><label for="d3forum">' .__('Comment integration with D3Forum', 'xpressme') . '</label></th>' . "\n";
506                $form .=  "<td>\n";
507                $form .=  __('Select the forum of D3Forum that does the comment integration from the following lists.', 'xpressme') ."<br />\n";
508                $form .=  $forum_list."\n";
509                $form .= '<br /><br />';
510                if ($this->is_use_d3forum)  $disible = ''; else $disible = 'disabled';
511                $form .=  __('Select the Type of display of D3Forum comment.', 'xpressme') . " \n&emsp";
512                if ($this->is_d3forum_flat){
513                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='1' checked='checked' />" . __('Flat','xpressme') ."</label>\n";
514                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='0' />". __('Threaded','xpressme') . "</label>\n";
515                }else{
516                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='1' />" . __('Flat','xpressme') . "</label>\n";
517                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_type' value='0' checked='checked' />". __('Threaded','xpressme') ."</label>\n";
518                }
519                $form .= '<br />';
520                $form .=  __('Select the order of display of D3Forum comment.', 'xpressme') . " \n&emsp";
521                if ($this->is_d3forum_desc){
522                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='1' checked='checked' />" . __('DESC','xpressme') ."</label>\n";
523                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='0' />". __('ASC','xpressme') . "</label>\n";
524                }else{
525                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='1' />" . __('DESC','xpressme') . "</label>\n";
526                        $form .= "&ensp<label><input type='radio' name='ch_d3forum_order' value='0' checked='checked' />". __('ASC','xpressme') ."</label>\n";
527                }
528                $form .= '<br />';
529                $form .=  __('Number of displays of D3Forum comments.', 'xpressme') ." \n";
530                $form .= '&emsp<label> <input name="ch_d3forum_view_num" type="text" size="3" maxlength="3" value="'  . $this->d3forum_views_num . '" /></label>'."\n";
531
532                $form .= '<div class="submit">'."\n";           
533                $form .=  __('The import and the export between Wordpress Comments and the D3Forum Posts can be done. ', 'xpressme') ."<br />\n";
534                $form .= '<input type="submit" value= "' . __('Export to D3Forum', 'xpressme') . '" name="export_d3f" ' . $disible . ' >' ."\n";
535                $form .= '<input type="submit" value= "' . __('Import from D3Forum', 'xpressme') . '" name="inport_d3f" ' . $disible . ' >' ."<br />\n";
536                $form .= '</div>'."\n";
537                if (!empty($do_message)){
538                        $form .= '<div>' . $do_message . '</div>';
539                }
540                $form .=  "</td>\n";
541                $form .=  "</tr><tr>\n";
542                return $form;
543        }
544       
545        function excerpt_option(){
546                $form = '';
547                $form .= '<tr><th><label for="excerpt">' .__('Contents Excerpt Setting', 'xpressme') . '</label></th>';
548                $form .= "<td>\n";
549                $form .= "<table>\n";
550                $form .= "<tr>\n";
551               
552                $form .= "<td>" . __('Is the excerpt display done with the archive of contents?','xpressme') . "</td>\n";               
553                $form .= "<td>\n";
554                $form .=  $this->yes_no_radio_option_sub('is_content_excerpt');
555                $form .= "</td>\n";
556                $form .= "</tr>\n";
557               
558                $form .= "<tr>\n";
559                $form .= "<td>" . __('When ASCII character more than the set ratio is included, it is judged ASCII contents. ','xpressme') . "</td>\n";         
560                $form .= "<td>\n";
561                $form .=  $this->text_option_sub('ascii_judged_rate');
562                $form .= "</td>\n";
563                $form .= "</tr>\n";
564               
565                $form .= "<tr>\n";
566                $form .= "<td>" . __('Excerpt length of word for ASCII contents','xpressme') . "</td>\n";               
567                $form .= "<td>\n";
568                $form .=  $this->text_option_sub('excerpt_length_word');
569                $form .= "</td>\n";
570                $form .= "</tr>\n";
571               
572                $form .= "<tr>\n";
573                $form .= "<td>" . __('Excerpt length of character for multibyte contents','xpressme') . "</td>\n";             
574                $form .= "<td>\n";
575                $form .=  $this->text_option_sub('excerpt_length_character');
576                $form .= "</td>\n";
577                $form .= "</tr>\n";
578
579                $form .= "<tr>\n";
580                $form .= "<td>" . __('More Link Text (Is not displayed for the blank.)','xpressme') . "</td>\n";               
581                $form .= "<td>\n";
582                $form .=  $this->text_option_sub('more_link_text');
583                $form .= "</td>\n";
584                $form .= "</tr>\n";
585
586                $form .= "</table></td></tr>\n";
587            return $form;
588        }
589
590        function viewer_type_option(){
591                $form  = "<tr>\n";
592                $form .= '<th><label for="viewer_type">' .__('Display Mode Setting', 'xpressme') . '</label></th>';
593                $form .= "<td>\n";
594               
595                $form .=  __('Select the XPressME Display Mode.', 'xpressme') ."\n";
596                $form .= '<select name="ch_viewer_type">' . "\n";
597               
598                $form .= '<option value="xoops" ';
599                if ($this->viewer_type == 'xoops') $form .= ' selected="selected"';
600                $form .= '>'.__('Xoops Mode', 'xpressme') ."</option>\n";
601
602                $form .= '<option value="wordpress" ';
603                if ($this->viewer_type == 'wordpress') $form .= ' selected="selected"';
604                $form .= '>'.__('WordPress Mode', 'xpressme') ."</option>\n";
605               
606                $form .= '<option value="user_select" ';
607                if ($this->viewer_type == 'user_select') $form .= ' selected="selected"';
608                $form .= '>'.__('User select', 'xpressme') ."</option>\n";
609
610                $form .= "</select><br />\n";
611               
612                $form .= "</td></tr>\n";
613            return $form;
614        }
615
616        function option_page()
617        {
618                $do_message ='';
619                if (!empty($_POST['submit_update'])) {
620                        $this->ReadPostData();
621                        $this->SettingValueWrite('update');
622                } else if (isset($_POST['submit_reset'])) {
623                        $this->setDefault();
624                        $this->SettingValueWrite('update');
625                } else if (isset($_POST['export_d3f'])) {
626                        $do_message  = 'export(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
627                        $do_message .= wp_to_d3forum($this->d3forum_forum_id, $this->d3forum_module_dir);
628                        $do_message .= '....END';
629                } else if (isset($_POST['inport_d3f'])) {
630                        $do_message  = 'Import(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
631                        $do_message .= d3forum_to_wp($this->d3forum_forum_id, $this->d3forum_module_dir);
632                        $do_message .= '....END';
633                }               
634               
635                echo    '<div class="wrap">'."\n";
636                echo            '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
637                echo            '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
638                echo            '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
639                echo                    '<table class="form-table">'."\n";
640                echo                            $this->viewer_type_option();
641                echo                            $this->yes_no_radio_option('is_use_xoops_upload_path',
642                                                                                                __('Media Upload Base Path','xpressme'),
643                                                                                                __('Use XOOPS UPLOAD PATH','xpressme'),
644                                                                                                __('USE WordPress BASE_PATH','xpressme')
645                                                                                                );
646                echo                            $this->yes_no_radio_option('is_theme_sidebar_disp',
647                                                                                                __('Thema Sidebar Display','xpressme'),
648                                                                                                __('YES','xpressme'),
649                                                                                                __('NO','xpressme')
650                                                                                                );
651                echo                            $this->yes_no_radio_option('is_save_post_revision',
652                                                                                                __('The change tracking of the post is preserved','xpressme'),
653                                                                                                __('YES','xpressme'),
654                                                                                                __('NO','xpressme')
655                                                                                                );
656               
657                echo                            $this->yes_no_radio_option('is_multi_user',
658                                                                                                __('Select Multi user mode','xpressme'),
659                                                                                                __('YES','xpressme'),
660                                                                                                __('NO','xpressme')
661                                                                                                );
662               
663               
664                echo                            $this->single_post_navi_option();
665                echo                            $this->posts_page_navi_option();
666                echo                            $this->excerpt_option();
667               
668                echo                            $this->yes_no_radio_option('is_author_view_count',
669                                                                                                __('Is the posts author views counted?','xpressme'),
670                                                                                                __('YES','xpressme'),
671                                                                                                __('NO','xpressme')             
672                                                                                                );
673                echo                            $this->yes_no_radio_option('is_sql_debug',
674                                                                                                __('Is SQL debugging window displayed?','xpressme'),
675                                                                                                __('YES','xpressme'),
676                                                                                                __('NO','xpressme')             
677                                                                                                );
678               
679                echo                            $this->groupe_role_option();           
680               
681                echo                            $this->d3forum_option($do_message);             
682//              $this->is_use_xoops_upload_path_html();
683                echo                    "</table>\n";
684               
685                echo            '<p class="submit">'."\n";
686                echo            '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
687                echo            '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
688                echo            "</p>\n";
689
690                echo            "</form>\n" ;
691                echo    "</div>\n";
692        }
693       
694        function xpress_upload_filter($uploads)
695        {
696                global $xoops_config;
697                if ($this->is_use_xoops_upload_path){
698                        $wordpress_dir = ABSPATH ;
699                        $xoops_dir = $xoops_config->xoops_upload_path . '/';
700                        $wordpress_base_url = get_option( 'siteurl' );
701                        $xoops_upload_url = $xoops_config->xoops_upload_url;
702                       
703                        $uploads[path] =  str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
704                        $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
705                        $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
706                        $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
707                }
708                return $uploads;
709        }
710
711        // SQL DEBUG TEST
712        function is_sql_debug_permission()
713        {
714                global $current_user;
715
716                if (!is_object($current_user)) return false;
717                if ($this->is_sql_debug && ($current_user->user_level >= 10))
718                        return true;
719                else
720                        return false;
721        }
722       
723        function xpress_sql_debug($query_strings)
724        {
725                if ($this->is_sql_debug_permission()){
726                        if (empty($GLOBALS['XPress_SQL_Query'])) $GLOBALS['XPress_SQL_Query'] = '';
727                        $GLOBALS['XPress_SQL_Query'] .= $query_strings . '<br />';
728                }
729                return $query_strings;
730        }
731       
732        function displayDebugLog()
733        {
734                if ($this->is_sql_debug_permission()){
735                        $content = '';
736                        $content .= '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />';
737                        $content .= '<meta http-equiv="content-language" content="'._LANGCODE.'" />' ;
738                        $content .= '<title>XPressME SQL DEBUG</title>' ;
739                        $content .= '</head><body>';
740                        $content .= $GLOBALS['XPress_SQL_Query'];
741                        $content .= '<div style="text-align:center;"><input class="formButton" value="CLOSE" type="button" onclick="javascript:window.close();" /></div></body></html>';
742
743                        echo '<script type="text/javascript">
744                                <!--//
745                                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");
746                                xpress_debug_window.document.clear();
747                                xpress_debug_window.focus();
748                                ';
749                        $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
750                        foreach ($lines as $line) {
751                                echo 'xpress_debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
752                        }
753                        echo '
754                                xpress_debug_window.document.close();
755                                //-->
756                        </script>';
757                }
758        }       
759       
760        function set_d3forum_external_link_format()
761        {
762                global $xoops_db;
763/*              var $is_use_d3forum;
764                var $d3forum_module_dir;
765                var $d3forum_forum_id;
766                var $d3forum_external_link_format;
767                if ($this->$is_use_d3forum){
768                        $content = '';
769                        $content .= '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />';
770                        $content .= '<meta http-equiv="content-language" content="'._LANGCODE.'" />' ;
771                        $content .= '<title>XPressME SQL DEBUG</title>' ;
772                        $content .= '</head><body>';
773                        $content .= $GLOBALS['XPress_SQL_Query'];
774                        $content .= '<div style="text-align:center;"><input class="formButton" value="CLOSE" type="button" onclick="javascript:window.close();" /></div></body></html>';
775
776                        echo '<script type="text/javascript">
777                                <!--//
778                                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");
779                                xpress_debug_window.document.clear();
780                                xpress_debug_window.focus();
781                                ';
782                        $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
783                        foreach ($lines as $line) {
784                                echo 'xpress_debug_window.document.writeln("'.str_replace('"', '\"', $line).'");';
785                        }
786                        echo '
787                                xpress_debug_window.document.close();
788                                //-->
789                        </script>';
790                }
791*/
792        }       
793
794}
795?>
Note: See TracBrowser for help on using the repository browser.