本文整理汇总了PHP中CI_Lang::load方法的典型用法代码示例。如果您正苦于以下问题:PHP CI_Lang::load方法的具体用法?PHP CI_Lang::load怎么用?PHP CI_Lang::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI_Lang
的用法示例。
在下文中一共展示了CI_Lang::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: load
public function load($langfile, $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 . '/');
// Falls back to a default language if the current language file is missing.
if ($path === FALSE && self::$fall_back)
{
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . self::$fall_back . '/');
}
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;
}
示例8: load
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
$this->CI =& get_instance();
$this->CI->load->library('lang_cache');
if (is_array($langfile)) {
foreach ($langfile as $value) {
$this->load($value, $idiom, $return, $add_suffix, $alt_path);
}
return;
}
$langfile = str_replace('.php', '', $langfile);
if ($add_suffix == TRUE) {
$langfile = str_replace('_lang.', '', $langfile) . '_lang';
}
if (in_array($langfile, $this->is_loaded, TRUE)) {
return;
}
$config =& get_config();
if ($idiom == '') {
$deft_lang = !isset($config['language']) ? 'english' : $config['language'];
$idiom = $deft_lang == '' ? 'english' : $deft_lang;
}
if ($langfile == 'db_lang') {
$lang = parent::load($langfile, $idiom, true);
} else {
$lang = $this->CI->lang_cache->get_lang($idiom, $langfile);
}
if (!isset($lang)) {
log_message('error', 'Language file contains no data: language/' . $idiom . '/' . $langfile);
return;
}
if ($return == TRUE) {
return $lang;
}
$this->is_loaded[] = $langfile;
$this->language = array_merge($this->language, $lang);
unset($lang);
log_message('debug', 'Language file loaded: language/' . $idiom . '/' . $langfile);
return TRUE;
}
示例9: load
public function load($langfile = '', $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
{
if (is_array($langfile)) {
foreach ($langfile as $_lang) {
$this->load($_lang);
}
return $this->language;
}
if (!class_exists('CI')) {
exit('An error has occured that cannot be reported correctly. Check your database settings.');
}
$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 . '/');
// Falls back to a default language if the current language file is missing.
if ($path === FALSE && self::$fall_back) {
list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . self::$fall_back . '/');
}
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;
}
示例10: load
public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '')
{
if (!class_exists('CI')) {
// This happens before the whole core has been loaded.
$alt_path = COMMONPATH;
return parent::load($langfile, $lang, $return, $add_suffix, $alt_path);
}
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.php', $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.php';
unset($lang);
}
}
return $this->language;
}
示例11: load
/**
* Load a language file
*
* @access public
* @param mixed the name of the language file to be loaded. Can be an array
* @param string the language (english, etc.)
* @return mixed
*/
public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
{
return parent::load($langfile, !empty($idiom) ? $idiom : $this->_language(), $return, $add_suffix, $alt_path);
}
示例12: load
/**
* Same behavior as the parent method, but it can load the first defined
* lang configuration to fill other languages gaps. This is very useful
* because you don't have to update all your lang files during development
* each time you update a text. If a constant is missing it will load
* it in the first language configured in the array $languages. (OPB)
*
*
* @param boolean $load_first_lang false to keep the old behavior. Please
* modify the default value to true to use this feature without having to
* modify your code
*/
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $load_first_lang = false)
{
if ($load_first_lang) {
reset($this->languages);
$firstKey = key($this->languages);
$firstValue = $this->languages[$firstKey];
if ($this->lang_code != $firstKey) {
$addedLang = parent::load($langfile, $firstValue, $return, $add_suffix, $alt_path);
if ($addedLang) {
if ($add_suffix) {
$langfileToRemove = str_replace('.php', '', $langfile);
$langfileToRemove = str_replace('_lang.', '', $langfileToRemove) . '_lang';
$langfileToRemove .= '.php';
}
$this->is_loaded = array_diff($this->is_loaded, array($langfileToRemove));
}
}
}
return parent::load($langfile, $idiom, $return, $add_suffix, $alt_path);
}
示例13: create
/**
* Display the form / action Create a new user
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function create()
{
$this->auth->check_is_granted('create_user');
expires_now();
$data = getUserContext($this);
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('polyglot');
$data['title'] = lang('users_create_title');
$data['help'] = $this->help->create_help_link('global_link_doc_page_create_user');
$this->load->model('roles_model');
$data['roles'] = $this->roles_model->get_roles();
$this->load->model('contracts_model');
$data['contracts'] = $this->contracts_model->get_contracts();
$data['public_key'] = file_get_contents('./assets/keys/public.pem', true);
$this->form_validation->set_rules('firstname', lang('users_create_field_firstname'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('lastname', lang('users_create_field_lastname'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('login', lang('users_create_field_login'), 'required|callback_login_check|xss_clean|strip_tags');
$this->form_validation->set_rules('email', lang('users_create_field_email'), 'required|xss_clean|strip_tags');
if (!$this->config->item('ldap_enabled')) {
$this->form_validation->set_rules('CipheredValue', lang('users_create_field_password'), 'required');
}
$this->form_validation->set_rules('role[]', lang('users_create_field_role'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('manager', lang('users_create_field_manager'), 'required|xss_clean|strip_tags');
$this->form_validation->set_rules('contract', lang('users_create_field_contract'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('position', lang('users_create_field_position'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('entity', lang('users_create_field_entity'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('datehired', lang('users_create_field_hired'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('identifier', lang('users_create_field_identifier'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('language', lang('users_create_field_language'), 'xss_clean|strip_tags');
$this->form_validation->set_rules('timezone', lang('users_create_field_timezone'), 'xss_clean|strip_tags');
if ($this->config->item('ldap_basedn_db')) {
$this->form_validation->set_rules('ldap_path', lang('users_create_field_ldap_path'), 'xss_clean|strip_tags');
}
if ($this->form_validation->run() === FALSE) {
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
$this->load->view('users/create', $data);
$this->load->view('templates/footer');
} else {
$password = $this->users_model->set_users();
log_message('info', 'User ' . $this->input->post('login') . ' has been created by user #' . $this->session->userdata('id'));
//Send an e-mail to the user so as to inform that its account has been created
$this->load->library('email');
$usr_lang = $this->polyglot->code2language($this->input->post('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);
$this->load->library('parser');
$data = array('Title' => $lang_mail->line('email_user_create_title'), 'BaseURL' => base_url(), 'Firstname' => $this->input->post('firstname'), 'Lastname' => $this->input->post('lastname'), 'Login' => $this->input->post('login'), 'Password' => $password);
$message = $this->parser->parse('emails/' . $this->input->post('language') . '/new_user', $data, TRUE);
if ($this->email->mailer_engine == 'phpmailer') {
$this->email->phpmailer->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('do.not@reply.me', 'LMS');
}
$this->email->to($this->input->post('email'));
if ($this->config->item('subject_prefix') != FALSE) {
$subject = $this->config->item('subject_prefix');
} else {
$subject = '[Jorani] ';
}
$this->email->subject($subject . $lang_mail->line('email_user_create_subject'));
$this->email->message($message);
$this->email->send();
$this->session->set_flashdata('msg', lang('users_create_flash_msg_success'));
redirect('users');
}
}
示例14: 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('do.not@reply.me', '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();
}
}
示例15: 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 <benjamin.balet@gmail.com>
*/
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('do.not@reply.me', 'LMS');
}
$this->email->to($leave['email']);
if (!is_null($supervisor)) {
$this->email->cc($supervisor->email);
}
$this->email->message($message);
$this->email->send();
}