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 = false;
$this->is_save_post_revision = true;
$this->is_postnavi_title_disp = true;
$this->is_left_postnavi_old = true;
$this->old_post_link_text = __('Older Post', 'xpressme');
$this->newer_post_link_text = __('Newer Post', 'xpressme');
$this->is_left_page_navi_old = true;
$this->old_page_link_text = __('Older Entries', 'xpressme');
$this->newer_page_link_text = __('Newer Entries', 'xpressme');
$this->is_author_view_count = false;
$this->is_sql_debug = false;
$this->is_use_d3forum = false;
$this->d3forum_module_dir = '';
$this->d3forum_forum_id = '';
$this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
$this->is_d3forum_flat = true;
$this->is_d3forum_desc = true;
$this->d3forum_views_num = 10;
$this->is_content_excerpt = true;
$this->ascii_judged_rate = 90;
$this->excerpt_length_word = 40;
$this->excerpt_length_character = 120;
$this->more_link_text = __('more', 'xpressme');
$this->viewer_type = 'xoops';
}
function SettingValueRead()
{
global $xoops_db;
$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;
}
}
if (!empty($xoops_db)) // at install trap
$this->GroupeRoleRead();
}
// 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 ,
'is_save_post_revision' => $this->is_save_post_revision ,
'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
'is_left_postnavi_old' => $this->is_left_postnavi_old ,
'old_post_link_text' => $this->old_post_link_text ,
'newer_post_link_text' => $this->newer_post_link_text,
'is_left_page_navi_old' => $this->is_left_page_navi_old ,
'old_page_link_text' => $this->old_page_link_text ,
'newer_page_link_text' => $this->newer_page_link_text,
'is_author_view_count' => $this->is_author_view_count,
'is_sql_debug' => $this->is_sql_debug,
'is_use_d3forum' => $this->is_use_d3forum,
'd3forum_module_dir' => $this->d3forum_module_dir,
'd3forum_forum_id' => $this->d3forum_forum_id,
'd3forum_external_link_format' => $this->d3forum_external_link_format,
'is_d3forum_flat' => $this->is_d3forum_flat,
'is_d3forum_desc' => $this->is_d3forum_desc,
'd3forum_views_num' =>$this->d3forum_views_num,
'is_content_excerpt' => $this->is_content_excerpt,
'ascii_judged_rate' => $this->ascii_judged_rate,
'excerpt_length_word' => $this->excerpt_length_word,
'excerpt_length_character' => $this->excerpt_length_character,
'more_link_text' => $this->more_link_text,
'viewer_type' => $this->viewer_type
);
if ($mode == 'add_new') {
add_option('xpressme_option', $write_options);
} else {
update_option("xpressme_option", $write_options);
}
}
function GroupeRoleRead() {
global $xoops_db;
// table sync
$table = get_wp_prefix() . 'group_role';
$xoops_group = get_xoops_prefix() . 'groups';
$sql= "SELECT * FROM $table";
$before_groupes = $xoops_db->get_results($sql);
$sql = "DELETE FROM $table";
$xoops_db->query($sql);
$sql= "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";
$groupes = $xoops_db->get_results($sql);
$insert_sql = '';
foreach ($groupes as $groupe) {
$role = '';
foreach ($before_groupes as $before_groupe) {
if ($groupe->groupid == $before_groupe->groupid) {
$role = $before_groupe->role;
$login_all = $before_groupe->login_all;
}
}
$insert_sql = "INSERT INTO $table ";
$insert_sql .= "(groupid , name , description , group_type , role , login_all) ";
$insert_sql .= "VALUES (";
$insert_sql .= $groupe->groupid . ', ';
$insert_sql .= "'" . $groupe->name . "' , ";
$insert_sql .= "'" . $groupe->description . "' , ";
$insert_sql .= "'" . $groupe->group_type . "' , ";
$insert_sql .= "'" . $role . "' , '";
$insert_sql .= $login_all . "')";
$xoops_db->query($insert_sql);
}
$sql= "SELECT * FROM $table";
$this->groupe_role = $xoops_db->get_results($sql);
$sql= "SELECT * FROM $table";
}
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']));
$this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
$this->is_postnavi_title_disp = stripslashes(trim($_POST['ch_is_postnavi_title_disp']));
$this->is_left_postnavi_old = stripslashes(trim($_POST['ch_is_left_postnavi_old']));
$this->old_post_link_text = stripslashes($_POST['ch_old_post_link_text']);
if(empty($this->old_post_link_text)) $this->old_post_link_text = __('Older Post', 'xpressme');
$this->newer_post_link_text = stripslashes($_POST['ch_newer_post_link_text']);
if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('Newer Post', 'xpressme');
$this->is_left_page_navi_old = stripslashes(trim($_POST['ch_is_left_page_navi_old']));
$this->old_page_link_text = stripslashes($_POST['ch_old_page_link_text']);
if(empty($this->old_page_link_text)) $this->old_page_link_text = __('Older Entries', 'xpressme');
$this->newer_page_link_text = stripslashes($_POST['ch_newer_page_link_text']);
if(empty($this->newer_page_link_text)) $this->newer_page_link_text = __('Newer Entries', 'xpressme');
$this->is_author_view_count = stripslashes(trim($_POST['ch_is_author_view_count']));
$this->is_sql_debug = stripslashes(trim($_POST['ch_is_sql_debug']));
//d3forum
$d3forum_select = stripslashes(trim($_POST['ch_d3forum']));
if ($d3forum_select == 'none') {
$this->is_use_d3forum = false;
$this->d3forum_module_dir = '';
$this->d3forum_forum_id = '';
$this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
} else {
$d3f_set = explode('|', $d3forum_select);
$this->is_use_d3forum = true;
$this->d3forum_module_dir = $d3f_set[1];
$this->d3forum_forum_id = $d3f_set[2];
$this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
}
$this->is_d3forum_flat = stripslashes(trim($_POST['ch_d3forum_type']));
$this->is_d3forum_desc = stripslashes(trim($_POST['ch_d3forum_order']));
$this->d3forum_views_num = stripslashes(trim($_POST['ch_d3forum_view_num']));
$this->is_content_excerpt = stripslashes(trim($_POST['ch_is_content_excerpt']));
$this->ascii_judged_rate = stripslashes(trim($_POST['ch_ascii_judged_rate']));
$this->excerpt_length_word = stripslashes(trim($_POST['ch_excerpt_length_word']));
$this->excerpt_length_character = stripslashes(trim($_POST['ch_excerpt_length_character']));
$this->more_link_text = stripslashes(trim($_POST['ch_more_link_text']));
$this->viewer_type = stripslashes(trim($_POST['ch_viewer_type']));
global $xoops_db;
$table = get_wp_prefix() . 'group_role';
// $sql= "SELECT * FROM $table";
// $this->groupe_role = $xoops_db->get_results($sql); // before Read
foreach ($this->groupe_role as $groupe) {
$post_name = 'role_gid_' . $groupe->groupid;
$role = stripslashes(trim($_POST[$post_name]));
$post_name = 'login_all_gid_' . $groupe->groupid;
$login_all = stripslashes(trim($_POST[$post_name]));
if (empty($login_all)) $login_all = '0';
$groupe->role = $role;
$groupe->login_all = $login_all;
$update_sql = "UPDATE $table ";
$update_sql .= 'SET ';
$update_sql .= "role = '$role' , ";
$update_sql .= "login_all = $login_all ";
$update_sql .= "WHERE (groupid = '$groupe->groupid' )";
$xoops_db->query($update_sql);
}
}
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 .= '' . $option_desc . " \n";
$form .= "\n";
$form .= $this->yes_no_radio_option_sub($option_name,$yes,$no);
$form .= " \n";
$form .= " \n";
return $form;
}
function yes_no_radio_option_sub($option_name,$yes = '',$no= ''){
if (empty( $yes )) $yes = __('YES','xpressme') ;
if (empty( $no )) $no = __('NO','xpressme') ;
$value = $this->{$option_name};
$ans_name = 'ch_' . $option_name;
if ($value){
$form .= " " . $yes ." \n";
$form .= " ". $no . " \n";
}else{
$form .= " " . $yes . " \n";
$form .= " ". $no ." \n";
}
return $form;
}
function text_option($option_name,$option_desc){
$value = $this->{$option_name};
$ans_name = 'ch_' . $option_name;
$form = "\n";
$form .= '' . $option_desc . " \n";
$form .= "\n";
$form .= $this->text_option_sub($option_name);
$form .= " \n";
$form .= " \n";
return $form;
}
function text_option_sub($option_name){
$value = $this->{$option_name};
$ans_name = 'ch_' . $option_name;
$form = ' '."\n";
return $form;
}
function single_post_navi_option(){
$form = '';
$form .= '' .__('Single Post Navi Setting', 'xpressme') . ' ';
$form .= "\n";
$form .= "\n";
$form .= "\n";
$form .= "" . __('Adjustment of Navi link display position','xpressme') . " \n";
$form .= "\n";
$form .= $this->yes_no_radio_option_sub('is_left_postnavi_old',
__("'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right",'xpressme'),
__("'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right",'xpressme')
);
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Select Display name of PostNavi Link','xpressme') . " \n";
$form .= "\n";
$form .= $this->yes_no_radio_option_sub('is_postnavi_title_disp',
__('Title of post','xpressme'),
__('Title of Navi','xpressme')
);
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Display Navi Title of Old Post Link','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('old_post_link_text');
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Display Navi Title of Newer Post Link','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('newer_post_link_text');
$form .= " \n";
$form .= " \n";
$form .= "
\n";
return $form;
}
function posts_page_navi_option(){
$form = '';
$form .= '' .__('Posts List Page Navi Setting', 'xpressme') . ' ';
$form .= "\n";
$form .= "\n";
$form .= "\n";
$form .= "" . __('Adjustment of Navi link display position','xpressme') . " \n";
$form .= "\n";
$form .= $this->yes_no_radio_option_sub('is_left_page_navi_old',
__("'Old Page Link' is displayed in the left, and 'Newer Page Link' is displayed in the right",'xpressme'),
__("'Newer Page Link' is displayed in the left, and 'Old Page Link' is displayed in the right",'xpressme')
);
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Display Navi Title of Old Page Link','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('old_page_link_text');
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Display Navi Title of Newer Page Link','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('newer_page_link_text');
$form .= " \n";
$form .= " \n";
$form .= "
\n";
return $form;
}
function groupe_role_option(){
global $wp_roles , $xoops_db;
$form = '';
$form .= '' .__('Role Setting at Login', 'xpressme') . ' ';
$form .= '';
$form .= " \n";
return $form;
}
function d3forum_option($do_message = ''){
global $xoops_db;
$d3frum_list = array();
$module_dir_path = get_xoops_root_path();
$forum_list = '' . "\n";
if ($this->is_use_d3forum != true)
$selected = ' selected="selected"';
else
$selected = '';
$forum_list .= '' . __('Do Not Comment Integration.', 'xpressme') . " \n";
// Form making for forum selection of D3forum
$modules_table = get_xoops_prefix() .'modules';
$sql = "SELECT mid,name,isactive,dirname FROM $modules_table WHERE isactive = 1";
$modules = $xoops_db->get_results($sql);
foreach ($modules as $module) {
$file_path = $module_dir_path . '/modules/' . $module->dirname . '/mytrustdirname.php';
if (! file_exists($file_path)) continue;
$array_files = file($file_path);
// It is checked whether there is character string "$mytrustdirname ='d3forum'"in the file.
foreach ($array_files as $aeey_file){
if( preg_match( "/\s*(mytrustdirname)\s*(=)\s*([\"'])(d3forum)([\"'])/", $aeey_file ) ) {
$forums_tb = get_xoops_prefix() . $module->dirname . '_forums';
$cat_tb = get_xoops_prefix() . $module->dirname . '_categories';
$sql= "SELECT * FROM $forums_tb LEFT JOIN $cat_tb ON $forums_tb.cat_id = $cat_tb.cat_id";
$forums = $xoops_db->get_results($sql);
foreach ($forums as $forum) {
if (($module->dirname == $this->d3forum_module_dir) && ($forum->forum_id == $this->d3forum_forum_id))
$selected = ' selected="selected"';
else
$selected = '';
$forum_div = 'forum|' . $module->dirname . '|' . $forum->forum_id;
$forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)";
$forum_list .= '' . $forum_select . " \n";
}
break;
}
}
$forum_list .= ' ';
}
$forum_list .= ' ' . "\n";
$form = '' . "\n";
$form .= '' .__('Comment integration with D3Forum', 'xpressme') . ' ' . "\n";
$form .= "\n";
$form .= __('Select the forum of D3Forum that does the comment integration from the following lists.', 'xpressme') ." \n";
$form .= $forum_list."\n";
$form .= ' ';
if ($this->is_use_d3forum) $disible = ''; else $disible = 'disabled';
$form .= __('Select the Type of display of D3Forum comment.', 'xpressme') . " \n&emsp";
if ($this->is_d3forum_flat){
$form .= "&ensp " . __('Flat','xpressme') ." \n";
$form .= "&ensp ". __('Threaded','xpressme') . " \n";
}else{
$form .= "&ensp " . __('Flat','xpressme') . " \n";
$form .= "&ensp ". __('Threaded','xpressme') ." \n";
}
$form .= ' ';
$form .= __('Select the order of display of D3Forum comment.', 'xpressme') . " \n&emsp";
if ($this->is_d3forum_desc){
$form .= "&ensp " . __('DESC','xpressme') ." \n";
$form .= "&ensp ". __('ASC','xpressme') . " \n";
}else{
$form .= "&ensp " . __('DESC','xpressme') . " \n";
$form .= "&ensp ". __('ASC','xpressme') ." \n";
}
$form .= ' ';
$form .= __('Number of displays of D3Forum comments.', 'xpressme') ." \n";
$form .= '&emsp '."\n";
$form .= ''."\n";
$form .= __('The import and the export between Wordpress Comments and the D3Forum Posts can be done. ', 'xpressme') ." \n";
$form .= ' ' ."\n";
$form .= ' ' ." \n";
$form .= '
'."\n";
if (!empty($do_message)){
$form .= '' . $do_message . '
';
}
$form .= " \n";
$form .= " \n";
return $form;
}
function excerpt_option(){
$form = '';
$form .= ' ' .__('Contents Excerpt Setting', 'xpressme') . ' ';
$form .= "\n";
$form .= "\n";
$form .= "\n";
$form .= "" . __('Is the excerpt display done with the archive of contents?','xpressme') . " \n";
$form .= "\n";
$form .= $this->yes_no_radio_option_sub('is_content_excerpt');
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('When ASCII character more than the set ratio is included, it is judged ASCII contents. ','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('ascii_judged_rate');
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Excerpt length of word for ASCII contents','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('excerpt_length_word');
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('Excerpt length of character for multibyte contents','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('excerpt_length_character');
$form .= " \n";
$form .= " \n";
$form .= "\n";
$form .= "" . __('More Link Text (Is not displayed for the blank.)','xpressme') . " \n";
$form .= "\n";
$form .= $this->text_option_sub('more_link_text');
$form .= " \n";
$form .= " \n";
$form .= "
\n";
return $form;
}
function viewer_type_option(){
$form = "\n";
$form .= '' .__('Display Mode Setting', 'xpressme') . ' ';
$form .= "\n";
$form .= __('Select the XPressME Display Mode.', 'xpressme') ."\n";
$form .= '' . "\n";
$form .= 'viewer_type == 'xoops') $form .= ' selected="selected"';
$form .= '>'.__('Xoops Mode', 'xpressme') ." \n";
$form .= 'viewer_type == 'wordpress') $form .= ' selected="selected"';
$form .= '>'.__('WordPress Mode', 'xpressme') ." \n";
$form .= 'viewer_type == 'user_select') $form .= ' selected="selected"';
$form .= '>'.__('User select', 'xpressme') ." \n";
$form .= " \n";
$form .= " \n";
return $form;
}
function option_page()
{
$do_message ='';
if (!empty($_POST['submit_update'])) {
$this->ReadPostData();
$this->SettingValueWrite('update');
} else if (isset($_POST['submit_reset'])) {
$this->setDefault();
$this->SettingValueWrite('update');
} else if (isset($_POST['export_d3f'])) {
$do_message = 'export(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
$do_message .= wp_to_d3forum($this->d3forum_forum_id, $this->d3forum_module_dir);
$do_message .= '....END';
} else if (isset($_POST['inport_d3f'])) {
$do_message = 'Import(' . $this->d3forum_module_dir . '--ID=' . $this->d3forum_forum_id . ')................';
$do_message .= d3forum_to_wp($this->d3forum_forum_id, $this->d3forum_module_dir);
$do_message .= '....END';
}
echo ''."\n";
echo '
'."\n";
echo '
' . __('XPressME Configuration Page', 'xpressme') . " \n";
echo '
\n" ;
echo "
\n";
}
function xpress_upload_filter($uploads)
{
global $xoops_config;
if ($this->is_use_xoops_upload_path){
$wordpress_dir = ABSPATH ;
$xoops_dir = $xoops_config->xoops_upload_path . '/';
$wordpress_base_url = get_option( 'siteurl' );
$xoops_upload_url = $xoops_config->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;
}
// SQL DEBUG TEST
function is_sql_debug_permission()
{
global $current_user;
if (!is_object($current_user)) return false;
if ($this->is_sql_debug && ($current_user->user_level >= 10))
return true;
else
return false;
}
function xpress_sql_debug($query_strings)
{
if ($this->is_sql_debug_permission()){
if (empty($GLOBALS['XPress_SQL_Query'])) $GLOBALS['XPress_SQL_Query'] = '';
$GLOBALS['XPress_SQL_Query'] .= $query_strings . ' ';
}
return $query_strings;
}
function displayDebugLog()
{
if ($this->is_sql_debug_permission()){
$content = '';
$content .= ' ';
$content .= ' ' ;
$content .= 'XPressME SQL DEBUG ' ;
$content .= '';
$content .= $GLOBALS['XPress_SQL_Query'];
$content .= '
';
echo '';
}
}
function set_d3forum_external_link_format()
{
global $xoops_db;
/* var $is_use_d3forum;
var $d3forum_module_dir;
var $d3forum_forum_id;
var $d3forum_external_link_format;
if ($this->$is_use_d3forum){
$content = '';
$content .= ' ';
$content .= ' ' ;
$content .= 'XPressME SQL DEBUG ' ;
$content .= '';
$content .= $GLOBALS['XPress_SQL_Query'];
$content .= '
';
echo '';
}
*/
}
}
?>