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'); + +?> + +