当前位置: 首页>>代码示例>>PHP>>正文


PHP get_list_of_languages函数代码示例

本文整理汇总了PHP中get_list_of_languages函数的典型用法代码示例。如果您正苦于以下问题:PHP get_list_of_languages函数的具体用法?PHP get_list_of_languages怎么用?PHP get_list_of_languages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_list_of_languages函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: print_header

 function print_header($title)
 {
     global $USER, $CFG;
     $replacements = array('%fullname%' => get_string('mymoodle', 'my'));
     foreach ($replacements as $search => $replace) {
         $title = str_replace($search, $replace, $title);
     }
     $site = get_site();
     $button = update_mymoodle_icon($USER->id);
     $nav = get_string('mymoodle', 'my');
     $header = $site->shortname . ': ' . $nav;
     $navlinks = array(array('name' => $nav, 'link' => '', 'type' => 'misc'));
     $navigation = build_navigation($navlinks);
     $loggedinas = user_login_string($site);
     if (empty($CFG->langmenu)) {
         $langmenu = '';
     } else {
         $currlang = current_language();
         $langs = get_list_of_languages();
         $langlabel = get_accesshide(get_string('language'));
         $langmenu = popup_form($CFG->wwwroot . '/my/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
     }
     print_header($title, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu);
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:24,代码来源:pagelib.php

示例2: dirname

 * A simple test script that hammers get_string, and times how long it takes.
 *
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package moodlecore
 */
/** */
require_once dirname(__FILE__) . '/../../config.php';
require_once $CFG->libdir . '/moodlelib.php';
define('NUM_CALLS', 20000);
define('NUM_REPITITIONS', 3);
$TEST_LANGUAGES = array('en_utf8', 'fr_utf8', 'fr_ca_utf8', 'nonexistant');
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$title = 'get_string performance test';
print_header($title, $title, build_navigation($title));
$installedlangs = get_list_of_languages();
$requiredlangs = $TEST_LANGUAGES;
array_pop($requiredlangs);
foreach ($requiredlangs as $lang) {
    if (!isset($installedlangs[$lang])) {
        echo $OUTPUT->notification('You must install the following language packs to run these test: ' . implode(', ', $requiredlangs));
        echo $OUTPUT->footer();
        die;
    }
}
time_for_loop();
echo $OUTPUT->heading('Timing calling functions');
time_function_call('dummy_function');
time_function_call('simple_eval');
time_function_call('simple_eval_with_interp');
time_function_call('sprintf_eval');
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:getstringperformancetester.php

示例3: print_languageform

 function print_languageform()
 {
     global $CFG;
     $editlang = optional_param('editlang', current_language(), PARAM_TEXT);
     $enKeys = get_records('podcaster_language', 'language', 'en_utf8', 'name DESC');
     $langKeys = $editlang != 'en_utf8' ? get_records('podcaster_language', 'language', $editlang, 'name') : $enKeys;
     $editMap = array();
     if ($langKeys) {
         foreach ($langKeys as $key) {
             $editMap[$key->name] = $key->value;
         }
     }
     $languages = get_list_of_languages();
     echo '<tr>
         <td>&nbsp;</td>
         <td>' . get_string('config_currentlanguage', 'podcaster') . '</td>
         <td>';
     choose_from_menu($languages, 'editlang', $editlang, '', 'document.location.href=\'' . $CFG->wwwroot . '/' . $CFG->admin . '/module.php?module=podcaster&amp;tab=language&amp;editlang=\' + this.value');
     echo '  </td>
       </tr>';
     if ($enKeys) {
         $i = 0;
         foreach ($enKeys as $key) {
             $exists = isset($editMap[$key->name]) ? true : false;
             $value = $exists ? $editMap[$key->name] : '';
             echo '<tr>
             <td valign="top"><b>' . $key->name . '</b></td>
             <td valign="top">' . $key->value . '</td>
             <td valign="top"' . ($exists ? '' : ' style="border:1px solid red;"') . '>';
             if (substr($key->name, -5) == 'title') {
                 echo '<input type="text" size="32" name="' . $key->name . '" value="' . htmlspecialchars($value) . '" />';
             } else {
                 echo '<textarea name="' . $key->name . '" rows="7" cols="32">' . $value . '</textarea>';
             }
             echo '
             </td>
           </tr>';
             if (++$i % 2 == 0) {
                 echo '<tr><td colspan="3"><hr size="1" /></td></tr>';
             }
         }
     }
 }
开发者ID:NextEinstein,项目名称:riverhills,代码行数:43,代码来源:admin.php

示例4: definition


//.........这里部分代码省略.........
     $mform->setType('enrolpassword', PARAM_RAW);
     if (empty($course) or $course->password !== '' and $course->id != SITEID) {
         // do not require password in existing courses that do not have password yet - backwards compatibility ;-)
         if (!empty($CFG->enrol_manual_requirekey)) {
             $mform->addRule('enrolpassword', get_string('required'), 'required', null, 'client');
         }
     }
     $choices = array();
     $choices['0'] = get_string('guestsno');
     $choices['1'] = get_string('guestsyes');
     $choices['2'] = get_string('guestskey');
     $mform->addElement('select', 'guest', get_string('opentoguests'), $choices);
     $mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true);
     $mform->setDefault('guest', $courseconfig->guest);
     // If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here
     $enrol_object = $CFG;
     if (!empty($course)) {
         $enrol_object = $course;
     }
     // If the print_entry method exists and the course enrol method isn't manual (both set or inherited from site), show cost
     if (method_exists(enrolment_factory::factory($enrol_object->enrol), 'print_entry') && !($enrol_object->enrol == 'manual' || empty($enrol_object->enrol) && $CFG->enrol == 'manual')) {
         $costgroup = array();
         $currencies = get_list_of_currencies();
         $costgroup[] =& MoodleQuickForm::createElement('text', 'cost', '', 'maxlength="6" size="6"');
         $costgroup[] =& MoodleQuickForm::createElement('select', 'currency', '', $currencies);
         $mform->addGroup($costgroup, 'costgrp', get_string('cost'), '&nbsp;', false);
         //defining a rule for a form element within a group :
         $costgrprules = array();
         //set the message to null to tell Moodle to use a default message
         //available for most rules, fetched from language pack (err_{rulename}).
         $costgrprules['cost'][] = array(null, 'numeric', null, 'client');
         $mform->addGroupRule('costgrp', $costgrprules);
         $mform->setHelpButton('costgrp', array('cost', get_string('cost')), true);
         $mform->setDefault('cost', '');
         $mform->setDefault('currency', empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency);
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('language'));
     $languages = array();
     $languages[''] = get_string('forceno');
     $languages += get_list_of_languages();
     $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
     $mform->setDefault('lang', $courseconfig->lang);
     //--------------------------------------------------------------------------------
     require_once $CFG->libdir . '/completionlib.php';
     if (completion_info::is_enabled_for_site()) {
         $mform->addElement('header', '', get_string('progress', 'completion'));
         $mform->addElement('select', 'enablecompletion', get_string('completion', 'completion'), array(0 => get_string('completiondisabled', 'completion'), 1 => get_string('completionenabled', 'completion')));
         $mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
     } else {
         $mform->addElement('hidden', 'enablecompletion');
         $mform->setDefault('enablecompletion', 0);
     }
     //--------------------------------------------------------------------------------
     if (has_capability('moodle/site:config', $systemcontext) && (!empty($course->requested) && $CFG->restrictmodulesfor == 'requested' || $CFG->restrictmodulesfor == 'all')) {
         $mform->addElement('header', '', get_string('restrictmodules'));
         $options = array();
         $options['0'] = get_string('no');
         $options['1'] = get_string('yes');
         $mform->addElement('select', 'restrictmodules', get_string('restrictmodules'), $options);
         $mods = array(0 => get_string('allownone'));
         $mods += $DB->get_records_menu('modules', array(), 'name', 'id, name');
         $mform->addElement('select', 'allowedmods', get_string('to'), $mods, array('multiple' => 'multiple', 'size' => '10'));
         $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0);
     } else {
         $mform->addElement('hidden', 'restrictmodules', null);
     }
     if ($CFG->restrictmodulesfor == 'all') {
         $mform->setDefault('allowedmods', explode(',', $CFG->defaultallowedmodules));
         if (!empty($CFG->restrictbydefault)) {
             $mform->setDefault('restrictmodules', 1);
         }
     }
     $mform->setType('restrictmodules', PARAM_INT);
     /// customizable role names in this course
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'rolerenaming', get_string('rolerenaming'));
     $mform->setHelpButton('rolerenaming', array('rolerenaming', get_string('rolerenaming')), true);
     if ($roles = get_all_roles()) {
         if ($coursecontext) {
             $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW);
         }
         $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE);
         foreach ($roles as $role) {
             $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->name));
             if (isset($role->localname)) {
                 $mform->setDefault('role_' . $role->id, $role->localname);
             }
             $mform->setType('role_' . $role->id, PARAM_TEXT);
             if (!in_array($role->id, $assignableroles)) {
                 $mform->setAdvanced('role_' . $role->id);
             }
         }
     }
     //--------------------------------------------------------------------------------
     $this->add_action_buttons();
     //--------------------------------------------------------------------------------
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:edit_form.php

