本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container::getTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getTranslator方法的具体用法?PHP Container::getTranslator怎么用?PHP Container::getTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chamilo\CoreBundle\Framework\Container
的用法示例。
在下文中一共展示了Container::getTranslator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Class constructor
*/
function HTML_QuickForm_Select_Language($elementName = null, $elementLabel = null, $options = null, $attributes = null)
{
if (!isset($attributes['class'])) {
$attributes['class'] = 'chzn-select';
}
parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
// Get all languages
$languages = api_get_languages();
$this->_options = array();
$this->_values = array();
$platformLanguage = Container::getTranslator()->getLocale();
foreach ($languages as $language) {
if ($language['isocode'] == $platformLanguage) {
$this->addOption($language['english_name'], $language['isocode'], array('selected' => 'selected'));
} else {
$this->addOption($language['english_name'], $language['isocode']);
}
}
}
示例2: api_get_language_isocode
/**
* Gets language isocode column from the language table, taking the given language as a query parameter.
* @param string $language This is the name of the folder containing translations for the corresponding language (e.g arabic, english).
* @param string $default_code This is the value to be returned if there was no code found corresponding to the given language.
* If $language is omitted, interface language is assumed then.
* @return string The found isocode or null on error.
* Returned codes are according to the following standards (in order of preference):
* - ISO 639-1 : Alpha-2 code (two-letters code - en, fr, es, ...)
* - RFC 4646 : five-letter code based on the ISO 639 two-letter language codes
* and the ISO 3166 two-letter territory codes (pt-BR, ...)
* - ISO 639-2 : Alpha-3 code (three-letters code - ast, fur, ...)
*/
function api_get_language_isocode($language = null, $default_code = 'en')
{
return Container::getTranslator()->getLocale();
}
示例3: array
$group = array();
$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form->addGroup($group, '', get_lang('Subscription'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$obj = new GradeModel();
$obj->fill_grade_model_select_in_form($form);
$form->add_progress_bar();
$form->addElement('style_submit_button', 'submit', get_lang('CreateCourse'), 'class="add"');
// Set some default values.
$values['course_language'] = Container::getTranslator()->getLocale();
// api_get_setting('platformLanguage');
$values['disk_quota'] = round(api_get_setting('document.default_document_quotum') / 1024 / 1024, 1);
$default_course_visibility = api_get_setting('course.courses_default_creation_visibility');
if (isset($default_course_visibility)) {
$values['visibility'] = api_get_setting('course.courses_default_creation_visibility');
} else {
$values['visibility'] = COURSE_VISIBILITY_OPEN_PLATFORM;
}
$values['subscribe'] = 1;
$values['unsubscribe'] = 0;
$form->setDefaults($values);
/*
// Validate the form
if ($form->validate()) {
$course = $form->exportValues();
示例4: api_get_language_isocode
/**
* Gets current language iso code
*
* @return string
*/
function api_get_language_isocode()
{
return Container::getTranslator()->getLocale();
}
示例5: api_get_user_language
function api_get_user_language()
{
$user_language = null;
if (!api_is_anonymous()) {
$userInfo = api_get_user_info();
if (isset($userInfo['language'])) {
$user_language = $userInfo['language'];
}
}
// When this is use?
/*
if (isset($_POST['language_list']) && !empty($_POST['language_list'])) {
if (in_array($_GET['language'], $valid_languages)) {
$user_language = str_replace('index.php?language=', '', $_POST['language_list']);
}
}*/
if (isset($_REQUEST['language']) && !empty($_REQUEST['language'])) {
api_set_login_language($_REQUEST['language']);
}
// Last chance we get the platform language
if (empty($user_language)) {
$user_language = Container::getTranslator()->getLocale();
}
return $user_language;
}
示例6: isset
/**
* function register_course to create a record in the course table of the main database
* @param string $course_sys_code
* @param string $course_screen_code
* @param string $course_repository
* @param string $course_db_name
* @param string $tutor_name
* @param string $category
* @param string $title complete name of course
* @param string $course_language lang for this course
* @param string $uid uid of owner
* @param integer Expiration date in unix time representation
* @param array Optional array of teachers' user ID
* @return int 0
* @todo use an array called $params instead of lots of params
*/
static function register_course($params)
{
global $error_msg, $firstExpirationDelay;
$title = $params['title'];
$code = $params['code'];
$visual_code = $params['visual_code'];
$directory = isset($params['directory']) ? $params['directory'] : null;
$tutor_name = isset($params['tutor_name']) ? $params['tutor_name'] : null;
$category_code = isset($params['category_code']) ? $params['category_code'] : null;
$defaultLanguage = Container::getTranslator()->getLocale();
$course_language = isset($params['course_language']) && !empty($params['course_language']) ? $params['course_language'] : $defaultLanguage;
$user_id = empty($params['user_id']) ? api_get_user_id() : intval($params['user_id']);
$department_name = isset($params['department_name']) ? $params['department_name'] : null;
$department_url = isset($params['department_url']) ? $params['department_url'] : null;
$disk_quota = isset($params['disk_quota']) ? $params['disk_quota'] : null;
if (!isset($params['visibility'])) {
$default_course_visibility = api_get_setting('course.courses_default_creation_visibility');
if (isset($default_course_visibility)) {
$visibility = $default_course_visibility;
} else {
$visibility = COURSE_VISIBILITY_OPEN_PLATFORM;
}
} else {
$visibility = $params['visibility'];
}
$subscribe = isset($params['subscribe']) ? intval($params['subscribe']) : ($visibility == COURSE_VISIBILITY_OPEN_PLATFORM ? 1 : 0);
$unsubscribe = isset($params['unsubscribe']) ? intval($params['unsubscribe']) : 0;
$expiration_date = isset($params['expiration_date']) ? $params['expiration_date'] : null;
$teachers = isset($params['teachers']) ? $params['teachers'] : null;
$status = isset($params['status']) ? $params['status'] : null;
$TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$ok_to_register_course = true;
// Check whether all the needed parameters are present.
if (empty($code)) {
$error_msg[] = 'courseSysCode is missing';
$ok_to_register_course = false;
}
if (empty($visual_code)) {
$error_msg[] = 'courseScreenCode is missing';
$ok_to_register_course = false;
}
if (empty($directory)) {
$error_msg[] = 'courseRepository is missing';
$ok_to_register_course = false;
}
if (empty($title)) {
$error_msg[] = 'title is missing';
$ok_to_register_course = false;
}
if (empty($expiration_date)) {
$expiration_date = api_get_utc_datetime(time() + $firstExpirationDelay);
} else {
$expiration_date = api_get_utc_datetime($expiration_date);
}
if ($visibility < 0 || $visibility > 3) {
$error_msg[] = 'visibility is invalid';
$ok_to_register_course = false;
}
if (empty($disk_quota)) {
$disk_quota = api_get_setting('document.default_document_quotum');
}
$time = api_get_utc_datetime();
if (stripos($department_url, 'http://') === false && stripos($department_url, 'https://') === false) {
$department_url = 'http://' . $department_url;
}
//just in case
if ($department_url == 'http://') {
$department_url = '';
}
$course_id = 0;
if ($ok_to_register_course) {
/** @var Course $course */
$course = self::getCourseManager()->create();
$course->setCode($code)->setDirectory($directory)->setCourseLanguage($course_language)->setTitle($title)->setDescription(get_lang('CourseDescription'))->setCategoryCode($category_code)->setVisibility($visibility)->setShowScore(1)->setDiskQuota($disk_quota)->setCreationDate(new \DateTime())->setExpirationDate(new \DateTime($expiration_date))->setDepartmentName($department_name)->setDepartmentUrl($department_url)->setSubscribe($subscribe)->setUnsubscribe($unsubscribe)->setVisualCode($visual_code);
self::getCourseManager()->save($course, true);
$course_id = $course->getId();
/*// Here we must add 2 fields.
$sql = "INSERT INTO ".$TABLECOURSE . " SET
code = '".Database :: escape_string($code) . "',
directory = '".Database :: escape_string($directory) . "',
course_language = '".Database :: escape_string($course_language) . "',
title = '".Database :: escape_string($title) . "',
description = '".Database::escape_string(get_lang('CourseDescription')) . "',
//.........这里部分代码省略.........
示例7: api_get_language_isocode
/**
* Gets language isocode column from the language table, taking the given language as a query parameter.
* @param string $language This is the name of the folder containing translations for the corresponding language (e.g arabic, english).
* @param string $default_code This is the value to be returned if there was no code found corresponding to the given language.
* If $language is omitted, interface language is assumed then.
* @return string The found isocode or null on error.
* Returned codes are according to the following standards (in order of preference):
* - ISO 639-1 : Alpha-2 code (two-letters code - en, fr, es, ...)
* - RFC 4646 : five-letter code based on the ISO 639 two-letter language codes
* and the ISO 3166 two-letter territory codes (pt-BR, ...)
* - ISO 639-2 : Alpha-3 code (three-letters code - ast, fur, ...)
*/
function api_get_language_isocode($language = null, $default_code = 'en')
{
return Container::getTranslator()->getLocale();
static $iso_code = array();
if (empty($language)) {
$language = api_get_interface_language(false, true);
}
if (!isset($iso_code[$language])) {
if (!class_exists('Database')) {
return $default_code;
// This might happen, in case of calling this function early during the global initialization.
}
$sql_result = Database::query("SELECT isocode FROM " . Database::get_main_table(TABLE_MAIN_LANGUAGE) . " WHERE dokeos_folder = '{$language}'");
if (Database::num_rows($sql_result)) {
$result = Database::fetch_array($sql_result);
$iso_code[$language] = trim($result['isocode']);
} else {
$language_purified_id = api_purify_language_id($language);
$iso_code[$language] = isset($iso_code[$language_purified_id]) ? $iso_code[$language_purified_id] : null;
}
if (empty($iso_code[$language])) {
$iso_code[$language] = $default_code;
}
}
return $iso_code[$language];
}
示例8: update_user
/**
* Update user information with all the parameters passed to this function
* @param int The ID of the user to be updated
* @param string The user's firstname
* @param string The user's lastname
* @param string The user's username (login)
* @param string The user's password
* @param string The authentication source (default: "platform")
* @param string The user's e-mail address
* @param int The user's status
* @param string The user's official code (usually just an internal institutional code)
* @param string The user's phone number
* @param string The user's picture URL (internal to the Chamilo directory)
* @param int The user ID of the person who registered this user (optional, defaults to null)
* @param int The department of HR in which the user is registered (optional, defaults to 0)
* @param array A series of additional fields to add to this user as extra fields (optional, defaults to null)
* @return boolean true if the user information was updated
* @assert (false) === false
*/
public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email = null, $status = STUDENT, $official_code = null, $phone = null, $picture_uri = null, $expiration_date = null, $active = 1, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '', $send_email = false, $reset_password = 0)
{
global $_configuration;
$original_password = $password;
$user_info = api_get_user_info($user_id, false, true);
if ($reset_password == 0) {
$password = null;
$auth_source = $user_info['auth_source'];
} elseif ($reset_password == 1) {
$original_password = $password = api_generate_password();
$auth_source = PLATFORM_AUTH_SOURCE;
} elseif ($reset_password == 2) {
$password = $password;
$auth_source = PLATFORM_AUTH_SOURCE;
} elseif ($reset_password == 3) {
$password = $password;
$auth_source = $auth_source;
}
if ($user_id != strval(intval($user_id))) {
return false;
}
if ($user_id === false) {
return false;
}
// Checking the user language.
$languages = api_get_platform_isocodes();
if (!in_array($language, $languages)) {
$language = Container::getTranslator()->getLocale();
}
if (!is_null($password)) {
if ($encrypt_method == '') {
$password = api_get_encrypted_password($password);
} else {
if ($_configuration['password_encryption'] === $encrypt_method) {
if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
return api_set_failure('encrypt_method invalid');
} else {
if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
return api_set_failure('encrypt_method invalid');
}
}
} else {
return api_set_failure('encrypt_method invalid');
}
}
}
$em = Database::getManager();
/** @var Chamilo\UserBundle\Entity\User $user */
$user = $em->getRepository('ChamiloUserBundle:User')->find($user_id);
if (is_array($extra) && count($extra) > 0) {
$res = true;
foreach ($extra as $name => $value) {
//$userField = $em->getRepository('ChamiloUserBundle:UserField')->findOneByName($name);
$res = $res && self::update_extra_field_value($user_id, $name, $value);
}
}
if ($user_info['active'] != $active) {
self::change_active_state($user_id, $active);
}
// Updating user
$user->setLastname($lastname)->setFirstname($firstname)->setUsername($username)->setAuthSource($auth_source)->setLanguage($language)->setEmail($email)->setOfficialCode($official_code)->setPhone($phone)->setPictureUri($picture_uri)->setExpirationDate($expiration_date)->setActive($active)->setHrDeptId($hr_dept_id);
if (!empty($original_password)) {
$user->setPlainPassword($original_password);
}
if (is_array($status)) {
foreach ($status as $groupId) {
$group = $em->getRepository('ChamiloUserBundle:Group')->find($groupId);
$user->addGroup($group);
}
} else {
$group = $em->getRepository('ChamiloUserBundle:Group')->find($status);
$user->addGroup($group);
}
Container::getUserManager()->updateUser($user, true);
if (!empty($email) && $send_email) {
$recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
$emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name');
$sender_name = api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('platform.administrator_email');
$emailbody = null;
/*api_mail_html($recipient_name, $email, $emailsubject,
//.........这里部分代码省略.........