XPressME Integration Kit

Trac

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

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

#119 キーワードやディスクリプションをXOOPS,WordPressいずれを使用すか選択するオプションを設ける。

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