本文整理汇总了PHP中Yii::t方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::t方法的具体用法?PHP Yii::t怎么用?PHP Yii::t使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::t方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
public function actionEdit($id)
{
$this->pageTitle = Yii::t('app', 'Редактирование категории');
$model = ShopCategories::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404, Yii::t('app', 'Категория не найдена'));
}
//var_dump($model->url);die;
// var_dump($model->path);die;
//var_dump($model->breadcrumbs);
//die;
$this->breadcrumbs = array_merge($this->breadcrumbs, array('Редактирование категории "' . $model->title . '"'));
$possibleParents = $model->getPossibleParents();
if (!empty($_POST) && array_key_exists('ShopCategories', $_POST)) {
$this->performAjaxValidation($model);
$model->attributes = $_POST['ShopCategories'];
//var_dump($model->attributes);die;
if ($model->validate()) {
if ($model->save()) {
Yii::app()->user->setFlash('success', 'Категория "' . $model->title . '" успешно отредактирована');
Yii::app()->request->redirect($this->createUrl('index'));
}
}
}
//var_dump($possibleParents);die;
$this->render('edit', array('model' => $model, 'possibleParents' => $possibleParents));
}
示例2: init
public function init()
{
parent::init();
if (!$this->items) {
throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - items');
}
}
示例3: run
/**
* Renders the content of the widget.
* @throws CException
*/
public function run()
{
// Hide empty breadcrumbs.
if (empty($this->links)) {
return;
}
$links = array();
if (!isset($this->homeLink)) {
$content = CHtml::link(Yii::t('zii', 'Inicio'), Yii::app()->homeUrl);
$links[] = $this->renderItem($content);
} else {
if ($this->homeLink !== false) {
$links[] = $this->renderItem($this->homeLink);
}
}
foreach ($this->links as $label => $url) {
if (is_string($label) || is_array($url)) {
$content = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url);
$links[] = $this->renderItem($content);
} else {
$links[] = $this->renderItem($this->encodeLabel ? CHtml::encode($url) : $url, true);
}
}
echo CHtml::tag('ul', $this->htmlOptions, implode('', $links));
}
示例4: run
public function run()
{
if (Yii::app()->user->isAuthenticated()) {
$this->controller->redirect(Url::redirectUrl(Yii::app()->getUser()->getReturnUrl()));
}
/**
* Если было совершено больше 3х попыток входа
* в систему, используем сценарий с капчей:
**/
$badLoginCount = Yii::app()->authenticationManager->getBadLoginCount(Yii::app()->getUser());
$module = Yii::app()->getModule('user');
$scenario = $badLoginCount > (int) $module->badLoginCount ? LoginForm::LOGIN_LIMIT_SCENARIO : '';
$form = new LoginForm($scenario);
if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['LoginForm'])) {
$form->setAttributes(Yii::app()->getRequest()->getPost('LoginForm'));
if ($form->validate() && Yii::app()->authenticationManager->login($form, Yii::app()->getUser(), Yii::app()->getRequest())) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'You authorized successfully!'));
if (Yii::app()->getUser()->isSuperUser() && $module->loginAdminSuccess) {
$redirect = $module->loginAdminSuccess;
} else {
$redirect = empty($module->loginSuccess) ? Yii::app()->getBaseUrl() : $module->loginSuccess;
}
$redirect = Yii::app()->getUser()->getReturnUrl($redirect);
Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), 0);
$this->controller->redirect(Url::redirectUrl($redirect));
} else {
$form->addError('email', Yii::t('UserModule.user', 'Email or password was typed wrong!'));
Yii::app()->authenticationManager->setBadLoginCount(Yii::app()->getUser(), $badLoginCount + 1);
}
}
$this->controller->render($this->id, array('model' => $form));
}
示例5: run
public function run()
{
$ids = Yii::app()->request->getParam('id');
$command = Yii::app()->request->getParam('command');
empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
if (!is_array($ids)) {
$ids = array($ids);
}
$criteria = new CDbCriteria();
$criteria->addInCondition('id', $ids);
switch ($command) {
case 'delete':
//删除
Comment::model()->deleteAll($criteria);
break;
case 'show':
//显示
Comment::model()->updateAll(['status' => Comment::STATUS_SHOW], $criteria);
break;
case 'hide':
//隐藏
Comment::model()->updateAll(['status' => Comment::STATUS_HIDE], $criteria);
break;
default:
$this->controller->message('error', Yii::t('admin', 'Error Operation'));
}
$this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
}
示例6: checkEmail
public function checkEmail($attribute, $params)
{
$model = User::model()->find('email = :email', array(':email' => $this->{$attribute}));
if ($model) {
$this->addError('email', Yii::t('UserModule.user', 'Email already busy'));
}
}
示例7: loadModel
public function loadModel($id)
{
if (($model = DictionaryGroup::model()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('DictionaryModule.dictionary', 'Requested page was not found'));
}
return $model;
}
示例8: getHint
public function getHint()
{
if ($this->owner->isNewRecord || !$this->file) {
return '';
}
return Html::a(Yii::t('app', 'View attached file'), $this->fileUrl, ['target' => '_blank']);
}
示例9: init
public function init()
{
$this->name = \Yii::t('skeeks/shop/app', 'Delivery services');
$this->modelShowAttribute = "name";
$this->modelClassName = ShopDelivery::className();
parent::init();
}
示例10: actionRegister
/**
* Creates account for new users
*/
public function actionRegister()
{
if (!Yii::app()->user->isGuest) {
Yii::app()->request->redirect('/');
}
$user = new User('register');
$profile = new UserProfile();
if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
$user->attributes = $_POST['User'];
$profile->attributes = $_POST['UserProfile'];
$valid = $user->validate();
$valid = $profile->validate() && $valid;
if ($valid) {
$user->save();
$profile->save();
$profile->setUser($user);
// Add user to authenticated group
Yii::app()->authManager->assign('Authenticated', $user->id);
$this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
// Authenticate user
$identity = new UserIdentity($user->username, $_POST['User']['password']);
if ($identity->authenticate()) {
Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
}
}
}
$this->render('register', array('user' => $user, 'profile' => $profile));
}
示例11: init
public function init()
{
$data = array('content' => array(), 'error' => Yii::t('main', 'Модуль отключен.'));
if (config('forum_threads.allow') == 1) {
$data = cache()->get(CacheNames::FORUM_THREADS);
if ($data === FALSE) {
$data = array();
try {
// Подключаюсь к БД
$this->db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . config('forum_threads.db_host') . ';port=' . config('forum_threads.db_port') . ';dbname=' . config('forum_threads.db_name'), 'enableProfiling' => YII_DEBUG, 'enableParamLogging' => TRUE, 'username' => config('forum_threads.db_user'), 'password' => config('forum_threads.db_pass'), 'charset' => 'utf8', 'emulatePrepare' => TRUE, 'tablePrefix' => config('forum_threads.prefix')));
app()->setComponent('ForumThreadsDb', $this->db);
$forumType = config('forum_threads.type');
if (method_exists($this, $forumType)) {
$data['content'] = $this->{$forumType}();
foreach ($data['content'] as $k => $v) {
$data['content'][$k]['user_link'] = $this->getUserLink($v['starter_id'], $v['starter_name']);
$data['content'][$k]['theme_link'] = $this->getForumLink($v['id_topic'], $v['title'], $v['id_forum']);
$data['content'][$k]['start_date'] = $this->getStartDate($v['start_date']);
}
if (config('forum_threads.cache')) {
cache()->set(CacheNames::FORUM_THREADS, $data, config('forum_threads.cache') * 60);
}
} else {
$data['error'] = Yii::t('main', 'Метод для обработки форума: :type не найден.', array(':type' => '<b>' . $forumType . '</b>'));
}
} catch (Exception $e) {
$data['error'] = $e->getMessage();
}
}
}
app()->controller->renderPartial('//forum-threads', $data);
}
示例12: actionEdit
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionEdit()
{
$model = $this->loadUser();
$profile = $model->profile;
// ajax validator
if (isset($_POST['ajax']) && $_POST['ajax'] === 'profile-form') {
echo UActiveForm::validate(array($model, $profile));
Yii::app()->end();
}
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->image = CUploadedFile::getInstance($model, 'image');
$profile->attributes = $_POST['Profile'];
if ($model->validate() && $profile->validate()) {
$model->save();
$profile->save();
Yii::app()->user->updateSession();
Yii::app()->user->setFlash('profileMessage', Yii::t('main', "Data saved successfully!"));
$this->redirect(array('/user/profile'));
} else {
$profile->validate();
}
}
$this->render('edit', array('model' => $model, 'profile' => $profile));
}
示例13: accessRules
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
if (!Yii::app()->user->checkAccess(Yii::app()->controller->action->id)) {
throw new CHttpException(401, Yii::t('mds', 'You are prohibited to access this page. Contact Super Administrator'));
}
return array(array('allow', 'actions' => array('index', 'view', 'create', 'update', 'admin', 'delete', 'print', 'details', 'bayar', 'PrintDetails', 'bayarkan'), 'users' => array('@')), array('deny', 'users' => array('*')));
}
示例14: handleRequest
public function handleRequest($request)
{
if (empty($this->catchAll)) {
list($route, $params) = $request->resolve();
} else {
$route = $this->catchAll[0];
$params = array_splice($this->catchAll, 1);
}
try {
LuLu::trace("Route requested: '{$route}'", __METHOD__);
$this->requestedRoute = $route;
$actionsResult = $this->runAction($route, $params);
$result = $actionsResult instanceof ActionResult ? $actionsResult->result : $actionsResult;
if ($result instanceof \yii\web\Response) {
return $result;
} else {
$response = $this->getResponse();
if ($result !== null) {
$response->data = $result;
}
return $response;
}
} catch (InvalidRouteException $e) {
throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
}
}
示例15: init
public function init()
{
$this->name = \Yii::t('skeeks/shop/app', 'Order statuses');
$this->modelShowAttribute = "name";
$this->modelClassName = ShopOrderStatus::className();
parent::init();
}