public function testMBYTE_languageListReturnsNotUtf8WithParameter()
 {
     $dummy = array('afrikaans' => 'Afrikaans', 'bosnian' => 'Bosnian', 'bulgarian' => 'Bulgarian', 'catalan' => 'Catalan', 'croatian' => 'Croatian', 'czech' => 'Czech', 'danish' => 'Danish', 'dutch' => 'Dutch', 'english' => 'English', 'estonian' => 'Estonian', 'finnish' => 'Finnish', 'french_canada' => 'French (Canada)', 'french_france' => 'French (France)', 'german' => 'German', 'german_formal' => 'German (Formal)', 'hellenic' => 'Hellenic', 'indonesian' => 'Indonesian', 'italian' => 'Italian', 'korean' => 'Korean', 'norwegian' => 'Norwegian', 'polish' => 'Polish', 'portuguese' => 'Portuguese', 'portuguese_brazil' => 'Portuguese (Brazil)', 'romanian' => 'Romanian', 'russian' => 'Russian', 'serbian' => 'Serbian', 'slovak' => 'Slovak', 'slovenian' => 'Slovenian', 'spanish' => 'Spanish', 'spanish_argentina' => 'Spanish (Argentina)', 'swedish' => 'Swedish', 'turkish' => 'Turkish', 'ukrainian' => 'Ukrainian', 'ukrainian_koi8-u' => 'Ukrainian (KOI8-U)');
     $retval = MBYTE_languageList('other');
     foreach ($dummy as $k => $v) {
         $this->assertEquals($v, $retval[$k], 'Error asserting dummy ' . $v . ' is equal to returned ' . $retval[$k] . '.');
     }
 }
