本文整理汇总了PHP中api_get_interface_language函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_interface_language函数的具体用法?PHP api_get_interface_language怎么用?PHP api_get_interface_language使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_interface_language函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: returnNotice
/**
* Returns an HTML block with the notice, as found in the
* home/home_notice_[lang].html file
* @return string HTML <div> block
* @assert () != ''
*/
public function returnNotice()
{
$sys_path = api_get_path(SYS_PATH);
$user_selected_language = api_get_interface_language();
$home = api_get_home_path();
// Notice
$home_notice = @(string) file_get_contents($sys_path . $home . 'home_notice_' . $user_selected_language . '.html');
if (empty($home_notice)) {
$home_notice = @(string) file_get_contents($sys_path . $home . 'home_notice.html');
}
if (!empty($home_notice)) {
$home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
$home_notice = Display::div($home_notice, array('class' => 'homepage_notice'));
$this->show_right_block(get_lang('Notice'), null, 'notice_block', array('content' => $home_notice));
}
}
示例2: api_substr
echo 'Error in database with email ' . $mail . "\n";
}
if (Database::num_rows($res) == 0) {
echo '[Error] Email not found in database: ' . $row['email'] . "\n";
} else {
$row = Database::fetch_assoc($res);
$pass = api_substr($row['username'], 0, 4) . rand(0, 9) . rand(0, 9);
if ($user) {
/** @var User $user */
$user = $repository->find($row['user_id']);
$user->setPlainPassword($pass);
$userManager->updateUser($user, true);
} else {
echo "[Error] Error updating password. Skipping {$mail}\n";
continue;
}
$user = array('FirstName' => $row['firstname'], 'LastName' => $row['lastname'], 'UserName' => $row['username'], 'Password' => $pass, 'Email' => $mail);
$l = api_get_interface_language();
if (!empty($row['language'])) {
$l = $row['language'];
}
//This comes from main/admin/user_import.php::save_data() slightly modified
$recipient_name = api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS);
$emailsubject = '[' . api_get_setting('siteName') . '] ' . get_lang('YourReg', null, $l) . ' ' . api_get_setting('siteName');
$emailbody = get_lang('Dear', null, $l) . ' ' . api_get_person_name($user['FirstName'], $user['LastName']) . ",\n\n" . get_lang('YouAreReg', null, $l) . " " . api_get_setting('siteName') . " " . get_lang('WithTheFollowingSettings', null, $l) . "\n\n" . get_lang('Username', null, $l) . " : " . $user['UserName'] . "\n" . get_lang('Pass', null, $l) . " : " . $user['Password'] . "\n\n" . get_lang('Address', null, $l) . " " . api_get_setting('siteName') . " " . get_lang('Is', null, $l) . " : " . api_get_path(WEB_PATH) . " \n\n" . get_lang('Problem', null, $l) . "\n\n" . get_lang('Formula', null, $l) . ",\n\n" . api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')) . "\n" . get_lang('Manager', null, $l) . " " . api_get_setting('siteName') . "\nT. " . api_get_setting('administratorTelephone') . "\n" . get_lang('Email', null, $l) . " : " . api_get_setting('emailAdministrator') . "";
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
@api_mail_html($recipient_name, $user['Email'], $emailsubject, $emailbody, $sender_name, $email_admin);
echo "[OK] Sent to {$mail} with new password {$pass} (encrypted:{$crypass})... w/ subject: {$emailsubject}\n";
}
}
示例3: display_announcements_slider
/**
* Displays announcements as an slideshow
* @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER
* @param int $id The identifier of the announcement to display
*/
public static function display_announcements_slider($visible, $id = null)
{
$user_selected_language = Database::escape_string(api_get_interface_language());
$table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$cut_size = 500;
$now = api_get_utc_datetime();
$sql = "SELECT * FROM " . $table . "\n\t\t\t\tWHERE ( lang = '{$user_selected_language}' OR lang IS NULL) AND ( '{$now}' >= date_start AND '{$now}' <= date_end) ";
switch ($visible) {
case self::VISIBLE_GUEST:
$sql .= " AND visible_guest = 1 ";
break;
case self::VISIBLE_STUDENT:
$sql .= " AND visible_student = 1 ";
break;
case self::VISIBLE_TEACHER:
$sql .= " AND visible_teacher = 1 ";
break;
}
if (isset($id) && !empty($id)) {
$id = intval($id);
$sql .= " AND id = {$id} ";
}
if (api_is_multiple_url_enabled()) {
$current_url_id = api_get_current_access_url_id();
$sql .= " AND access_url_id IN ('1', '{$current_url_id}') ";
}
$sql .= " ORDER BY date_start DESC";
$announcements = Database::query($sql);
$html = '';
if (Database::num_rows($announcements) > 0) {
$html .= Display::page_header(get_lang('SystemAnnouncements'));
$html .= '<div id="container-slider" class="span6"><ul id="slider">';
while ($announcement = Database::fetch_object($announcements)) {
$content = $announcement->content;
$url = api_get_path(WEB_PUBLIC_PATH) . 'news/' . $announcement->id;
if (empty($id)) {
if (api_strlen(strip_tags($content)) > $cut_size) {
$content = Text::cut($announcement->content, $cut_size) . ' ' . Display::url(get_lang('More'), $url);
}
}
$html .= '<li><h2>' . $announcement->title . '</h2>' . $content . '</li>';
}
$html .= '</ul></div>';
}
return $html;
}
示例4: custompages_get_lang
function custompages_get_lang($variable)
{
return get_lang($variable, null, $_SESSION['user_language_choice']);
}
$language_file = array('courses', 'index', 'registration', 'admin', 'userInfo');
$available_langs = array('en', 'fr', 'es');
$chamilo_langs = array(null => 'english', 'en' => 'english', 'fr' => 'french', 'nl' => 'dutch', 'de' => 'german', 'es' => 'spanish');
$lang_match = $chamilo_langs[get_preferred_language($available_langs)];
// recover previous value ...
if (isset($_SESSION['user_language_choice'])) {
$lang_match = $_SESSION['user_language_choice'];
}
// Chamilo parameter, on logout
if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) {
$lang_match = $_REQUEST['language'];
}
// Incoming link parameter
if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) {
$lang_match = $chamilo_langs[$_REQUEST['lang']];
}
global $_configuration;
if (isset($_configuration['auto_detect_language_custom_pages']) && $_configuration['auto_detect_language_custom_pages'] == true) {
// Auto detect
$_user['language'] = $lang_match;
$_SESSION['user_language_choice'] = $lang_match;
} else {
// Chamilo default platform.
$defaultLanguage = api_get_interface_language();
$_user['language'] = $defaultLanguage;
$_SESSION['user_language_choice'] = $defaultLanguage;
}
示例5: _api_get_locale_from_language
/**
* Returns isocode (see api_get_language_isocode()) which is purified accordingly to
* be used by the php intl extension (ICU library).
* @param string $language (optional) This is the name of the folder containing translations for the corresponding language.
* If $language is omitted, interface language is assumed then.
* @return string The found language locale id or null on error. Examples: bg, en, pt_BR, ...
*/
function _api_get_locale_from_language($language = null)
{
static $locale = array();
if (empty($language)) {
$language = api_get_interface_language();
}
if (!isset($locale[$language])) {
$locale[$language] = str_replace('-', '_', api_get_language_isocode($language));
}
return $locale[$language];
}
示例6: array
// Moved here to include extra fields when creating a user. Formerly placed after user creation
// Register extra fields
$extras = array();
foreach ($values as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
$extras[substr($key, 6)] = $value;
} elseif (strpos($key, 'remove_extra_') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value($user_id, substr($key, 13), $extra_value);
}
}
$status = isset($values['status']) ? $values['status'] : STUDENT;
$phone = isset($values['phone']) ? $values['phone'] : null;
$values['language'] = isset($values['language']) ? $values['language'] : api_get_interface_language();
// Creates a new user
$user_id = UserManager::create_user($values['firstname'], $values['lastname'], $status, $values['email'], $values['username'], $values['pass1'], $values['official_code'], $values['language'], $phone, null, PLATFORM_AUTH_SOURCE, null, 1, 0, $extras, null, true);
//update the extra fields
$count_extra_field = count($extras);
if ($count_extra_field > 0) {
foreach ($extras as $key => $value) {
// For array $value -> if exists key 'tmp_name' then must not be empty
// This avoid delete from user field value table when doesn't upload a file
if (is_array($value)) {
if (array_key_exists('tmp_name', $value) && empty($value['tmp_name'])) {
//Nothing to do
} else {
if (array_key_exists('tmp_name', $value)) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']);
}
示例7: displayAnnouncement
/**
* Get the HTML code for an announcement
* @param int $announcementId The announcement ID
* @param int $visibility The announcement visibility
* @return string The HTML code
*/
public static function displayAnnouncement($announcementId, $visibility)
{
$selectedUserLanguage = Database::escape_string(api_get_interface_language());
$announcementTable = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$now = api_get_utc_datetime();
$whereConditions = ["(lang = ? OR lang IS NULL) " => $selectedUserLanguage, "AND (? >= date_start AND ? <= date_end) " => [$now, $now], "AND id = ? " => intval($announcementId)];
switch ($visibility) {
case self::VISIBLE_GUEST:
$whereConditions["AND visible_guest = ? "] = 1;
break;
case self::VISIBLE_STUDENT:
$whereConditions["AND visible_student = ? "] = 1;
break;
case self::VISIBLE_TEACHER:
$whereConditions["AND visible_teacher = ? "] = 1;
break;
}
if (api_is_multiple_url_enabled()) {
$whereConditions["AND access_url_id IN (1, ?) "] = api_get_current_access_url_id();
}
$announcement = Database::select("*", $announcementTable, ["where" => $whereConditions, "order" => "date_start"], 'first');
$template = new Template(null, false, false);
$template->assign('announcement', $announcement);
return $template->fetch('default/announcement/view.tpl');
}
示例8: explode
$emailForm = $_SERVER['SERVER_ADMIN'];
}
$email_parts = explode('@', $emailForm);
if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
$emailForm .= '.localdomain';
}
$adminLastName = get_lang('DefaultInstallAdminLastname');
$adminFirstName = get_lang('DefaultInstallAdminFirstname');
$loginForm = 'admin';
$passForm = api_generate_password();
$campusForm = 'My campus';
$educationForm = 'Albert Einstein';
$adminPhoneForm = '(000) 001 02 03';
$institutionForm = 'My Organisation';
$institutionUrlForm = 'http://www.chamilo.org';
$languageForm = api_get_interface_language();
$checkEmailByHashSent = 0;
$ShowEmailNotCheckedToStudent = 1;
$userMailCanBeEmpty = 1;
$allowSelfReg = 1;
$allowSelfRegProf = 1;
$encryptPassForm = 'sha1';
$session_lifetime = 360000;
if (!empty($_GET['profile'])) {
$installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
}
} else {
foreach ($_POST as $key => $val) {
$magic_quotes_gpc = ini_get('magic_quotes_gpc');
if (is_string($val)) {
if ($magic_quotes_gpc) {
示例9: make_charset_clause
/**
* Constructs a SQL clause about default character set and default collation for newly created databases and tables.
* Example: Database::make_charset_clause('UTF-8', 'bulgarian') returns
* DEFAULT CHARACTER SET `utf8` DEFAULT COLLATE `utf8_general_ci`
* @param string $encoding (optional) The default database/table encoding (a system conventional id) to be used.
* @param string $language (optional) Language (a system conventional id) used for choosing language sensitive collation (if it is possible).
* @return string Returns the constructed SQL clause or empty string if $encoding is not correct or is not supported.
* @author Ivan Tcholakov
*/
public static function make_charset_clause($encoding = null, $language = null)
{
if (empty($encoding)) {
$encoding = api_get_system_encoding();
}
if (empty($language)) {
$language = api_get_interface_language();
}
$charset_clause = '';
if (self::is_encoding_supported($encoding)) {
$db_encoding = Database::to_db_encoding($encoding);
$charset_clause .= " DEFAULT CHARACTER SET `" . $db_encoding . "`";
$db_collation = Database::to_db_collation($encoding, $language);
if (!empty($db_collation)) {
$charset_clause .= " DEFAULT COLLATE `" . $db_collation . "`";
}
}
return $charset_clause;
}
示例10: foreach
foreach ($_languages['name'] as $key => $value) {
$english_name = $_languages['folder'][$key];
if ($language == $english_name) {
$html .= '<option value="' . $english_name . '" selected="selected">' . $value . '</option>';
} else {
$html .= '<option value="' . $english_name . '">' . $value . '</option>';
}
}
$html .= '</select></td></tr>';
$form->addElement('html', $html);
}
$default[$name] = str_replace('{rel_path}', api_get_path(REL_PATH), $open);
$form->addHtmlEditor($name, '', true, false, array('ToolbarSet' => 'PortalHomePage', 'Width' => '100%', 'Height' => '400'));
$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
$form->addElement('html', '<table id="table_langs" style="margin-left:5px;"><tr>');
$currentLanguage = api_get_interface_language();
$i = 0;
foreach ($_languages['name'] as $key => $value) {
$lang_name = $_languages['folder'][$key];
$i++;
$checked = null;
if ($languageGet == $lang_name) {
$checked = "checked";
}
$html_langs = '<td width="300">';
$html_langs .= '<label><input type="checkbox" ' . $checked . ' id="lang" name="' . $lang_name . '" /> ' . $value . '<label/>';
$html_langs .= '</td>';
if ($i % 5 == 0) {
$html_langs .= '</tr><tr>';
}
$form->addElement('html', $html_langs);
示例11: api_get_interface_language
echo api_get_interface_language();
?>
">
<?php
echo custompages_get_lang('Registration');
?>
</a><br />
<?php
}
?>
<a href="<?php
echo api_get_path(WEB_PATH);
?>
main/auth/lostPassword.php?language=<?php
echo api_get_interface_language();
?>
">
<?php
echo custompages_get_lang('LostPassword');
?>
</a>
</div>
</div> <!-- #form -->
<div id="footer">
<img src="<?php
echo api_get_path(WEB_PATH);
?>
/custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
示例12: toHtml
/**
* The ajax call must contain an array of id and text
* @return string
*/
function toHtml()
{
$html = api_get_js('select2/select2.js');
$iso = api_get_language_isocode(api_get_interface_language());
$localeFile = 'select2_locale_' . $iso . '.js';
if (file_exists(api_get_path(LIBRARY_PATH) . 'javascript/select2/' . $localeFile)) {
$html .= api_get_js('select2/' . $localeFile);
}
$html .= api_get_css(api_get_path(WEB_LIBRARY_PATH) . 'javascript/select2/select2.css');
$formatResult = $this->getAttribute('formatResult');
$formatCondition = null;
if (!empty($formatResult)) {
$formatCondition = ',
formatResult : ' . $formatResult . ',
formatSelection : ' . $formatResult . ',';
}
$defaultValues = $this->getAttribute('defaults');
$dataCondition = null;
$tags = null;
if (!empty($defaultValues)) {
$result = json_encode($defaultValues);
$result = str_replace('"id"', 'id', $result);
$result = str_replace('"text"', 'text', $result);
$dataCondition = '$("#' . $this->getAttribute('name') . '").select2("data", ' . $result . ')';
$tags = ', tags : function() { return ' . $result . '} ';
}
$width = 'element';
$givenWidth = $this->getAttribute('width');
if (!empty($givenWidth)) {
$width = $givenWidth;
}
//Get the minimumInputLength for select2
$minimumInputLength = $this->getAttribute('minimumInputLength') > 3 ? $this->getAttribute('minimumInputLength') : 3;
$plHolder = $this->getAttribute('placeholder');
if (empty($plHolder)) {
$plHolder = get_lang('SelectAnOption');
}
$html .= '<script>
$(function() {
$("#' . $this->getAttribute('name') . '").select2({
placeholder: "' . $plHolder . '",
allowClear: true,
width: "' . $width . '",
minimumInputLength: ' . $minimumInputLength . ',
// instead of writing the function to execute the request we use Select2s convenient helper
ajax: {
url: "' . $this->getAttribute('url') . '",
dataType: "json",
data: function (term, page) {
return {
q: term, // search term
page_limit: 10,
};
},
results: function (data, page) { // parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to alter remote JSON data
return {
results: data
};
}
}
' . $tags . '
' . $formatCondition . '
});
' . $dataCondition . '
});
</script>';
$html .= '<input id="' . $this->getAttribute('name') . '" name="' . $this->getAttribute('name') . '" />';
return $html;
}
示例13: toHtml
/**
* The ajax call must contain an array of id and text
* @return string
*/
function toHtml()
{
$html = api_get_asset('select2/dist/js/select2.min.js');
$iso = api_get_language_isocode(api_get_interface_language());
$languageCondition = '';
if (file_exists(api_get_path(SYS_PATH) . "web/assets/select2/dist/js/i18n/{$iso}.js")) {
$html .= api_get_asset("select2/dist/js/i18n/{$iso}.js");
$languageCondition = "language: '{$iso}',";
}
$html .= api_get_css(api_get_path(WEB_PATH) . 'web/assets/select2/dist/css/select2.min.css');
$formatResult = $this->getAttribute('formatResult');
$formatCondition = null;
if (!empty($formatResult)) {
$formatCondition = ',
templateResult : ' . $formatResult . ',
templateSelection : ' . $formatResult;
}
$width = 'element';
$givenWidth = '100%';
if (!empty($givenWidth)) {
$width = $givenWidth;
}
//Get the minimumInputLength for select2
$minimumInputLength = $this->getAttribute('minimumInputLength') > 3 ? $this->getAttribute('minimumInputLength') : 3;
$plHolder = $this->getAttribute('placeholder');
if (empty($plHolder)) {
$plHolder = get_lang('SelectAnOption');
}
$id = $this->getAttribute('id');
if (empty($id)) {
$id = $this->getAttribute('name');
$this->setAttribute('id', $id);
}
$html .= <<<JS
<script>
\$(function(){
\$('#{$this->getAttribute('id')}').select2({
{$languageCondition}
placeholder: '{$plHolder}',
allowClear: true,
width: '{$width}',
minimumInputLength: '{$minimumInputLength}',
ajax: {
url: '{$this->getAttribute('url')}',
dataType: 'json',
data: function(params) {
return {
q: params.term, // search term
page_limit: 10,
};
},
processResults: function (data, page) {
//parse the results into the format expected by Select2
return {
results: data.items
};
}
{$formatCondition}
}
});
});
</script>
JS;
$this->removeAttribute('formatResult');
$this->removeAttribute('minimumInputLength');
$this->removeAttribute('placeholder');
$this->removeAttribute('class');
$this->removeAttribute('url');
$this->setAttribute('style', 'width: 100%;');
return parent::toHtml() . $html;
}
示例14: create_username
/**
* Creates a username using person's names, i.e. creates jmontoya from Julio Montoya.
* @param string $firstname The first name of the user.
* @param string $lastname The last name of the user.
* @param string $language (optional) The language in which comparison is to be made. If language is omitted, interface language is assumed then.
* @param string $encoding (optional) The character encoding for the input names. If it is omitted, the platform character set will be used by default.
* @return string Suggests a username that contains only ASCII-letters and digits, without check for uniqueness within the system.
* @author Julio Montoya Armas
* @author Ivan Tcholakov, 2009 - rework about internationalization.
* @assert ('','') === false
* @assert ('a','b') === 'ab'
*/
public static function create_username($firstname, $lastname, $language = null, $encoding = null)
{
if (is_null($encoding)) {
$encoding = api_get_system_encoding();
}
if (is_null($language)) {
$language = api_get_interface_language();
}
$firstname = api_substr(preg_replace(USERNAME_PURIFIER, '', api_transliterate($firstname, '', $encoding)), 0, 1);
// The first letter only.
//Looking for a space in the lastname
$pos = api_strpos($lastname, ' ');
if ($pos !== false) {
$lastname = api_substr($lastname, 0, $pos);
}
$lastname = preg_replace(USERNAME_PURIFIER, '', api_transliterate($lastname, '', $encoding));
//$username = api_is_western_name_order(null, $language) ? $firstname.$lastname : $lastname.$firstname;
$username = $firstname . $lastname;
if (empty($username)) {
$username = 'user';
}
return strtolower(substr($username, 0, USERNAME_MAX_LENGTH - 3));
}
示例15: display_language_selection
/**
* This function displays a language dropdown box so that the installatioin
* can be done in the language of the user
*/
function display_language_selection()
{
?>
<h2><?php
translate('WelcomeToTheDokeosInstaller');
?>
</h2>
<div class="RequirementHeading">
<h2><?php
echo display_step_sequence();
echo translate('InstallationLanguage');
?>
</h2>
<p><?php
echo translate('PleaseSelectInstallationProcessLanguage');
?>
:</p>
<form id="lang_form" method="post" action="<?php
echo api_get_self();
?>
">
<?php
display_language_selection_box('language_list', api_get_interface_language());
?>
<button type="submit" name="step1" class="btn next" autofocus="autofocus"
value="<?php
echo translate('Next');
?>
"><?php
echo translate('Next');
?>
</button>
<input type="hidden" name="is_executable" id="is_executable" value="-"/>
</form>
</div>
<?php
}