本文整理汇总了PHP中CI_Lang类的典型用法代码示例。如果您正苦于以下问题:PHP CI_Lang类的具体用法?PHP CI_Lang怎么用?PHP CI_Lang使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CI_Lang类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: load
public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
{
// Are we loading an array of languages? If so, handle each one on its own.
if (is_array($langfile)) {
foreach ($langfile as $_lang) {
$this->load($_lang);
}
return $this->language;
}
// --------------------------------------------------------------------------
// Determine which language we're using, if not specified, use the app's default
$_default = CI::$APP->config->item('language');
$idiom = $lang == '' ? $_default : $lang;
// --------------------------------------------------------------------------
// Check to see if the language file has already been loaded
if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
return $this->language;
}
// --------------------------------------------------------------------------
// Look for the language
$_module or $_module = CI::$APP->router->fetch_module();
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
/**
*
* Confession. I'm not entirely sure how/why this works. Dumping out debug statements confuses
* me as they don't make sense, but the right lang files seem to be laoded. Sorry, future Pablo.
*
**/
if ($path === FALSE) {
// File not found, fallback to the default language if not already using it
if ($idiom != $_default) {
// Using MXs version seems to work as expected.
if ($lang = parent::load($langfile, $_default, $return, $add_suffix, $alt_path)) {
return $lang;
}
} else {
// Not found within modules, try normal load()
if ($lang = CI_Lang::load($langfile, $idiom, $return, $add_suffix, $alt_path)) {
return $lang;
}
}
} else {
// Lang file was found. Load it.
if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
if ($return) {
return $lang;
}
$this->language = array_merge($this->language, $lang);
$this->is_loaded[] = $langfile . '_lang' . EXT;
unset($lang);
}
}
// --------------------------------------------------------------------------
return $this->language;
}
开发者ID:nailsapp,项目名称:common,代码行数:55,代码来源:CORE_NAILS_Lang.php
示例2: sendMail
/**
* Send a leave request email to the employee that requested the leave
* The method will check if the leave request was accepted or rejected
* before sending the e-mail
* @param int $id Leave request identifier
* @author Benjamin BALET <[email protected]>
*/
private function sendMail($id)
{
$this->load->model('users_model');
$this->load->model('organization_model');
$leave = $this->leaves_model->getLeaves($id);
$employee = $this->users_model->getUsers($leave['employee']);
$supervisor = $this->organization_model->getSupervisor($employee['organization']);
//Send an e-mail to the employee
$this->load->library('email');
$this->load->library('polyglot');
$usr_lang = $this->polyglot->code2language($employee['language']);
//We need to instance an different object as the languages of connected user may differ from the UI lang
$lang_mail = new CI_Lang();
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
$date = new DateTime($leave['startdate']);
$startdate = $date->format($lang_mail->line('global_date_format'));
$date = new DateTime($leave['enddate']);
$enddate = $date->format($lang_mail->line('global_date_format'));
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_leave_request_validation_title'), 'Firstname' => $employee['firstname'], 'Lastname' => $employee['lastname'], 'StartDate' => $startdate, 'EndDate' => $enddate, 'StartDateType' => $lang_mail->line($leave['startdatetype']), 'EndDateType' => $lang_mail->line($leave['enddatetype']), 'Cause' => $leave['cause'], 'Type' => $leave['type_name']);
if ($leave['status'] == 3) {
//accepted
$message = $this->parser->parse('emails/' . $employee['language'] . '/request_accepted', $data, TRUE);
$subject = $lang_mail->line('email_leave_request_accept_subject');
} else {
//rejected
$message = $this->parser->parse('emails/' . $employee['language'] . '/request_rejected', $data, TRUE);
$subject = $lang_mail->line('email_leave_request_reject_subject');
}
sendMailByWrapper($this, $subject, $message, $employee['email'], is_null($supervisor) ? NULL : $supervisor->email);
}
开发者ID:Rotron,项目名称:jorani,代码行数:39,代码来源:requests.php
示例3: sendMail
private function sendMail($id)
{
$this->load->model('users_model');
$this->load->model('organization_model');
$extra = $this->overtime_model->getExtras($id);
$employee = $this->users_model->getUsers($extra['employee']);
$supervisor = $this->organization_model->getSupervisor($employee['organization']);
$this->load->library('email');
$this->load->library('polyglot');
$usr_lang = $this->polyglot->code2language($employee['language']);
$lang_mail = new CI_Lang();
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
$date = new DateTime($extra['date']);
$startdate = $date->format($lang_mail->line('global_date_format'));
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_overtime_request_validation_title'), 'Firstname' => $employee['firstname'], 'Lastname' => $employee['lastname'], 'Date' => $startdate, 'Duration' => $extra['duration'], 'Cause' => $extra['cause']);
if ($extra['status'] == 3) {
$message = $this->parser->parse('emails/' . $employee['language'] . '/overtime_accepted', $data, TRUE);
$subject = $lang_mail->line('email_overtime_request_accept_subject');
} else {
$message = $this->parser->parse('emails/' . $employee['language'] . '/overtime_rejected', $data, TRUE);
$subject = $lang_mail->line('email_overtime_request_reject_subject');
}
sendMailByWrapper($this, $subject, $message, $employee['email'], is_null($supervisor) ? NULL : $supervisor->email);
}
开发者ID:HarkiratGhotra,项目名称:application,代码行数:26,代码来源:overtime.php
示例4: forgetpassword
/**
* Ajax : Send the password by e-mail to a user requesting it
* POST: string login Login of the user
* RETURN: UNKNOWN if the login was not found, OK otherwise
* @author Benjamin BALET <[email protected]>
*/
public function forgetpassword()
{
$this->output->set_content_type('text/plain');
$login = $this->input->post('login');
$this->load->model('users_model');
$user = $this->users_model->getUserByLogin($login);
if (is_null($user)) {
echo "UNKNOWN";
} else {
//We need to instance an different object as the languages of connected user may differ from the UI lang
$lang_mail = new CI_Lang();
$usr_lang = $this->polyglot->code2language($user->language);
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
//Generate random password and store its hash into db
$password = $this->users_model->resetClearPassword($user->id);
//Prepare the e-mail content by parsing a view
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_password_forgotten_title'), 'BaseURL' => base_url(), 'Firstname' => $user->firstname, 'Lastname' => $user->lastname, 'Login' => $user->login, 'Password' => $password);
$message = $this->parser->parse('emails/' . $user->language . '/password_forgotten', $data, TRUE);
//Send the e-mail
sendMailByWrapper($this, $lang_mail->line('email_password_forgotten_subject'), $message, $user->email);
//Tell to the frontend that we've found the login and sent the email
echo "OK";
}
}
开发者ID:shawnyeh,项目名称:jorani,代码行数:32,代码来源:session.php
示例5: sendMail
private function sendMail($id)
{
$this->load->model('users_model');
$this->load->model('delegations_model');
$manager = $this->users_model->getUsers($this->session->userdata('manager'));
if (empty($manager['email'])) {
$this->session->set_flashdata('msg', lang('extra_create_msg_error'));
} else {
$acceptUrl = base_url() . 'overtime/accept/' . $id;
$rejectUrl = base_url() . 'overtime/reject/' . $id;
$this->load->library('email');
$this->load->library('polyglot');
$usr_lang = $this->polyglot->code2language($manager['language']);
$lang_mail = new CI_Lang();
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
$date = new DateTime($this->input->post('date'));
$startdate = $date->format($lang_mail->line('global_date_format'));
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_extra_request_validation_title'), 'Firstname' => $this->session->userdata('firstname'), 'Lastname' => $this->session->userdata('lastname'), 'Date' => $startdate, 'Duration' => $this->input->post('duration'), 'Cause' => $this->input->post('cause'), 'UrlAccept' => $acceptUrl, 'UrlReject' => $rejectUrl);
$message = $this->parser->parse('emails/' . $manager['language'] . '/overtime', $data, TRUE);
$this->email->set_encoding('quoted-printable');
if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
$this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
} else {
$this->email->from('[email protected]', 'LMS');
}
$this->email->to($manager['email']);
if ($this->config->item('subject_prefix') != FALSE) {
$subject = $this->config->item('subject_prefix');
} else {
$subject = '[Jorani] ';
}
$delegates = $this->delegations_model->listMailsOfDelegates($manager['id']);
if ($delegates != '') {
$this->email->cc($delegates);
}
$this->email->subject($subject . $lang_mail->line('email_extra_request_reject_subject') . ' ' . $this->session->userdata('firstname') . ' ' . $this->session->userdata('lastname'));
$this->email->message($message);
$this->email->send();
}
}
开发者ID:HarkiratGhotra,项目名称:application,代码行数:42,代码来源:extra.php
示例6: sendMail
/**
* Send a leave request email to the employee that requested the leave
* The method will check if the leave request wes accepted or rejected
* before sending the e-mail
* @param int $id Leave request identifier
* @author Benjamin BALET <[email protected]>
*/
private function sendMail($id)
{
$this->load->model('users_model');
$this->load->model('organization_model');
$leave = $this->leaves_model->get_leave_details($id);
//Load details about the employee (manager, supervisor of entity)
$supervisor = $this->organization_model->get_supervisor($leave['organization']);
//Send an e-mail to the employee
$this->load->library('email');
$this->load->library('polyglot');
$usr_lang = $this->polyglot->code2language($leave['language']);
//We need to instance an different object as the languages of connected user may differ from the UI lang
$lang_mail = new CI_Lang();
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
$date = new DateTime($leave['startdate']);
$startdate = $date->format($lang_mail->line('global_date_format'));
$date = new DateTime($leave['enddate']);
$enddate = $date->format($lang_mail->line('global_date_format'));
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_leave_request_validation_title'), 'Firstname' => $leave['firstname'], 'Lastname' => $leave['lastname'], 'StartDate' => $startdate, 'EndDate' => $enddate, 'StartDateType' => $lang_mail->line($leave['startdatetype']), 'EndDateType' => $lang_mail->line($leave['enddatetype']), 'Cause' => $leave['cause'], 'Type' => $leave['type']);
$message = "";
if ($this->config->item('subject_prefix') != FALSE) {
$subject = $this->config->item('subject_prefix');
} else {
$subject = '[Jorani] ';
}
if ($leave['status'] == 3) {
$message = $this->parser->parse('emails/' . $leave['language'] . '/request_accepted', $data, TRUE);
$this->email->subject($subject . $lang_mail->line('email_leave_request_accept_subject'));
} else {
$message = $this->parser->parse('emails/' . $leave['language'] . '/request_rejected', $data, TRUE);
$this->email->subject($subject . $lang_mail->line('email_leave_request_reject_subject'));
}
$this->email->set_encoding('quoted-printable');
if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
$this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
} else {
$this->email->from('[email protected]', 'LMS');
}
$this->email->to($leave['email']);
if (!is_null($supervisor)) {
$this->email->cc($supervisor->email);
}
$this->email->message($message);
$this->email->send();
}
开发者ID:roidelapluie,项目名称:jorani,代码行数:54,代码来源:requests.php
示例7: sendMail
/**
* Send a leave request email to the manager of the connected employee
* @param int $id Leave request identifier
* @author Benjamin BALET <[email protected]>
*/
private function sendMail($id)
{
$this->load->model('users_model');
$this->load->model('types_model');
$this->load->model('delegations_model');
//We load everything from DB as the LR can be edited from HR/Employees
$leave = $this->leaves_model->getLeaves($id);
$user = $this->users_model->getUsers($leave['employee']);
$manager = $this->users_model->getUsers($user['manager']);
//Test if the manager hasn't been deleted meanwhile
if (empty($manager['email'])) {
$this->session->set_flashdata('msg', lang('leaves_create_flash_msg_error'));
} else {
//Send an e-mail to the manager
$this->load->library('email');
$this->load->library('polyglot');
$usr_lang = $this->polyglot->code2language($manager['language']);
//We need to instance an different object as the languages of connected user may differ from the UI lang
$lang_mail = new CI_Lang();
$lang_mail->load('email', $usr_lang);
$lang_mail->load('global', $usr_lang);
$date = new DateTime($leave['startdate']);
$startdate = $date->format($lang_mail->line('global_date_format'));
$date = new DateTime($leave['enddate']);
$enddate = $date->format($lang_mail->line('global_date_format'));
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_leave_request_title'), 'Firstname' => $user['firstname'], 'Lastname' => $user['lastname'], 'StartDate' => $startdate, 'EndDate' => $enddate, 'StartDateType' => $lang_mail->line($leave['startdatetype']), 'EndDateType' => $lang_mail->line($leave['enddatetype']), 'Type' => $this->types_model->getName($leave['type']), 'Duration' => $leave['duration'], 'Balance' => $this->leaves_model->getLeavesTypeBalanceForEmployee($leave['employee'], $leave['type_name'], $leave['startdate']), 'Reason' => $leave['cause'], 'BaseUrl' => $this->config->base_url(), 'LeaveId' => $id, 'UserId' => $this->user_id);
$message = $this->parser->parse('emails/' . $manager['language'] . '/request', $data, TRUE);
$this->email->set_encoding('quoted-printable');
if ($this->config->item('from_mail') != FALSE && $this->config->item('from_name') != FALSE) {
$this->email->from($this->config->item('from_mail'), $this->config->item('from_name'));
} else {
$this->email->from('[email protected]', 'LMS');
}
$this->email->to($manager['email']);
if ($this->config->item('subject_prefix') != FALSE) {
$subject = $this->config->item('subject_prefix');
} else {
$subject = '[Jorani] ';
}
//Copy to the delegates, if any
$delegates = $this->delegations_model->listMailsOfDelegates($manager['id']);
if ($delegates != '') {
$this->email->cc($delegates);
}
$this->email->subject($subject . $lang_mail->line('email_leave_request_subject') . ' ' . $this->session->userdata('firstname') . ' ' . $this->session->userdata('lastname'));
$this->email->message($message);
$this->email->send();
}
}
开发者ID:ishawge,项目名称:jorani,代码行数:55,代码来源:leaves.php
示例8: load
public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
{
if (is_array($langfile)) {
return $this->load_many($langfile);
}
$deft_lang = CI::$APP->config->item('language');
$idiom = $lang == '' ? $deft_lang : $lang;
if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
return $this->language;
}
$_module || ($_module = CI::$APP->router->fetch_module());
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
if ($path === FALSE) {
if ($lang = parent::load($langfile, $lang, $return)) {
return $lang;
}
} else {
if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
if ($return) {
return $lang;
}
$this->language = array_merge($this->language, $lang);
$this->is_loaded[] = $langfile . '_lang';
unset($lang);
}
}
return $this->language;
}
开发者ID:unisexx,项目名称:adf16,代码行数:28,代码来源:Lang.php
示例9: header
/**
* __construct
*
* @global mixed $CFG
* @global mixed $URI
*
* @return void
*/
function MY_Lang()
{
parent::__construct();
global $CFG;
global $URI;
require_once APPPATH . "config/language.php";
$this->supported_languages = array_key_exists('supported_languages', $config) && !empty($config['supported_languages']) ? $config['supported_languages'] : $this->supported_languages;
$this->current_language = array_key_exists('default_language', $config) && !empty($config['default_language']) ? $config['default_language'] : $this->current_language;
$this->detect_language = array_key_exists('detect_language', $config) ? $config['detect_language'] : $this->detect_language;
$this->default_uri = array_key_exists('default_uri', $config) ? $config['default_uri'] : $this->default_uri;
$this->special_uris = array_key_exists('special_uris', $config) ? $config['special_uris'] : $this->special_uris;
$this->uri = $URI->uri_string();
$uri_segment = $this->get_uri_lang($this->uri);
$this->lang_code = $uri_segment['lang'];
$url_ok = FALSE;
if (!empty($this->lang_code) && array_key_exists($this->lang_code, $this->supported_languages)) {
$language = $this->supported_languages[$this->lang_code];
$CFG->set_item('language', $language);
$this->current_language = $this->lang_code;
$url_ok = TRUE;
}
if (!$url_ok && !$this->is_special($uri_segment['parts'][0])) {
// set default language
$this->current_language = $this->default_lang();
$CFG->set_item('language', $this->supported_languages[$this->current_language]);
$uri = !empty($this->uri) ? $this->uri : $this->default_uri;
$uri = $uri[0] != '/' ? '/' . $uri : $uri;
$new_url = $CFG->config['base_url'] . $this->default_lang() . $uri;
header("Location: " . $new_url, TRUE, 302);
exit;
}
}
开发者ID:Elangomanii,项目名称:sedarglobal,代码行数:40,代码来源:MY_Lang.php
示例10: load
public function load($langfile, $lang = '', $return = FALSE, $_module = NULL)
{
if (is_array($langfile)) {
return $this->load_many($langfile);
}
$deft_lang = CI::$APP->config->item('language');
$idiom = $lang == '' ? $deft_lang : $lang;
if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) {
return $this->language;
}
$_module or $_module = CI::$APP->router->fetch_module();
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
// Falls back to a default language if the current language file is missing.
if ($path === FALSE && FALLBACK_LANGUAGE) {
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . FALLBACK_LANGUAGE . '/');
}
if ($path === FALSE) {
if ($lang = parent::load($langfile, $lang, $return)) {
return $lang;
}
} else {
if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
if ($return) {
return $lang;
}
$this->language = array_merge($this->language, $lang);
$this->is_loaded[] = $langfile . '_lang';
unset($lang);
}
}
return $this->language;
}
开发者ID:hqye,项目名称:stblog,代码行数:32,代码来源:Lang.php
示例11: isset
function __construct()
{
parent::__construct();
$config =& get_config();
if (isset($config['languages']) && isset($config['redirect_urls'])) {
global $URI, $CFG, $IN;
//var_dump($URI);
$subdomain = $this->get_subdomain();
$lang = isset($subdomain) ? $subdomain : '';
$uri = $URI->segments;
if (strlen($lang) == 2 && array_key_exists($lang, $config['languages']) == true) {
$config['language'] = $config['languages'][$lang];
$config['prefix_language'] = $lang;
$config['base_url'] = "http://{$lang}." . $config['base_domain'];
} elseif ($config['redirect_urls'] == true || strlen($lang) == 2 && array_key_exists($lang, $config['languages']) == false) {
//todo: arreglar
$url = $config['base_url'];
$url .= empty($config['index_page']) ? '' : $config['index_page'] . '/';
$url .= array_search($config['language'], $config['languages']) . '/';
if (strlen($lang) == 2) {
array_shift($uri);
$url .= implode('/', $uri);
} else {
$url .= implode('/', $uri);
}
header("location: {$url}");
}
}
}
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:29,代码来源:MY_Lang.php
示例12: load
public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
// first we need to check if this is called before CI_controller
// if yes, well just use default
if (!class_exists('CI_controller')) {
return parent::load($file, $use_sections, $fail_gracefully);
}
if (is_array($langfile)) {
foreach ($langfile as $_lang) {
$this->load($_lang);
}
return $this->language;
}
$deft_lang = get_instance()->config->item('language');
$idiom or $idiom = $deft_lang;
if (in_array($langfile . '_lang.php', $this->is_loaded, TRUE)) {
return $this->language;
}
$_module = get_instance()->router->fetch_module();
if ($path = modules::find($langfile . '_lang', $_module, 'language/' . $idiom)) {
include $path;
if (!isset($lang) or !is_array($lang)) {
show_error("{$path} does not contain a valid lang array");
}
if ($return) {
return $lang;
}
$this->language = array_merge($this->language, $lang);
$this->is_loaded[] = $langfile . '_lang.php';
unset($lang);
return $this->language;
}
return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
}
开发者ID:egig,项目名称:CodeIgniter-HMVC-Support,代码行数:34,代码来源:Lang.php
示例13: header
function __construct()
{
parent::__construct();
global $CFG;
global $URI;
global $RTR;
$segment = $URI->segment(1);
if (isset($this->languages[$segment])) {
// URI with language -> ok
$language = $this->languages[$segment];
$CFG->set_item('language', $language);
} else {
if ($this->is_special($segment)) {
// special URI -> no redirect
return;
} else {
// URI without language -> redirect to default_uri
// set default language
$CFG->set_item('language', $this->languages[$this->default_lang()]);
// redirect
header("Location: " . $CFG->site_url($this->localized($this->default_uri)), TRUE, 302);
exit;
}
}
}
开发者ID:postyim,项目名称:greenteathai,代码行数:25,代码来源:MY_Lang.php
示例14: load
public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
{
if (is_array($langfile)) {
foreach ($langfile as $_lang) {
$this->load($_lang);
}
return $this->language;
}
$deft_lang = CI::$APP->config->item('language');
$idiom = $lang == '' ? $deft_lang : $lang;
if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) {
return $this->language;
}
$_module or $_module = CI::$APP->router->fetch_module();
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/');
if ($path === FALSE) {
if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) {
return $lang;
}
} else {
if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
if ($return) {
return $lang;
}
$this->language = array_merge($this->language, $lang);
$this->is_loaded[] = $langfile . '_lang' . EXT;
unset($lang);
}
}
return $this->language;
}
开发者ID:acampos1916,项目名称:air,代码行数:31,代码来源:Lang.php
示例15: load
/**
* Load language file.
* @param string $langfile language file without suffix _lang.php.
* @param string $idiom language idiom, if empty, default idiom will be used.
* @param boolean $return flag for returning lang file content from this method as array.
* @param boolean $add_sufix add suffix _lang to $langfile.
* @param string $alt_path alternative path to look for lang file.
* @return mixed
*/
public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
if ($idiom == '') {
$idiom = $this->lang_idiom;
}
return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
}
开发者ID:andrejjursa,项目名称:list-lms,代码行数:16,代码来源:LIST_Lang.php
示例16: header
function MY_Lang()
{
parent::__construct();
global $CFG;
global $URI;
global $RTR;
$this->uri = $URI->uri_string();
$this->default_uri = $RTR->default_controller;
$uri_segment = $this->get_uri_lang($this->uri);
$this->lang_code = $uri_segment['lang'];
$url_ok = false;
if (!empty($this->lang_code) && array_key_exists($this->lang_code, $this->languages)) {
$language = $this->languages[$this->lang_code];
$CFG->set_item('language', $language);
$url_ok = true;
}
if (!$url_ok && !$this->is_special($uri_segment['parts'][0])) {
// set default language
$CFG->set_item('language', $this->languages[$this->default_lang()]);
$uri = !empty($this->uri) ? $this->uri : $this->default_uri;
$uri = $uri[0] != '/' ? '/' . $uri : $uri;
$new_url = $CFG->config['base_url'] . $this->default_lang();
header("Location: " . $new_url, TRUE, 302);
exit;
}
}
开发者ID:anhlethe,项目名称:Share,代码行数:26,代码来源:_MY_Lang.php
示例17: line
/**
* Fetch a single line of text from the language array
*
* @access public
* @param string $line the language line
* @return string
*/
public function line($line = '')
{
$value = parent::line($line);
if ($value === FALSE) {
return $line;
}
return $value;
}
开发者ID:quemao18,项目名称:ci_cms,代码行数:15,代码来源:CMS_Lang.php
示例18: line
public function line()
{
$line = func_get_arg(0);
$text = parent::line($line);
if (func_num_args() > 1 and preg_match('/\\%/', $text)) {
$args = func_get_args();
array_shift($args);
$text = vsprintf($text, $args);
}
return $text;
}
开发者ID:anupkelkar02,项目名称:FSM,代码行数:11,代码来源:MY_Lang.php
示例19: line
function line($line, $params = null)
{
$return = parent::line($line);
if ($return === false) {
return str_replace('_', ' ', $line);
} else {
if (!is_null($params)) {
$return = $this->_ni_line($return, $params);
}
return $return;
}
}
开发者ID:princejeru10,项目名称:dras,代码行数:12,代码来源:MY_Lang.php
示例20: empty
function __construct()
{
parent::__construct();
global $URI, $CFG, $IN;
$config =& $CFG->config;
$index_page = $config['index_page'];
$lang_ignore = $config['lang_ignore'];
$default_abbr = $config['language_abbr'];
$lang_uri_abbr = $config['lang_uri_abbr'];
$lang_ignore_url = $config['lang_ignore_url'];
$uri_abbr = $URI->segment(1);
if (in_array($uri_abbr, $lang_ignore_url)) {
return;
}
// ignore url
$URI->uri_string = preg_replace("|^\\/?|", '/', $URI->uri_string);
if ($lang_ignore) {
if (isset($lang_uri_abbr[$uri_abbr])) {
$IN->set_cookie('user_lang', $uri_abbr, $config['sess_expiration']);
} else {
$lang_abbr = $IN->cookie($config['cookie_prefix'] . 'user_lang');
}
if (strlen($uri_abbr) == 2) {
$index_page .= empty($index_page) ? '' : '/';
$URI->uri_string = preg_replace("|^\\/?{$uri_abbr}\\/?|", '', $URI->uri_string);
header('Location: ' . $config['base_url'] . $index_page . $URI->uri_string);
exit;
}
} else {
$lang_abbr = $uri_abbr;
}
if (isset($lang_uri_abbr[$lang_abbr])) {
$this->_set_segment();
$URI->uri_string = preg_replace("|^\\/?{$lang_abbr}|", '', $URI->uri_string);
$config['language'] = $lang_uri_abbr[$lang_abbr];
$config['language_abbr'] = $lang_abbr;
if (!$lang_ignore) {
$index_page .= empty($index_page) ? $lang_abbr : "/{$lang_abbr}";
$config['index_page'] = $index_page . '/';
}
$IN->set_cookie('user_lang', $lang_abbr, $config['sess_expiration']);
} else {
if (!$lang_ignore) {
$index_page .= empty($index_page) ? $default_abbr : "/{$default_abbr}";
if (strlen($lang_abbr) == 2) {
$URI->uri_string = preg_replace("|^\\/?{$lang_abbr}|", '', $URI->uri_string);
}
header('Location: ' . $config['base_url'] . $index_page . $URI->uri_string);
exit;
}
$IN->set_cookie('user_lang', $default_abbr, $config['sess_expiration']);
}
}
开发者ID:n3mz77,项目名称:CodeIgniter-multi-lang,代码行数:53,代码来源:MY_Lang.php
注:本文中的CI_Lang类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论