Example #2
0
// +---------------------------------------------------------------------------+
/**
* @package LanguageSelectionBlock
*/
require_once '../lib-common.php';
// take user back to the homepage if the plugin is not active
if (!in_array('langsel', $_PLUGINS)) {
    echo COM_refresh($_CONF['site_url'] . '/index.php');
    exit;
}
// Figure out where to go back after changing the language
if (isset($_REQUEST['target']) && $_REQUEST['target'] == COM_applyFilter($_REQUEST['target'])) {
    $target = COM_applyFilter($_REQUEST['target']);
} else {
    $target = $_CONF['site_url'] . '/index.php';
}
// Check if the language is valid
if (!array_key_exists($_REQUEST['langsel'], MBYTE_languageList($_CONF['default_charset']))) {
    // Invalid language - let's silently bail out
    echo COM_refresh($target);
    exit;
} else {
    $language = $_REQUEST['langsel'];
}
// Perform language switch
setcookie($_CONF['cookie_language'], $language, 0, '/');
if ($_USER['uid'] > 1) {
    DB_query("UPDATE {$_TABLES['users']} SET language='{$language}' WHERE uid='{$_USER['uid']}'");
}
echo COM_refresh($target);
exit;
Example #3
0
/**
* Displays user preferences
*
*/
function editpreferences()
{
    global $_TABLES, $_CONF, $LANG04, $_USER, $_GROUPS;
    $result = DB_query("SELECT noicons,willing,dfid,tzid,noboxes,maxstories,tids,aids,boxes,emailfromadmin,emailfromuser,showonline FROM {$_TABLES['userprefs']},{$_TABLES['userindex']} WHERE {$_TABLES['userindex']}.uid = {$_USER['uid']} AND {$_TABLES['userprefs']}.uid = {$_USER['uid']}");
    $A = DB_fetchArray($result);
    // 'maxstories' may be 0, in which case it will pick up the default
    // setting for the current topic or $_CONF['limitnews'] (see index.php)
    if (empty($A['maxstories'])) {
        $A['maxstories'] = 0;
    } else {
        if ($A['maxstories'] > 0) {
            if ($A['maxstories'] < $_CONF['minnews']) {
                $A['maxstories'] = $_CONF['minnews'];
            }
        }
    }
    $preferences = new Template($_CONF['path_layout'] . 'preferences');
    $preferences->set_file(array('prefs' => 'displayprefs.thtml', 'display' => 'displayblock.thtml', 'exclude' => 'excludeblock.thtml', 'digest' => 'digestblock.thtml', 'boxes' => 'boxesblock.thtml', 'comment' => 'commentblock.thtml', 'language' => 'language.thtml', 'theme' => 'theme.thtml', 'privacy' => 'privacyblock.thtml'));
    $preferences->set_var('xhtml', XHTML);
    $preferences->set_var('site_url', $_CONF['site_url']);
    $preferences->set_var('layout_url', $_CONF['layout_url']);
    $preferences->set_var('user_name', $_USER['username']);
    $preferences->set_var('lang_language', $LANG04[73]);
    $preferences->set_var('lang_theme', $LANG04[72]);
    $preferences->set_var('lang_theme_text', $LANG04[74]);
    $preferences->set_var('lang_misc_title', $LANG04[138]);
    $preferences->set_var('lang_misc_help_title', $LANG04[139]);
    $preferences->set_var('lang_misc_help', $LANG04[140]);
    $preferences->set_var('lang_noicons', $LANG04[40]);
    $preferences->set_var('lang_noicons_text', $LANG04[49]);
    $preferences->set_var('lang_noboxes', $LANG04[44]);
    $preferences->set_var('lang_noboxes_text', $LANG04[51]);
    $preferences->set_var('lang_maxstories', $LANG04[43]);
    if (strpos($LANG04[52], '%d') === false) {
        $maxtext = $LANG04[52] . ' ' . $_CONF['limitnews'];
    } else {
        $maxtext = sprintf($LANG04[52], $_CONF['limitnews']);
    }
    $preferences->set_var('lang_maxstories_text', $maxtext);
    $preferences->set_var('lang_dateformat', $LANG04[42]);
    $preferences->set_var('lang_excluded_items_title', $LANG04[137]);
    $preferences->set_var('lang_excluded_items', $LANG04[54]);
    $preferences->set_var('lang_exclude_title', $LANG04[136]);
    $preferences->set_var('lang_topics', $LANG04[48]);
    $preferences->set_var('lang_emailedtopics', $LANG04[76]);
    $preferences->set_var('lang_digest_top_header', $LANG04[131]);
    $preferences->set_var('lang_digest_help_header', $LANG04[132]);
    $preferences->set_var('lang_boxes_title', $LANG04[144]);
    $preferences->set_var('lang_boxes_help_title', $LANG04[143]);
    $preferences->set_var('lang_boxes', $LANG04[55]);
    $preferences->set_var('lang_displaymode', $LANG04[57]);
    $preferences->set_var('lang_displaymode_text', $LANG04[60]);
    $preferences->set_var('lang_sortorder', $LANG04[58]);
    $preferences->set_var('lang_sortorder_text', $LANG04[61]);
    $preferences->set_var('lang_comment_title', $LANG04[133]);
    $preferences->set_var('lang_comment_help_title', $LANG04[134]);
    $preferences->set_var('lang_comment_help', $LANG04[135]);
    $preferences->set_var('lang_commentlimit', $LANG04[59]);
    $preferences->set_var('lang_commentlimit_text', $LANG04[62]);
    $preferences->set_var('lang_privacy_title', $LANG04[141]);
    $preferences->set_var('lang_privacy_help_title', $LANG04[141]);
    $preferences->set_var('lang_privacy_help', $LANG04[142]);
    $preferences->set_var('lang_emailfromadmin', $LANG04[100]);
    $preferences->set_var('lang_emailfromadmin_text', $LANG04[101]);
    $preferences->set_var('lang_emailfromuser', $LANG04[102]);
    $preferences->set_var('lang_emailfromuser_text', $LANG04[103]);
    $preferences->set_var('lang_showonline', $LANG04[104]);
    $preferences->set_var('lang_showonline_text', $LANG04[105]);
    $preferences->set_var('lang_submit', $LANG04[9]);
    $display_name = COM_getDisplayName($_USER['uid']);
    $preferences->set_var('lang_authors_exclude', $LANG04[46]);
    $preferences->set_var('lang_boxes_exclude', $LANG04[47]);
    $preferences->set_var('start_block_display', COM_startBlock($LANG04[45] . ' ' . $display_name));
    $preferences->set_var('start_block_digest', COM_startBlock($LANG04[75] . ' ' . $display_name));
    $preferences->set_var('start_block_comment', COM_startBlock($LANG04[64] . ' ' . $display_name));
    $preferences->set_var('start_block_privacy', COM_startBlock($LANG04[99] . ' ' . $display_name));
    $preferences->set_var('end_block', COM_endBlock());
    $preferences->set_var('display_headline', $LANG04[45] . ' ' . $display_name);
    $preferences->set_var('exclude_headline', $LANG04[46] . ' ' . $display_name);
    $preferences->set_var('digest_headline', $LANG04[75] . ' ' . $display_name);
    $preferences->set_var('boxes_headline', $LANG04[47] . ' ' . $display_name);
    $preferences->set_var('comment_headline', $LANG04[64] . ' ' . $display_name);
    $preferences->set_var('privacy_headline', $LANG04[99] . ' ' . $display_name);
    // display preferences block
    if ($_CONF['allow_user_language'] == 1) {
        if (empty($_USER['language'])) {
            $userlang = $_CONF['language'];
        } else {
            $userlang = $_USER['language'];
        }
        // Get available languages
        $language = MBYTE_languageList($_CONF['default_charset']);
        $has_valid_language = count(array_keys($language, $userlang));
        if ($has_valid_language == 0) {
            // The user's preferred language is no longer available.
            // We have a problem now, since we've overwritten $_CONF['language']
            // with the user's preferred language ($_USER['language']) and
            // therefore don't know what the system's default language is.
            // So we'll try to find a similar language. If that doesn't help,
            // the dropdown will default to the first language in the list ...
            $tmp = explode('_', $userlang);
            $similarLang = $tmp[0];
        }
        $selection = '<select id="language" name="language">' . LB;
        foreach ($language as $langFile => $langName) {
            $selection .= '<option value="' . $langFile . '"';
            if ($langFile == $userlang || $has_valid_language == 0 && strpos($langFile, $similarLang) === 0) {
                $selection .= ' selected="selected"';
                $has_valid_language = 1;
            } else {
                if ($userlang == $langFile) {
                    $selection .= ' selected="selected"';
                }
            }
            $selection .= '>' . $langName . '</option>' . LB;
        }
        $selection .= '</select>';
        $preferences->set_var('language_selector', $selection);
        $preferences->parse('language_selection', 'language', true);
    } else {
        $preferences->set_var('language_selection', '');
    }
    if ($_CONF['allow_user_themes'] == 1) {
        $selection = '<select id="theme" name="theme">' . LB;
        if (empty($_USER['theme'])) {
            $usertheme = $_CONF['theme'];
        } else {
            $usertheme = $_USER['theme'];
        }
        $themeFiles = COM_getThemes();
        usort($themeFiles, 'strcasecmp');
        foreach ($themeFiles as $theme) {
            $selection .= '<option value="' . $theme . '"';
            if ($usertheme == $theme) {
                $selection .= ' selected="selected"';
            }
            $words = explode('_', $theme);
            $bwords = array();
            foreach ($words as $th) {
                if (strtolower($th[0]) == $th[0] && strtolower($th[1]) == $th[1]) {
                    $bwords[] = ucfirst($th);
                } else {
                    $bwords[] = $th;
                }
            }
            $selection .= '>' . implode(' ', $bwords) . '</option>' . LB;
        }
        $selection .= '</select>';
        $preferences->set_var('theme_selector', $selection);
        $preferences->parse('theme_selection', 'theme', true);
    } else {
        $preferences->set_var('theme_selection', '');
    }
    // Timezone
    require_once $_CONF['path_system'] . 'classes/timezoneconfig.class.php';
    $timezone = TimeZoneConfig::getUserTimeZone();
    $selection = TimeZoneConfig::getTimeZoneDropDown($timezone, array('id' => 'tzid', 'name' => 'tzid'));
    $preferences->set_var('timezone_selector', $selection);
    $preferences->set_var('lang_timezone', $LANG04[158]);
    if ($A['noicons'] == '1') {
        $preferences->set_var('noicons_checked', 'checked="checked"');
    } else {
        $preferences->set_var('noicons_checked', '');
    }
    if ($A['noboxes'] == 1) {
        $preferences->set_var('noboxes_checked', 'checked="checked"');
    } else {
        $preferences->set_var('noboxes_checked', '');
    }
    $preferences->set_var('maxstories_value', $A['maxstories']);
    $selection = '<select id="dfid" name="dfid">' . LB . COM_optionList($_TABLES['dateformats'], 'dfid,description', $A['dfid']) . '</select>';
    $preferences->set_var('dateformat_selector', $selection);
    $preferences->parse('display_block', 'display', true);
    // privacy options block
    if ($A['emailfromadmin'] == 1) {
        $preferences->set_var('emailfromadmin_checked', 'checked="checked"');
    } else {
        $preferences->set_var('emailfromadmin_checked', '');
    }
    if ($A['emailfromuser'] == 1) {
        $preferences->set_var('emailfromuser_checked', 'checked="checked"');
    } else {
        $preferences->set_var('emailfromuser_checked', '');
    }
    if ($A['showonline'] == 1) {
        $preferences->set_var('showonline_checked', 'checked="checked"');
    } else {
        $preferences->set_var('showonline_checked', '');
    }
    PLG_profileVariablesEdit($_USER['uid'], $preferences);
    $preferences->parse('privacy_block', 'privacy', true);
    // excluded items block
    $permissions = COM_getPermSQL('');
    $preferences->set_var('exclude_topic_checklist', COM_checkList($_TABLES['topics'], 'tid,topic', $permissions, $A['tids'], 'topics'));
    if ($_CONF['contributedbyline'] == 1 && $_CONF['hide_author_exclusion'] == 0) {
        $preferences->set_var('lang_authors', $LANG04[56]);
        $sql = "SELECT DISTINCT story.uid, users.username,users.fullname FROM {$_TABLES['stories']} story, {$_TABLES['users']} users WHERE story.uid = users.uid";
        if ($_CONF['show_fullname'] == 1) {
            $sql .= ' ORDER BY users.fullname';
        } else {
            $sql .= ' ORDER BY users.username';
        }
        $query = DB_query($sql);
        $nrows = DB_numRows($query);
        $authors = explode(' ', $A['aids']);
        $selauthors = '';
        for ($i = 0; $i < $nrows; $i++) {
            $B = DB_fetchArray($query);
            $selauthors .= '<option value="' . $B['uid'] . '"';
            if (in_array(sprintf('%d', $B['uid']), $authors)) {
                $selauthors .= ' selected';
            }
            $selauthors .= '>' . COM_getDisplayName($B['uid'], $B['username'], $B['fullname']) . '</option>' . LB;
        }
        if (DB_count($_TABLES['topics']) > 10) {
            $Selboxsize = intval(DB_count($_TABLES['topics']) * 1.5);
        } else {
            $Selboxsize = 15;
        }
        $preferences->set_var('exclude_author_checklist', '<select name="selauthors[]" multiple="multiple" size="' . $Selboxsize . '">' . $selauthors . '</select>');
    } else {
        $preferences->set_var('lang_authors', '');
        $preferences->set_var('exclude_author_checklist', '');
    }
    $preferences->parse('exclude_block', 'exclude', true);
    // daily digest block
    if ($_CONF['emailstories'] == 1) {
        $user_etids = DB_getItem($_TABLES['userindex'], 'etids', "uid = {$_USER['uid']}");
        if (empty($user_etids)) {
            // an empty string now means "all topics"
            $etids = USER_getAllowedTopics();
            $user_etids = implode(' ', $etids);
        } elseif ($user_etids == '-') {
            // this means "no topics"
            $user_etids = '';
        }
        $tmp = COM_checkList($_TABLES['topics'], 'tid,topic', $permissions, $user_etids, 'topics');
        $preferences->set_var('email_topic_checklist', str_replace($_TABLES['topics'], 'etids', $tmp));
        $preferences->parse('digest_block', 'digest', true);
    } else {
        $preferences->set_var('digest_block', '');
    }
    // boxes block
    $selectedblocks = '';
    if (strlen($A['boxes']) > 0) {
        $blockresult = DB_query("SELECT bid FROM {$_TABLES['blocks']} WHERE bid NOT IN (" . str_replace(' ', ',', $A['boxes']) . ")");
        for ($x = 1; $x <= DB_numRows($blockresult); $x++) {
            $row = DB_fetchArray($blockresult);
            $selectedblocks .= $row['bid'];
            if ($x != DB_numRows($blockresult)) {
                $selectedblocks .= ' ';
            }
        }
    }
    $whereblock = '';
    if (!empty($permissions)) {
        $whereblock .= $permissions . ' AND ';
    }
    $whereblock .= "((type != 'layout' AND type != 'gldefault' AND is_enabled = 1) OR " . "(type = 'gldefault' AND is_enabled = 1 AND name IN ('whats_new_block','older_stories'))) " . "ORDER BY onleft desc,blockorder,title";
    $preferences->set_var('boxes_checklist', COM_checkList($_TABLES['blocks'], 'bid,title,type', $whereblock, $selectedblocks));
    $preferences->parse('boxes_block', 'boxes', true);
    // comment preferences block
    $result = DB_query("SELECT commentmode,commentorder,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = {$_USER['uid']}");
    $A = DB_fetchArray($result);
    if (empty($A['commentmode'])) {
        $A['commentmode'] = $_CONF['comment_mode'];
    }
    if (empty($A['commentorder'])) {
        $A['commentorder'] = 0;
    }
    if (empty($A['commentlimit'])) {
        $A['commentlimit'] = 100;
    }
    $selection = '<select id="commentmode" name="commentmode">';
    $selection .= COM_optionList($_TABLES['commentmodes'], 'mode,name', $A['commentmode']);
    $selection .= '</select>';
    $preferences->set_var('displaymode_selector', $selection);
    $selection = '<select id="commentorder" name="commentorder">';
    $selection .= COM_optionList($_TABLES['sortcodes'], 'code,name', $A['commentorder']);
    $selection .= '</select>';
    $preferences->set_var('sortorder_selector', $selection);
    $preferences->set_var('commentlimit_value', $A['commentlimit']);
    $preferences->parse('comment_block', 'comment', true);
    return $preferences->finish($preferences->parse('output', 'prefs'));
}
Example #4
0
function USER_layoutPanel($U, $newuser = 0)
{
    global $_CONF, $_SYSTEM, $_TABLES, $_USER, $LANG_MYACCOUNT, $LANG04, $LANG_confignames, $LANG_configselects;
    $uid = $U['uid'];
    // set template
    $userform = new Template($_CONF['path_layout'] . 'admin/user/');
    $userform->set_file('user', 'layoutpanel.thtml');
    $userform->set_var('lang_misc_title', $LANG04[138]);
    $userform->set_var('lang_misc_help_title', $LANG04[139]);
    $userform->set_var('lang_misc_help', $LANG04[140]);
    $userform->set_var('lang_language', $LANG04[73]);
    $userform->set_var('lang_theme', $LANG04[72]);
    $userform->set_var('lang_noicons', $LANG04[40]);
    $userform->set_var('lang_noboxes', $LANG04[44]);
    $userform->set_var('lang_maxstories', $LANG04[43]);
    $userform->set_var('lang_timezone', $LANG04[158]);
    $userform->set_var('lang_dateformat', $LANG04[42]);
    $userform->set_var('lang_search_format', $LANG_confignames['Core']['search_show_type']);
    $userform->set_var('lang_comment_title', $LANG04[133]);
    $userform->set_var('lang_comment_help_title', $LANG04[134]);
    $userform->set_var('lang_comment_help', $LANG04[135]);
    $userform->set_var('lang_displaymode', $LANG04[57]);
    $userform->set_var('lang_sortorder', $LANG04[58]);
    $userform->set_var('lang_commentlimit', $LANG04[59]);
    if ($_CONF['allow_user_language'] == 1) {
        if (empty($U['language'])) {
            $userlang = $_CONF['language'];
        } else {
            $userlang = $U['language'];
        }
        // Get available languages
        $language = MBYTE_languageList($_CONF['default_charset']);
        $has_valid_language = count(array_keys($language, $userlang));
        if ($has_valid_language == 0) {
            // The user's preferred language is no longer available.
            // We have a problem now, since we've overwritten $_CONF['language']
            // with the user's preferred language ($U['language']) and
            // therefore don't know what the system's default language is.
            // So we'll try to find a similar language. If that doesn't help,
            // the dropdown will default to the first language in the list ...
            $tmp = explode('_', $userlang);
            $similarLang = $tmp[0];
        }
        // build language select
        $selection = '<select id="language" name="language">' . LB;
        foreach ($language as $langFile => $langName) {
            $selection .= '<option value="' . $langFile . '"';
            if ($langFile == $userlang || $has_valid_language == 0 && strpos($langFile, $similarLang) === 0) {
                $selection .= ' selected="selected"';
                $has_valid_language = 1;
            } else {
                if ($userlang == $langFile) {
                    $selection .= ' selected="selected"';
                }
            }
            $selection .= '>' . $langName . '</option>' . LB;
        }
        $selection .= '</select>';
        $userform->set_var('language_selector', $selection);
    } else {
        $userform->set_var('language_selector', $_CONF['language']);
    }
    if ($_CONF['allow_user_themes'] == 1) {
        $selection = '<select id="theme" name="theme">' . LB;
        if (empty($U['theme'])) {
            $usertheme = $_CONF['theme'];
        } else {
            $usertheme = $U['theme'];
        }
        $themeFiles = COM_getThemes();
        usort($themeFiles, create_function('$a,$b', 'return strcasecmp($a,$b);'));
        foreach ($themeFiles as $theme) {
            $selection .= '<option value="' . $theme . '"';
            if ($usertheme == $theme) {
                $selection .= ' selected="selected"';
            }
            $words = explode('_', $theme);
            $bwords = array();
            foreach ($words as $th) {
                if (strtolower($th[0]) == $th[0] && strtolower($th[1]) == $th[1]) {
                    $bwords[] = strtoupper($th[0]) . substr($th, 1);
                } else {
                    $bwords[] = $th;
                }
            }
            $selection .= '>' . implode(' ', $bwords) . '</option>' . LB;
        }
        $selection .= '</select>';
        $userform->set_var('theme_selector', $selection);
    } else {
        $userform->set_var('theme_selector', $_CONF['theme']);
    }
    if ($U['noicons'] == '1') {
        $userform->set_var('noicons_checked', 'checked="checked"');
    } else {
        $userform->set_var('noicons_checked', '');
    }
    if ($U['noboxes'] == 1) {
        $userform->set_var('noboxes_checked', 'checked="checked"');
    } else {
        $userform->set_var('noboxes_checked', '');
    }
    $userform->set_var('maxstories_value', $U['maxstories']);
    // Timezone
    if (isset($U['tzid'])) {
        $timezone = $U['tzid'];
    } else {
        $timezone = $_CONF['timezone'];
    }
    $selection = Date::getTimeZoneDropDown($timezone, array('id' => 'tzid', 'name' => 'tzid'));
    $userform->set_var('timezone_selector', $selection);
    $selection = '<select id="dfid" name="dfid">' . LB . COM_optionList($_TABLES['dateformats'], 'dfid,description', $U['dfid']) . '</select>';
    $userform->set_var('dateformat_selector', $selection);
    $search_result_select = '<select name="search_result_format" id="search_result_format">' . LB;
    foreach ($LANG_configselects['Core'][18] as $name => $type) {
        $search_result_select .= '<option value="' . $type . '"' . ($U['search_result_format'] == $type ? 'selected="selected"' : '') . '>' . $name . '</option>' . LB;
    }
    $search_result_select .= '</select>';
    $userform->set_var('search_result_select', $search_result_select);
    if (!empty($uid) && $uid > 1) {
        $userform->set_var('plugin_layout_display', PLG_profileEdit($uid, 'layout', 'display'));
    }
    // comment preferences block
    if (!empty($uid) && $uid > 1) {
        $result = DB_query("SELECT commentmode,commentorder,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = {$uid}");
        $C = DB_fetchArray($result);
        if (empty($C['commentmode'])) {
            $C['commentmode'] = $_CONF['comment_mode'];
        }
        if (empty($C['commentorder'])) {
            $C['commentorder'] = 0;
        }
        if (empty($C['commentlimit'])) {
            $C['commentlimit'] = 100;
        }
    } else {
        $C['commentmode'] = $_CONF['comment_mode'];
        $C['commentorder'] = 0;
        $C['commentlimit'] = 100;
    }
    $selection = '<select id="commentmode" name="commentmode">';
    $selection .= COM_optionList($_TABLES['commentmodes'], 'mode,name', $C['commentmode']);
    $selection .= '</select>';
    $userform->set_var('displaymode_selector', $selection);
    $selection = '<select id="commentorder" name="commentorder">';
    $selection .= COM_optionList($_TABLES['sortcodes'], 'code,name', $C['commentorder']);
    $selection .= '</select>';
    $userform->set_var('sortorder_selector', $selection);
    $userform->set_var('commentlimit_value', $U['commentlimit']);
    if (!empty($uid) && $uid > 1) {
        $userform->set_var('plugin_layout_comment', PLG_profileEdit($uid, 'layout', 'comment'));
        $userform->set_var('plugin_layout', PLG_profileEdit($uid, 'layout'));
    }
    $retval = $userform->finish($userform->parse('output', 'user'));
    return $retval;
}
Example #5
0
/**
 * Custom validation rule for language
 *
 * @param string $rule String of rule name
 * @param array $ruleParams Parameter of validation
 * @return boolean Success
 *
 */
