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 |
|
---|
15 | //constructor
|
---|
16 | function XPressME_Class()
|
---|
17 | {
|
---|
18 | $this->setdefault(); //not setting propaty load
|
---|
19 | $this->SettingValueRead();
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | function add_option_page()
|
---|
24 | {
|
---|
25 | add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
|
---|
26 | }
|
---|
27 |
|
---|
28 | function add_admin_head()
|
---|
29 | {
|
---|
30 | // add header text
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | //Set Default Value
|
---|
35 | function setDefault()
|
---|
36 | {
|
---|
37 | $this->is_use_xoops_upload_path = true;
|
---|
38 | $this->is_theme_sidebar_disp = true;
|
---|
39 | $this->is_save_post_revision = true;
|
---|
40 | $this->is_postnavi_title_disp = true;
|
---|
41 | $this->is_left_postnavi_old = true;
|
---|
42 | $this->old_post_link_text = __('to Old Post');
|
---|
43 | $this->newer_post_link_text = __('to Newer Post');
|
---|
44 | }
|
---|
45 |
|
---|
46 | function SettingValueRead()
|
---|
47 | {
|
---|
48 | $options = get_option('xpressme_option');
|
---|
49 | if (!$options) {
|
---|
50 | $this->setDefault();
|
---|
51 | $this->SettingValueWrite('add_new');
|
---|
52 | } else {
|
---|
53 | foreach ($options as $option_name => $option_value){
|
---|
54 | $this-> {$option_name} = $option_value;
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | // mode 0:add 1:update
|
---|
60 | function SettingValueWrite($mode)
|
---|
61 | {
|
---|
62 | $write_options = array (
|
---|
63 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
64 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ,
|
---|
65 | 'is_save_post_revision' => $this->is_save_post_revision ,
|
---|
66 | 'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
|
---|
67 | 'is_left_postnavi_old' => $this->is_left_postnavi_old ,
|
---|
68 | 'old_post_link_text' => $this->old_post_link_text ,
|
---|
69 | 'newer_post_link_text' => $this->newer_post_link_text
|
---|
70 | );
|
---|
71 | if ($mode == 'add_new') {
|
---|
72 | add_option('xpressme_option', $write_options);
|
---|
73 | } else {
|
---|
74 | update_option("xpressme_option", $write_options);
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | function ReadPostData()
|
---|
79 | {
|
---|
80 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
81 | $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
|
---|
82 | $this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
|
---|
83 | $this->is_postnavi_title_disp = stripslashes(trim($_POST['ch_is_postnavi_title_disp']));
|
---|
84 | $this->is_left_postnavi_old = stripslashes(trim($_POST['ch_is_left_postnavi_old']));
|
---|
85 | $this->old_post_link_text = stripslashes($_POST['ch_old_post_link_text']);
|
---|
86 | if(empty($this->old_post_link_text)) $this->old_post_link_text = __('to Old Post');
|
---|
87 | $this->newer_post_link_text = stripslashes($_POST['ch_newer_post_link_text']);
|
---|
88 | if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('to Newer Post');
|
---|
89 |
|
---|
90 | }
|
---|
91 |
|
---|
92 | function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
|
---|
93 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
94 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
95 | $value = $this->{$option_name};
|
---|
96 | $ans_name = 'ch_' . $option_name;
|
---|
97 |
|
---|
98 | $form = "<tr>\n";
|
---|
99 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
100 | $form .= "<td>\n";
|
---|
101 | if ($value){
|
---|
102 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
|
---|
103 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
|
---|
104 | }else{
|
---|
105 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
|
---|
106 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
|
---|
107 | }
|
---|
108 | $form .= "</td>\n";
|
---|
109 | $form .= "</tr><tr>\n";
|
---|
110 |
|
---|
111 | return $form;
|
---|
112 |
|
---|
113 | }
|
---|
114 |
|
---|
115 | function text_option($option_name,$option_desc){
|
---|
116 | $value = $this->{$option_name};
|
---|
117 | $ans_name = 'ch_' . $option_name;
|
---|
118 |
|
---|
119 | $form = "<tr>\n";
|
---|
120 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
121 | $form .= "<td>\n";
|
---|
122 | $form .= '<label> <input name="'. $ans_name . '" type="text" size="25" maxlength="50" value="' . $value . '" /></label>'."\n";
|
---|
123 | $form .= "</td>\n";
|
---|
124 | $form .= "</tr><tr>\n";
|
---|
125 |
|
---|
126 | return $form;
|
---|
127 |
|
---|
128 | }
|
---|
129 |
|
---|
130 | function option_page()
|
---|
131 | {
|
---|
132 | if (!empty($_POST['submit_update'])) {
|
---|
133 | $this->ReadPostData();
|
---|
134 | $this->SettingValueWrite('update');
|
---|
135 | } else if (isset($_POST['submit_reset'])) {
|
---|
136 | $this->fck_setDefault();
|
---|
137 | $this->SettingValueWrite('update');
|
---|
138 | }
|
---|
139 |
|
---|
140 |
|
---|
141 | echo '<div class="wrap">'."\n";
|
---|
142 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
143 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
|
---|
144 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
145 | echo '<table class="form-table">'."\n";
|
---|
146 | echo $this->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
147 | __('Media Upload Base Path','xpressme'),
|
---|
148 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
149 | __('USE WordPress BASE_PATH','xpressme')
|
---|
150 | );
|
---|
151 | echo $this->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
152 | __('Thema Sidebar Display','xpressme'),
|
---|
153 | __('YES','xpressme'),
|
---|
154 | __('NO','xpressme')
|
---|
155 | );
|
---|
156 | echo $this->yes_no_radio_option('is_save_post_revision',
|
---|
157 | __('The change tracking of the post is preserved','xpressme'),
|
---|
158 | __('YES','xpressme'),
|
---|
159 | __('NO','xpressme')
|
---|
160 | );
|
---|
161 | echo $this->yes_no_radio_option('is_postnavi_title_disp',
|
---|
162 | __('Select Display name of PostNavi Link','xpressme'),
|
---|
163 | __('Title of post','xpressme'),
|
---|
164 | __('Next and Previous','xpressme')
|
---|
165 | );
|
---|
166 | echo $this->yes_no_radio_option('is_left_postnavi_old',
|
---|
167 | __('Adjustment of Navi link display position','xpressme'),
|
---|
168 | __("'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right",'xpressme'),
|
---|
169 | __("'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right",'xpressme')
|
---|
170 | );
|
---|
171 | echo $this->text_option('old_post_link_text',
|
---|
172 | __('Display Title of Old Post Link','xpressme')
|
---|
173 | );
|
---|
174 | echo $this->text_option('newer_post_link_text',
|
---|
175 | __('Display Title of Newer Post Link','xpressme')
|
---|
176 | );
|
---|
177 |
|
---|
178 |
|
---|
179 | // $this->is_use_xoops_upload_path_html();
|
---|
180 | echo "</table>\n";
|
---|
181 |
|
---|
182 | echo '<p class="submit">'."\n";
|
---|
183 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
184 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
185 | echo "</p>\n";
|
---|
186 |
|
---|
187 | echo "</form>\n" ;
|
---|
188 | echo "</div>\n";
|
---|
189 | }
|
---|
190 |
|
---|
191 | function xpress_upload_filter($uploads)
|
---|
192 | {
|
---|
193 | if ($this->is_use_xoops_upload_path){
|
---|
194 | if (!defined("XOOPS_UPLOAD_PATH"))
|
---|
195 | define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
|
---|
196 | if (!defined("XOOPS_UPLOAD_URL"))
|
---|
197 | define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
|
---|
198 |
|
---|
199 | $wordpress_dir = ABSPATH ;
|
---|
200 | $xoops_dir = XOOPS_UPLOAD_PATH . '/';
|
---|
201 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
202 | $xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
203 |
|
---|
204 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
205 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
206 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
207 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
208 | }
|
---|
209 | return $uploads;
|
---|
210 | }
|
---|
211 |
|
---|
212 | }
|
---|
213 | ?> |
---|