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