function custom_validation_language($rule, $ruleParams)
{
    global $_CONF;
    $ret = false;
    $languages = array_flip(MBYTE_languageList($_CONF['default_charset']));
    if (isset($ruleParams[0]['language']) && in_array($ruleParams[0]['language'], $languages)) {
        $ret = true;
    }
    return $ret;
}
Example #6
0
/**
* Helper function: Provide language dropdown
*
* @return   Array   Array of (filename, displayname) pairs
*
* @note     Note that key/value are being swapped!
*
*/
function configmanager_select_language_helper()
{
    global $_CONF;
    return array_flip(MBYTE_languageList($_CONF['default_charset']));
}
Example #7
0
function editPreferences()
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $LANG_confignames, $LANG_configselects, $_IMAGE_TYPE;
    $retval = '';
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/user.php', 'text' => $LANG_ADMIN['admin_users']), array('url' => $_CONF['site_admin_url'] . '/user.php?edit=x', 'text' => $LANG_ADMIN['create_new']), array('url' => $_CONF['site_admin_url'] . '/user.php?import=x', 'text' => $LANG28[23]), array('url' => $_CONF['site_admin_url'] . '/user.php?batchadmin=x', 'text' => $LANG28[54]), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $T = new Template($_CONF['path_layout'] . 'admin/user/');
    $T->set_file('editor', 'prefeditor.thtml');
    $T->set_var(array('lang_save' => $LANG_ADMIN['save'], 'lang_cancel' => $LANG_ADMIN['cancel'], 'lang_language' => $LANG04[73], 'lang_theme' => $LANG04[72], 'lang_cooktime' => $LANG04[68], 'lang_noicons' => $LANG04[40], 'lang_noboxes' => $LANG04[44], 'lang_maxstories' => $LANG04[43], 'lang_timezone' => $LANG04[158], 'lang_dateformat' => $LANG04[42], 'lang_search_format' => $LANG_confignames['Core']['search_show_type'], 'lang_displaymode' => $LANG28[97], 'lang_sortorder' => $LANG28[98], 'lang_commentlimit' => $LANG04[59], 'lang_emailfromadmin' => $LANG04[100], 'lang_emailfromuser' => $LANG04[102], 'lang_showonline' => $LANG04[104], 'lang_confirm' => $LANG28[91], 'lang_attribute' => $LANG28[92], 'lang_value' => $LANG28[93], 'lang_selected' => $LANG28[94]));
    // Get available languages
    $language = MBYTE_languageList($_CONF['default_charset']);
    // build language select
    $selection = '<select id="language" name="language">' . LB;
    foreach ($language as $langFile => $langName) {
        $selection .= '<option value="' . $langFile . '"';
        if ($langFile == $_CONF['language']) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $langName . '</option>' . LB;
    }
    $selection .= '</select>';
    $T->set_var('language_selector', $selection);
    if ($_CONF['allow_user_themes'] == 1) {
        $selection = '<select id="theme" name="theme">' . LB;
        $usertheme = $_CONF['theme'];
        $themeFiles = COM_getThemes();
        usort($themeFiles, create_function('$a,$b', 'return strcasecmp($a,$b);'));
        foreach ($themeFiles as $theme) {
            $selection .= '<option value="' . $theme . '"';
            if ($usertheme == $theme) {
                $selection .= ' selected="selected"';
            }
            $words = explode('_', $theme);
            $bwords = array();
            foreach ($words as $th) {
                if (strtolower($th[0]) == $th[0] && strtolower($th[1]) == $th[1]) {
                    $bwords[] = strtoupper($th[0]) . substr($th, 1);
                } else {
                    $bwords[] = $th;
                }
            }
            $selection .= '>' . implode(' ', $bwords) . '</option>' . LB;
        }
        $selection .= '</select>';
        $T->set_var('theme_selector', $selection);
    } else {
        $T->set_var('theme_selector', $_CONF['theme']);
    }
    $selection = '<select id="cooktime" name="cooktime">' . LB;
    $selection .= COM_optionList($_TABLES['cookiecodes'], 'cc_value,cc_descr', 2678400, 0);
    $selection .= '</select>';
    $T->set_var('cooktime_selector', $selection);
    $selection = Date::getTimeZoneDropDown($_CONF['timezone'], array('id' => 'tzid', 'name' => 'tzid'));
    $T->set_var('timezone_selector', $selection);
    $selection = '<select id="dfid" name="dfid">' . LB . COM_optionList($_TABLES['dateformats'], 'dfid,description', 0) . '</select>';
    $T->set_var('dateformat_selector', $selection);
    $search_result_select = '<select name="search_result_format" id="search_result_format">' . LB;
    foreach ($LANG_configselects['Core'][18] as $name => $type) {
        $search_result_select .= '<option value="' . $type . '"' . ('google' == $type ? 'selected="selected"' : '') . '>' . $name . '</option>' . LB;
    }
    $search_result_select .= '</select>';
    $T->set_var('search_result_select', $search_result_select);
    $selection = '<select id="commentmode" name="commentmode">';
    $selection .= COM_optionList($_TABLES['commentmodes'], 'mode,name', $_CONF['comment_mode']);
    $selection .= '</select>';
    $T->set_var('displaymode_selector', $selection);
    $selection = '<select id="commentorder" name="commentorder">';
    $selection .= COM_optionList($_TABLES['sortcodes'], 'code,name', 0);
    $selection .= '</select>';
    $T->set_var('sortorder_selector', $selection);
    $T->set_var('gltoken_name', CSRF_TOKEN);
    $T->set_var('gltoken', SEC_createToken());
    $retval .= COM_startBlock($LANG28[95], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG28[96], $_CONF['layout_url'] . '/images/icons/user.' . $_IMAGE_TYPE);
    $retval .= $T->finish($T->parse('output', 'editor'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}