setdefault(); //not setting propaty load $this->SettingValueRead(); } function add_option_page() { add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page')); } function add_admin_head() { // add header text } //Set Default Value function setDefault() { $this->is_use_xoops_upload_path = true; $this->is_theme_sidebar_disp = true; } function SettingValueRead() { $options = get_option('xpressme_option'); if (!$options) { $this->setDefault(); $this->SettingValueWrite('add_new'); } else { foreach ($options as $option_name => $option_value){ $this-> {$option_name} = $option_value; } } } // mode 0:add 1:update function SettingValueWrite($mode) { $write_options = array ( 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path , 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ); if ($mode == 'add_new') { add_option('xpressme_option', $write_options); } else { update_option("xpressme_option", $write_options); } } function ReadPostData() { $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path'])); $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp'])); } function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){ if (empty( $yes )) $yes = __('YES','xpressme') ; if (empty( $no )) $no = __('NO','xpressme') ; $value = $this->{$option_name}; $ans_name = 'ch_' . $option_name; $form = "\n"; $form .= '\n"; $form .= "\n"; if ($value){ $form .= "
\n"; $form .= "\n"; }else{ $form .= "
\n"; $form .= "\n"; } $form .= "\n"; $form .= "\n"; return $form; } function option_page() { if (!empty($_POST['submit_update'])) { $this->ReadPostData(); $this->SettingValueWrite('update'); } else if (isset($_POST['submit_reset'])) { $this->fck_setDefault(); $this->SettingValueWrite('update'); } echo '
'."\n"; echo '

'."\n"; echo '

' . __('XPressME Configuration Page', 'xpressme') . "

\n"; echo '
'."\n" ; echo ''."\n"; echo $this->yes_no_radio_option('is_use_xoops_upload_path', __('Media Upload Base Path','xpressme'), __('Use XOOPS UPLOAD PATH','xpressme'), __('USE WordPress BASE_PATH','xpressme') ); echo $this->yes_no_radio_option('is_theme_sidebar_disp', __('Thema Sidebar Display','xpressme'), __('YES','xpressme'), __('NO','xpressme') ); // $this->is_use_xoops_upload_path_html(); echo "
\n"; echo '

'."\n"; echo '' ."\n"; echo '' ."\n"; echo "

\n"; echo "
\n" ; echo "
\n"; } function xpress_upload_filter($uploads) { if ($this->is_use_xoops_upload_path){ if (!defined("XOOPS_UPLOAD_PATH")) define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads"); if (!defined("XOOPS_UPLOAD_URL")) define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads"); $wordpress_dir = ABSPATH ; $xoops_dir = XOOPS_UPLOAD_PATH . '/'; $wordpress_base_url = get_option( 'siteurl' ); $xoops_upload_url = XOOPS_UPLOAD_URL; $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]); $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]); $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]); $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]); } return $uploads; } } ?>