[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;
|
---|
[19] | 10 | //constructor
|
---|
[20] | 11 | function XPressME_Class()
|
---|
[19] | 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;
|
---|
[26] | 33 | $this->is_theme_sidebar_disp = true;
|
---|
[28] | 34 | $this->is_save_post_revision = true;
|
---|
[19] | 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 (
|
---|
[26] | 54 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
| 55 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp
|
---|
[19] | 56 | );
|
---|
| 57 | if ($mode == 'add_new') {
|
---|
| 58 | add_option('xpressme_option', $write_options);
|
---|
| 59 | } else {
|
---|
| 60 | update_option("xpressme_option", $write_options);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
[20] | 63 |
|
---|
| 64 | function ReadPostData()
|
---|
| 65 | {
|
---|
| 66 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
[26] | 67 | $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
|
---|
[28] | 68 | $this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
|
---|
[20] | 69 | }
|
---|
[21] | 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";
|
---|
[19] | 89 |
|
---|
[21] | 90 | return $form;
|
---|
| 91 |
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[19] | 94 | function option_page()
|
---|
| 95 | {
|
---|
[20] | 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 | }
|
---|
[19] | 103 |
|
---|
[20] | 104 |
|
---|
[21] | 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'),
|
---|
[22] | 113 | __('USE WordPress BASE_PATH','xpressme')
|
---|
[21] | 114 | );
|
---|
[26] | 115 | echo $this->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
| 116 | __('Thema Sidebar Display','xpressme'),
|
---|
| 117 | __('YES','xpressme'),
|
---|
| 118 | __('NO','xpressme')
|
---|
| 119 | );
|
---|
[28] | 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 | );
|
---|
[21] | 125 |
|
---|
| 126 | // $this->is_use_xoops_upload_path_html();
|
---|
| 127 | echo "</table>\n";
|
---|
[20] | 128 |
|
---|
[21] | 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";
|
---|
[19] | 133 |
|
---|
[21] | 134 | echo "</form>\n" ;
|
---|
| 135 | echo "</div>\n";
|
---|
[19] | 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 | }
|
---|
[28] | 158 |
|
---|
[19] | 159 | }
|
---|
| 160 | ?> |
---|