[19] | 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;
|
---|
[26] | 8 | var $is_theme_sidebar_disp;
|
---|
[28] | 9 | var $is_save_post_revision;
|
---|
[32] | 10 | var $is_postnavi_title_disp;
|
---|
| 11 | var $is_left_postnavi_old;
|
---|
| 12 | var $old_post_link_text;
|
---|
| 13 | var $newer_post_link_text;
|
---|
[51] | 14 | var $is_author_view_count;
|
---|
[76] | 15 | var $groupe_role_serial;
|
---|
| 16 | var $groupe_role;
|
---|
[32] | 17 |
|
---|
[19] | 18 | //constructor
|
---|
[20] | 19 | function XPressME_Class()
|
---|
[19] | 20 | {
|
---|
[76] | 21 | global $xoops_db;
|
---|
| 22 |
|
---|
[19] | 23 | $this->setdefault(); //not setting propaty load
|
---|
| 24 | $this->SettingValueRead();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | function add_option_page()
|
---|
| 29 | {
|
---|
| 30 | add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | function add_admin_head()
|
---|
| 34 | {
|
---|
| 35 | // add header text
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | //Set Default Value
|
---|
| 40 | function setDefault()
|
---|
| 41 | {
|
---|
| 42 | $this->is_use_xoops_upload_path = true;
|
---|
[26] | 43 | $this->is_theme_sidebar_disp = true;
|
---|
[28] | 44 | $this->is_save_post_revision = true;
|
---|
[32] | 45 | $this->is_postnavi_title_disp = true;
|
---|
| 46 | $this->is_left_postnavi_old = true;
|
---|
| 47 | $this->old_post_link_text = __('to Old Post');
|
---|
| 48 | $this->newer_post_link_text = __('to Newer Post');
|
---|
[51] | 49 | $this->is_author_view_count = false;
|
---|
[19] | 50 | }
|
---|
| 51 |
|
---|
| 52 | function SettingValueRead()
|
---|
| 53 | {
|
---|
[76] | 54 | global $xoops_db;
|
---|
[19] | 55 | $options = get_option('xpressme_option');
|
---|
| 56 | if (!$options) {
|
---|
| 57 | $this->setDefault();
|
---|
| 58 | $this->SettingValueWrite('add_new');
|
---|
| 59 | } else {
|
---|
| 60 | foreach ($options as $option_name => $option_value){
|
---|
| 61 | $this-> {$option_name} = $option_value;
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | // mode 0:add 1:update
|
---|
| 67 | function SettingValueWrite($mode)
|
---|
| 68 | {
|
---|
| 69 | $write_options = array (
|
---|
[26] | 70 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
[32] | 71 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ,
|
---|
| 72 | 'is_save_post_revision' => $this->is_save_post_revision ,
|
---|
| 73 | 'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
|
---|
| 74 | 'is_left_postnavi_old' => $this->is_left_postnavi_old ,
|
---|
| 75 | 'old_post_link_text' => $this->old_post_link_text ,
|
---|
[51] | 76 | 'newer_post_link_text' => $this->newer_post_link_text,
|
---|
[76] | 77 | 'is_author_view_count' => $this->is_author_view_count,
|
---|
| 78 | 'groupe_role_serial' => $this->$groupe_role_serial
|
---|
[19] | 79 | );
|
---|
| 80 | if ($mode == 'add_new') {
|
---|
| 81 | add_option('xpressme_option', $write_options);
|
---|
| 82 | } else {
|
---|
| 83 | update_option("xpressme_option", $write_options);
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
[20] | 86 |
|
---|
[76] | 87 | function GroupeRoleRead() {
|
---|
| 88 | global $xoops_db;
|
---|
| 89 |
|
---|
| 90 | // table sync
|
---|
| 91 | $table = get_wp_prefix() . 'group_role';
|
---|
| 92 | $xoops_group = get_xoops_prefix() . 'groups';
|
---|
| 93 | $sql= "SELECT * FROM $table";
|
---|
| 94 | $before_groupes = $xoops_db->get_results($sql);
|
---|
| 95 |
|
---|
| 96 | $sql = "DELETE FROM $table";
|
---|
| 97 | $xoops_db->query($sql);
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | $sql= "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";
|
---|
| 101 | $groupes = $xoops_db->get_results($sql);
|
---|
| 102 | $insert_sql = '';
|
---|
| 103 | foreach ($groupes as $groupe) {
|
---|
| 104 | $role = '';
|
---|
| 105 | foreach ($before_groupes as $before_groupe) {
|
---|
| 106 | if ($groupe->groupid == $before_groupe->groupid) $role = $before_groupe->role;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | $insert_sql = "INSERT INTO $table ";
|
---|
| 110 | $insert_sql .= "(groupid , name , description , group_type , role) ";
|
---|
| 111 | $insert_sql .= "VALUES (";
|
---|
| 112 | $insert_sql .= $groupe->groupid . ', ';
|
---|
| 113 | $insert_sql .= "'" . $groupe->name . "' , ";
|
---|
| 114 | $insert_sql .= "'" . $groupe->description . "' , ";
|
---|
| 115 | $insert_sql .= "'" . $groupe->group_type . "' , ";
|
---|
| 116 | $insert_sql .= "'" . $role . "')";
|
---|
| 117 | $xoops_db->query($insert_sql);
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | $sql= "SELECT * FROM $table";
|
---|
| 121 |
|
---|
| 122 | $this->groupe_role = $xoops_db->get_results($sql);
|
---|
| 123 | $sql= "SELECT * FROM $table";
|
---|
| 124 | }
|
---|
| 125 |
|
---|
[20] | 126 | function ReadPostData()
|
---|
| 127 | {
|
---|
| 128 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
[26] | 129 | $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
|
---|
[28] | 130 | $this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
|
---|
[32] | 131 | $this->is_postnavi_title_disp = stripslashes(trim($_POST['ch_is_postnavi_title_disp']));
|
---|
| 132 | $this->is_left_postnavi_old = stripslashes(trim($_POST['ch_is_left_postnavi_old']));
|
---|
| 133 | $this->old_post_link_text = stripslashes($_POST['ch_old_post_link_text']);
|
---|
| 134 | if(empty($this->old_post_link_text)) $this->old_post_link_text = __('to Old Post');
|
---|
| 135 | $this->newer_post_link_text = stripslashes($_POST['ch_newer_post_link_text']);
|
---|
| 136 | if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('to Newer Post');
|
---|
[51] | 137 | $this->is_author_view_count = stripslashes(trim($_POST['ch_is_author_view_count']));
|
---|
[32] | 138 |
|
---|
[20] | 139 | }
|
---|
[21] | 140 |
|
---|
| 141 | function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
|
---|
[32] | 142 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
| 143 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
| 144 | $value = $this->{$option_name};
|
---|
| 145 | $ans_name = 'ch_' . $option_name;
|
---|
| 146 |
|
---|
| 147 | $form = "<tr>\n";
|
---|
| 148 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
| 149 | $form .= "<td>\n";
|
---|
| 150 | if ($value){
|
---|
| 151 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
|
---|
| 152 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
|
---|
| 153 | }else{
|
---|
| 154 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
|
---|
| 155 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
|
---|
| 156 | }
|
---|
| 157 | $form .= "</td>\n";
|
---|
| 158 | $form .= "</tr><tr>\n";
|
---|
| 159 |
|
---|
| 160 | return $form;
|
---|
[21] | 161 |
|
---|
| 162 | }
|
---|
[32] | 163 |
|
---|
| 164 | function text_option($option_name,$option_desc){
|
---|
| 165 | $value = $this->{$option_name};
|
---|
| 166 | $ans_name = 'ch_' . $option_name;
|
---|
[19] | 167 |
|
---|
[32] | 168 | $form = "<tr>\n";
|
---|
| 169 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
| 170 | $form .= "<td>\n";
|
---|
| 171 | $form .= '<label> <input name="'. $ans_name . '" type="text" size="25" maxlength="50" value="' . $value . '" /></label>'."\n";
|
---|
| 172 | $form .= "</td>\n";
|
---|
| 173 | $form .= "</tr><tr>\n";
|
---|
| 174 |
|
---|
| 175 | return $form;
|
---|
[21] | 176 |
|
---|
[32] | 177 | }
|
---|
[76] | 178 |
|
---|
| 179 | function groupe_role_option(){
|
---|
| 180 | global $wp_roles , $xoops_db;
|
---|
| 181 | $this->GroupeRoleRead();
|
---|
| 182 | // $table = get_xoops_prefix() . 'groups';
|
---|
| 183 | // $sql= "SELECT * FROM $table WHERE group_type <> 'Anonymous'";
|
---|
| 184 | // $groupes = array_diff($this->$groupe_role,array());
|
---|
[21] | 185 |
|
---|
[76] | 186 | $form = '';
|
---|
| 187 | $form .= '<tr><th><label for="role">' .__('Role Setting at Login') . '</label></th>';
|
---|
| 188 | $form .= '<td>';
|
---|
| 189 | $form .= "<table>\n";
|
---|
| 190 | $form .= '<tr><td>' . __('XOOPS Groupe') . '</td><td>' . __('WordPress Role') . '</td><td>' . __('Only First Login') . "</td></tr>\n";
|
---|
| 191 | foreach ($this->groupe_role as $groupe) {
|
---|
| 192 | $form .= "<tr>";
|
---|
| 193 | $form .= "<td> $groupe->name </td>";
|
---|
| 194 | $form .= "<td>\n" . '<select name="role_gid_'.$groupe->groupid . '" id="role_gid_' . $groupe->groupid . '">' . "\n";
|
---|
| 195 | $role_list = '';
|
---|
| 196 | $group_has_role = false;
|
---|
| 197 |
|
---|
| 198 | $select_value = $groupe->role;
|
---|
| 199 |
|
---|
| 200 | foreach($wp_roles->role_names as $role => $name) {
|
---|
| 201 | $name = translate_with_context($name);
|
---|
| 202 | if ( $role == $select_value) {
|
---|
| 203 | $selected = ' selected="selected"';
|
---|
| 204 | $group_has_role = true;
|
---|
| 205 | } else {
|
---|
| 206 | $selected = '';
|
---|
| 207 | }
|
---|
| 208 | $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>\n";
|
---|
| 209 | }
|
---|
| 210 | if ( $group_has_role )
|
---|
| 211 | $role_list .= '<option value="">' . __('— No role for this blog —') . "</option>\n";
|
---|
| 212 | else
|
---|
| 213 | $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . "</option>\n";
|
---|
| 214 | $form .= $role_list . "</select>\n</td></tr>\n";
|
---|
| 215 | }
|
---|
| 216 | $form .= "</table></td></tr>\n";
|
---|
| 217 | return $form;
|
---|
| 218 |
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[19] | 221 | function option_page()
|
---|
| 222 | {
|
---|
[76] | 223 | /*
|
---|
| 224 | $script = <<< _TAB_
|
---|
| 225 | <script type="text/javascript">
|
---|
| 226 | $(function() {
|
---|
| 227 | $('#jqtab-example2 > ul').tabs({fxFade:true,fxSpeed:'fast'});
|
---|
| 228 | });
|
---|
| 229 | </script>
|
---|
| 230 |
|
---|
| 231 | <div id="jqtab-example2">
|
---|
| 232 | <ul>
|
---|
| 233 | <li><a href="#tab2-1"><span>JavaScript</span></a></li>
|
---|
| 234 | <li><a href="#tab2-2"><span>Document</span></a></li>
|
---|
| 235 | <li><a href="#tab2-3"><span>Links</span></a></li>
|
---|
| 236 | </ul>
|
---|
| 237 |
|
---|
| 238 | <div id="tab2-1">
|
---|
| 239 | $('#jqtab-example1 > ul')<br>
|
---|
| 240 | .tabs({ fxFade: true, fxSpeed: 'fast' });
|
---|
| 241 | </div>
|
---|
| 242 |
|
---|
| 243 | <div id="tab2-2">
|
---|
| 244 | �E��E��E�\�E�b�E�htabs�E�̈��E��E�A�E�t�E�F�E�C�E�h�E�G�E�t�E�F�E�N�E�gfxFade�E�ƃG�E�t�E�F�E�N�E�g�E�X�E�s�E�[�E�hfxSpeed
|
---|
| 245 | ("slow", "normal", "fast" ,�E�܂��E�̓~�E��E��E�b) �E��E�w�E�肵�E�Ă��E�܂��E�B
|
---|
| 246 | </div>
|
---|
| 247 |
|
---|
| 248 | <div id="tab2-3">
|
---|
| 249 | �E�\�E�[�E�X
|
---|
| 250 | </div>
|
---|
| 251 | </div>;
|
---|
| 252 | _TAB_;
|
---|
| 253 |
|
---|
| 254 | echo $script;
|
---|
| 255 | */
|
---|
[20] | 256 | if (!empty($_POST['submit_update'])) {
|
---|
| 257 | $this->ReadPostData();
|
---|
| 258 | $this->SettingValueWrite('update');
|
---|
| 259 | } else if (isset($_POST['submit_reset'])) {
|
---|
| 260 | $this->fck_setDefault();
|
---|
| 261 | $this->SettingValueWrite('update');
|
---|
| 262 | }
|
---|
[19] | 263 |
|
---|
[20] | 264 |
|
---|
[21] | 265 | echo '<div class="wrap">'."\n";
|
---|
| 266 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
| 267 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
|
---|
| 268 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
| 269 | echo '<table class="form-table">'."\n";
|
---|
| 270 | echo $this->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
| 271 | __('Media Upload Base Path','xpressme'),
|
---|
| 272 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
[22] | 273 | __('USE WordPress BASE_PATH','xpressme')
|
---|
[21] | 274 | );
|
---|
[26] | 275 | echo $this->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
| 276 | __('Thema Sidebar Display','xpressme'),
|
---|
| 277 | __('YES','xpressme'),
|
---|
| 278 | __('NO','xpressme')
|
---|
| 279 | );
|
---|
[28] | 280 | echo $this->yes_no_radio_option('is_save_post_revision',
|
---|
| 281 | __('The change tracking of the post is preserved','xpressme'),
|
---|
| 282 | __('YES','xpressme'),
|
---|
| 283 | __('NO','xpressme')
|
---|
| 284 | );
|
---|
[32] | 285 | echo $this->yes_no_radio_option('is_postnavi_title_disp',
|
---|
| 286 | __('Select Display name of PostNavi Link','xpressme'),
|
---|
| 287 | __('Title of post','xpressme'),
|
---|
| 288 | __('Next and Previous','xpressme')
|
---|
| 289 | );
|
---|
| 290 | echo $this->yes_no_radio_option('is_left_postnavi_old',
|
---|
| 291 | __('Adjustment of Navi link display position','xpressme'),
|
---|
| 292 | __("'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right",'xpressme'),
|
---|
| 293 | __("'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right",'xpressme')
|
---|
| 294 | );
|
---|
| 295 | echo $this->text_option('old_post_link_text',
|
---|
| 296 | __('Display Title of Old Post Link','xpressme')
|
---|
| 297 | );
|
---|
| 298 | echo $this->text_option('newer_post_link_text',
|
---|
| 299 | __('Display Title of Newer Post Link','xpressme')
|
---|
[51] | 300 | );
|
---|
| 301 | echo $this->yes_no_radio_option('is_author_view_count',
|
---|
| 302 | __('Is the posts author views counted?','xpressme'),
|
---|
| 303 | __('YES','xpressme'),
|
---|
| 304 | __('NO','xpressme')
|
---|
[76] | 305 | );
|
---|
| 306 | echo $this->groupe_role_option();
|
---|
[21] | 307 | // $this->is_use_xoops_upload_path_html();
|
---|
| 308 | echo "</table>\n";
|
---|
[20] | 309 |
|
---|
[21] | 310 | echo '<p class="submit">'."\n";
|
---|
| 311 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
| 312 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
| 313 | echo "</p>\n";
|
---|
[19] | 314 |
|
---|
[21] | 315 | echo "</form>\n" ;
|
---|
| 316 | echo "</div>\n";
|
---|
[19] | 317 | }
|
---|
| 318 |
|
---|
| 319 | function xpress_upload_filter($uploads)
|
---|
| 320 | {
|
---|
| 321 | if ($this->is_use_xoops_upload_path){
|
---|
| 322 | if (!defined("XOOPS_UPLOAD_PATH"))
|
---|
| 323 | define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
|
---|
| 324 | if (!defined("XOOPS_UPLOAD_URL"))
|
---|
| 325 | define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
|
---|
| 326 |
|
---|
| 327 | $wordpress_dir = ABSPATH ;
|
---|
| 328 | $xoops_dir = XOOPS_UPLOAD_PATH . '/';
|
---|
| 329 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
| 330 | $xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
| 331 |
|
---|
| 332 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
| 333 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
| 334 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
| 335 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
| 336 | }
|
---|
| 337 | return $uploads;
|
---|
| 338 | }
|
---|
[28] | 339 |
|
---|
[19] | 340 | }
|
---|
| 341 | ?> |
---|