From 6db4e4252bcc06271a0ded4ff114a793b8746074 Mon Sep 17 00:00:00 2001 From: Sasha Rybkin Date: Mon, 23 Dec 2019 17:34:09 +0300 Subject: [PATCH] translet --- Bootstrap.php | 27 +++++++++ composer.json | 3 + controllers/DefaultController.php | 12 +++- messages/message.php | 26 +++++++++ messages/ru-RU/app.php | 4 -- messages/ru-RU/mole.php | 4 ++ models/MoleTask.php | 34 ++++++------ models/search/MoleTaskSearch.php | 91 +++++++++++++++++++++++++++++++ views/default/index.php | 59 ++++++++++++++++---- 9 files changed, 226 insertions(+), 34 deletions(-) create mode 100644 Bootstrap.php create mode 100644 messages/message.php delete mode 100644 messages/ru-RU/app.php create mode 100644 messages/ru-RU/mole.php create mode 100644 models/search/MoleTaskSearch.php diff --git a/Bootstrap.php b/Bootstrap.php new file mode 100644 index 0000000..83b4b0b --- /dev/null +++ b/Bootstrap.php @@ -0,0 +1,27 @@ +get('i18n')->translations['user*'])) + { + $app->get('i18n')->translations['user*'] = [ + 'class' => PhpMessageSource::className(), + 'basePath' => __DIR__ . '/messages', + 'sourceLanguage' => 'ru-RU' + ]; + } + } + +} diff --git a/composer.json b/composer.json index d63cad5..3cad1e1 100644 --- a/composer.json +++ b/composer.json @@ -17,5 +17,8 @@ "psr-4": { "dominion\\cron\\": "" } + }, + "extra": { + "bootstrap": "dominion\\cron\\Bootstrap" } } diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php index 797a4c8..9130a09 100644 --- a/controllers/DefaultController.php +++ b/controllers/DefaultController.php @@ -2,19 +2,29 @@ namespace dominion\cron\controllers; +use Yii; use yii\web\Controller; +use dominion\cron\models\search\MoleTaskSearch; /** * Default controller for the `cron` module */ class DefaultController extends Controller { + /** * Renders the index view for the module * @return string */ public function actionIndex() { - return $this->render('index'); + $searchModel = new MoleTaskSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); } + } diff --git a/messages/message.php b/messages/message.php new file mode 100644 index 0000000..24adeb3 --- /dev/null +++ b/messages/message.php @@ -0,0 +1,26 @@ + __DIR__ . '/../', + 'messagePath' => __DIR__, + 'languages' => [ + 'ru-RU', + ], + 'translator' => 'Yii::t', + 'sort' => false, + 'overwrite' => true, + 'removeUnused' => false, + 'only' => ['*.php'], + 'except' => [ + '.svn', + '.git', + '.gitignore', + '.gitkeep', + '.hgignore', + '.hgkeep', + '/messages', + '/tests', + '/vendor', + ], + 'format' => 'php', +]; diff --git a/messages/ru-RU/app.php b/messages/ru-RU/app.php deleted file mode 100644 index 957e64d..0000000 --- a/messages/ru-RU/app.php +++ /dev/null @@ -1,4 +0,0 @@ - 'wwww', +]; \ No newline at end of file diff --git a/models/MoleTask.php b/models/MoleTask.php index 0c41168..ac0d6a3 100644 --- a/models/MoleTask.php +++ b/models/MoleTask.php @@ -56,23 +56,23 @@ class MoleTask extends \yii\db\ActiveRecord public function attributeLabels() { return [ - 'id' => Yii::t('dominion\cron\app', 'ID'), - 'parentId' => Yii::t('dominion\cron\app', 'Parent ID'), - 'dateAdd' => Yii::t('dominion\cron\app', 'Date Add'), - 'dateStart' => Yii::t('dominion\cron\app', 'Date Start'), - 'dateEnd' => Yii::t('dominion\cron\app', 'Date End'), - 'module' => Yii::t('dominion\cron\app', 'Module'), - 'controller' => Yii::t('dominion\cron\app', 'Controller'), - 'type' => Yii::t('dominion\cron\app', 'Type'), - 'name' => Yii::t('dominion\cron\app', 'Name'), - 'params' => Yii::t('dominion\cron\app', 'Params'), - 'isReady' => Yii::t('dominion\cron\app', 'Is Ready'), - 'completed' => Yii::t('dominion\cron\app', 'Completed'), - 'priority' => Yii::t('dominion\cron\app', 'Priority'), - 'childsTotalCount' => Yii::t('dominion\cron\app', 'Childs Total Count'), - 'childsCompleted' => Yii::t('dominion\cron\app', 'Childs Completed'), - 'status' => Yii::t('dominion\cron\app', 'Status'), - 'project' => Yii::t('dominion\cron\app', 'Project'), + 'id' => Yii::t('mole', 'ID'), + /* 'parentId' => Yii::t('mole', 'Parent ID'), + 'dateAdd' => Yii::t('mole', 'Date Add'), + 'dateStart' => Yii::t('mole', 'Date Start'), + 'dateEnd' => Yii::t('mole', 'Date End'), + 'module' => Yii::t('mole', 'Module'), + 'controller' => Yii::t('mole', 'Controller'), + 'type' => Yii::t('mole', 'Type'), + 'name' => Yii::t('mole', 'Name'), + 'params' => Yii::t('mole', 'Params'), + 'isReady' => Yii::t('mole', 'Is Ready'), + 'completed' => Yii::t('mole', 'Completed'), + 'priority' => Yii::t('mole', 'Priority'), + 'childsTotalCount' => Yii::t('mole', 'Childs Total Count'), + 'childsCompleted' => Yii::t('mole', 'Childs Completed'), + 'status' => Yii::t('mole', 'Status'), + 'project' => Yii::t('mole', 'Project'),*/ ]; } } diff --git a/models/search/MoleTaskSearch.php b/models/search/MoleTaskSearch.php new file mode 100644 index 0000000..e2823a6 --- /dev/null +++ b/models/search/MoleTaskSearch.php @@ -0,0 +1,91 @@ + 255], + [['project'], 'string', 'max' => 50], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = MoleTask::find(); + // add conditions that should always apply here + + $this->load($params); + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'sort' => [ + 'defaultOrder' => [ + 'id' => SORT_DESC + ] + ] + ]); + + if (!$this->validate()) + { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + + + $query->andFilterWhere([ + 'id' => $this->id, + 'parentId' => $this->parentId, + 'isReady' => $this->isReady, + 'completed' => $this->completed, + 'priority' => $this->priority, + 'childsTotalCount' => $this->childsTotalCount, + 'childsCompleted' => $this->childsCompleted, + ]); + + $query->andFilterWhere(['like', 'params', $this->params]) + ->andFilterWhere(['like', 'controller', $this->controller]) + ->andFilterWhere(['like', 'module', $this->module]) + ->andFilterWhere(['like', 'type', $this->type]) + ->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'status', $this->status]) + ->andFilterWhere(['like', 'project', $this->project]); + + return $dataProvider; + } + +} diff --git a/views/default/index.php b/views/default/index.php index 320919d..a8d3503 100644 --- a/views/default/index.php +++ b/views/default/index.php @@ -1,12 +1,47 @@ -
-

context->action->uniqueId ?>

-

- This is the view content for action "context->action->id ?>". - The action belongs to the controller "context) ?>" - in the "context->module->id ?>" module. -

-

- You may customize this page by editing the following file:
- -

-
+ + * + * For the full copyright and license information, please view the LICENSE.md + * file that was distributed with this source code. + */ + +use yii\grid\GridView; +use yii\helpers\Html; +use yii\helpers\Url; +use yii\web\View; +use yii\widgets\Pjax; + +/** + * @var \yii\web\View $this + * @var \yii\data\ActiveDataProvider $dataProvider + * @var \dektrium\user\models\UserSearch $searchModel + */ +$this->title = Yii::t('app', 'User List'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Manage users'), 'url' => ['']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+
+ + $dataProvider, + 'filterModel' => $searchModel, + 'layout' => "{items}\n{pager}", + 'columns' => [ + [ + 'attribute' => 'id', + ], + + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{update}', + ], + ], + ]); + ?> +
+
\ No newline at end of file