XPressME Integration Kit

Trac

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

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

Bump Ver0.22 「ログイン時の権限設定」権限リストをグループタイプではなく
module_read(モジュールアクセス権限)のあるものはwordPressの全ての権限をリストし
module_admin(モジュール管理者権限)のあるものはwordPressの管理者権限だけをリストするようにする。
但しグループタイプがゲスト(Anonymous)のグループはリストから省く #86

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