当前位置: 首页>>代码示例>>PHP>>正文


PHP Str::tr方法代码示例

本文整理汇总了PHP中Str::tr方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::tr方法的具体用法?PHP Str::tr怎么用?PHP Str::tr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Str的用法示例。


在下文中一共展示了Str::tr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * Returns a (dot notated) language string
  *
  * @param string|array $line
  * @param array        $params
  * @param mixed        $default
  *
  * @return mixed
  */
 public static function get($line, array $params = array(), $default = null)
 {
     // create the list of keys to search
     if (!is_array($line)) {
         $line = array($line);
     }
     // look for a match
     foreach ($line as $key) {
         if (($found = static::getInstance()->get($key, '__FAIL__')) !== '__FAIL__') {
             break;
         }
     }
     // no match
     if ($found === '__FAIL__') {
         // do we have a default?
         if (func_num_args() == 4) {
             $found = $default;
         } else {
             // get the globally configured default
             $found = \Config::get('lang.default', '');
             $found = str_replace('{key}', array_shift($line), $found);
         }
     }
     // stuff in any parameters passed, and return the result
     return \Str::tr($found, $params);
 }
开发者ID:fuelphp,项目名称:legacy,代码行数:35,代码来源:Lang.php

示例2: create_user

 public function create_user($userdata)
 {
     $password = \Arr::get($userdata, 'password', null);
     $email = \Arr::get($userdata, 'email', null);
     if (is_null($password) || is_null($email)) {
         Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email);
         throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
     }
     $user = Auth_Driver::get_core_user($email);
     $security = new Model_User_Security();
     //Generate a salt
     $security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random());
     $security->password = Hasher::instance()->hash($password, $security->salt);
     if (\Config::get('ethanol.activate_emails', false)) {
         $keyLength = \Config::get('ethanol.activation_key_length');
         $security->activation_hash = Random::instance()->random($keyLength);
         $user->activated = 0;
         //Send email
         \Package::load('email');
         //Build an array of data that can be passed to the email template
         $emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash)));
         $email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send();
     } else {
         $user->activated = 1;
         $security->activation_hash = '';
     }
     $user->security = $security;
     $user->save();
     $user->clean_security();
     return $user;
 }
开发者ID:inespons,项目名称:ethanol,代码行数:31,代码来源:Database.php

