[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;
|
---|
[19] | 9 |
|
---|
| 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;
|
---|
[19] | 34 | }
|
---|
| 35 |
|
---|
| 36 | function SettingValueRead()
|
---|
| 37 | {
|
---|
| 38 | $options = get_option('xpressme_option');
|
---|
| 39 | if (!$options) {
|
---|
| 40 | $this->setDefault();
|
---|
| 41 | $this->SettingValueWrite('add_new');
|
---|
| 42 | } else {
|
---|
| 43 | foreach ($options as $option_name => $option_value){
|
---|
| 44 | $this-> {$option_name} = $option_value;
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | // mode 0:add 1:update
|
---|
| 50 | function SettingValueWrite($mode)
|
---|
| 51 | {
|
---|
| 52 | $write_options = array (
|
---|
[26] | 53 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
| 54 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp
|
---|
[19] | 55 | );
|
---|
| 56 | if ($mode == 'add_new') {
|
---|
| 57 | add_option('xpressme_option', $write_options);
|
---|
| 58 | } else {
|
---|
| 59 | update_option("xpressme_option", $write_options);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
[20] | 62 |
|
---|
| 63 | function ReadPostData()
|
---|
| 64 | {
|
---|
| 65 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
[26] | 66 | $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
|
---|
[20] | 67 | }
|
---|
[21] | 68 |
|
---|
| 69 | function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
|
---|
| 70 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
| 71 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
| 72 | $value = $this->{$option_name};
|
---|
| 73 | $ans_name = 'ch_' . $option_name;
|
---|
| 74 |
|
---|
| 75 | $form = "<tr>\n";
|
---|
| 76 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
| 77 | $form .= "<td>\n";
|
---|
| 78 | if ($value){
|
---|
| 79 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
|
---|
| 80 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
|
---|
| 81 | }else{
|
---|
| 82 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
|
---|
| 83 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
|
---|
| 84 | }
|
---|
| 85 | $form .= "</td>\n";
|
---|
| 86 | $form .= "</tr><tr>\n";
|
---|
[19] | 87 |
|
---|
[21] | 88 | return $form;
|
---|
| 89 |
|
---|
| 90 | }
|
---|
| 91 |
|
---|
[19] | 92 | function option_page()
|
---|
| 93 | {
|
---|
[20] | 94 | if (!empty($_POST['submit_update'])) {
|
---|
| 95 | $this->ReadPostData();
|
---|
| 96 | $this->SettingValueWrite('update');
|
---|
| 97 | } else if (isset($_POST['submit_reset'])) {
|
---|
| 98 | $this->fck_setDefault();
|
---|
| 99 | $this->SettingValueWrite('update');
|
---|
| 100 | }
|
---|
[19] | 101 |
|
---|
[20] | 102 |
|
---|
[21] | 103 | echo '<div class="wrap">'."\n";
|
---|
| 104 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
| 105 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
|
---|
| 106 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
| 107 | echo '<table class="form-table">'."\n";
|
---|
| 108 | echo $this->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
| 109 | __('Media Upload Base Path','xpressme'),
|
---|
| 110 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
[22] | 111 | __('USE WordPress BASE_PATH','xpressme')
|
---|
[21] | 112 | );
|
---|
[26] | 113 | echo $this->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
| 114 | __('Thema Sidebar Display','xpressme'),
|
---|
| 115 | __('YES','xpressme'),
|
---|
| 116 | __('NO','xpressme')
|
---|
| 117 | );
|
---|
[21] | 118 |
|
---|
| 119 | // $this->is_use_xoops_upload_path_html();
|
---|
| 120 | echo "</table>\n";
|
---|
[20] | 121 |
|
---|
[21] | 122 | echo '<p class="submit">'."\n";
|
---|
| 123 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
| 124 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
| 125 | echo "</p>\n";
|
---|
[19] | 126 |
|
---|
[21] | 127 | echo "</form>\n" ;
|
---|
| 128 | echo "</div>\n";
|
---|
[19] | 129 | }
|
---|
| 130 |
|
---|
| 131 | function xpress_upload_filter($uploads)
|
---|
| 132 | {
|
---|
| 133 | if ($this->is_use_xoops_upload_path){
|
---|
| 134 | if (!defined("XOOPS_UPLOAD_PATH"))
|
---|
| 135 | define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
|
---|
| 136 | if (!defined("XOOPS_UPLOAD_URL"))
|
---|
| 137 | define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
|
---|
| 138 |
|
---|
| 139 | $wordpress_dir = ABSPATH ;
|
---|
| 140 | $xoops_dir = XOOPS_UPLOAD_PATH . '/';
|
---|
| 141 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
| 142 | $xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
| 143 |
|
---|
| 144 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
| 145 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
| 146 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
| 147 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
| 148 | }
|
---|
| 149 | return $uploads;
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
| 152 | ?> |
---|