示例5: get_string

                        break;
                    default:
                }
            } else {
            }
        }
        if ($updated) {
            $notice_ok[] = get_string('langupdatecomplete', 'admin');
        } else {
            $notice_ok[] = get_string('nolangupdateneeded', 'admin');
        }
        break;
}
//close of main switch
admin_externalpage_print_header();
$installedlangs = get_list_of_languages(true, true);
$missingparents = array();
$oldlang = isset($SESSION->lang) ? $SESSION->lang : null;
// override current lang
foreach ($installedlangs as $l => $unused) {
    $SESSION->lang = $l;
    $parent = get_string('parentlanguage');
    if ($parent == 'en_utf8') {
        continue;
    }
    if (strpos($parent, '[[') !== false) {
        continue;
        // no parent
    }
    if (!isset($installedlangs[$parent])) {
        $missingparents[$l] = $parent;
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:langimport.php

示例6: tabobject

if (has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) {
    $firstrow[] = new tabobject('uselocal', "{$CFG->wwwroot}/{$CFG->admin}/lang.php?mode={$mode}&amp;currentfile={$currentfile}&amp;uselocal=1", $strlocalstringcustomization);
}
if (has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) {
    $firstrow[] = new tabobject('usemaster', "{$CFG->wwwroot}/{$CFG->admin}/lang.php?mode={$mode}&amp;currentfile={$currentfile}&amp;uselocal=0", $strlangpackmaintaining);
}
$secondrow[] = new tabobject('missing', "{$CFG->wwwroot}/{$CFG->admin}/lang.php?mode=missing", $strmissingstrings);
$secondrow[] = new tabobject('compare', "{$CFG->wwwroot}/{$CFG->admin}/lang.php?mode=compare", $streditstrings);
$secondrow[] = new tabobject('helpfiles', "{$CFG->wwwroot}/{$CFG->admin}/lang.php?mode=helpfiles", $stredithelpdocs);
$tabs = array($firstrow, $secondrow);
print_tabs($tabs, $currenttab, $inactive, $activated);
if (!$mode) {
    // TODO this is a very nice place to put some translation statistics
    print_box_start();
    $currlang = current_language();
    $langs = get_list_of_languages(false, true);
    popup_form("{$CFG->wwwroot}/{$CFG->admin}/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", false, 'self', $strcurrentlanguage . ':');
    print_box_end();
    admin_externalpage_print_footer();
    exit;
}
// Get a list of all the root files in the English directory
$langbase = $CFG->dataroot . '/lang';
$enlangdir = "{$CFG->dirroot}/lang/en_utf8";
if ($currentlang == 'en_utf8') {
    $langdir = $enlangdir;
} else {
    $langdir = "{$langbase}/{$currentlang}";
}
$locallangdir = "{$langbase}/{$currentlang}_local";
$saveto = $uselocal ? $locallangdir : $langdir;
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:lang.php

示例7: restore_create_users

function restore_create_users($restore, $xml_file)
{
    global $CFG, $db;
    require_once $CFG->dirroot . '/tag/lib.php';
    $authcache = array();
    // Cache to get some bits from authentication plugins
    $status = true;
    // Users have already been checked by restore_precheck_users() so they are loaded
    // in backup_ids table. They don't need to be loaded (parsed) from XML again. Also, note
    // the same function has performed the needed modifications in the $user->mnethostid field
    // so we don't need to do it again here at all. Just some checks.
    // Get users ids from backup_ids table
    $userids = get_fieldset_select('backup_ids', 'old_id', "backup_code = {$restore->backup_unique_code} AND table_name = 'user'");
    // Have users to process, proceed with them
    if (!empty($userids)) {
        /// Get languages for quick search later
        $languages = get_list_of_languages();
        /// Iterate over all users loaded from xml
        $counter = 0;
        /// Init trailing messages
        $messages = array();
        foreach ($userids as $userid) {
            // Defaults
            $user_exists = false;
            // By default user does not exist
            $newid = null;
            // By default, there is not newid
            // Get record from backup_ids
            $useridsdbrec = backup_getid($restore->backup_unique_code, 'user', $userid);
            // Based in restore_precheck_users() calculations, if the user exists
            // new_id must contain the id of the matching user
            if (!empty($useridsdbrec->new_id)) {
                $user_exists = true;
                $newid = $useridsdbrec->new_id;
            }
            $user = $useridsdbrec->info;
            foreach (array_keys(get_object_vars($user)) as $field) {
                if (!is_array($user->{$field})) {
                    $user->{$field} = backup_todb($user->{$field}, false);
                    if (is_null($user->{$field})) {
                        $user->{$field} = '';
                    }
                }
            }
            //Now, recode some languages (Moodle 1.5)
            if ($user->lang == 'ma_nt') {
                $user->lang = 'mi_nt';
            }
            //Country list updates - MDL-13060
            //Any user whose country code has been deleted or modified needs to be assigned a valid one.
            $country_update_map = array('ZR' => 'CD', 'TP' => 'TL', 'FX' => 'FR', 'KO' => 'RS', 'CS' => 'RS', 'WA' => 'GB');
            if (array_key_exists($user->country, $country_update_map)) {
                $user->country = $country_update_map[$user->country];
            }
            //If language does not exist here - use site default
            if (!array_key_exists($user->lang, $languages)) {
                $user->lang = $CFG->lang;
            }
            //Check if it's admin and coursecreator
            $is_admin = !empty($user->roles['admin']);
            $is_coursecreator = !empty($user->roles['coursecreator']);
            //Check if it's teacher and student
            $is_teacher = !empty($user->roles['teacher']);
            $is_student = !empty($user->roles['student']);
            //Check if it's needed
            $is_needed = !empty($user->roles['needed']);
            //Calculate if it is a course user
            //Has role teacher or student or needed
            $is_course_user = ($is_teacher or $is_student or $is_needed);
            // Only try to perform mnethost/auth modifications if restoring to another server
            // or if, while restoring to same server, the user doesn't exists yet (rebuilt site)
            //
            // So existing user data in same server *won't be modified by restore anymore*,
            // under any circumpstance. If somehting is wrong with existing data, it's server fault.
            if (!backup_is_same_site($restore) || backup_is_same_site($restore) && !$user_exists) {
                //Arriving here, any user with mnet auth and using $CFG->mnet_localhost_id is wrong
                //as own server cannot be accesed over mnet. Change auth to manual and inform about the switch
                if ($user->auth == 'mnet' && $user->mnethostid == $CFG->mnet_localhost_id) {
                    // Respect registerauth
                    if ($CFG->registerauth == 'email') {
                        $user->auth = 'email';
                    } else {
                        $user->auth = 'manual';
                    }
                    // inform about the automatic switch of authentication/host
                    if (empty($user->mnethosturl)) {
                        $user->mnethosturl = '----';
                    }
                    $messages[] = get_string('mnetrestore_extusers_switchuserauth', 'admin', $user);
                }
            }
            unset($user->mnethosturl);
            //Flags to see what parts are we going to restore
            $create_user = true;
            $create_roles = true;
            $create_custom_profile_fields = true;
            $create_tags = true;
            $create_preferences = true;
            //If we are restoring course users and it isn't a course user
            if ($restore->users == 1 and !$is_course_user) {
//.........这里部分代码省略.........
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:101,代码来源:restorelib.php

示例8: jclic_get_languages

/**
* Get an array with the languages
*
* @return array   The array with each language.
*/
function jclic_get_languages()
{
    global $CFG;
    $tmplanglist = get_list_of_languages();
    $langlist = array();
    foreach ($tmplanglist as $lang => $langname) {
        if (substr($lang, -5) == '_utf8') {
            //Remove the _utf8 suffix from the lang to show
            $lang = substr($lang, 0, -5);
        }
        $langlist[$lang] = $langname;
    }
    return $langlist;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:19,代码来源:lib.php

示例9: restore_create_users

function restore_create_users($restore, $xml_file)
{
    global $CFG, $db;
    $status = true;
    //Check it exists
    if (!file_exists($xml_file)) {
        $status = false;
    }
    //Get info from xml
    if ($status) {
        //info will contain the old_id of every user
        //in backup_ids->info will be the real info (serialized)
        $info = restore_read_xml_users($restore, $xml_file);
    }
    //Now, get evey user_id from $info and user data from $backup_ids
    //and create the necessary records (users, user_students, user_teachers
    //user_course_creators and user_admins
    if (!empty($info->users)) {
        // Grab mnethosts keyed by wwwroot, to map to id
        $mnethosts = get_records('mnet_host', '', '', 'wwwroot', 'wwwroot, id');
        $languages = get_list_of_languages();
        foreach ($info->users as $userid) {
            $rec = backup_getid($restore->backup_unique_code, "user", $userid);
            $user = $rec->info;
            //Now, recode some languages (Moodle 1.5)
            if ($user->lang == 'ma_nt') {
                $user->lang = 'mi_nt';
            }
            //If language does not exist here - use site default
            if (!array_key_exists($user->lang, $languages)) {
                $user->lang = $CFG->lang;
            }
            //Check if it's admin and coursecreator
            $is_admin = !empty($user->roles['admin']);
            $is_coursecreator = !empty($user->roles['coursecreator']);
            //Check if it's teacher and student
            $is_teacher = !empty($user->roles['teacher']);
            $is_student = !empty($user->roles['student']);
            //Check if it's needed
            $is_needed = !empty($user->roles['needed']);
            //Calculate if it is a course user
            //Has role teacher or student or needed
            $is_course_user = ($is_teacher or $is_student or $is_needed);
            //Calculate mnethostid
            if (empty($user->mnethosturl) || $user->mnethosturl === $CFG->wwwroot) {
                $user->mnethostid = $CFG->mnet_localhost_id;
            } else {
                // fast url-to-id lookups
                if (isset($mnethosts[$user->mnethosturl])) {
                    $user->mnethostid = $mnethosts[$user->mnethosturl]->id;
                } else {
                    // should not happen, as we check in restore_chech.php
                    // but handle the error if it does
                    error("This backup file contains external Moodle Network Hosts that are not configured locally.");
                }
            }
            unset($user->mnethosturl);
            //To store new ids created
            $newid = null;
            //check if it exists (by username) and get its id
            $user_exists = true;
            $user_data = get_record("user", "username", addslashes($user->username), 'mnethostid', $user->mnethostid);
            if (!$user_data) {
                $user_exists = false;
            } else {
                $newid = $user_data->id;
            }
            //Flags to see if we have to create the user, roles and preferences
            $create_user = true;
            $create_roles = true;
            $create_preferences = true;
            //If we are restoring course users and it isn't a course user
            if ($restore->users == 1 and !$is_course_user) {
                //If only restoring course_users and user isn't a course_user, inform to $backup_ids
                $status = backup_putid($restore->backup_unique_code, "user", $userid, null, 'notincourse');
                $create_user = false;
                $create_roles = false;
                $create_preferences = false;
            }
            if ($user_exists and $create_user) {
                //If user exists mark its newid in backup_ids (the same than old)
                $status = backup_putid($restore->backup_unique_code, "user", $userid, $newid, 'exists');
                $create_user = false;
            }
            //Here, if create_user, do it
            if ($create_user) {
                //Unset the id because it's going to be inserted with a new one
                unset($user->id);
                //We addslashes to necessary fields
                $user->username = addslashes($user->username);
                $user->firstname = addslashes($user->firstname);
                $user->lastname = addslashes($user->lastname);
                $user->email = addslashes($user->email);
                $user->institution = addslashes($user->institution);
                $user->department = addslashes($user->department);
                $user->address = addslashes($user->address);
                $user->city = addslashes($user->city);
                $user->url = addslashes($user->url);
                $user->description = backup_todb($user->description);
                //We need to analyse the AUTH field to recode it:
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:restorelib.php

示例10: make_filter_options_custom

 /**
  * Make Custom Filter Options
  *
  * This function handles filters that require custom values (languages, countries, etc).
  *
  * @param string $group  The index of the group to which the sub filter belongs to.
  * @param string $name   The name of the sub filter to process.
  * @param array  $help   An array representing the help icon for the filter
  * @return array The customized options for the selected sub-filter
  */
 function make_filter_options_custom($options, $group, $name)
 {
     switch ($name) {
         case 'fullname':
             $firstname = $this->tables[$group]['user'] . '.firstname';
             $lastname = $this->tables[$group]['user'] . '.lastname';
             $options['dbfield'] = sql_concat($firstname, "' '", $lastname);
             $options['talias'] = '';
             $this->fieldtofiltermap[$group][$options['dbfield']] = generalized_filter_userprofilematch::filtertypetext;
             break;
         case 'country':
             // TBD: new 'country' filter spec???
             $countries = get_list_of_countries();
             $options['choices'] = $countries;
             // TBD: foreach assoc.
             //$this->err_dump($countries, '$countries');
             break;
         case 'confirmed':
             // TBD: yesno filter???
             $options['choices'] = array('0' => 'No', 1 => 'Yes');
             $options['numeric'] = 1;
             //$this->err_dump($myoptions['choices'],'options for confir
             break;
         case 'crsrole':
             $roles = get_records('role', '', '', '', 'id,name');
             $options['choices'] = array();
             foreach ($roles as $role) {
                 $options['choices'][$role->id] = $role->name;
             }
             $options['numeric'] = 1;
             $options['talias'] = $this->tables[$group]['role_assignments'];
             $options['dbfield'] = 'roleid';
             break;
         case 'lang':
             $options['choices'] = get_list_of_languages(true);
             // TBD
             //$this->err_dump($myoptions['choices'], 'list_of_languages
             break;
         case 'crscat':
             break;
         case 'sysrole':
             break;
         case 'auth':
             $auths = get_list_of_plugins('auth');
             //$this->err_dump($auths, '$auths');
             $options['choices'] = array();
             foreach ($auths as $auth) {
                 $options['choices'][$auth] = $auth;
                 // TBD
             }
             break;
     }
     if (array_key_exists($name, $this->_choices)) {
         $options['choices'] = $this->_choices[$name];
     }
     if (array_key_exists($name, $this->_fieldids)) {
         $options['fieldid'] = $this->_fieldids[$name];
     }
     return $options;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:70,代码来源:userprofilematch.php

示例11: cm_get_list_of_languages

/**
 * Return the language options.
 */
function cm_get_list_of_languages()
{
    /// Get them from Moodle... Replace this if they should be something else.
    /// Should thie really rely on Moodle? Or should we provide our own?
    $languages = get_list_of_languages(false, true);
    return $languages;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:10,代码来源:lib.php

示例12: make_template

 /**
  * realizes the template (the standard way is to compile content fields 
  * in a HTML template. 
  */
 public function make_template($lang = '')
 {
     global $CFG, $USER, $COURSE;
     $content = '';
     $context = context_course::instance($COURSE->id);
     if (!empty($lang)) {
         $languages[] = $lang;
     } else {
         if (strpos(@$CFG->textfilters, 'filter/multilang') !== false || strpos(@$CFG->textfilters, 'filter/multilangenhanced') !== false) {
             // We have multilang.
             $languages = array_keys(get_list_of_languages());
         } else {
             $languages[] = current_language();
         }
     }
     $content = '';
     foreach ($languages as $lang) {
         $template = $this->get_template($lang);
         if (!$template && !empty($CFG->defaultlang)) {
             $template = $this->get_template($CFG->defaultlang);
         }
         if ($template) {
             $contentlang = "<span class=\"multilang\" lang=\"{$lang}\" >";
             $contentlang .= $this->process_conditional($template);
             $contentlang .= "</span>";
             if (!empty($this->data)) {
                 $CFG->multilang_target_language = $lang;
                 foreach ($this->data as $key => $value) {
                     if (is_array($value) || is_object($value)) {
                         continue;
                     }
                     if (file_exists($CFG->dirroot . '/filter/multilangenhanced/filter.php')) {
                         include_once $CFG->dirroot . '/filter/multilangenhanced/filter.php';
                         $filter = new filter_multilangenhanced($context, array());
                         $formattedvalue = preg_match('/option$/', $key) || preg_match('/^http?:\\/\\//', $value) ? $value : $filter->filter($value);
                     } else {
                         $formattedvalue = $value;
                     }
                     $contentlang = str_replace("<%%{$key}%%>", $formattedvalue, $contentlang);
                 }
                 // Cleanup any unused tags and final replacements.
                 $contentlang = str_replace("<%%WWWROOT%%>", $CFG->wwwroot, $contentlang);
                 $contentlang = str_replace("<%%COURSEID%%>", $COURSE->id, $contentlang);
                 $contentlang = str_replace("<%%USERID%%>", $USER->id, $contentlang);
                 $contentlang = preg_replace("/<%%.*?%%>/", '', $contentlang);
                 unset($CFG->multilang_target_language);
             }
         } else {
             $contentlang = "<span class=\"multilang\" lang=\"{$multilang}\" >";
             $contentlang .= get_string('nocontentforthislanguage', 'customlabel');
             $contentlang .= "</span>";
         }
         $content .= $contentlang;
     }
     return $content;
 }
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:60,代码来源:customtype.class.php

示例13: definition

 function definition()
 {
     global $CFG;
     $templateuser = $this->_customdata;
     if (empty($templateuser)) {
         if (!($templateuser = get_admin())) {
             error('Could not find site admin');
         }
     }
     $mform =& $this->_form;
     $mform->addElement('file', 'userfile', get_string('file'));
     $mform->addRule('userfile', null, 'required');
     $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'admin'));
     $mform->addElement('text', 'username', get_string('username'), 'size="20"');
     $modules = get_list_of_plugins('auth');
     $auth_options = array();
     foreach ($modules as $module) {
         $auth_options[$module] = get_string("auth_{$module}" . "title", "auth");
     }
     $mform->addElement('select', 'auth', get_string('chooseauthmethod', 'auth'), $auth_options);
     $mform->setDefault('auth', $templateuser->auth);
     $mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod', 'auth')));
     $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
     $choices = array(get_string('emaildisplayno'), get_string('emaildisplayyes'), get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $choices = array(get_string('emailenable'), get_string('emaildisable'));
     $mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
     $choices = array(get_string('textformat'), get_string('htmlformat'));
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
     $mform->setDefault('mailformat', 1);
     $choices = array(get_string('autosubscribeyes'), get_string('autosubscribeno'));
     $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
     $mform->setDefault('autosubscribe', 1);
     if ($CFG->htmleditor) {
         $choices = array(get_string('texteditor'), get_string('htmleditor'));
         $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
         $mform->setDefault('htmleditor', 1);
     }
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
     $mform->setType('city', PARAM_MULTILANG);
     $mform->setDefault('city', $templateuser->city);
     $mform->addElement('select', 'country', get_string('selectacountry'), get_list_of_countries());
     $mform->setDefault('country', $templateuser->country);
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_list_of_languages());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->addElement('htmleditor', 'description', get_string('userdescription'));
     $mform->setType('description', PARAM_CLEAN);
     $mform->setHelpButton('description', array('text', get_string('helptext')));
     $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
     $mform->setType('institution', PARAM_MULTILANG);
     $mform->setDefault('institution', $templateuser->institution);
     $mform->addElement('text', 'department', get_string('department'), 'maxlength="30" size="25"');
     $mform->setType('department', PARAM_MULTILANG);
     $mform->setDefault('department', $templateuser->department);
     $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone1', PARAM_CLEAN);
     $mform->addElement('text', 'phone2', get_string('phone'), 'maxlength="20" size="25"');
     $mform->setType('phone2', PARAM_CLEAN);
     $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="25"');
     $mform->setType('address', PARAM_MULTILANG);
     $mform->addElement('header', 'settingsheader', get_string('settings'));
     $choices = array(get_string('infilefield', 'auth'), get_string('createpasswordifneeded', 'auth'));
     $mform->addElement('select', 'createpassword', get_string('passwordhandling', 'auth'), $choices);
     $mform->addElement('selectyesno', 'updateaccounts', get_string('updateaccounts', 'admin'));
     $mform->addElement('selectyesno', 'allowrenames', get_string('allowrenames', 'admin'));
     $choices = array(get_string('addcounter', 'admin'), get_string('skipuser', 'admin'));
     $mform->addElement('select', 'duplicatehandling', get_string('newusernamehandling', 'admin'), $choices);
     $this->add_action_buttons(false, get_string('uploadusers'));
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:75,代码来源:uploaduser_form.php

示例14: setup_lang_from_browser

/**
 * This function will search for browser prefereed languages, setting Moodle
 * to use the best one available if $SESSION->lang is undefined
 */
function setup_lang_from_browser()
{
    global $CFG, $SESSION, $USER;
    if (!empty($SESSION->lang) or !empty($USER->lang) or empty($CFG->autolang)) {
        // Lang is defined in session or user profile, nothing to do
        return;
    }
    if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        // There isn't list of browser langs, nothing to do
        return;
    }
    /// Extract and clean langs from headers
    $rawlangs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    $rawlangs = str_replace('-', '_', $rawlangs);
    // we are using underscores
    $rawlangs = explode(',', $rawlangs);
    // Convert to array
    $langs = array();
    $order = 1.0;
    foreach ($rawlangs as $lang) {
        if (strpos($lang, ';') === false) {
            $langs[(string) $order] = $lang;
            $order = $order - 0.01;
        } else {
            $parts = explode(';', $lang);
            $pos = strpos($parts[1], '=');
            $langs[substr($parts[1], $pos + 1)] = $parts[0];
        }
    }
    krsort($langs, SORT_NUMERIC);
    $langlist = get_list_of_languages();
    /// Look for such langs under standard locations
    foreach ($langs as $lang) {
        $lang = strtolower(clean_param($lang . '_utf8', PARAM_SAFEDIR));
        // clean it properly for include
        if (!array_key_exists($lang, $langlist)) {
            continue;
            // language not allowed, try next one
        }
        if (file_exists($CFG->dataroot . '/lang/' . $lang) or file_exists($CFG->dirroot . '/lang/' . $lang)) {
            $SESSION->lang = $lang;
            /// Lang exists, set it in session
            break;
            /// We have finished. Go out
        }
    }
    return;
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:52,代码来源:moodlelib.php

示例15: definition


//.........这里部分代码省略.........
     $mform->addElement('select', 'groupmodeforce', get_string('force'), $choices);
     $mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true);
     $mform->setDefault('groupmodeforce', 0);
     if (!empty($CFG->enablegroupings)) {
         //default groupings selector
         $options = array();
         $options[0] = get_string('none');
         $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('availability'));
     $choices = array();
     $choices['0'] = get_string('courseavailablenot');
     $choices['1'] = get_string('courseavailable');
     $mform->addElement('select', 'visible', get_string('availability'), $choices);
     $mform->setHelpButton('visible', array('courseavailability', get_string('availability')), true);
     $mform->setDefault('visible', 1);
     $mform->addElement('passwordunmask', 'enrolpassword', get_string('enrolmentkey'), 'size="25"');
     $mform->setHelpButton('enrolpassword', array('enrolmentkey', get_string('enrolmentkey')), true);
     $mform->setDefault('enrolpassword', '');
     $mform->setType('enrolpassword', PARAM_RAW);
     $choices = array();
     $choices['0'] = get_string('guestsno');
     $choices['1'] = get_string('guestsyes');
     $choices['2'] = get_string('guestskey');
     $mform->addElement('select', 'guest', get_string('opentoguests'), $choices);
     $mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true);
     $mform->setDefault('guest', 0);
     // If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here
     $enrol_object = $CFG;
     if (!empty($course)) {
         $enrol_object = $course;
     }
     if (method_exists(enrolment_factory::factory($enrol_object->enrol), 'print_entry') && $enrol_object->enrol != 'manual') {
         $costgroup = array();
         $currencies = get_list_of_currencies();
         $costgroup[] =& MoodleQuickForm::createElement('text', 'cost', '', 'maxlength="6" size="6"');
         $costgroup[] =& MoodleQuickForm::createElement('select', 'currency', '', $currencies);
         $mform->addGroup($costgroup, 'costgrp', get_string('cost'), '&nbsp;', false);
         //defining a rule for a form element within a group :
         $costgrprules = array();
         //set the message to null to tell Moodle to use a default message
         //available for most rules, fetched from language pack (err_{rulename}).
         $costgrprules['cost'][] = array(null, 'numeric', null, 'client');
         $mform->addGroupRule('costgrp', $costgrprules);
         $mform->setHelpButton('costgrp', array('cost', get_string('cost')), true);
         $mform->setDefault('cost', '');
         $mform->setDefault('currency', empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency);
     }
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('language'));
     $languages = array();
     $languages[''] = get_string('forceno');
     $languages += get_list_of_languages();
     $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
     //--------------------------------------------------------------------------------
     if (has_capability('moodle/site:config', $systemcontext) && (!empty($course->requested) && $CFG->restrictmodulesfor == 'requested' || $CFG->restrictmodulesfor == 'all')) {
         $mform->addElement('header', '', get_string('restrictmodules'));
         $options = array();
         $options['0'] = get_string('no');
         $options['1'] = get_string('yes');
         $mform->addElement('select', 'restrictmodules', get_string('restrictmodules'), $options);
         $mods = array(0 => get_string('allownone'));
         $mods += get_records_menu('modules', '', '', '', 'id, name');
         $mform->addElement('select', 'allowedmods', get_string('to'), $mods, array('multiple' => 'multiple', 'size' => '10'));
         $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0);
     } else {
         $mform->addElement('hidden', 'restrictmodules', null);
     }
     if ($CFG->restrictmodulesfor == 'all') {
         $mform->setDefault('allowedmods', explode(',', $CFG->defaultallowedmodules));
         if (!empty($CFG->restrictbydefault)) {
             $mform->setDefault('restrictmodules', 1);
         }
     }
     $mform->setType('restrictmodules', PARAM_INT);
     /// customizable role names in this course
     //--------------------------------------------------------------------------------
     $mform->addElement('header', '', get_string('roles'));
     if ($roles = get_records('role')) {
         foreach ($roles as $role) {
             $mform->addElement('text', 'role_' . $role->id, $role->name);
             if ($coursecontext) {
                 if ($rolename = get_record('role_names', 'roleid', $role->id, 'contextid', $coursecontext->id)) {
                     $mform->setDefault('role_' . $role->id, $rolename->text);
                 }
             }
         }
     }
     //--------------------------------------------------------------------------------
     $this->add_action_buttons();
     //--------------------------------------------------------------------------------
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
     // fill in default teacher and student names to keep backwards compatibility for a while
     $mform->addElement('hidden', 'teacher', get_string('defaultcourseteacher'));
     $mform->addElement('hidden', 'teachers', get_string('defaultcourseteachers'));
     $mform->addElement('hidden', 'student', get_string('defaultcoursestudent'));
     $mform->addElement('hidden', 'students', get_string('defaultcoursestudents'));
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:edit_form.php


注:本文中的get_list_of_languages函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。