예제 #1
0
파일: Lang.php 프로젝트: unisexx/adf16
 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;
 }
예제 #2
0
 /**
  * __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;
     }
 }
예제 #3
0
파일: Lang.php 프로젝트: hqye/stblog
 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;
 }
예제 #4
0
 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}");
         }
     }
 }
예제 #5
0
 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);
 }
예제 #6
0
 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;
         }
     }
 }
예제 #7
0
파일: Lang.php 프로젝트: acampos1916/air
 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;
 }
예제 #8
0
 /**
  * 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);
 }
예제 #9
0
파일: _MY_Lang.php 프로젝트: anhlethe/Share
 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;
     }
 }
예제 #10
0
 /**
  * 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;
 }
예제 #11
0
 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;
 }
예제 #12
0
 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;
 }
예제 #13
0
 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;
     }
 }
예제 #14
0
 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']);
     }
 }
예제 #15
0
 function line($line, $params = null)
 {
     $return = parent::line($line);
     if ($return === false) {
         return "<em>{$line}</em>";
     } else {
         if (!is_null($params)) {
             $return = $this->_ni_line($return, $params);
         }
         return $return;
     }
 }
예제 #16
0
 function __construct()
 {
     parent::__construct();
     global $CFG, $URI, $RTR;
     $segment = $URI->segment(1);
     if (isset($this->languages[$segment])) {
         $language = $this->languages[$segment];
         $CFG->set_item('language', $language);
     } else {
         return;
     }
 }
예제 #17
0
 function __construct()
 {
     global $URI, $CFG;
     parent::__construct();
     $CFG->load('mci_languages');
     $this->mci_languages = $CFG->item('mci_languages');
     $this->mci_hide_default = $CFG->item('mci_hide_default');
     $this->mci_segment = $URI->segment(1, 0);
     $this->mci_default_language = array_search($CFG->item('language'), $this->mci_languages);
     if (array_key_exists($this->mci_segment, $this->mci_languages)) {
         $CFG->set_item('language', $this->mci_languages[$this->mci_segment]);
     }
 }
예제 #18
0
파일: Lang.php 프로젝트: JamieLomas/pyrocms
	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;
	}
예제 #19
0
 function line($line = '')
 {
     if (!$this->CI) {
         $this->CI =& get_instance();
         $this->CI->load->model('lang_model');
         $this->lang_model = $this->CI->lang_model;
     }
     $lang = get_lang();
     $l = $this->lang_model->line($line, $lang);
     if ($l != $line) {
         // If we found the line in the database
         return $l;
     }
     return parent::line($line, $lang);
     // Fallback to CI's default
 }
예제 #20
0
파일: MY_Lang.php 프로젝트: ukroficer/myci3
 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;
 }
예제 #21
0
 /**
  * Class constructor
  *
  * @return	void
  */
 public function __construct()
 {
     parent::__construct();
     log_message('debug', 'XtraUpload Zend Locale Class Initialized');
     try {
         $this->_default_locale = new Zend_Locale();
     } catch (Exception $e) {
         $this->_default_locale = new Zend_Locale('en_US');
     }
     if (!Zend_Locale::isLocale($this->_default_locale, true, false)) {
         if (!Zend_Locale::isLocale($this->_default_locale, false, false)) {
             throw new Zend_Locale_Exception("The locale '{$locale}' is no known locale");
         }
     }
     $locale = APPPATH . "/language/{$this->_default_locale}/xtraupload.mo";
     if (!is_file($locale)) {
         $this->_default_locale->setLocale('en_US');
     }
     $this->_default_locale = new Zend_Locale($this->_default_locale);
     $this->_translate = new Zend_Translate('gettext', APPPATH . "/language/{$this->_default_locale}/xtraupload.mo", $this->_default_locale->getLanguage());
     $this->_dbtypes = array('db_invalid_connection_str' => $this->lang('Unable to determine the database settings based on the connection string you submitted.'), 'db_unable_to_connect' => $this->lang('Unable to connect to your database server using the provided settings.'), 'db_invalid_query' => $this->lang('The query you submitted is not valid.'), 'db_must_set_table' => $this->lang('You must set the database table to be used with your query.'), 'db_must_use_set' => $this->lang('You must use the "set" method to update an entry.'), 'db_must_use_index' => $this->lang('You must specify an index to match on for batch updates.'), 'db_batch_missing_index' => $this->lang('One or more rows submitted for batch updating is missing the specified index.'), 'db_must_use_where' => $this->lang('Updates are not allowed unless they contain a "where" clause.'), 'db_del_must_use_where' => $this->lang('Deletes are not allowed unless they contain a "where" or "like" clause.'), 'db_field_param_missing' => $this->lang('To fetch fields requires the name of the table as a parameter.'), 'db_unsupported_function' => $this->lang('This feature is not available for the database you are using.'), 'db_transaction_failure' => $this->lang('Transaction failure: Rollback performed.'), 'db_unable_to_drop' => $this->lang('Unable to drop the specified database.'), 'db_unsuported_feature' => $this->lang('Unsupported feature of the database platform you are using.'), 'db_unsuported_compression' => $this->lang('The file compression format you chose is not supported by your server.'), 'db_filepath_error' => $this->lang('Unable to write data to the file path you have submitted.'), 'db_invalid_cache_path' => $this->lang('The cache path you submitted is not valid or writable.'), 'db_table_name_required' => $this->lang('A table name is required for that operation.'), 'db_column_name_required' => $this->lang('A column name is required for that operation.'), 'db_column_definition_required' => $this->lang('A column definition is required for that operation.'), 'db_error_heading' => $this->lang('A Database Error Occurred'));
 }
