XPressME Integration Kit

Trac

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

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

投稿記事の履歴機能の有効・無効を設定できるようにする機能の実装 #39

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