示例3: get

 public static function get($line, array $params = array(), $default = null, $language = null)
 {
     $output = parent::get($line, $params, '__NOT__FOUND__', $language);
     if (!empty($output) && $output != '__NOT__FOUND__') {
         return $output;
     }
     if ($output == '__NOT__FOUND__') {
         $output = $default;
     }
     if (!static::$autosave || !\CMF::$lang_enabled) {
         return $output;
     }
     $language === null and $language = static::get_lang();
     $pos = strpos($line, '.');
     $group = 'common';
     $basename = $line;
     if ($pos === false) {
         if (empty($default)) {
             $default = $line;
         }
         $line = "{$group}.{$line}";
     } else {
         $basename = substr($line, $pos + 1);
         if (empty($default)) {
             $default = $basename;
         }
         $group = substr($line, 0, $pos);
     }
     // Try and load from the DB...
     if (!in_array($group . '_' . $language, static::$loaded)) {
         static::load("{$group}.db", $group, $language, true, true);
         static::$loaded[] = $group . '_' . $language;
     }
     // Don't continue if it's not the 'common' group
     if ($group != 'common') {
         return $output != null ? \Str::tr(\Fuel::value($output), $params) : $default;
     }
     $output = \Arr::get(static::$lines, "{$language}.{$line}");
     if ($output == null) {
         // First try and get from the fallback...
         $output = \Arr::get(static::$lines, static::$fallback[0] . ".{$line}");
         if (!in_array($group, static::$to_save)) {
             static::$to_save[] = $group;
         }
         //if (!empty($default) && $default != $line)
         static::set($line, $default);
         static::set($line, $default, null, static::$fallback[0]);
         if ($output == null) {
             $output = $default;
         }
     }
     return $output != null ? \Str::tr(\Fuel::value($output), $params) : $default;
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:53,代码来源:Lang.php

示例4: join

 public function join($alias_from, $rel_name, $alias_to_nr, $conditions = array())
 {
     $alias_to = 't' . $alias_to_nr;
     $model = array('model' => $this->model_to, 'connection' => call_user_func(array($this->model_to, 'connection')), 'table' => array(call_user_func(array($this->model_to, 'table')), $alias_to), 'primary_key' => call_user_func(array($this->model_to, 'primary_key')), 'join_type' => \Arr::get($conditions, 'join_type') ?: \Arr::get($this->conditions, 'join_type', 'left'), 'join_on' => array(), 'columns' => $this->select($alias_to), 'rel_name' => strpos($rel_name, '.') ? substr($rel_name, strrpos($rel_name, '.') + 1) : $rel_name, 'relation' => $this, 'where' => \Arr::get($conditions, 'where', array()), 'order_by' => \Arr::get($conditions, 'order_by') ?: \Arr::get($this->conditions, 'order_by', array()));
     var_dump($model);
     exit;
     reset($this->key_to);
     foreach ($this->key_from as $key) {
         $key_to = current($this->key_to);
         $alias = array();
         if ($key instanceof \Fuel\Core\Database_Query_Builder_Select) {
             $key = $key->compile();
             $key = \Str::tr($key, array('alias_to' => $alias_to, 'alias_from' => $alias_from, $rel_name => $alias_to));
             $key = \DB::expr('(' . $key . ')');
             $alias[0] = $key;
         } else {
             $alias[0] = $alias_from . '.' . $key;
         }
         $alias[1] = '=';
         if ($key_to instanceof \Fuel\Core\Database_Query_Builder_Select) {
             $key_to = current($this->key_to);
             $key_to = $key_to->compile();
             $key_to = \Str::tr($key_to, array('alias_to' => $alias_to, 'alias_from' => $alias_from, $rel_name => $alias_to));
             $key_to = \DB::expr('(' . $key_to . ')');
             $alias[2] = $key_to;
         } else {
             $alias[2] = $alias_to . '.' . $key_to;
         }
         $model['join_on'][] = $alias;
         next($this->key_to);
     }
     foreach (array(\Arr::get($this->conditions, 'where', array()), \Arr::get($conditions, 'join_on', array())) as $c) {
         foreach ($c as $key => $condition) {
             !is_array($condition) and $condition = array($key, '=', $condition);
             if (!$condition[0] instanceof \Fuel\Core\Database_Expression and strpos($condition[0], '.') === false) {
                 $condition[0] = $alias_to . '.' . $condition[0];
             }
             is_string($condition[2]) and $condition[2] = \Db::quote($condition[2], $model['connection']);
             $model['join_on'][] = $condition;
         }
     }
     return array($rel_name => $model);
 }
开发者ID:indigophp,项目名称:erp-stock-extra,代码行数:43,代码来源:hasone.php

示例5: line

 /**
  * Fetch a line from the language
  *
  * @param   string  key for the line
  * @param   array   array of params to str_replace
  * @return  bool|string  either the line or false when not found
  * @depricated  Remove in v1.2
  */
 public static function line($line, array $params = array())
 {
     logger(\Fuel::L_WARNING, 'This method is deprecated. Please use Lang::get() instead.', __METHOD__);
     return \Str::tr(\Arr::get(static::$lines, $line, false), $params);
 }
开发者ID:reganhimself,项目名称:KeeleProgrammers,代码行数:13,代码来源:lang.php

示例6: get

 /**
  * Returns a (dot notated) language string
  *
  * @param   string       $line      key for the line
  * @param   array        $params    array of params to str_replace
  * @param   mixed        $default   default value to return
  * @param   string|null  $language  name of the language to get, null for the configurated language
  * @return  mixed                   either the line or default when not found
  */
 public static function get($line, array $params = array(), $default = null, $language = null)
 {
     if ($language === null) {
         $languages = static::$fallback;
         array_unshift($languages, $language ?: \Config::get('language'));
         $language = reset($languages);
     }
     return isset(static::$lines[$language]) ? \Str::tr(\Fuel::value(\Arr::get(static::$lines[$language], $line, $default)), $params) : $default;
 }
开发者ID:wushian,项目名称:MDD,代码行数:18,代码来源:lang.php

示例7: get

 /**
  * Returns a (dot notated) language string
  *
  * @param   string       $line      key for the line
  * @param   array        $params    array of params to str_replace
  * @param   mixed        $default   default value to return
  * @param   string|null  $language  name of the language to get, null for the configurated language
  * @return  mixed                   either the line or default when not found
  */
 public static function get($line, array $params = array(), $default = null, $language = null)
 {
     $language === null and $language = static::get_lang();
     return isset(static::$lines[$language]) ? \Str::tr(\Fuel::value(\Arr::get(static::$lines[$language], $line, $default)), $params) : $default;
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:14,代码来源:lang.php

示例8: compile

 /**
  * Compile the SQL query and return it. Replaces any parameters with their
  * given values.
  *
  * @param   mixed $db Database instance or instance name
  *
  * @return  string
  */
 public function compile($db = null)
 {
     if ($this->_connection !== null and $db === null) {
         $db = $this->_connection;
     }
     if (!$db instanceof \Database_Connection) {
         // Get the database instance
         $db = $this->_connection ?: \Database_Connection::instance($db);
     }
     // Import the SQL locally
     $sql = $this->_sql;
     if (!empty($this->_parameters)) {
         // Quote all of the values
         $values = array_map(array($db, 'quote'), $this->_parameters);
         // Replace the values in the SQL
         $sql = \Str::tr($sql, $values);
     }
     return trim($sql);
 }
开发者ID:socialskeptic,项目名称:sainsburys,代码行数:27,代码来源:query.php

示例9: get

 /**
  * Returns a (dot notated) language string
  *
  * @param   string  key for the line
  * @param   array   array of params to str_replace
  * @param   mixed   default value to return
  * @return  mixed   either the line or default when not found
  */
 public static function get($line, array $params = array(), $default = null)
 {
     return \Str::tr(\Fuel::value(\Arr::get(static::$lines, $line, $default)), $params);
 }
开发者ID:beingsane,项目名称:TTII_2012,代码行数:12,代码来源:lang.php


注:本文中的Str::tr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。