XPressME Integration Kit

Trac

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

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

抜粋のロジックを、wp-multibyte-patchと同等の処理を行うようにする。 #82
XOOPS,WordPressの表示切替(ユーザ選択)機能 #11
bump Ver0.20

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