diff --git a/application/messages/ru/app.php b/application/messages/ru/app.php index 4b5f7af1f..83168d10e 100755 --- a/application/messages/ru/app.php +++ b/application/messages/ru/app.php @@ -352,6 +352,7 @@ 'Don\'t use in filtration' => 'Не использовать в фильтрации', 'Done ({n})' => 'Завершено ({n})', 'DotPlant2 translated languages:' => 'Переведенные языки DotPlant2:', + 'Doubles Redirects' => 'Дубли перенапралений', 'Download' => 'Скачать', 'Duration' => 'Продолжтельность', 'Dynamic Content' => 'Динамический контент', @@ -442,6 +443,7 @@ 'Filter widget' => 'Виджет фильтров', 'Filters' => '', 'Find broken images' => 'Найти битые изображения', + 'Find doubles' => 'Поиск дублей', 'First Name' => 'Имя', 'Floating panel' => 'Плавающая панель', 'Flush cache' => 'Очистить кэш', diff --git a/application/modules/seo/controllers/ManageController.php b/application/modules/seo/controllers/ManageController.php index 2fd9d65b8..7bccae747 100644 --- a/application/modules/seo/controllers/ManageController.php +++ b/application/modules/seo/controllers/ManageController.php @@ -650,6 +650,18 @@ public function actionDeleteRedirectFile() echo (int)Redirect::deleteRedirectFile(); } + public function actionRedirectDoublesFinder() + { + $redirectDoublesFinder = new Redirect(); + $dataProvider = $redirectDoublesFinder->findDoubles(); + return $this->render( + 'redirect-doubles-finder', + [ + 'dataProvider' => $dataProvider, + ] + ); + } + public function actionEcommerce() { $yaCounter = $gaCounter = ['id' => '', 'active' => 0]; diff --git a/application/modules/seo/models/Redirect.php b/application/modules/seo/models/Redirect.php index 8ff379b70..6dd5c63ed 100644 --- a/application/modules/seo/models/Redirect.php +++ b/application/modules/seo/models/Redirect.php @@ -4,7 +4,6 @@ use yii\data\ActiveDataProvider; use yii\db\ActiveRecord; -use yii\helpers\ArrayHelper; use Yii; /** @@ -140,4 +139,23 @@ public static function deleteRedirectFile() { return unlink(self::getFilename()); } + + public function findDoubles() + { + + $query = self::find() + ->select(['type', 'from', 'COUNT(*) as count']) + ->groupBy('from') + ->having('COUNT(*) > 1'); + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'pagination' => [ + 'pageSize' => 10, + ], + ] + ); + return $dataProvider; + } } diff --git a/application/modules/seo/views/manage/redirect-doubles-finder.php b/application/modules/seo/views/manage/redirect-doubles-finder.php new file mode 100644 index 000000000..6fe59be01 --- /dev/null +++ b/application/modules/seo/views/manage/redirect-doubles-finder.php @@ -0,0 +1,63 @@ +title = Yii::t('app', 'Doubles Redirects'); + +?> + +

title) ?>

+ + + + 'redirects', + 'dataProvider' => $dataProvider, + 'layout' => "{items}\n{summary}\n{pager}", + 'columns' => [ + [ + 'class' => 'yii\grid\CheckboxColumn', + 'options' => [ + 'width' => '10px', + ], + ], + [ + 'class' => 'yii\grid\DataColumn', + 'attribute' => 'type', + 'filter' => \app\modules\seo\models\Redirect::getTypes(), + ], + 'from', + [ + 'class' => 'app\backend\components\ActionColumn', + 'urlCreator' => function ($action, $model, $key, $index) { + $params = ['Redirect[from]' => $model->from]; + $params[0] = '/seo/manage/redirect'; + return Url::toRoute($params); + }, + 'buttons' => [ + [ + 'url' => 'all', + 'icon' => 'list', + 'class' => 'btn-primary', + 'label' => Yii::t('app', 'Show all'), + ], + ], + ], + + ], + 'tableOptions' => [ + 'class' => 'table table-striped table-condensed table-hover', + ] +]); ?> + + \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-success']) ?> \app\backend\components\Helper::getReturnUrl()], ['class' => 'btn btn-warning']) ?> 'btn btn-danger', 'id' => 'deleteRedirects']); ?> + 'btn btn-warning']) ?>

render('_redirectGrid', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'id' => 'redirects']); ?>