XPressME Integration Kit

Trac

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

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

言語ファイルのドメイン名指定忘れを修正

File size: 4.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       
9        //constructor
10        function XPressME_Class()
11        {
12                $this->setdefault();    //not setting propaty load
13                $this->SettingValueRead();
14        }
15
16
17        function add_option_page()
18        {
19                add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
20        }
21       
22        function add_admin_head()
23        {
24                // add header text
25        }
26
27       
28                //Set Default Value     
29        function setDefault()
30        {
31                $this->is_use_xoops_upload_path = true;
32        }
33       
34        function SettingValueRead()
35        {
36                $options = get_option('xpressme_option');
37                if (!$options) {
38                        $this->setDefault();
39                        $this->SettingValueWrite('add_new');
40                } else {
41                        foreach ($options as $option_name => $option_value){
42                                $this-> {$option_name} = $option_value;
43                        }
44                }
45        }
46       
47                // mode 0:add  1:update
48        function SettingValueWrite($mode)
49        {
50                $write_options = array (
51                        'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path
52                );
53                if ($mode == 'add_new') {
54                        add_option('xpressme_option', $write_options);
55                } else {                       
56                        update_option("xpressme_option", $write_options);
57                }
58        }
59       
60        function ReadPostData()
61        {
62                $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
63        }
64       
65        function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
66        if (empty( $yes ))  $yes = __('YES','xpressme') ;
67        if (empty( $no ))  $no = __('NO','xpressme') ;
68        $value = $this->{$option_name};
69        $ans_name = 'ch_' . $option_name;
70       
71        $form  =  "<tr>\n";
72        $form .=  '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
73        $form .=  "<td>\n";
74        if ($value){
75                $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
76                $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
77        }else{
78                $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
79                $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
80        }
81        $form .=  "</td>\n";
82        $form .=  "</tr><tr>\n";
83               
84    return $form;
85       
86}
87               
88        function option_page()
89        {
90                if (!empty($_POST['submit_update'])) {
91                        $this->ReadPostData();
92                        $this->SettingValueWrite('update');
93                } else if (isset($_POST['submit_reset'])) {
94                        $this->fck_setDefault();
95                        $this->SettingValueWrite('update');
96                }
97
98               
99                echo    '<div class="wrap">'."\n";
100                echo            '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
101                echo            '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
102                echo            '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
103                echo                    '<table class="form-table">'."\n";
104                echo                            $this->yes_no_radio_option('is_use_xoops_upload_path',
105                                                                                                __('Media Upload Base Path','xpressme'),
106                                                                                                __('Use XOOPS UPLOAD PATH','xpressme'),
107                                                                                                __('USE WordPress BASE_PATH','xpressme')
108                                                                                                );
109                       
110//              $this->is_use_xoops_upload_path_html();
111                echo                    "</table>\n";
112               
113                echo            '<p class="submit">'."\n";
114                echo            '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
115                echo            '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
116                echo            "</p>\n";
117
118                echo            "</form>\n" ;
119                echo    "</div>\n";
120        }
121       
122        function xpress_upload_filter($uploads)
123        {
124                if ($this->is_use_xoops_upload_path){
125                        if (!defined("XOOPS_UPLOAD_PATH"))
126                                define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
127                        if (!defined("XOOPS_UPLOAD_URL"))
128                                define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
129
130                        $wordpress_dir = ABSPATH ;
131                        $xoops_dir = XOOPS_UPLOAD_PATH . '/';
132                        $wordpress_base_url = get_option( 'siteurl' );
133                        $xoops_upload_url = XOOPS_UPLOAD_URL;
134                       
135                        $uploads[path] =  str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
136                        $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
137                        $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
138                        $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
139                }
140                return $uploads;
141        }       
142}
143?>
Note: See TracBrowser for help on using the repository browser.