예제 #22
0
 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;
 }
예제 #23
0
 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;
 }
예제 #24
0
파일: requests.php 프로젝트: Rotron/jorani
 /**
  * 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 <*****@*****.**>
  */
 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);
 }
예제 #25
0
 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);
 }
예제 #26
0
파일: session.php 프로젝트: shawnyeh/jorani
 /**
  * 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 <*****@*****.**>
  */
 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";
     }
 }
예제 #27
0
 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('*****@*****.**', '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();
     }
 }
예제 #28
0
 /**
  * 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 <*****@*****.**>
  */
 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('*****@*****.**', 'LMS');
     }
     $this->email->to($leave['email']);
     if (!is_null($supervisor)) {
         $this->email->cc($supervisor->email);
     }
     $this->email->message($message);
     $this->email->send();
 }
예제 #29
0
파일: leaves.php 프로젝트: ishawge/jorani
 /**
  * Send a leave request email to the manager of the connected employee
  * @param int $id Leave request identifier
  * @author Benjamin BALET <*****@*****.**>
  */
 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('*****@*****.**', '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();
     }
 }
예제 #30
0
 function __construct()
 {
     parent::__construct();
     global $CFG;
     global $URI;
     global $RTR;
     //$_SESSION['dfksl']="dfkjsdlfslkfslk";
     //echo "I am here";
     //print_r($_SESSION); exit;
     //echo "I am here"; exit;
     //$_SESSION['choosen_language']='no';
     /*ini_set('display_startup_errors',1);
     		ini_set('display_errors',1);
     		error_reporting(-1);*/
     $this->host = str_replace("www.", "", $_SERVER['HTTP_HOST']);
     $segment = $URI->segment(1);
     if (!empty($segment) && !isset($this->languages[$segment]) && !empty($_SESSION['choosen_language']) && $_SESSION['choosen_language'] == 'yes') {
         //echo "I am here"; exit;
         return true;
     }
     if (isset($segment) && $segment == 'en') {
         //return true;
         //----------------------------------$_SESSION['choosen_language']='yes';
         //----------------------------------return ;
     }
     //------------------- this is for enable en.domainname.com/en
     /*if(isset($segment) && $segment == 'en')
     		{ 
     			$url=$CFG->item('root_url');
     			$_SESSION['choosen_language']='yes';
     			header("Location: " . $url, TRUE, 302);
     			exit;
     		}
     		else
     		{
     			$_SESSION['choosen_language']='no';
     		}*/
     //print_r($_SESSION); exit;
     $subdomains = explode('.', $this->host);
     if (array_key_exists($subdomains[0], $this->languages)) {
         //echo "I am here"; exit;
         //echo $this->host; exit;
         //echo $this->host;
         //echo "<br>";
         $CFG->set_item('base_url', "http://" . $this->host . "/");
         $CFG->set_item('language', $this->languages[$subdomains[0]]);
         return true;
     }
     //echo $CFG->item('base_url');exit;
     //echo $CFG->item('base_url');exit;
     //echo "dkflsf"; exit;
     if (!empty($segment) && !isset($this->languages[$segment])) {
         //echo "I am here"; exit;
         //--------------------return true;
     }
     if (isset($this->languages[$segment])) {
         //print_r($segment); exit;
         $language = $this->languages[$segment];
         //print_r($language ); exit;
         $CFG->set_item('language', $language);
         //echo $segment; exit;
         //---------------
         $subdomains = explode('.', $this->host);
         //print_r($subdomains); exit;
         if (!array_key_exists($subdomains[0], $this->languages)) {
             //echo $CFG->site_url($this->localized($subdomains[0])); exit;
             //print_r($this->languages); exit;
             $CFG->set_item('base_url', "http://" . $segment . "." . $this->host . "/");
             $final_url = $CFG->site_url();
             if ($URI->uri_string) {
                 $final_url .= $URI->uri_string;
             }
             //echo $final_url; exit;
             header("Location: " . $final_url, TRUE, 302);
             //exit;
         }
         //$CFG->set_item('base_url', "http://".$this->host."/");
         //print_r($this->host); exit;
         return;
         //----------------
     } else {
         if ($this->is_special($segment)) {
             return;
         } else {
             //$browser_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
             //print_r($browser_lang); exit;
             $subdomains = explode('.', $this->host);
             //print_r($subdomains); exit;
             //print_r($subdomains); exit;
             //print_r($this->languages); exit;
             if (array_key_exists($subdomains[0], $this->languages)) {
                 //echo $CFG->site_url($this->localized($subdomains[0])); exit;
                 header("Location: " . $CFG->site_url($this->localized($subdomains[0])), TRUE, 302);
                 exit;
             }
             //-------------
             $browser_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
             //print_r($browser_lang); exit;
             if (array_key_exists($browser_lang, $this->languages)) {
                 $CFG->set_item('language', $this->languages[$browser_lang]);
             } else {
                 $CFG->set_item('language', $this->languages[$this->default_lang()]);
             }
             //--------------------------------if($CFG->item('language') == 'english') return true;
             //--------------
             //echo $CFG->site_url($this->localized($this->default_uri)) ; exit;
             // set default language
             //echo $this->default_uri ;exit;
             // redirect
             //print_r($URI->uri_string);
             //echo $this->default_uri; exit;
             $language_code = array_search($CFG->item('language'), $this->languages);
             //print_r($subdomains[0]);
             if (!array_key_exists($subdomains[0], $this->languages)) {
                 //echo "I am here"; exit;
                 $CFG->set_item('base_url', "http://" . $language_code . "." . $this->host . "/");
             }
             //echo $this->host; exit;
             $final_url = $CFG->site_url($this->localized($this->default_uri));
             $final_url = rtrim(trim($final_url), '/');
             //print_r($final_url); exit;
             if ($URI->uri_string) {
                 $final_url .= "/" . $URI->uri_string;
             }
             //echo $final_url; exit;
             header("Location: " . $final_url, TRUE, 302);
             exit;
         }
     }
 }