本文整理汇总了PHP中yii::t方法的典型用法代码示例。如果您正苦于以下问题:PHP yii::t方法的具体用法?PHP yii::t怎么用?PHP yii::t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii
的用法示例。
在下文中一共展示了yii::t方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdd
public function actionAdd()
{
$shipping_id = (int) \yii::$app->request->get('shipping', 0);
$sql = "SELECT shipping_name,shipping_code FROM " . Shipping::tableName() . " WHERE id={$shipping_id}";
$shipping = \yii::$app->getDb()->createCommand($sql)->queryOne();
$set_modules = 1;
include_once \yii::getAlias('@ext') . '/shipping/' . $shipping['shipping_code'] . '.php';
$fields = [];
foreach ($modules[0]['configure'] as $key => $val) {
$fields[$key]['name'] = $val['name'];
$fields[$key]['value'] = $val['value'];
$fields[$key]['label'] = \yii::t('shipping', $val['name']);
}
$count = count($fields);
$fields[$count]['name'] = "freee_money";
$fields[$count]['value'] = "0";
$fields[$count]['label'] = \yii::t('shipping', 'free_money');
//如果支持货到付款,则允许设置货到付款支付费用
if ($modules[0]['cod']) {
$count++;
$fields[$count]['name'] = "pay_fee";
$fields[$count]['value'] = "0";
$fields[$count]['label'] = \yii::t('shipping', 'pay_fee');
}
$shipping_area['shipping_id'] = 0;
$shipping_area['free_money'] = 0;
return $this->render('shipping_area_info', ['shipping_area' => ['shipping_id' => $shipping_id, 'shipping_code' => $shipping['shipping_code']], 'fields' => $fields, 'form_action' => 'insert']);
}
示例2: admin_log
/**
* 记录管理员的操作内容
*
* @access public
* @param string $sn 数据的唯一值
* @param string $action 操作的类型
* @param string $content 操作的内容
* @return void
*/
public static function admin_log($sn = '', $action, $content)
{
$log_info = \yii::t('log', $action) . \yii::t('log', $content) . ":" . Html::encode($sn);
$time = time();
$sql = "INSERT INTO " . self::tableName() . " (log_time,user_id,log_info,ip_address) " . " VALUES ('{$time}','" . \yii::$app->user->id . "','" . Html::encode($log_info) . "','" . \yii::$app->request->userIP . "')";
return \yii::$app->getDb()->createCommand($sql)->execute();
}
示例3: actionUpdate
public function actionUpdate()
{
$pictures = array();
$lid = Yii::app()->request->getParam('lid');
Until::isUpdateValid(array($lid), $this->companyId, $this);
//0,表示企业任何时候都在云端更新。
$criteria = new CDbCriteria();
$criteria->with = 'productImg';
$criteria->addCondition('t.lid=:lid and t.dpid=:dpid and t.delete_flag=0 ');
$criteria->order = ' t.lid desc ';
$criteria->params[':lid'] = $lid;
$criteria->params[':dpid'] = $this->companyId;
$model = Product::model()->find($criteria);
if (Yii::app()->request->isPostRequest) {
$postData = Yii::app()->request->getPost('productImg');
if (ProductPicture::saveImg($this->companyId, $lid, $postData)) {
Yii::app()->user->setFlash('success', yii::t('app', '修改成功'));
$this->redirect(array('productImg/index', 'companyId' => $this->companyId));
}
}
if (!empty($model->productImg)) {
foreach ($model->productImg as $pic) {
array_push($pictures, $pic->pic_path);
}
}
$this->render('updateProductImg', array('model' => $model, 'pictures' => $pictures));
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$pageSize = Yii::app()->request->getParam('pageSize', Yii::app()->params['pageSize']);
Yii::app()->user->setState('pageSize', $pageSize);
$model = new RejectModel('search');
$model->unsetAttributes();
// clear any default values
//lay mang phone
$phone = Yii::app()->request->getParam('phone');
$phoneModel = RejectModel::model()->findByAttributes(array('phone' => $phone));
if (empty($phoneModel)) {
$model = new RejectModel();
$model->phone = $phone;
try {
if ($model->save()) {
$message = yii::t('SpamModule', 'Success!');
} else {
$message = yii::t('SpamModule', 'Insert fail');
}
} catch (Exception $exc) {
echo $exc->getTrace();
}
} else {
$message = yii::t('SpamModule', 'The number had exists');
}
echo $message;
}
示例5: actionIndex
public function actionIndex()
{
$type = CHtml::encode(Yii::app()->request->getParam('type', 'HOT'));
$callBack = (int) Yii::app()->request->getParam('call_back', 0);
$page = (int) Yii::app()->request->getParam('page', 1);
$limit = Yii::app()->params['numberSongPerPage'];
if ($this->layout == 'application.views.wap.layouts.main') {
$limit = Yii::app()->params['numberSongPerPageWap'];
}
$count_hot = WapSongModel::countListByCollection('SONG_HOT');
$songs = WapSongModel::getListByCollection('SONG_HOT', $page, $limit);
$pager = new CPagination($count_hot);
$pager->setPageSize($limit);
$offset = $pager->getOffset();
$count_new = WapSongModel::countListByCollection('SONG_NEW');
$songs_new = WapSongModel::getListByCollection('SONG_NEW', $page, $limit);
$arr_songs = array(array('headerText' => yii::t('wap', 'BÀI HÁT HOT'), 'song' => $songs, 'link' => 'song/list?type=HOT'), array('headerText' => yii::t('wap', 'BÀI HÁT MỚI'), 'song' => $songs_new, 'link' => 'song/list?type=NEW'));
$callBackLink = Yii::app()->createUrl("song/index", array('type' => $type));
if ($callBack) {
$this->layout = false;
$this->render("_ajaxList", compact('songs', 'pager', 'callBackLink', 'options'));
} else {
$userPlaylist = array();
if ($this->userPhone) {
$userPlaylist = WapPlaylistModel::model()->getPlaylistByPhone($this->userPhone, $limit, $page);
}
$this->render("index", compact('arr_songs', 'pager', 'callBackLink', 'userPlaylist'));
}
}
示例6: actionLogin
/**
* User login
*/
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$userDriver = isset(\Yii::$app->params['user_driver']) == true && empty(\Yii::$app->params['user_driver']) == false ? strtolower(\Yii::$app->params['user_driver']) : 'local';
if ($userDriver == 'ldap') {
if (isset(\Yii::$app->params['ldap']) == false) {
throw new \Exception(yii::t('walle', 'the login dirver configs does not defined', array('loginType' => \Yii::$app->params['user_driver'])));
}
if (is_array(\Yii::$app->params['ldap']) == false) {
throw new \Exception(yii::t('walle', 'the login dirver configs parse error', array('loginType' => \Yii::$app->params['user_driver'])));
}
$model = new LdapLoginForm(\Yii::$app->params['ldap']);
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', ['isLdapLigin' => true, 'model' => $model]);
}
} elseif ($userDriver == 'local') {
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', ['isLdapLigin' => false, 'model' => $model]);
}
} else {
throw new \Exception(yii::t('walle', 'login type could not support', array('loginType' => \Yii::$app->params['user_driver'])));
}
}
示例7: renderHtmlInput
public function renderHtmlInput($input_type_id, $options = [])
{
$field = $options['prefix_text'] . " ";
switch ($input_type_id) {
case Types::$input_type['small_text']['id']:
$field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:60px']);
break;
case Types::$input_type['med_text']['id']:
$field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', []);
break;
case Types::$input_type['large_text']['id']:
$field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:240px']);
break;
case Types::$input_type['date']['id']:
$field = sprintf('');
break;
case Types::$input_type['radio']['id']:
// Enable tristate behavior with custom indeterminate value, custom toggle icon, and a custom label for the indeterminate state.
$options['tristate_option_id'] == Types::$boolean['true']['id'] ? $tristate = true : ($tristate = false);
$field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [Types::$boolean['true']['description'] => Types::$boolean['true']['description'], Types::$boolean['false']['description'] => Types::$boolean['false']['description']], ['unselect' => Types::$boolean['null']['description'], 'separator' => ' ']);
break;
case Types::$input_type['text_agreement']['id']:
case Types::$input_type['text_agreement']['id']:
$field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [yii::t('app', 'Agree') => yii::t('app', 'Agree'), yii::t('app', 'Disagree') => yii::t('app', 'Disagree')], ['unselect' => Types::$boolean['null']['description'], 'separator' => ' ']);
break;
break;
case Types::$input_type['image_overlay']['id']:
$field = sprintf('image overlay');
break;
}
$field .= " " . $options['suffix_text'];
return $field;
}
示例8: validatePassword
/**
* Validates the password.
* This method serves as the inline validation for password.
*
* @param string $attribute the attribute currently being validated
* @param array $params the additional name-value pairs given in the rule
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) {
$this->addError($attribute, yii::t('adminlte', 'Incorrect username or password.'));
}
}
}
示例9: moneySingle
/**
* 检查货币是否符合规范
* @param $data 需要检查的字符串 (此值用传址格式传递,当其格式误差不大时会将其修改为货币格式)
* @param $name 错误提示名
* @return 成功返回转换后的字符串,否则返回false
*/
static function moneySingle(&$data = null, $name = 'data')
{
if (empty($data)) {
throw new BeubeuException($name . yii::t('public', "为空"), BeubeuException::FIELD_EMPTY);
}
if (!is_numeric($data)) {
throw new BeubeuException($name . Yii::t('public', '格式不正确'), BeubeuException::FIELD_FORMAT);
} else {
$data = number_format($data, 2);
}
}
示例10: getRevision
public static function getRevision($conf)
{
switch ($conf->repo_type) {
case Project::REPO_GIT:
return new Git($conf);
case Project::REPO_SVN:
return new Svn($conf);
default:
throw new \Exception(\yii::t('walle', 'unknown scm'));
break;
}
}
示例11: validatePassword
/**
* Validates the password.
* This method serves as the inline validation for password.
*/
public function validatePassword()
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if (!$user) {
return $this->addError('password', yii::t('user', 'inactive or ban'));
}
if (!$user->validatePassword($this->password)) {
return $this->addError('password', yii::t('user', 'password error'));
}
}
}
示例12: init
public function init()
{
parent::init();
if (empty($this->secret)) {
if (!\yii::$app->has("recaptcha") || empty(\yii::$app->recaptcha->secret)) {
throw new \yii\base\InvalidConfigException("`secret` param is required");
}
$this->secret = \yii::$app->recaptcha->secret;
}
if ($this->message === null) {
$this->message = \yii::t("yii", "The verification code is incorrect.");
}
}
示例13: actionContact
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', yii::t('adminlte', 'Thank you for contacting us. We will respond to you as soon as possible.'));
} else {
Yii::$app->session->setFlash('error', yii::t('adminlte', 'There was an error sending email.'));
}
return $this->refresh();
} else {
return $this->render('contact', ['model' => $model]);
}
}
示例14: connect
/**
* Connects to our database
*/
public function connect()
{
if (!extension_loaded('mongo')) {
throw new EMongoException(yii::t('yii', 'We could not find the MongoDB extension ( http://php.net/manual/en/mongo.installation.php ), please install it'));
}
try {
$this->_mongo = new MongoClient($this->connectionString, $this->connectOptions);
$dbname = $this->db;
$this->_db = $this->_mongo->{$dbname};
$this->_db->setWriteConcern($this->options['writeConcerns'], $this->options['wTimeoutMS']);
} catch (Exception $e) {
throw new EMongoException(yii::t('yii', 'We could not find the MongoDB extension ( http://php.net/manual/en/mongo.installation.php ), please install it'));
}
}
示例15: getSelecter
public function getSelecter($categoryTree)
{
$selecter = '';
for ($i = 0, $count = count($categoryTree); $i < $count - 1; $i++) {
$categoties = Helper::getCategories($this->companyId, $categoryTree[$i]);
$selecter .= '<select class="form-control category_selecter" tabindex="-1" name="category_id_selecter">';
$selecter .= yii::t('app', '<option value="">--请选择--</option>');
foreach ($categoties as $c) {
$selecter .= '<option value="' . $c['lid'] . '" ' . (in_array($c['lid'], $categoryTree) ? 'selected' : '') . '>' . $c['category_name'] . '</option>';
}
$selecter .= '</select>';
}
return $selecter;
}