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