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 @@ -
- This is the view content for action "= $this->context->action->id ?>". - The action belongs to the controller "= get_class($this->context) ?>" - in the "= $this->context->module->id ?>" module. -
-
- You may customize this page by editing the following file:
- = __FILE__ ?>
-