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