From 30d76ad23d9a72e204a9e8cada46a1bac00d5b6d Mon Sep 17 00:00:00 2001 From: Egorka Date: Wed, 5 Sep 2018 19:14:43 +0300 Subject: [PATCH] Remove blog --- common/modules/blog/BlogModule.php | 116 ------- common/modules/blog/controllers/PostController.php | 249 -------------- .../blog/controllers/manage/CategoryController.php | 156 --------- .../blog/controllers/manage/CommentController.php | 159 --------- .../blog/controllers/manage/PostController.php | 311 ----------------- .../blog/controllers/manage/TagController.php | 151 --------- common/modules/blog/entities/BlogCategory.php | 117 ------- common/modules/blog/entities/BlogComment.php | 93 ----- common/modules/blog/entities/BlogPost.php | 376 --------------------- common/modules/blog/entities/BlogTag.php | 58 ---- common/modules/blog/entities/BlogTagAssignment.php | 37 -- .../blog/entities/queries/BlogCategoryQuery.php | 15 - .../blog/entities/queries/BlogPostQuery.php | 50 --- common/modules/blog/forms/BlogCategoryForm.php | 83 ----- common/modules/blog/forms/BlogCommentEditForm.php | 37 -- common/modules/blog/forms/BlogCommentForm.php | 20 -- common/modules/blog/forms/BlogPostForm.php | 144 -------- common/modules/blog/forms/BlogTagForm.php | 46 --- common/modules/blog/forms/BlogTagSingleForm.php | 51 --- .../blog/forms/search/BlogCategorySearch.php | 56 --- .../blog/forms/search/BlogCommentSearch.php | 72 ---- .../modules/blog/forms/search/BlogPostSearch.php | 71 ---- common/modules/blog/forms/search/BlogTagSearch.php | 55 --- common/modules/blog/helpers/BlogPostHelper.php | 132 -------- common/modules/blog/manifest.php | 11 - common/modules/blog/messages/ru/blog.php | 83 ----- common/modules/blog/messages/ru/blog_public.php | 8 - ...m180605_184534_create_blog_categories_table.php | 31 -- .../m180605_190347_create_blog_posts_table.php | 42 --- .../m180605_193423_create_blog_tags_table.php | 28 -- ...05_193748_create_blog_tag_assignments_table.php | 36 -- .../m180605_194207_create_blog_comments_table.php | 43 --- .../m180725_091725_add_blog_posts_type_field.php | 33 -- ..._113503_remove_blog_posts_slug_unique_index.php | 27 -- .../m180827_195932_set_blog_unicode_collate.php | 33 -- .../m180828_190314_create_blog_post_lng_table.php | 54 --- ...830_163050_create_blog_categories_lng_table.php | 55 --- .../blog/repositories/BlogCategoryRepository.php | 31 -- .../modules/blog/repositories/BlogRepository.php | 36 -- .../blog/repositories/BlogTagRepository.php | 36 -- .../read/BlogCategoryReadRepository.php | 23 -- .../repositories/read/BlogPostReadRepository.php | 99 ------ .../repositories/read/BlogTagReadRepository.php | 18 - .../blog/services/BlogCategoryManageService.php | 52 --- .../blog/services/BlogCommentManageService.php | 37 -- .../modules/blog/services/BlogCommentService.php | 32 -- .../blog/services/BlogPostManageService.php | 193 ----------- .../modules/blog/services/BlogTagManageService.php | 43 --- common/modules/blog/urls/BlogCategoryUrlRule.php | 92 ----- common/modules/blog/urls/BlogMainUrlRule.php | 90 ----- common/modules/blog/urls/BlogTagUrlRule.php | 91 ----- .../modules/blog/views/manage/category/_form.php | 73 ---- .../blog/views/manage/category/_form_tab.php | 35 -- .../blog/views/manage/category/_view_tab.php | 77 ----- .../modules/blog/views/manage/category/create.php | 17 - .../modules/blog/views/manage/category/index.php | 59 ---- .../modules/blog/views/manage/category/update.php | 19 -- common/modules/blog/views/manage/category/view.php | 69 ---- common/modules/blog/views/manage/comment/index.php | 54 --- .../modules/blog/views/manage/comment/update.php | 34 -- common/modules/blog/views/manage/comment/view.php | 71 ---- common/modules/blog/views/manage/post/_form.php | 222 ------------ .../modules/blog/views/manage/post/_form_tab.php | 35 -- .../modules/blog/views/manage/post/_view_tab.php | 78 ----- common/modules/blog/views/manage/post/create.php | 17 - common/modules/blog/views/manage/post/index.php | 80 ----- common/modules/blog/views/manage/post/update.php | 21 -- common/modules/blog/views/manage/post/view.php | 183 ---------- common/modules/blog/views/manage/tag/_form.php | 45 --- common/modules/blog/views/manage/tag/create.php | 17 - common/modules/blog/views/manage/tag/index.php | 47 --- common/modules/blog/views/manage/tag/update.php | 19 -- common/modules/blog/views/manage/tag/view.php | 39 --- common/modules/blog/views/post/_list.php | 42 --- common/modules/blog/views/post/_post.php | 51 --- common/modules/blog/views/post/category.php | 40 --- common/modules/blog/views/post/index.php | 13 - common/modules/blog/views/post/post.php | 113 ------- common/modules/blog/widgets/CategoriesWidget.php | 29 -- common/modules/blog/widgets/CommentView.php | 20 -- common/modules/blog/widgets/CommentsWidget.php | 57 ---- .../modules/blog/widgets/MenuItemCreatorWidget.php | 30 -- common/modules/blog/widgets/PostByTagsWidget.php | 42 --- common/modules/blog/widgets/TagWidget.php | 39 --- .../blog/widgets/views/categories/categories.php | 32 -- .../blog/widgets/views/comments/_comment.php | 78 ----- .../blog/widgets/views/comments/comments.php | 103 ------ .../blog/widgets/views/menu-item/creator.php | 128 ------- .../modules/blog/widgets/views/slider-relative.php | 38 --- common/modules/blog/widgets/views/tags/tags.php | 21 -- 90 files changed, 6199 deletions(-) delete mode 100644 common/modules/blog/BlogModule.php delete mode 100644 common/modules/blog/controllers/PostController.php delete mode 100644 common/modules/blog/controllers/manage/CategoryController.php delete mode 100644 common/modules/blog/controllers/manage/CommentController.php delete mode 100644 common/modules/blog/controllers/manage/PostController.php delete mode 100644 common/modules/blog/controllers/manage/TagController.php delete mode 100644 common/modules/blog/entities/BlogCategory.php delete mode 100644 common/modules/blog/entities/BlogComment.php delete mode 100644 common/modules/blog/entities/BlogPost.php delete mode 100644 common/modules/blog/entities/BlogTag.php delete mode 100644 common/modules/blog/entities/BlogTagAssignment.php delete mode 100644 common/modules/blog/entities/queries/BlogCategoryQuery.php delete mode 100644 common/modules/blog/entities/queries/BlogPostQuery.php delete mode 100644 common/modules/blog/forms/BlogCategoryForm.php delete mode 100644 common/modules/blog/forms/BlogCommentEditForm.php delete mode 100644 common/modules/blog/forms/BlogCommentForm.php delete mode 100644 common/modules/blog/forms/BlogPostForm.php delete mode 100644 common/modules/blog/forms/BlogTagForm.php delete mode 100644 common/modules/blog/forms/BlogTagSingleForm.php delete mode 100644 common/modules/blog/forms/search/BlogCategorySearch.php delete mode 100644 common/modules/blog/forms/search/BlogCommentSearch.php delete mode 100644 common/modules/blog/forms/search/BlogPostSearch.php delete mode 100644 common/modules/blog/forms/search/BlogTagSearch.php delete mode 100644 common/modules/blog/helpers/BlogPostHelper.php delete mode 100644 common/modules/blog/manifest.php delete mode 100644 common/modules/blog/messages/ru/blog.php delete mode 100644 common/modules/blog/messages/ru/blog_public.php delete mode 100644 common/modules/blog/migrations/m180605_184534_create_blog_categories_table.php delete mode 100644 common/modules/blog/migrations/m180605_190347_create_blog_posts_table.php delete mode 100644 common/modules/blog/migrations/m180605_193423_create_blog_tags_table.php delete mode 100644 common/modules/blog/migrations/m180605_193748_create_blog_tag_assignments_table.php delete mode 100644 common/modules/blog/migrations/m180605_194207_create_blog_comments_table.php delete mode 100644 common/modules/blog/migrations/m180725_091725_add_blog_posts_type_field.php delete mode 100644 common/modules/blog/migrations/m180725_113503_remove_blog_posts_slug_unique_index.php delete mode 100644 common/modules/blog/migrations/m180827_195932_set_blog_unicode_collate.php delete mode 100644 common/modules/blog/migrations/m180828_190314_create_blog_post_lng_table.php delete mode 100644 common/modules/blog/migrations/m180830_163050_create_blog_categories_lng_table.php delete mode 100644 common/modules/blog/repositories/BlogCategoryRepository.php delete mode 100644 common/modules/blog/repositories/BlogRepository.php delete mode 100644 common/modules/blog/repositories/BlogTagRepository.php delete mode 100644 common/modules/blog/repositories/read/BlogCategoryReadRepository.php delete mode 100644 common/modules/blog/repositories/read/BlogPostReadRepository.php delete mode 100644 common/modules/blog/repositories/read/BlogTagReadRepository.php delete mode 100644 common/modules/blog/services/BlogCategoryManageService.php delete mode 100644 common/modules/blog/services/BlogCommentManageService.php delete mode 100644 common/modules/blog/services/BlogCommentService.php delete mode 100644 common/modules/blog/services/BlogPostManageService.php delete mode 100644 common/modules/blog/services/BlogTagManageService.php delete mode 100644 common/modules/blog/urls/BlogCategoryUrlRule.php delete mode 100644 common/modules/blog/urls/BlogMainUrlRule.php delete mode 100644 common/modules/blog/urls/BlogTagUrlRule.php delete mode 100644 common/modules/blog/views/manage/category/_form.php delete mode 100644 common/modules/blog/views/manage/category/_form_tab.php delete mode 100644 common/modules/blog/views/manage/category/_view_tab.php delete mode 100644 common/modules/blog/views/manage/category/create.php delete mode 100644 common/modules/blog/views/manage/category/index.php delete mode 100644 common/modules/blog/views/manage/category/update.php delete mode 100644 common/modules/blog/views/manage/category/view.php delete mode 100644 common/modules/blog/views/manage/comment/index.php delete mode 100644 common/modules/blog/views/manage/comment/update.php delete mode 100644 common/modules/blog/views/manage/comment/view.php delete mode 100644 common/modules/blog/views/manage/post/_form.php delete mode 100644 common/modules/blog/views/manage/post/_form_tab.php delete mode 100644 common/modules/blog/views/manage/post/_view_tab.php delete mode 100644 common/modules/blog/views/manage/post/create.php delete mode 100644 common/modules/blog/views/manage/post/index.php delete mode 100644 common/modules/blog/views/manage/post/update.php delete mode 100644 common/modules/blog/views/manage/post/view.php delete mode 100644 common/modules/blog/views/manage/tag/_form.php delete mode 100644 common/modules/blog/views/manage/tag/create.php delete mode 100644 common/modules/blog/views/manage/tag/index.php delete mode 100644 common/modules/blog/views/manage/tag/update.php delete mode 100644 common/modules/blog/views/manage/tag/view.php delete mode 100644 common/modules/blog/views/post/_list.php delete mode 100644 common/modules/blog/views/post/_post.php delete mode 100644 common/modules/blog/views/post/category.php delete mode 100644 common/modules/blog/views/post/index.php delete mode 100644 common/modules/blog/views/post/post.php delete mode 100644 common/modules/blog/widgets/CategoriesWidget.php delete mode 100644 common/modules/blog/widgets/CommentView.php delete mode 100644 common/modules/blog/widgets/CommentsWidget.php delete mode 100644 common/modules/blog/widgets/MenuItemCreatorWidget.php delete mode 100644 common/modules/blog/widgets/PostByTagsWidget.php delete mode 100644 common/modules/blog/widgets/TagWidget.php delete mode 100644 common/modules/blog/widgets/views/categories/categories.php delete mode 100644 common/modules/blog/widgets/views/comments/_comment.php delete mode 100644 common/modules/blog/widgets/views/comments/comments.php delete mode 100644 common/modules/blog/widgets/views/menu-item/creator.php delete mode 100644 common/modules/blog/widgets/views/slider-relative.php delete mode 100644 common/modules/blog/widgets/views/tags/tags.php diff --git a/common/modules/blog/BlogModule.php b/common/modules/blog/BlogModule.php deleted file mode 100644 index 10197cd..0000000 --- a/common/modules/blog/BlogModule.php +++ /dev/null @@ -1,116 +0,0 @@ -controllerMap['migrate']['migrationPath'][] = '@common/modules/blog/migrations'; - - // add search rules - $app->params['search_rules'][] = "SELECT title, content, CONCAT('/blog/manage/post/view/', blog_post_id) AS url FROM {{blog_posts_lng}}"; - - // add rules - $app->getUrlManager()->addRules([ - 'blog' => 'blog/post/index', - ]); - - $app->getUrlManager()->addRules([ - ['class' => 'common\modules\blog\urls\BlogMainUrlRule'], - ['class' => 'common\modules\blog\urls\BlogCategoryUrlRule'], - ['class' => 'common\modules\blog\urls\BlogTagUrlRule'], - ]); - - $app->getUrlManager()->addRules([ - 'blog/manage/post/view/' => 'blog/manage/post/view', - ]); - - // add languages - $app->getI18n()->translations = ArrayHelper::merge($app->getI18n()->translations, [ - 'blog' => [ - 'class' => 'yii\i18n\PhpMessageSource', - 'basePath' => '@common/modules/blog/messages', - ], - 'blog_public' => [ - 'class' => 'yii\i18n\PhpMessageSource', - 'basePath' => '@common/modules/blog/messages', - ], - ]); - - // add menu items - /*$app->params['adminMenu'][] = [ - 'label' => \Yii::t('blog', 'Blog'), 'icon' => 'book', 'items' => [ - ['label' => \Yii::t('blog', 'Categories'), 'icon' => 'caret-right', 'url' => ['/blog/manage/category/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'blog/manage/category'], - ['label' => \Yii::t('blog', 'Posts'), 'icon' => 'caret-right', 'url' => ['/blog/manage/post/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'blog/manage/post'], - ], 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('BlogManagement') - ];*/ - //print_r(basename($app->getBasePath())); die; - //print_r($app->basePath); die; - - if (basename($app->getBasePath()) === 'backend') { - $app->params['adminMenu'][] = [ - 'label' => \Yii::t( 'blog', 'Blog' ), - 'icon' => 'book', - 'items' => [ - [ - 'label' => \Yii::t( 'blog', 'Categories' ), - 'icon' => 'caret-right', - 'url' => [ '/blog/manage/category/index' ] - ], - [ - 'label' => \Yii::t( 'blog', 'Posts' ), - 'icon' => 'caret-right', - 'url' => [ '/blog/manage/post/index' ] - ], - [ - 'label' => \Yii::t( 'blog', 'Comments' ), - 'icon' => 'caret-right', - 'url' => [ '/blog/manage/comment/index' ] - ], - [ - 'label' => \Yii::t( 'blog', 'Tags' ), - 'icon' => 'caret-right', - 'url' => [ '/blog/manage/tag/index' ] - ], - ], - 'visible' => \Yii::$app->user->can( 'admin' ) || \Yii::$app->user->can( 'BlogManagement' ) - ]; - } - } - - public static function getMenuItemCreator($menu_id): array - { - $widgets = []; - $widgets[] = [ - 'id' => 'blog', - 'title' => \Yii::t('blog', 'Blog'), - 'content' => MenuItemCreatorWidget::widget([ - 'menu_id' => $menu_id, - ]), - ]; - return $widgets; - } -} diff --git a/common/modules/blog/controllers/PostController.php b/common/modules/blog/controllers/PostController.php deleted file mode 100644 index fd226ce..0000000 --- a/common/modules/blog/controllers/PostController.php +++ /dev/null @@ -1,249 +0,0 @@ -service = $service; - $this->posts = $posts; - $this->categories = $categories; - $this->tags = $tags; - } - - public function behaviors(): array - { - return [ - 'access' => [ - 'class' => AccessControl::class, - 'rules' => [ - [ - 'actions' => ['index', 'category', 'tag', 'post'], - 'allow' => true, - //'roles' => ['Blog'], - ], - [ - 'actions' => ['preview'], - 'allow' => true, - 'roles' => ['BlogManagement'], - ], - [ - 'actions' => ['comment'], - 'allow' => true, - 'roles' => ['Comments'], - ], - [ // all the action are accessible to admin - 'allow' => true, - 'roles' => ['admin'], - ], - ], - ], - ]; - } - - /** - * @return string - */ - public function actionIndex() - { - /* @var $dataProvider ActiveDataProvider */ - $dataProvider = $this->posts->getAll(); - $dataProvider->pagination->pageSize = 10; - - return $this->render('index', [ - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $id - * - * @return string - * @throws NotFoundHttpException - */ - public function actionCategory($id) - { - if (!$category = $this->categories->find($id)) { - throw new NotFoundHttpException('The requested page does not exist.'); - } - $dataProvider = $this->posts->getAllByCategory($category); - - return $this->render('category', [ - 'category' => $category, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $id - * @return mixed - * @throws NotFoundHttpException - */ - public function actionTag($id) - { - if (!$tag = $this->tags->find($id)) { - throw new NotFoundHttpException('The requested page does not exist.'); - } - $dataProvider = $this->posts->getAllByTag($tag); - - return $this->render('tag', [ - 'tag' => $tag, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $id - * @return mixed - * @throws NotFoundHttpException - */ - public function actionPost($id) - { - if (!$post = $this->posts->find($id)) { - throw new NotFoundHttpException('The requested page does not exist.'); - } - - return $this->render('post', [ - 'post' => $post, - ]); - } - - /** - * @param $id - * @return mixed - * @throws NotFoundHttpException - */ - public function actionComment($id) - { - if (!$post = $this->posts->find($id)) { - throw new NotFoundHttpException('The requested page does not exist.'); - } - - $form = new BlogCommentForm(); - - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $comment = $this->service->create($post->id, Yii::$app->user->id, $form); - return $this->redirect(['post', 'id' => $post->id, '#' => 'comment_' . $comment->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - - return $this->render('comment', [ - 'post' => $post, - 'model' => $form, - ]); - } - - public function beforeAction($action) - { - // ...set `$this->enableCsrfValidation` here based on some conditions... - // call parent method that will check CSRF if such property is true. - if ($action->id === 'preview') { - # code... - $this->enableCsrfValidation = false; - } - return parent::beforeAction($action); - } - - /*public function actionPreview($id = null) - { - Yii::$app->controller->enableCsrfValidation = false; - $form = new BlogPostForm(); - $parent = $id ? BlogPost::findOne($id) : null; - - if ($form->load(Yii::$app->request->post())) { - $form->slug = md5(time()); - if ($form->validate()) { - $post = new BlogPost(); - $post->id = - 1; - $post->title = $form->title; - $post->description = $form->description; - $post->content = $form->content; - $post->category_id = $form->category_id; - $post->created_at = time(); - $post->updated_at = time(); - $post->published_at = time(); - - $meta = new Meta( $form->meta->title, $form->meta->description, $form->meta->keywords ); - $post->meta = $meta; - $post->meta_json = Json::encode( [ - 'title' => $form->meta->title, - 'description' => $form->meta->description, - 'keywords' => $form->meta->keywords, - ] ); - $post->video = $form->video; - $post->slug = $form->slug; - - if ( $form->image ) { - $post->setImage( $form->image ); - } else if ( $form->video ) { - $src = 'https://i.ytimg.com/vi/' . BlogPostHelper::parseYoutubeUrl( $post->video ) . '/maxresdefault.jpg'; - $filename = ( new Security() )->generateRandomString( 15 ) . '.jpg'; - copy( $src, \Yii::getAlias( BlogPost::FILE_ORIGINAL_PATH . '/' . $post->id . '.jpg' ) ); - //copy($src, \Yii::getAlias(BlogPost::FILE_ORIGINAL_PATH . '/' . $filename)); - $post->image = $filename; - } - - if ( $post->image ) { - $path = $post->getUploadedFilePath( 'image' ); - FileHelper::createDirectory( pathinfo( $path, PATHINFO_DIRNAME ), 0775, true ); - $post->image->saveAs( $path ); - $post->image = $post->getImageFileUrl( 'image' ); - } else { - $post->image = $parent->image; - //$post->image = $post->getImageFileUrl( 'image' ); - } - - return $this->render( 'post', [ - 'post' => $post, - ] ); - } - } else {print_r($form->errors);} - return ''; - }*/ - - public function actionPreview($id, $language = '') - { - if (!$post = $this->posts->findPreview($id, $language)) { - throw new NotFoundHttpException('The requested page does not exist.'); - } - - /*if ($language) { - Yii::$app->language = $language; - }*/ - return $this->render('post', [ - 'post' => $post, - ]); - } -} \ No newline at end of file diff --git a/common/modules/blog/controllers/manage/CategoryController.php b/common/modules/blog/controllers/manage/CategoryController.php deleted file mode 100644 index ac22b18..0000000 --- a/common/modules/blog/controllers/manage/CategoryController.php +++ /dev/null @@ -1,156 +0,0 @@ -service = $service; - } - - public function behaviors(): array - { - return [ - 'access' => [ - 'class' => AccessControl::class, - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['BlogManagement'], - ], - [ // all the action are accessible to admin - 'allow' => true, - 'roles' => ['admin'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::class, - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * @return string - */ - public function actionIndex() - { - $searchModel = new BlogCategorySearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $id - * - * @return string - * @throws NotFoundHttpException - */ - public function actionView($id) - { - $category = $this->findModel($id); - return $this->render('view', [ - 'category' => $category, - ]); - } - - /** - * @return string|\yii\web\Response - */ - public function actionCreate() - { - $form = new BlogCategoryForm(); - $form->updateSort(); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $category = $this->service->create($form); - return $this->redirect(['view', 'id' => $category->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - return $this->render('create', [ - 'model' => $form, - ]); - } - - /** - * @param $id - * - * @return string|\yii\web\Response - * @throws NotFoundHttpException - */ - public function actionUpdate($id) - { - $category = $this->findModel($id); - $form = new BlogCategoryForm($category); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $this->service->edit($category->id, $form); - return $this->redirect(['view', 'id' => $category->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - return $this->render('update', [ - 'model' => $form, - 'category' => $category, - ]); - } - - /** - * @param $id - * - * @return \yii\web\Response - */ - public function actionDelete($id) - { - //$category = $this->findModel($id); - try { - $this->service->remove($id); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['index']); - } - - - /** - * @param $id - * - * @return BlogCategory - * @throws NotFoundHttpException - */ - protected function findModel($id): BlogCategory - { - if (($model = BlogCategory::findOne($id)) !== null) { - return $model; - } - throw new NotFoundHttpException('The requested page does not exist.'); - } -} diff --git a/common/modules/blog/controllers/manage/CommentController.php b/common/modules/blog/controllers/manage/CommentController.php deleted file mode 100644 index 90264b6..0000000 --- a/common/modules/blog/controllers/manage/CommentController.php +++ /dev/null @@ -1,159 +0,0 @@ -service = $service; - } - - public function behaviors(): array - { - return [ - 'access' => [ - 'class' => AccessControl::class, - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['BlogManagement'], - ], - [ // all the action are accessible to admin - 'allow' => true, - 'roles' => ['admin'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::class, - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * @return mixed - */ - public function actionIndex() - { - $searchModel = new BlogCommentSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $post_id - * @param $id - * - * @return string|\yii\web\Response - * @throws NotFoundHttpException - */ - public function actionUpdate($post_id, $id) - { - $post = $this->findModel($post_id); - $comment = $post->getComment($id); - - $form = new BlogCommentEditForm($comment); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $this->service->edit($post->id, $comment->id, $form); - return $this->redirect(['view', 'post_id' => $post->id, 'id' => $comment->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - return $this->render('update', [ - 'post' => $post, - 'model' => $form, - ]); - } - - /** - * @param $post_id - * @param $id - * - * @return string - * @throws NotFoundHttpException - */ - public function actionView($post_id, $id) - { - $post = $this->findModel($post_id); - $comment = $post->getComment($id); - - return $this->render('view', [ - 'post' => $post, - 'comment' => $comment, - ]); - } - - /** - * @param $post_id - * @param $id - * - * @return \yii\web\Response - * @throws NotFoundHttpException - */ - public function actionActivate($post_id, $id) - { - $post = $this->findModel($post_id); - try { - $this->service->activate($post->id, $id); - } catch (\DomainException $e) { - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['view', 'post_id' => $post_id, 'id' => $id]); - } - - /** - * @param $post_id - * @param $id - * - * @return \yii\web\Response - * @throws NotFoundHttpException - */ - public function actionDelete($post_id, $id) - { - $post = $this->findModel($post_id); - try { - $this->service->remove($post->id, $id); - } catch (\DomainException $e) { - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['index']); - } - - /** - * @param $id - * - * @return BlogPost - * @throws NotFoundHttpException - */ - protected function findModel($id): BlogPost - { - if (($model = BlogPost::findOne($id)) !== null) { - return $model; - } - throw new NotFoundHttpException('The requested page does not exist.'); - } -} diff --git a/common/modules/blog/controllers/manage/PostController.php b/common/modules/blog/controllers/manage/PostController.php deleted file mode 100644 index 5035491..0000000 --- a/common/modules/blog/controllers/manage/PostController.php +++ /dev/null @@ -1,311 +0,0 @@ -service = $service; - } - - public function behaviors(): array - { - return [ - 'access' => [ - 'class' => AccessControl::class, - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['BlogManagement'], - ], - [ // all the action are accessible to admin - 'allow' => true, - 'roles' => ['admin'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::class, - 'actions' => [ - 'delete' => ['POST'], - 'activate' => ['POST'], - 'draft' => ['POST'], - 'delete-photo' => ['POST'], - 'move-photo-up' => ['POST'], - 'move-photo-down' => ['POST'], - 'restore-history' => ['POST'], - 'clear-history' => ['POST'], - ], - ], - ]; - } - - /** - * @return string - */ - public function actionIndex() - { - $searchModel = new BlogPostSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - return $this->render( 'index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $id - * - * @return string - * @throws NotFoundHttpException - */ - public function actionView($id) - { - $post = $this->findModel($id); - - $history = BlogPost::find() - ->andWhere(['OR', ['revision_id' => $id], ['id' => $id]]) - ->orderBy(['revision_at' => SORT_DESC]) - ->limit(20) - ->all(); - - return $this->render('view', [ - 'post' => $post, - 'history' => $history, - ]); - } - - public function actionCreatePreview($id = null, $language = '') - { - $this->service->removePreviews(); - - $form = new BlogPostForm(); - $form->type = BlogPost::TYPE_PREVIEW; - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $post = $this->service->create( $form, BlogPost::TYPE_PREVIEW ); - if ($id && !$post->image) { - $real_post = BlogPost::findOne($id); - if ($real_post->image) { - $post->image = $real_post->image; - $post->save(); - $path = Yii::getAlias('@staticRoot/origin/posts'); - $parts = pathinfo($real_post->image); - copy($path . '/' . $real_post->id . '.' . $parts['extension'], $path . '/' . $post->id . '.' . $parts['extension']); - } - } - return $this->redirect(Url::to(Yii::$app->get('frontendUrlManager')->createAbsoluteUrl(['/blog/post/preview', 'id' => $post->id, 'language' => $language]))); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - $form->published_at = date('d.m.Y H:i:s'); - return $this->render('create', [ - 'model' => $form, - ]); - } - - public function actionCreate() - { - $form = new BlogPostForm(); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $post = $this->service->create( $form ); - return $this->redirect( [ 'view', 'id' => $post->id ] ); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - $form->published_at = date('d.m.Y H:i:s'); - return $this->render('create', [ - 'model' => $form, - ]); - } - - /** - * @param $id - * - * @return string|\yii\web\Response - * @throws NotFoundHttpException - */ - public function actionUpdate($id) - { - $post = $this->findModel($id); - $form = new BlogPostForm($post); - - $form->published_at = date('d.m.Y H:i:s', $form->published_at); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $this->service->edit($post->id, $form); - return $this->redirect(['view', 'id' => $post->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - return $this->render('update', [ - 'model' => $form, - 'post' => $post, - ]); - } - - /** - * @param $id - * - * @return Response - */ - public function actionDelete($id) - { - try { - $this->service->remove($id); - } catch (\DomainException $e) { - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['index']); - } - - /** - * @param integer $id - * @return mixed - */ - public function actionActivate($id) - { - try { - $this->service->activate($id); - } catch (\DomainException $e) { - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['view', 'id' => $id]); - } - - /** - * @param integer $id - * @return mixed - */ - public function actionDraft($id) - { - try { - $this->service->draft($id); - } catch (\DomainException $e) { - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['view', 'id' => $id]); - } - - public function actionTagSearch($q = null, $id = null) - { - \Yii::$app->response->format = Response::FORMAT_JSON; - $out = ['results' => ['id' => '', 'text' => '']]; - if (!is_null($q)) { - $data = BlogTag::find()->select('name as id, name as text')->andWhere(['like', 'name', $q])->orderBy('name')->limit(20)->asArray()->all(); - $out['results'] = array_values($data); - } - elseif ($id > 0) { - $tag_name = BlogTag::findOne($id)->name; - $out['results'] = ['id' => $tag_name, 'text' => $tag_name]; - } - return $out; - } - - public function actionPostSearch($q = null, $id = null) - { - \Yii::$app->response->format = Response::FORMAT_JSON; - $out = ['results' => ['id' => '', 'text' => '']]; - if (!is_null($q)) { - //$data = BlogPost::find()->select('id, title as text')->andWhere(['like', 'title', $q])->limit(20)->asArray()->all(); - //$out['results'] = array_values($data); - $data = []; - $posts = BlogPost::find() - ->with('translation') - ->leftJoin('{{%blog_posts_lng}}', '`blog_posts_lng`.`blog_post_id` = `blog_posts`.`id`') - ->andWhere(['like', 'blog_posts_lng.title', $q]) - ->limit(20) - ->all(); - - foreach ($posts as $post) { - $data[] = [ - 'id' => $post->id, - 'text' => isset($post->translation) ? $post->translation->title : null, - ]; - } - $out['results'] = array_values($data); - } - elseif ($id > 0) { - $tag_name = BlogPost::findOne($id)->translation->title; - $out['results'] = ['id' => $tag_name, 'text' => $tag_name]; - } - else { - //$data = BlogPost::find()->select('id, title as text')->orderBy(['created_at' => SORT_DESC])->limit(20)->asArray()->all(); - //$out['results'] = array_values($data); - $data = []; - $posts = BlogPost::find()->orderBy(['id' => SORT_DESC])->limit(20)->all(); - - foreach ($posts as $post) { - $data[] = [ - 'id' => $post->id, - 'text' => isset($post->translation) ? $post->translation->title : null, - ]; - } - $out['results'] = array_values($data); - } - return $out; - } - - public function actionRestoreHistory($id) - { - $post = $this->findModel($id); - if ($post_id = $post->revision_id) { - $new_id = $this->service->restoreHistory($id, $post->revision_id); - return $this->redirect(['/blog/manage/post/view', 'id' => $new_id]); - } - return $this->redirect(['/blog/manage/post/index']); - } - - public function actionClearHistory($id) - { - $post = $this->findModel($id); - $this->service->clearHistory($post); - return $this->redirect(['/blog/manage/post/view', 'id' => $post->id]); - } - - /** - * @param $id - * - * @return BlogPost - * @throws NotFoundHttpException - */ - protected function findModel($id): BlogPost - { - if (($model = BlogPost::findOne($id)) !== null) { - return $model; - } - throw new NotFoundHttpException('The requested page does not exist.'); - } - - protected function findLanguageModel($id) - { - if (($model = BlogPost::find()->multilingual()->andWhere(['id' => $id])->one()) !== null) { - return $model; - } - throw new NotFoundHttpException('The requested page does not exist.'); - } -} diff --git a/common/modules/blog/controllers/manage/TagController.php b/common/modules/blog/controllers/manage/TagController.php deleted file mode 100644 index d2dc23b..0000000 --- a/common/modules/blog/controllers/manage/TagController.php +++ /dev/null @@ -1,151 +0,0 @@ -service = $service; - } - - public function behaviors(): array - { - return [ - 'access' => [ - 'class' => AccessControl::class, - 'rules' => [ - [ - 'allow' => true, - 'roles' => ['BlogManagement'], - ], - [ // all the action are accessible to admin - 'allow' => true, - 'roles' => ['admin'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::class, - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * @return string - */ - public function actionIndex() - { - $searchModel = new BlogTagSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * @param $id - * - * @return string - * @throws NotFoundHttpException - */ - public function actionView($id) - { - $tag = $this->findModel($id); - return $this->render('view', [ - 'tag' => $tag, - ]); - } - - /** - * @return string|\yii\web\Response - */ - public function actionCreate() - { - $form = new BlogTagSingleForm(); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $tag = $this->service->create($form); - return $this->redirect(['view', 'id' => $tag->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - return $this->render('create', [ - 'model' => $form, - ]); - } - - /** - * @param $id - * - * @return string|\yii\web\Response - * @throws NotFoundHttpException - */ - public function actionUpdate($id) - { - $tag = $this->findModel($id); - $form = new BlogTagSingleForm($tag); - if ($form->load(Yii::$app->request->post()) && $form->validate()) { - try { - $this->service->edit($tag->id, $form); - return $this->redirect(['view', 'id' => $tag->id]); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - } - return $this->render('update', [ - 'model' => $form, - 'tag' => $tag, - ]); - } - - /** - * @param $id - * - * @return \yii\web\Response - */ - public function actionDelete($id) - { - try { - $this->service->remove($id); - } catch (\DomainException $e) { - Yii::$app->errorHandler->logException($e); - Yii::$app->session->setFlash('error', $e->getMessage()); - } - return $this->redirect(['index']); - } - - /** - * @param $id - * - * @return BlogTag - * @throws NotFoundHttpException - */ - protected function findModel($id): BlogTag - { - if (($model = BlogTag::findOne($id)) !== null) { - return $model; - } - throw new NotFoundHttpException('The requested page does not exist.'); - } -} diff --git a/common/modules/blog/entities/BlogCategory.php b/common/modules/blog/entities/BlogCategory.php deleted file mode 100644 index 47ed277..0000000 --- a/common/modules/blog/entities/BlogCategory.php +++ /dev/null @@ -1,117 +0,0 @@ -slug = $slug; - $category->sort = $sort; - $category->_form = $form; - - return $category; - } - - public function edit($form, $slug, $sort): void - { - $this->slug = $slug; - $this->sort = $sort; - $this->_form = $form; - } - - public function attributeLabels() - { - return [ - 'id' => Yii::t('blog', 'ID'), - 'name' => Yii::t('blog', 'Name'), - 'slug' => Yii::t('blog', 'SEO link'), - 'sort' => Yii::t('blog', 'Sort'), - 'title' => Yii::t('blog', 'Title'), - 'description' => Yii::t('blog', 'Description'), - 'meta_title' => Yii::t('blog', 'META Title'), - 'meta_description' => Yii::t('blog', 'META Description'), - 'meta_keywords' => Yii::t('blog', 'META Keywords'), - ]; - } - - public function getSeoTitle(): string - { - return $this->translation->meta_title ?: $this->getHeadingTile(); - } - - public function getHeadingTile(): string - { - return $this->translation->title ?: $this->translation->name; - } - - public function getPostsCount(): int - { - return BlogPost::find()->where(['category_id' => $this->id])->count('*'); - } - - public static function tableName(): string - { - return '{{%blog_categories}}'; - } - - public function behaviors(): array - { - return [ - /*[ - 'class' => SluggableBehavior::class, - 'attribute' => 'title', - 'ensureUnique' => true, - 'preserveNonEmptyValues' => true, - ],*/ - [ - 'class' => LanguageBehavior::class, - 'virtualClassName' => 'BlogCategoryVirtualTranslate', - 'translatedLanguages' => \Yii::$app->params['translatedLanguages'], - 'relativeField' => 'blog_category_id', - 'tableName' => '{{%blog_categories_lng}}', - 'attributes' => [ - 'title', - 'description', - 'name', - 'meta_title', - 'meta_description', - 'meta_keywords' - ], - //'defaultLanguage' => basename(Yii::$app->getBasePath()) === 'backend' ? Yii::$app->language : Yii::$app->params['defaultLanguage'], - 'defaultLanguage' => \Yii::$app->params['defaultLanguage'], - ], - [ - 'class' => SluggableRelationBehavior::class, - 'attribute' => 'name', - 'relation' => 'translation', - ], - ]; - } - - public static function find(): BlogCategoryQuery - { - return new BlogCategoryQuery(static::class); - } -} diff --git a/common/modules/blog/entities/BlogComment.php b/common/modules/blog/entities/BlogComment.php deleted file mode 100644 index 0788cb5..0000000 --- a/common/modules/blog/entities/BlogComment.php +++ /dev/null @@ -1,93 +0,0 @@ -user_id = $userId; - $review->parent_id = $parentId; - $review->text = $text; - $review->created_at = time(); - $review->active = true; - return $review; - } - - public function edit($parentId, $text): void - { - $this->parent_id = $parentId; - $this->text = $text; - } - - public function attributeLabels() - { - return [ - 'id' => Yii::t('blog', 'ID'), - 'user_id' => Yii::t('blog', 'User'), - 'parent_id' => Yii::t('blog', 'Parent Comment ID'), - 'created_at' => Yii::t('blog', 'Created At'), - 'active' => Yii::t('blog', 'Published'), - 'post_id' => Yii::t('blog', 'Post'), - 'text' => Yii::t('blog', 'Comment'), - ]; - } - - public function activate(): void - { - $this->active = true; - } - - public function draft(): void - { - $this->active = false; - } - - public function isActive(): bool - { - return $this->active == true; - } - - public function isIdEqualTo($id): bool - { - return $this->id == $id; - } - - public function isChildOf($id): bool - { - return $this->parent_id == $id; - } - - public function getPost(): ActiveQuery - { - return $this->hasOne(BlogPost::class, ['id' => 'post_id']); - } - - public function getUser(): ActiveQuery - { - return $this->hasOne(User::class, ['id' => 'user_id']); - } - - public static function tableName(): string - { - return '{{%blog_comments}}'; - } -} \ No newline at end of file diff --git a/common/modules/blog/entities/BlogPost.php b/common/modules/blog/entities/BlogPost.php deleted file mode 100644 index f6140d4..0000000 --- a/common/modules/blog/entities/BlogPost.php +++ /dev/null @@ -1,376 +0,0 @@ -category_id = $categoryId; - $post->slug = $slug; - $post->status = self::STATUS_DRAFT; - $post->created_at = time(); - $post->comments_count = 0; - $post->published_at = $published_at; - $post->video = $video; - $post->type = $type; - $post->revision_at = time(); - $post->_form = $form; - return $post; - } - - public function setImage(UploadedFile $image): void - { - $this->image = $image; - } - - - public function edit($form, $categoryId, $slug, $published_at, $video, $type = BlogPost::TYPE_PUBLIC): void - { - $this->category_id = $categoryId; - $this->slug = $slug; - $this->published_at = $published_at; - $this->video = $video; - $this->type = $type; - $this->revision_at = time(); - $this->_form = $form; - } - - /** - * @inheritdoc - */ - public static function tableName() - { - return 'blog_posts'; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => Yii::t('blog', 'ID'), - 'category_id' => Yii::t('blog', 'Category'), - 'published_at' => Yii::t('blog', 'Published At'), - 'created_at' => Yii::t('blog', 'Created At'), - 'updated_at' => Yii::t('blog', 'Updated At'), - 'title' => Yii::t('blog', 'Title'), - 'description' => Yii::t('blog', 'Description'), - 'content' => Yii::t('blog', 'Content'), - 'image' => Yii::t('blog', 'Image'), - 'video' => Yii::t('blog', 'Video'), - 'type' => Yii::t('blog', 'Type'), - 'revision_at' => Yii::t('blog', 'Revision At'), - 'status' => Yii::t('blog', 'Status'), - 'meta_json' => Yii::t('blog', 'Meta Json'), - 'comments_count' => Yii::t('blog', 'Comments Count'), - 'views' => Yii::t('blog', 'Views'), - 'slug' => Yii::t('blog', 'Slug'), - 'meta_title' => Yii::t('blog', 'META Title'), - 'meta_description' => Yii::t('blog', 'META Description'), - 'meta_keywords' => Yii::t('blog', 'META Keywords'), - ]; - } - - public function activate(): void - { - if ($this->isActive()) { - throw new \DomainException('Post is already active.'); - } - $this->status = self::STATUS_ACTIVE; - } - - public function draft(): void - { - if ($this->isDraft()) { - throw new \DomainException('Post is already draft.'); - } - $this->status = self::STATUS_DRAFT; - } - - public function isActive(): bool - { - return $this->status == self::STATUS_ACTIVE; - } - - - public function isDraft(): bool - { - return $this->status == self::STATUS_DRAFT; - } - - public function getSeoTitle(): string - { - return $this->translation->meta_title ?: $this->translation->title; - } - - // Tags - - public function assignTag($id): void - { - $assignments = $this->blogTagAssignments; - foreach ($assignments as $assignment) { - if ($assignment->isForTag($id)) { - return; - } - } - $assignments[] = BlogTagAssignment::create($id); - $this->blogTagAssignments = $assignments; - } - - public function revokeTag($id): void - { - $assignments = $this->blogTagAssignments; - foreach ($assignments as $i => $assignment) { - if ($assignment->isForTag($id)) { - unset($assignments[$i]); - $this->blogTagAssignments = $assignments; - return; - } - } - throw new \DomainException('Assignment is not found.'); - } - - public function revokeTags(): void - { - $this->blogTagAssignments = []; - } - - // Comments - - public function addComment($userId, $parentId, $text): BlogComment - { - $parent = $parentId ? $this->getComment($parentId) : null; - if ($parent && !$parent->isActive()) { - throw new \DomainException('Cannot add comment to inactive parent.'); - } - $comments = $this->blogComments; - $comments[] = $comment = BlogComment::create($userId, $parent ? $parent->id : null, $text); - $this->updateComments($comments); - return $comment; - } - - public function editComment($id, $parentId, $text): void - { - $parent = $parentId ? $this->getComment($parentId) : null; - $comments = $this->blogComments; - foreach ($comments as $comment) { - if ($comment->isIdEqualTo($id)) { - $comment->edit($parent ? $parent->id : null, $text); - $this->updateComments($comments); - return; - } - } - throw new \DomainException('Comment is not found.'); - } - - public function activateComment($id): void - { - $comments = $this->blogComments; - foreach ($comments as $comment) { - if ($comment->isIdEqualTo($id)) { - $comment->activate(); - $this->updateComments($comments); - return; - } - } - throw new \DomainException('Comment is not found.'); - } - - public function removeComment($id): void - { - $comments = $this->blogComments; - foreach ($comments as $i => $comment) { - if ($comment->isIdEqualTo($id)) { - if ($this->hasChildren($comment->id)) { - $comment->draft(); - } else { - unset($comments[$i]); - } - $this->updateComments($comments); - return; - } - } - throw new \DomainException('Comment is not found.'); - } - - public function getComment($id): BlogComment - { - foreach ($this->blogComments as $comment) { - if ($comment->isIdEqualTo($id)) { - return $comment; - } - } - throw new \DomainException('Comment is not found.'); - } - - private function hasChildren($id): bool - { - foreach ($this->blogComments as $comment) { - if ($comment->isChildOf($id)) { - return true; - } - } - return false; - } - - private function updateComments(array $comments): void - { - $this->blogComments = $comments; - $this->comments_count = count(array_filter($comments, function (BlogComment $comment) { - return $comment->isActive(); - })); - } - - ###################################### - - public function getBlogComments(): ActiveQuery - { - return $this->hasMany(BlogComment::class, ['post_id' => 'id']); - } - - public function getBlogTagAssignments(): ActiveQuery - { - return $this->hasMany(BlogTagAssignment::class, ['post_id' => 'id']); - } - - public function getTags(): ActiveQuery - { - return $this->hasMany(BlogTag::class, ['id' => 'tag_id'])->viaTable('blog_tag_assignments', ['post_id' => 'id']); - } - - public function getCategory(): ActiveQuery - { - return $this->hasOne(BlogCategory::class, ['id' => 'category_id']); - } - - ###################################### - - public function behaviors(): array - { - return [ - TimestampBehavior::class, - [ - 'class' => SaveRelationsBehavior::class, - 'relations' => ['blogTagAssignments', 'blogComments'], - ], - /*[ - 'class' => SluggableBehavior::class, - 'attribute' => 'title', - 'ensureUnique' => true, - 'preserveNonEmptyValues' => true, - ],*/ - [ - 'class' => LanguageBehavior::class, - 'virtualClassName' => 'BlogVirtualTranslate', - 'translatedLanguages' => \Yii::$app->params['translatedLanguages'], - 'relativeField' => 'blog_post_id', - 'tableName' => "{{%blog_posts_lng}}", - 'attributes' => ['title', 'description', 'content', 'meta_title', 'meta_description', 'meta_keywords'], - //'defaultLanguage' => basename(Yii::$app->getBasePath()) === 'backend' ? Yii::$app->language : Yii::$app->params['defaultLanguage'], - 'defaultLanguage' => \Yii::$app->params['defaultLanguage'], - ], - [ - 'class' => SluggableRelationBehavior::class, - 'attribute' => 'title', - 'relation' => 'translation', - ], - [ - // todo Image Sizes to settings or theme settings - 'class' => ImageUploadBehavior::class, - 'attribute' => 'image', - 'createThumbsOnRequest' => true, - //'filePath' => $this::FILE_ORIGINAL_PATH . '/[[id]].[[extension]]', - 'filePath' => '@staticRoot/origin/posts/[[id]].[[extension]]', - 'fileUrl' => '@static/origin/posts/[[id]].[[extension]]', - 'thumbPath' => '@staticRoot/cache/posts/[[profile]]_[[id]].[[extension]]', - 'thumbUrl' => '@static/cache/posts/[[profile]]_[[id]].[[extension]]', - 'thumbs' => [ - 'blog_list' => ['width' => 750, 'height' => 300, 'resizeUp' => true], - 'blog_post' => ['width' => 900, 'height' => 300], - - 'admin' => ['width' => 60, 'height' => 60], - 'thumb' => ['width' => 150, 'height' => 150], - 'list' => ['width' => 200, 'height' => 200], - 'home_slider' => ['width' => 369, 'height' => 343], - '94_94' => ['width' => 94, 'height' => 94], - '368_287' => ['width' => 368, 'height' => 287], - '370_325' => ['width' => 370, 'height' => 325], - '683_407' => ['width' => 683, 'height' => 407], - 'thumb_gallery_view' => ['width' => 300, 'height' => 170], - //'widget_list' => ['width' => 228, 'height' => 228], - //'origin' => ['processor' => [new WaterMarker(1024, 768, '@frontend/web/image/logo.png'), 'process']], - 'origin' => ['width' => 1024, 'height' => 768], - ], - ], - ]; - } - - public function transactions(): array - { - return [ - self::SCENARIO_DEFAULT => self::OP_ALL, - ]; - } - - public static function find(): BlogPostQuery - { - return new BlogPostQuery(static::class); - } -} diff --git a/common/modules/blog/entities/BlogTag.php b/common/modules/blog/entities/BlogTag.php deleted file mode 100644 index 11691d3..0000000 --- a/common/modules/blog/entities/BlogTag.php +++ /dev/null @@ -1,58 +0,0 @@ -name = $name; - $tag->slug = $slug; - return $tag; - } - - public function edit($name, $slug): void - { - $this->name = $name; - if ($slug != $this->slug) - { - TagDependency::invalidate(\Yii::$app->cache, 'blog_tags'); - } - $this->slug = $slug; - } - - public function attributeLabels() - { - return [ - 'name' => Yii::t('blog', 'Tag Name'), - 'slug' => Yii::t('blog', 'SEO link'), - ]; - } - - public static function tableName(): string - { - return '{{%blog_tags}}'; - } - - public function behaviors() { - return [ - [ - 'class' => SluggableBehavior::class, - 'attribute' => 'name', - 'ensureUnique' => true, - 'preserveNonEmptyValues' => true, - ], - ]; - } -} \ No newline at end of file diff --git a/common/modules/blog/entities/BlogTagAssignment.php b/common/modules/blog/entities/BlogTagAssignment.php deleted file mode 100644 index adb6aee..0000000 --- a/common/modules/blog/entities/BlogTagAssignment.php +++ /dev/null @@ -1,37 +0,0 @@ -tag_id = $tagId; - return $assignment; - } - - public function isForTag($id): bool - { - return $this->tag_id == $id; - } - - public static function tableName(): string - { - return '{{%blog_tag_assignments}}'; - } - - public function getTag(): ActiveQuery - { - return $this->hasOne(BlogTag::class, ['id' => 'tag_id']); - } -} \ No newline at end of file diff --git a/common/modules/blog/entities/queries/BlogCategoryQuery.php b/common/modules/blog/entities/queries/BlogCategoryQuery.php deleted file mode 100644 index a8d58c4..0000000 --- a/common/modules/blog/entities/queries/BlogCategoryQuery.php +++ /dev/null @@ -1,15 +0,0 @@ -andWhere([ - ($alias ? $alias . '.' : '') . 'status' => BlogPost::STATUS_ACTIVE, - ]); - } - - public function pubDate() - { - return $this->andWhere(['<', 'published_at', time()]); - } - - public function typePublic($alias = null) - { - return $this->andWhere([ - ($alias ? $alias . '.' : '') . 'type' => BlogPost::TYPE_PUBLIC, - ]); - } - - /*public function byType($type) - { - return $this->andWhere(['type_id' => $type]); - }*/ - - public function last() - { - return $this->orderBy(['published_at' => SORT_DESC]); - } - - public function popular() - { - return $this->orderBy(['views' => SORT_DESC]); - } -} \ No newline at end of file diff --git a/common/modules/blog/forms/BlogCategoryForm.php b/common/modules/blog/forms/BlogCategoryForm.php deleted file mode 100644 index a4c9ea7..0000000 --- a/common/modules/blog/forms/BlogCategoryForm.php +++ /dev/null @@ -1,83 +0,0 @@ -slug = $category->slug; - $this->sort = $category->sort; - $this->_category = $category; - } else { - $this->sort = BlogCategory::find()->max('sort') + 1; - } - parent::__construct($category, $attributes, $config); - } - - public function rules(): array - { - return array_merge( - parent::rules(), - [ - [['name'], 'required'], - [['name', 'slug', 'title', 'meta_title', 'meta_keywords'], 'string', 'max' => 255], - [['description', 'meta_description'], 'string'], - ['slug', SlugValidator::class], - [['slug'], 'unique', 'targetClass' => BlogCategory::class, 'filter' => $this->_category ? ['<>', 'id', $this->_category->id] : null] - ] - ); - } - - public function attributeLabels() - { - return array_merge( - parent::attributeLabels(), - [ - 'name' => Yii::t('blog', 'Name'), - 'slug' => Yii::t('blog', 'SEO link'), - 'sort' => Yii::t('blog', 'Sort'), - 'title' => Yii::t('blog', 'Title'), - 'description' => Yii::t('blog', 'Description'), - 'meta_title' => Yii::t('blog', 'META Title'), - 'meta_description' => Yii::t('blog', 'META Description'), - 'meta_keywords' => Yii::t('blog', 'META Keywords'), - ] - ); - } - - public function attributeHints() { - return array_merge( - parent::attributeHints(), - [ - 'slug' => Yii::t('blog', 'SEO link will be generated automatically if not specified'), - ] - ); - } - - public function updateSort() { - $this->sort = BlogCategory::find()->max('sort') + 1; - } -} \ No newline at end of file diff --git a/common/modules/blog/forms/BlogCommentEditForm.php b/common/modules/blog/forms/BlogCommentEditForm.php deleted file mode 100644 index f73fb26..0000000 --- a/common/modules/blog/forms/BlogCommentEditForm.php +++ /dev/null @@ -1,37 +0,0 @@ -parentId = $comment->parent_id; - $this->text = $comment->text; - parent::__construct($config); - } - - public function rules(): array - { - return [ - [['text'], 'required'], - ['text', 'string'], - ['parentId', 'integer'], - ]; - } - - public function attributeLabels() - { - return [ - 'parentId' => Yii::t('blog', 'Parent Comment ID'), - 'text' => Yii::t('blog', 'Comment'), - ]; - } -} \ No newline at end of file diff --git a/common/modules/blog/forms/BlogCommentForm.php b/common/modules/blog/forms/BlogCommentForm.php deleted file mode 100644 index eb81b7a..0000000 --- a/common/modules/blog/forms/BlogCommentForm.php +++ /dev/null @@ -1,20 +0,0 @@ -category_id = $post->category_id; - $this->video = $post->video; - $this->published_at = $post->published_at; - $this->slug = $post->slug; - $this->tags = new BlogTagForm($post); - $this->status = $post->status; - $this->_post = $post; - } else { - $this->tags = new BlogTagForm(); - $this->status = 0; - } - parent::__construct($post, $attributes, $config); - } - - public function rules(): array - { - return array_merge( - parent::rules(), - [ - [['category_id', 'title'], 'required'], - [['title', 'video', 'meta_title', 'meta_keywords'], 'string', 'max' => 255], - [['category_id', 'status'], 'integer'], - [['description', 'content', 'meta_description'], 'string'], - [['image'], 'image'], - ['reset_image', 'boolean'], - ['published_at', 'safe'], - ['slug', SlugValidator::class], - [['slug'], 'unique', 'targetClass' => BlogPost::class, 'filter' => function (ActiveQuery $query) { - if ($this->type != BlogPost::TYPE_PUBLIC) { - $query->andWhere($this->type . '=' . BlogPost::TYPE_PUBLIC); - } - - $query->andWhere(['type' => BlogPost::TYPE_PUBLIC]); - if ($this->_post) { - $query->andWhere(['<>', 'id', $this->_post->id]); - } - return $query; - }], - ] - ); - } - - public function attributeLabels() - { - return array_merge( - parent::attributeLabels(), - [ - 'id' => Yii::t('blog', 'ID'), - 'category_id' => Yii::t('blog', 'Category'), - 'published_at' => Yii::t('blog', 'Published At'), - 'created_at' => Yii::t('blog', 'Created At'), - 'updated_at' => Yii::t('blog', 'Updated At'), - 'title' => Yii::t('blog', 'Title'), - 'description' => Yii::t('blog', 'Description'), - 'content' => Yii::t('blog', 'Content'), - 'image' => Yii::t('blog', 'Image'), - 'video' => Yii::t('blog', 'Video'), - 'status' => Yii::t('blog', 'Status'), - 'comments_count' => Yii::t('blog', 'Comments Count'), - 'views' => Yii::t('blog', 'Views'), - 'slug' => Yii::t('blog', 'Slug'), - 'reset_image' => Yii::t('blog', 'Reset Image'), - 'meta_title' => Yii::t('blog', 'META Title'), - 'meta_description' => Yii::t('blog', 'META Description'), - 'meta_keywords' => Yii::t('blog', 'META Keywords'), - ] - ); - } - - public function attributeHints() { - return array_merge( - parent::attributeHints(), - [ - 'published_at' => Yii::t('blog', 'The article will be published after the specified date if its status is not a draft'), - 'slug' => Yii::t('pages', 'SEO link will be generated automatically if not specified'), - ] - ); - } - - public function categoriesList(): array - { - return ArrayHelper::map(BlogCategory::find()->orderBy('sort')->all(), 'id', function (BlogCategory $category) { - return $category->translation->name; - }); - } - - protected function internalForms(): array - { - return ['tags']; - } - - public function beforeValidate(): bool - { - if (parent::beforeValidate()) { - $this->image = UploadedFile::getInstance($this, 'image'); - $this->published_at = strtotime($this->published_at); - return true; - } - return false; - } -} \ No newline at end of file diff --git a/common/modules/blog/forms/BlogTagForm.php b/common/modules/blog/forms/BlogTagForm.php deleted file mode 100644 index 1bc367b..0000000 --- a/common/modules/blog/forms/BlogTagForm.php +++ /dev/null @@ -1,46 +0,0 @@ -new_tags = ArrayHelper::map($post->blogTagAssignments, 'tag_id', 'tag.name'); - } - parent::__construct($config); - } - - public function rules(): array - { - return [ - ['existing', 'each', 'rule' => ['integer']], - [['textNew'], 'string'], - ['existing', 'default', 'value' => []], - ['new_tags', 'each', 'rule' => ['string']], - ]; - } - - public function tagsList(): array - { - return ArrayHelper::map(BlogTag::find()->orderBy('name')->asArray()->all(), 'id', 'name'); - } - - public function getNewNames(): array - { - return array_filter(array_map('trim', preg_split('#\s*,\s*#i', $this->textNew))); - } -} \ No newline at end of file diff --git a/common/modules/blog/forms/BlogTagSingleForm.php b/common/modules/blog/forms/BlogTagSingleForm.php deleted file mode 100644 index 50f5fdb..0000000 --- a/common/modules/blog/forms/BlogTagSingleForm.php +++ /dev/null @@ -1,51 +0,0 @@ -name = $tag->name; - $this->slug = $tag->slug; - $this->_tag = $tag; - } - parent::__construct($config); - } - - public function rules(): array - { - return [ - [['name'], 'required'], - [['name', 'slug'], 'string', 'max' => 255], - ['slug', SlugValidator::class], - [['name', 'slug'], 'unique', 'targetClass' => BlogTag::class, 'filter' => $this->_tag ? ['<>', 'id', $this->_tag->id] : null] - ]; - } - - public function attributeLabels() - { - return [ - 'name' => Yii::t('blog', 'Tag Name'), - 'slug' => Yii::t('blog', 'SEO link'), - ]; - } - - public function attributeHints() { - return [ - 'slug' => Yii::t('pages', 'SEO link will be generated automatically if not specified'), - ]; - } -} \ No newline at end of file diff --git a/common/modules/blog/forms/search/BlogCategorySearch.php b/common/modules/blog/forms/search/BlogCategorySearch.php deleted file mode 100644 index 3b2bd99..0000000 --- a/common/modules/blog/forms/search/BlogCategorySearch.php +++ /dev/null @@ -1,56 +0,0 @@ - $query, - 'sort' => [ - 'defaultOrder' => ['sort' => SORT_ASC] - ] - ]); - $this->load($params); - - if (!$this->validate()) { - $query->where('0=1'); - return $dataProvider; - } - - $query->andFilterWhere([ - 'id' => $this->id, - ]); - - $query - ->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'slug', $this->slug]) - ->andFilterWhere(['like', 'title', $this->title]); - return $dataProvider; - } -} diff --git a/common/modules/blog/forms/search/BlogCommentSearch.php b/common/modules/blog/forms/search/BlogCommentSearch.php deleted file mode 100644 index 610c108..0000000 --- a/common/modules/blog/forms/search/BlogCommentSearch.php +++ /dev/null @@ -1,72 +0,0 @@ -with(['post']); - - $dataProvider = new ActiveDataProvider([ - 'query' => $query, - 'key' => function (BlogComment $comment) { - return [ - 'post_id' => $comment->post_id, - 'id' => $comment->id, - ]; - }, - 'sort' => [ - 'defaultOrder' => ['id' => SORT_DESC] - ] - ]); - - $this->load($params); - - if (!$this->validate()) { - $query->where('0=1'); - return $dataProvider; - } - - $query->andFilterWhere([ - 'id' => $this->id, - 'post_id' => $this->post_id, - ]); - - $query - ->andFilterWhere(['like', 'text', $this->text]); - - return $dataProvider; - } - - public function activeList(): array - { - return [ - 1 => Yii::$app->formatter->asBoolean(true), - 0 => Yii::$app->formatter->asBoolean(false), - ]; - } -} diff --git a/common/modules/blog/forms/search/BlogPostSearch.php b/common/modules/blog/forms/search/BlogPostSearch.php deleted file mode 100644 index b68447f..0000000 --- a/common/modules/blog/forms/search/BlogPostSearch.php +++ /dev/null @@ -1,71 +0,0 @@ -typePublic()->joinWith('translation'); - - $dataProvider = new ActiveDataProvider([ - 'query' => $query, - 'sort' => [ - 'defaultOrder' => ['id' => SORT_DESC] - ] - ]); - - $this->load($params); - - if (!$this->validate()) { - $query->where('0=1'); - return $dataProvider; - } - - $query->andFilterWhere([ - 'id' => $this->id, - 'category_id' => $this->category_id, - ]); - - $query - ->andFilterWhere(['like', 'title', $this->title]); - - return $dataProvider; - } - - public function categoriesList(): array - { - return ArrayHelper::map(BlogCategory::find()->orderBy('sort')->all(), 'id', function (BlogCategory $category) { - return $category->translation->name; - }); - } - - public function statusList(): array - { - return BlogPostHelper::statusList(); - } -} diff --git a/common/modules/blog/forms/search/BlogTagSearch.php b/common/modules/blog/forms/search/BlogTagSearch.php deleted file mode 100644 index 621d875..0000000 --- a/common/modules/blog/forms/search/BlogTagSearch.php +++ /dev/null @@ -1,55 +0,0 @@ - $query, - 'sort' => [ - 'defaultOrder' => ['name' => SORT_ASC] - ] - ]); - - $this->load($params); - - if (!$this->validate()) { - $query->where('0=1'); - return $dataProvider; - } - - $query->andFilterWhere([ - 'id' => $this->id, - ]); - - $query - ->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'slug', $this->slug]); - - return $dataProvider; - } -} diff --git a/common/modules/blog/helpers/BlogPostHelper.php b/common/modules/blog/helpers/BlogPostHelper.php deleted file mode 100644 index 6173836..0000000 --- a/common/modules/blog/helpers/BlogPostHelper.php +++ /dev/null @@ -1,132 +0,0 @@ - Yii::t('blog', 'Draft'), - Post::STATUS_ACTIVE => Yii::t('blog', 'Active'), - ]; - } - - public static function statusName($status): string - { - return ArrayHelper::getValue(self::statusList(), $status); - } - - public static function statusLabel($status): string - { - switch ($status) { - case Post::STATUS_DRAFT: - $class = 'label label-default'; - break; - case Post::STATUS_ACTIVE: - $class = 'label label-success'; - break; - default: - $class = 'label label-default'; - } - - return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [ - 'class' => $class, - ]); - } - - public static function parseYoutubeUrl($url) - { - $urls = parse_url($url); - //url is http://youtu.be/xxxx - if($urls['host'] == 'youtu.be'){ - $id = ltrim($urls['path'],'/'); - } - //url is http://www.youtube.com/embed/xxxx - else if(strpos($urls['path'],'embed') == 1){ - $id = end(explode('/',$urls['path'])); - } - //url is xxxx only - else if(strpos($url,'/')===false){ - $id = $url; - } - //http://www.youtube.com/watch?feature=player_embedded&v=m-t4pcO99gI - //url is http://www.youtube.com/watch?v=xxxx - else{ - parse_str($urls['query']); - /* @var $v */ - $id = $v; - if(!empty($feature)){ - $id = end(explode('v=',$urls['query'])); - } - } - return $id; - } - - public static function saveRevision1(BlogPost $model) { - if (!$model->revision_id) { - - $blogForm = new BlogPostForm($model); - $blog = BlogPost::create( - $blogForm, - $model->category_id, - $model->slug, - $model->published_at, - $model->video, - $model->type - ); - $blog->type = BlogPost::TYPE_REVISION; - $blog->revision_at = $model->updated_at; - $blog->revision_id = $model->id; - - foreach ($model->tags as $tag) { - $blog->assignTag($tag->id); - } - - $blog->save(); - - if ($model->image) { - $path = Yii::getAlias( '@staticRoot/origin/posts' ); - $parts = pathinfo( $model->image ); - copy( $path . '/' . $model->id . '.' . $parts['extension'], $path . '/' . $blog->id . '.' . $parts['extension'] ); - } - } - } - - public static function saveRevision(BlogPost $model) { - if (!$model->revision_id) { - $revision = clone $model; - $revision->id = null; - $revision->isNewRecord = true; - $revision->revision_at = $revision->updated_at; - $revision->revision_id = $model->id; - $revision->type = BlogPost::TYPE_REVISION; - $revision->_form = new BlogPostForm($model); - $revision->save(); - - // tags - foreach ($model->tags as $tag) { - $revision->assignTag($tag->id); - } - $revision->save(); - - if ($model->image) { - $path = Yii::getAlias( '@staticRoot/origin/posts' ); - $parts = pathinfo( $model->image ); - copy( $path . '/' . $model->id . '.' . $parts['extension'], $path . '/' . $revision->id . '.' . $parts['extension'] ); - } - } - } -} \ No newline at end of file diff --git a/common/modules/blog/manifest.php b/common/modules/blog/manifest.php deleted file mode 100644 index dbb0617..0000000 --- a/common/modules/blog/manifest.php +++ /dev/null @@ -1,11 +0,0 @@ - '1.0.1', - 'name' => 'blog', - 'description' => 'Blog system for site with comments and slug', - 'module' => 'BlogModule', - 'permissions' => [ - 'BlogManagement' => 'Blog management system' - ], -]; diff --git a/common/modules/blog/messages/ru/blog.php b/common/modules/blog/messages/ru/blog.php deleted file mode 100644 index 43cade2..0000000 --- a/common/modules/blog/messages/ru/blog.php +++ /dev/null @@ -1,83 +0,0 @@ - 'Блог', - 'Blog system for site with comments and slug' => 'Публикация статей на сайте в виде ленты. Статьи разделены по категориям', - 'All Posts' => 'Все статьи', - 'Posts' => 'Статьи', - 'Categories' => 'Категории', - 'Tags' => 'Теги', - 'News' => 'Новости', - 'Comments' => 'Комментарии', - 'Articles' => 'Статьи', - 'Blog' => 'Блог', - 'Blogs' => 'Блоги', - 'Events' => 'События', - 'Gallery' => 'Фотогалерея', - 'Create Post' => 'Новая статья', - 'Create Category' => 'Новая категория', - 'Create Tag' => 'Новый тег', - 'Common' => 'Основное', - 'Title' => 'Заголовок', - 'Description' => 'Описание', - 'Content' => 'Содержание', - 'Image' => 'Изображение', - 'Existing' => 'Существующие', - 'New tag' => 'Новый тег', - 'Category' => 'Категория', - 'Post is already active.' => 'Статья уже опубликована.', - 'Published At' => 'Опубликовано', - 'Created At' => 'Создано', - 'Updated At' => 'Обновлено', - 'Status' => 'Статус', - 'ID' => '№', - 'SEO' => 'МЕТА теги', - 'Tag Name' => 'Тег', - 'SEO link' => 'ЧПУ ссылка', - 'Draft' => 'Черновик', - 'Active' => 'Опубликовано', - 'Activate' => 'Опубликовать', - 'META Title' => 'Заголовок', - 'META Description' => 'Описание', - 'META Keywords' => 'Ключевые слова', - 'Name' => 'Название', - 'Sort' => 'Позиция', - 'Update: {name}' => 'Редактирование: {name}', - 'Types' => 'Типы', - 'Create Type' => 'Новый тип', - 'Singular' => 'Единственное число', - 'Plural' => 'Множественное число', - 'Slug' => 'ЧПУ ссылка', - 'Update Post: {name}' => 'Редактирование: {name}', - 'Update Post Comment: {name}' => 'Редактирование комментария: {name}', - 'Update Tag: {name}' => 'Редактирование тега: {name}', - 'Parent Comment ID' => 'Родительский комментарий', - 'Comment' => 'Комментарий', - 'Published' => 'Опубликовано', - 'User' => 'Пользователь', - 'Post' => 'Статья', - 'YouTube URL' => 'Ссылка YouTube', - 'Video URL' => 'Ссылка на видео (YouTube, Vimeo)', - 'Add Image' => 'Новое изображение', - 'Video' => 'Видео', - 'If a video link is specified, the image will be used as a preview image' => 'Если указана ссылка на видео, то изображение будет рассматриваться как картинка для предварительного просмотра', - 'Reset Image' => 'Сбросить изображение', - 'Set tags...' => 'Укажите теги...', - 'Publish' => 'Публикация', - 'Preview on site' => 'Просмотр на сайте', - 'Publish Date' => 'Дата публикации', - 'The article will be published after the specified date if its status is not a draft' => 'Статья будет опубликована после наступления указанной даты, если ее статус не черновик.', - 'Blog Post' => 'Статья', - 'Blog Home' => 'Блог', - 'Select post...' => 'Укажите статью...', - 'Type' => 'Тип', - 'Revision At' => 'Версия', - 'History' => 'История изменений', - 'Clear History' => 'Очистить историю', - 'History is empty' => 'Нет изменений', - 'Current Edition' => 'Текущая редакция', - 'Restore' => 'Восстановить', - 'Are you sure you want to restore this history item?' => 'Вы уверены, что хотите восстановить эту запись?', - 'Are you sure you want to remove this history?' => 'Вы уверены, что хотите удалить всю историю?', - 'View' => 'Просмотр', - 'SEO link will be generated automatically if not specified' => 'ЧПУ ссылка будет сгенерирована автоматически, если не указано', -]; \ No newline at end of file diff --git a/common/modules/blog/messages/ru/blog_public.php b/common/modules/blog/messages/ru/blog_public.php deleted file mode 100644 index 516f94f..0000000 --- a/common/modules/blog/messages/ru/blog_public.php +++ /dev/null @@ -1,8 +0,0 @@ - 'Блог', - 'Read More' => 'Подробнее', - 'Leave a Comment' => 'Комментировать', - 'Categories' => 'Категории', -]; \ No newline at end of file diff --git a/common/modules/blog/migrations/m180605_184534_create_blog_categories_table.php b/common/modules/blog/migrations/m180605_184534_create_blog_categories_table.php deleted file mode 100644 index e64ec5e..0000000 --- a/common/modules/blog/migrations/m180605_184534_create_blog_categories_table.php +++ /dev/null @@ -1,31 +0,0 @@ -createTable('{{%blog_categories}}', [ - 'id' => $this->primaryKey(), - 'name' => $this->string()->notNull(), - 'slug' => $this->string()->notNull(), - 'title' => $this->string(), - 'description' => $this->text(), - 'sort' => $this->integer()->notNull(), - 'meta_json' => 'LONGTEXT NOT NULL', - ], $tableOptions); - - $this->createIndex('{{%idx-blog_categories-slug}}', '{{%blog_categories}}', 'slug', true); - } - - public function down() - { - $this->dropTable('{{%blog_categories}}'); - } -} diff --git a/common/modules/blog/migrations/m180605_190347_create_blog_posts_table.php b/common/modules/blog/migrations/m180605_190347_create_blog_posts_table.php deleted file mode 100644 index fe6c9bb..0000000 --- a/common/modules/blog/migrations/m180605_190347_create_blog_posts_table.php +++ /dev/null @@ -1,42 +0,0 @@ -createTable('{{%blog_posts}}', [ - 'id' => $this->primaryKey(), - 'category_id' => $this->integer()->notNull(), - 'published_at' => $this->integer()->unsigned()->notNull(), - 'created_at' => $this->integer()->unsigned(), - 'updated_at' => $this->integer()->unsigned(), - 'title' => $this->string()->notNull(), - 'description' => $this->text(), - 'content' => 'MEDIUMTEXT', - 'image' => $this->string(), - 'video' => $this->string(), - 'status' => $this->integer()->notNull(), - 'meta_json' => 'TEXT NOT NULL', - 'comments_count' => $this->integer()->notNull()->defaultValue(0), - 'views' => $this->integer()->notNull()->defaultValue(0), - 'slug' => $this->string()->notNull(), - ], $tableOptions); - - $this->createIndex('{{%idx-blog_posts-category_id}}', '{{%blog_posts}}', 'category_id'); - $this->createIndex('{{%idx-blog_posts-slug}}', '{{%blog_posts}}', 'slug', true); - $this->addForeignKey('{{%fk-blog_posts-category_id}}', '{{%blog_posts}}', 'category_id', '{{%blog_categories}}', 'id'); - } - - public function down() - { - $this->dropForeignKey('{{%fk-blog_posts-category_id}}', '{{%blog_posts}}'); - $this->dropTable('{{%blog_posts}}'); - } -} diff --git a/common/modules/blog/migrations/m180605_193423_create_blog_tags_table.php b/common/modules/blog/migrations/m180605_193423_create_blog_tags_table.php deleted file mode 100644 index 5124ef1..0000000 --- a/common/modules/blog/migrations/m180605_193423_create_blog_tags_table.php +++ /dev/null @@ -1,28 +0,0 @@ -createTable('{{%blog_tags}}', [ - 'id' => $this->primaryKey(), - 'name' => $this->string()->notNull(), - 'slug' => $this->string()->notNull(), - ], $tableOptions); - - $this->createIndex('{{%idx-blog_tags-slug}}', '{{%blog_tags}}', 'slug', true); - } - - public function down() - { - $this->dropIndex('{{%idx-blog_tags-slug}}', '{{%blog_tags}}'); - $this->dropTable('{{%blog_tags}}'); - } -} diff --git a/common/modules/blog/migrations/m180605_193748_create_blog_tag_assignments_table.php b/common/modules/blog/migrations/m180605_193748_create_blog_tag_assignments_table.php deleted file mode 100644 index 5dbeec4..0000000 --- a/common/modules/blog/migrations/m180605_193748_create_blog_tag_assignments_table.php +++ /dev/null @@ -1,36 +0,0 @@ -createTable('{{%blog_tag_assignments}}', [ - 'post_id' => $this->integer()->notNull(), - 'tag_id' => $this->integer()->notNull(), - ], $tableOptions); - - $this->addPrimaryKey('{{%pk-blog_tag_assignments}}', '{{%blog_tag_assignments}}', ['post_id', 'tag_id']); - - $this->createIndex('{{%idx-blog_tag_assignments-post_id}}', '{{%blog_tag_assignments}}', 'post_id'); - $this->createIndex('{{%idx-blog_tag_assignments-tag_id}}', '{{%blog_tag_assignments}}', 'tag_id'); - - $this->addForeignKey('{{%fk-blog_tag_assignments-post_id}}', '{{%blog_tag_assignments}}', 'post_id', '{{%blog_posts}}', 'id', 'CASCADE', 'RESTRICT'); - $this->addForeignKey('{{%fk-blog_tag_assignments-tag_id}}', '{{%blog_tag_assignments}}', 'tag_id', '{{%blog_tags}}', 'id', 'CASCADE', 'RESTRICT'); - } - - public function down() - { - $this->dropIndex('{{%idx-blog_tag_assignments-tag_id}}', '{{%blog_tag_assignments}}'); - $this->dropIndex('{{%idx-blog_tag_assignments-post_id}}', '{{%blog_tag_assignments}}'); - $this->dropForeignKey('{{%fk-blog_tag_assignments-tag_id}}', '{{%blog_tag_assignments}}'); - $this->dropForeignKey('{{%fk-blog_tag_assignments-post_id}}', '{{%blog_tag_assignments}}'); - $this->dropTable('{{%blog_tag_assignments}}'); - } -} diff --git a/common/modules/blog/migrations/m180605_194207_create_blog_comments_table.php b/common/modules/blog/migrations/m180605_194207_create_blog_comments_table.php deleted file mode 100644 index 4ed2dda..0000000 --- a/common/modules/blog/migrations/m180605_194207_create_blog_comments_table.php +++ /dev/null @@ -1,43 +0,0 @@ -createTable('{{%blog_comments}}', [ - 'id' => $this->primaryKey(), - 'post_id' => $this->integer()->notNull(), - 'user_id' => $this->integer()->notNull(), - 'parent_id' => $this->integer(), - 'created_at' => $this->integer()->unsigned()->notNull(), - 'text' => $this->text()->notNull(), - 'active' => $this->boolean()->notNull(), - ], $tableOptions); - - $this->createIndex('{{%idx-blog_comments-post_id}}', '{{%blog_comments}}', 'post_id'); - $this->createIndex('{{%idx-blog_comments-user_id}}', '{{%blog_comments}}', 'user_id'); - $this->createIndex('{{%idx-blog_comments-parent_id}}', '{{%blog_comments}}', 'parent_id'); - - $this->addForeignKey('{{%fk-blog_comments-post_id}}', '{{%blog_comments}}', 'post_id', '{{%blog_posts}}', 'id', 'CASCADE'); - $this->addForeignKey('{{%fk-blog_comments-user_id}}', '{{%blog_comments}}', 'user_id', '{{%users}}', 'id', 'CASCADE'); - $this->addForeignKey('{{%fk-blog_comments-parent_id}}', '{{%blog_comments}}', 'parent_id', '{{%blog_comments}}', 'id', 'CASCADE'); - } - - public function down() - { - $this->dropForeignKey('{{%fk-blog_comments-parent_id}}', '{{%blog_comments}}'); - $this->dropForeignKey('{{%fk-blog_comments-user_id}}', '{{%blog_comments}}'); - $this->dropForeignKey('{{%fk-blog_comments-post_id}}', '{{%blog_comments}}'); - $this->dropIndex('{{%idx-blog_comments-parent_id}}', '{{%blog_comments}}'); - $this->dropIndex('{{%idx-blog_comments-user_id}}', '{{%blog_comments}}'); - $this->dropIndex('{{%idx-blog_comments-post_id}}', '{{%blog_comments}}'); - $this->dropTable('{{%blog_comments}}'); - } -} diff --git a/common/modules/blog/migrations/m180725_091725_add_blog_posts_type_field.php b/common/modules/blog/migrations/m180725_091725_add_blog_posts_type_field.php deleted file mode 100644 index 077ce65..0000000 --- a/common/modules/blog/migrations/m180725_091725_add_blog_posts_type_field.php +++ /dev/null @@ -1,33 +0,0 @@ -addColumn('{{%blog_posts}}', 'type', $this->integer(2)->defaultValue(0)); // 0 - public, 1 - revision, 2 - preview - $this->addColumn('{{%blog_posts}}', 'revision_at', $this->integer()->unsigned()); - $this->addColumn('{{%blog_posts}}', 'revision_id', $this->integer()); - - $this->createIndex('idx_blog_posts_revision_id', '{{%blog_posts}}', 'revision_id'); - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - $this->dropIndex('idx_blog_posts_revision_id', '{{%blog_posts}}'); - - $this->dropColumn('{{%blog_posts}}', 'type'); - $this->dropColumn('{{%blog_posts}}', 'revision_at'); - $this->dropColumn('{{%blog_posts}}', 'revision_id'); - } -} diff --git a/common/modules/blog/migrations/m180725_113503_remove_blog_posts_slug_unique_index.php b/common/modules/blog/migrations/m180725_113503_remove_blog_posts_slug_unique_index.php deleted file mode 100644 index 8658c7c..0000000 --- a/common/modules/blog/migrations/m180725_113503_remove_blog_posts_slug_unique_index.php +++ /dev/null @@ -1,27 +0,0 @@ -dropIndex('{{%idx-blog_posts-slug}}', '{{%blog_posts}}'); - $this->createIndex('{{%idx-blog_posts-slug}}', '{{%blog_posts}}', 'slug'); - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - $this->dropIndex('{{%idx-blog_posts-slug}}', '{{%blog_posts}}'); - $this->createIndex('{{%idx-blog_posts-slug}}', '{{%blog_posts}}', 'slug'); - } -} diff --git a/common/modules/blog/migrations/m180827_195932_set_blog_unicode_collate.php b/common/modules/blog/migrations/m180827_195932_set_blog_unicode_collate.php deleted file mode 100644 index ddd92f0..0000000 --- a/common/modules/blog/migrations/m180827_195932_set_blog_unicode_collate.php +++ /dev/null @@ -1,33 +0,0 @@ -getDb(); - $db->createCommand('SET FOREIGN_KEY_CHECKS=0;')->execute(); - - foreach ($tables as $table) { - $db->createCommand("ALTER TABLE `$table` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci")->execute(); - } - - $db->createCommand('SET FOREIGN_KEY_CHECKS=1;')->execute(); - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - true; - } -} diff --git a/common/modules/blog/migrations/m180828_190314_create_blog_post_lng_table.php b/common/modules/blog/migrations/m180828_190314_create_blog_post_lng_table.php deleted file mode 100644 index a058c85..0000000 --- a/common/modules/blog/migrations/m180828_190314_create_blog_post_lng_table.php +++ /dev/null @@ -1,54 +0,0 @@ -createTable('{{%blog_posts_lng}}', [ - 'id' => $this->primaryKey(), - 'blog_post_id' => $this->integer()->notNull(), - 'language' => $this->string(6)->notNull(), - 'title' => $this->string()->notNull(), - 'description' => $this->text(), - 'content' => 'MEDIUMTEXT', - 'meta_title' => $this->string(255), - 'meta_description' => $this->text(), - 'meta_keywords' => $this->string(255), - ], $tableOptions); - - $this->createIndex('idx_blog_posts_lng_language', '{{%blog_posts_lng}}', 'language'); - $this->createIndex('idx_blog_posts_lng_blog_post_id', '{{%blog_posts_lng}}', 'blog_post_id'); - $this->addForeignKey('frg_blog_posts_lng_blog_posts_blog_post_id_id', '{{%blog_posts_lng}}', 'blog_post_id', '{{%blog_posts}}', 'id', 'CASCADE', 'CASCADE'); - - $this->dropColumn('{{%blog_posts}}', 'title'); - $this->dropColumn('{{%blog_posts}}', 'description'); - $this->dropColumn('{{%blog_posts}}', 'content'); - $this->dropColumn('{{%blog_posts}}', 'meta_json'); - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - $this->addColumn('{{%blog_posts}}', 'title', $this->string(255)->notNull()); - $this->addColumn('{{%blog_posts}}', 'description', $this->text()); - $this->addColumn('{{%blog_posts}}', 'description', 'MEDIUMTEXT'); - $this->addColumn('{{%blog_posts}}', 'meta_json', $this->text()); - - $this->dropForeignKey('frg_blog_posts_lng_blog_posts_blog_post_id_id', '{{%blog_posts_lng}}'); - $this->dropIndex('idx_blog_posts_lng_blog_post_id', '{{%blog_posts_lng}}'); - $this->dropIndex('idx_blog_posts_lng_language', '{{%blog_posts_lng}}'); - $this->dropTable('{{%blog_posts_lng}}'); - } -} diff --git a/common/modules/blog/migrations/m180830_163050_create_blog_categories_lng_table.php b/common/modules/blog/migrations/m180830_163050_create_blog_categories_lng_table.php deleted file mode 100644 index f1b48e8..0000000 --- a/common/modules/blog/migrations/m180830_163050_create_blog_categories_lng_table.php +++ /dev/null @@ -1,55 +0,0 @@ -createTable('{{%blog_categories_lng}}', [ - 'id' => $this->primaryKey(), - 'blog_category_id' => $this->integer()->notNull(), - 'language' => $this->string(6)->notNull(), - 'name' => $this->string()->notNull(), - 'title' => $this->string(), - 'description' => $this->text(), - 'meta_title' => $this->string(255), - 'meta_description' => $this->text(), - 'meta_keywords' => $this->string(255), - ], $tableOptions); - - $this->createIndex('idx_blog_categories_lng_language', '{{%blog_categories_lng}}', 'language'); - $this->createIndex('idx_blog_categories_lng_blog_category_id', '{{%blog_categories_lng}}', 'blog_category_id'); - $this->addForeignKey('frg_blog_categories_lng_blog_categories_blog_category_id_id', '{{%blog_categories_lng}}', 'blog_category_id', '{{%blog_categories}}', 'id', 'CASCADE', 'CASCADE'); - - $this->dropColumn('{{%blog_categories}}', 'title'); - $this->dropColumn('{{%blog_categories}}', 'description'); - $this->dropColumn('{{%blog_categories}}', 'name'); - $this->dropColumn('{{%blog_categories}}', 'meta_json'); - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - $this->dropForeignKey('frg_blog_categories_lng_blog_categories_blog_category_id_id', '{{%blog_categories_lng}}'); - $this->dropIndex('idx_blog_categories_lng_blog_category_id', '{{%blog_categories_lng}}'); - $this->dropIndex('idx_blog_categories_lng_language', '{{%blog_categories_lng}}'); - - $this->dropTable('{{%blog_categories_lng}}'); - - $this->addColumn('{{%blog_categories}}', 'title', $this->string(255)); - $this->addColumn('{{%blog_categories}}', 'name', $this->string(255)->notNull()); - $this->addColumn('{{%blog_categories}}', 'description', $this->text()); - $this->addColumn('{{%blog_categories}}', 'meta_json', 'LONGTEXT NOT NULL'); - } -} diff --git a/common/modules/blog/repositories/BlogCategoryRepository.php b/common/modules/blog/repositories/BlogCategoryRepository.php deleted file mode 100644 index ff9603e..0000000 --- a/common/modules/blog/repositories/BlogCategoryRepository.php +++ /dev/null @@ -1,31 +0,0 @@ -save()) { - throw new \RuntimeException('Saving error.'); - } - } - - public function remove(BlogCategory $category): void - { - if (!$category->delete()) { - throw new \RuntimeException('Removing error.'); - } - } -} \ No newline at end of file diff --git a/common/modules/blog/repositories/BlogRepository.php b/common/modules/blog/repositories/BlogRepository.php deleted file mode 100644 index ab9800a..0000000 --- a/common/modules/blog/repositories/BlogRepository.php +++ /dev/null @@ -1,36 +0,0 @@ -andWhere(['category_id' => $id])->exists(); - } - - public function save(BlogPost $post): void - { - if (!$post->save()) { - throw new \RuntimeException('Saving error.'); - } - } - - public function remove(BlogPost $post): void - { - if (!$post->delete()) { - throw new \RuntimeException('Removing error.'); - } - } -} \ No newline at end of file diff --git a/common/modules/blog/repositories/BlogTagRepository.php b/common/modules/blog/repositories/BlogTagRepository.php deleted file mode 100644 index 482f96b..0000000 --- a/common/modules/blog/repositories/BlogTagRepository.php +++ /dev/null @@ -1,36 +0,0 @@ - $name]); - } - - public function save(BlogTag $tag): void - { - if (!$tag->save()) { - throw new \RuntimeException('Saving error.'); - } - } - - public function remove(BlogTag $tag): void - { - if (!$tag->delete()) { - throw new \RuntimeException('Removing error.'); - } - } -} \ No newline at end of file diff --git a/common/modules/blog/repositories/read/BlogCategoryReadRepository.php b/common/modules/blog/repositories/read/BlogCategoryReadRepository.php deleted file mode 100644 index 6974a3d..0000000 --- a/common/modules/blog/repositories/read/BlogCategoryReadRepository.php +++ /dev/null @@ -1,23 +0,0 @@ -orderBy('sort')->all(); - } - - public function find($id): ?BlogCategory - { - return BlogCategory::findOne($id); - } - - public function findBySlug($slug): ?BlogCategory - { - return BlogCategory::find()->andWhere(['slug' => $slug])->one(); - } -} \ No newline at end of file diff --git a/common/modules/blog/repositories/read/BlogPostReadRepository.php b/common/modules/blog/repositories/read/BlogPostReadRepository.php deleted file mode 100644 index f512cf7..0000000 --- a/common/modules/blog/repositories/read/BlogPostReadRepository.php +++ /dev/null @@ -1,99 +0,0 @@ -active()->pubDate()->typePublic()->count(); - } - - public function getAllByRange($offset, $limit): array - { - return BlogPost::find()->active()->pubDate()->typePublic()->orderBy(['id' => SORT_ASC])->limit($limit)->offset($offset)->all(); - } - - public function getAll(): DataProviderInterface - { - $query = BlogPost::find()->active()->pubDate()->typePublic()->with('category'); - return $this->getProvider($query); - } - - public function getAllByCategory(BlogCategory $category): DataProviderInterface - { - $query = BlogPost::find()->active()->pubDate()->typePublic()->andWhere(['category_id' => $category->id])->with('category'); - return $this->getProvider($query); - } - - public function findNext(int $id): ?BlogPost - { - return BlogPost::find()->active()->pubDate()->typePublic()->andWhere(['>', 'id', $id])->one(); - } - - public function findPrev(int $id): ?BlogPost - { - return BlogPost::find()->active()->pubDate()->typePublic()->andWhere(['<', 'id', $id])->orderBy(['id' => SORT_DESC])->one(); - } - - - public function getAllByTag(BlogTag $tag): DataProviderInterface - { - $query = BlogPost::find()->alias('p')->active('p')->typePublic('p')->with('category'); - $query->joinWith(['blogTagAssignments ta'], false); - $query->andWhere(['ta.tag_id' => $tag->id]); - $query->groupBy('p.id'); - return $this->getProvider($query); - } - - public function getByTagsId(BlogPost $post, array $tag_ids, int $limit = 15): DataProviderInterface - { - $query = BlogPost::find()->alias('p')->active('p')->typePublic('p')->with('category'); - $query->joinWith(['blogTagAssignments ta'], false); - $query->andWhere(['ta.tag_id' => $tag_ids]); - $query->andWhere(['!=', 'p.id', $post->id]); - $query->groupBy('p.id'); - $query->limit($limit); - return $this->getProvider($query); - } - - public function getLast($limit): array - { - return BlogPost::find()->with('category')->orderBy(['id' => SORT_DESC])->limit($limit)->all(); - } - - public function getPopular($limit): array - { - return BlogPost::find()->with('category')->orderBy(['comments_count' => SORT_DESC])->limit($limit)->all(); - } - - public function find($id): ?BlogPost - { - return BlogPost::find()->active()->andWhere(['id' => $id])->one(); - } - - private function getProvider(ActiveQuery $query): ActiveDataProvider - { - return new ActiveDataProvider([ - 'query' => $query, - 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]], - ]); - } - - public function findBySlug($slug): ?BlogPost - { - return BlogPost::find()->andWhere(['slug' => $slug])->one(); - } - - public function findPreview($id, $language): ?BlogPost - { - return BlogPost::find()->localized($language)->andWhere(['id' => $id])->one(); - } -} \ No newline at end of file diff --git a/common/modules/blog/repositories/read/BlogTagReadRepository.php b/common/modules/blog/repositories/read/BlogTagReadRepository.php deleted file mode 100644 index 67062f0..0000000 --- a/common/modules/blog/repositories/read/BlogTagReadRepository.php +++ /dev/null @@ -1,18 +0,0 @@ -andWhere(['slug' => $slug])->one(); - } -} \ No newline at end of file diff --git a/common/modules/blog/services/BlogCategoryManageService.php b/common/modules/blog/services/BlogCategoryManageService.php deleted file mode 100644 index 8cf9871..0000000 --- a/common/modules/blog/services/BlogCategoryManageService.php +++ /dev/null @@ -1,52 +0,0 @@ -categories = $categories; - $this->posts = $posts; - } - - public function create(BlogCategoryForm $form): BlogCategory - { - $category = BlogCategory::create( - $form, - $form->slug, - $form->sort - ); - $this->categories->save($category); - return $category; - } - - public function edit($id, BlogCategoryForm $form): void - { - $category = $this->categories->get($id); - $category->edit( - $form, - $form->slug, - $form->sort - ); - $this->categories->save($category); - } - - public function remove($id): void - { - $category = $this->categories->get($id); - if ($this->posts->existsByCategory($category->id)) { - throw new \DomainException('Unable to remove category with posts.'); - } - $this->categories->remove($category); - } -} \ No newline at end of file diff --git a/common/modules/blog/services/BlogCommentManageService.php b/common/modules/blog/services/BlogCommentManageService.php deleted file mode 100644 index 9059f8d..0000000 --- a/common/modules/blog/services/BlogCommentManageService.php +++ /dev/null @@ -1,37 +0,0 @@ -posts = $posts; - } - - public function edit($postId, $id, BlogCommentEditForm $form): void - { - $post = $this->posts->get($postId); - $post->editComment($id, $form->parentId, $form->text); - $this->posts->save($post); - } - - public function activate($postId, $id): void - { - $post = $this->posts->get($postId); - $post->activateComment($id); - $this->posts->save($post); - } - - public function remove($postId, $id): void - { - $post = $this->posts->get($postId); - $post->removeComment($id); - $this->posts->save($post); - } -} \ No newline at end of file diff --git a/common/modules/blog/services/BlogCommentService.php b/common/modules/blog/services/BlogCommentService.php deleted file mode 100644 index a2c8990..0000000 --- a/common/modules/blog/services/BlogCommentService.php +++ /dev/null @@ -1,32 +0,0 @@ -posts = $posts; - $this->users = $users; - } - - public function create($postId, $userId, BlogCommentForm $form): BlogComment - { - $post = $this->posts->get($postId); - $user = $this->users->get($userId); - - $comment = $post->addComment($user->id, $form->parentId, $form->text); - - $this->posts->save($post); - - return $comment; - } -} \ No newline at end of file diff --git a/common/modules/blog/services/BlogPostManageService.php b/common/modules/blog/services/BlogPostManageService.php deleted file mode 100644 index e614033..0000000 --- a/common/modules/blog/services/BlogPostManageService.php +++ /dev/null @@ -1,193 +0,0 @@ -posts = $posts; - $this->categories = $categories; - $this->tags = $tags; - $this->transaction = $transaction; - } - - public function create(BlogPostForm $form, $type = BlogPost::TYPE_PUBLIC): BlogPost - { - $category = $this->categories->get($form->category_id); - - $post = BlogPost::create( - $form, - $category->id, - $form->slug, - $form->published_at, - $form->video, - $type - ); - - $this->transaction->wrap(function () use ($post, $form) { - - if (is_array($form->tags->new_tags) && !empty($form->tags->new_tags)) { - foreach ( $form->tags->new_tags as $tag_id => $tag_name ) { - if ( !$tag = $this->tags->findByName( $tag_name ) ) { - $tag = BlogTag::create( $tag_name, Inflector::slug( $tag_name, '_' ) ); - $this->tags->save( $tag ); - } - $post->assignTag( $tag->id ); - } - } - $this->posts->save($post); - - if ($form->image) { - $post->setImage($form->image); - } - else if ($form->video) { - $src = VideoHelper::getThumb($form->video); - //$src = 'https://i.ytimg.com/vi/' . BlogPostHelper::parseYoutubeUrl($post->video) . '/maxresdefault.jpg'; - $filename = (new Security())->generateRandomString(15) . '.jpg'; - copy($src, \Yii::getAlias(BlogPost::FILE_ORIGINAL_PATH . '/' . $post->id . '.jpg')); - $post->image = $filename; - } - - if ($form->status == BlogPost::STATUS_ACTIVE) { - $post->activate(); - } - - $this->posts->save($post); - }); - - return $post; - } - - public function edit($id, BlogPostForm $form): void - { - $post = $this->posts->get($id); - BlogPostHelper::saveRevision(clone $post); - //$this->saveRevision(clone $post); - - //print_r($post->translations); die; - - $category = $this->categories->get($form->category_id); - - $post->edit( - $form, - $category->id, - $form->slug, - $form->published_at, - $form->video, - $post->type - ); - - if ($form->image) { - $post->cleanFiles(); - $post->setImage($form->image); - } - elseif ($form->video && (!$post->image || $form->reset_image)) { - $post->cleanFiles(); - $src = VideoHelper::getThumb($form->video); - $filename = (new Security())->generateRandomString(15) . '.jpg'; - copy($src, \Yii::getAlias(BlogPost::FILE_ORIGINAL_PATH . '/' . $post->id . '.jpg')); - $post->image = $filename; - } - elseif ($post->image && $form->reset_image) { - $post->cleanFiles(); - $post->image = null; - $post->updateAttributes(['image']); - } - - $this->transaction->wrap(function () use ($post, $form) { - $post->revokeTags(); - $this->posts->save($post); - - if (is_array($form->tags->new_tags) && !empty($form->tags->new_tags)) { - foreach ( $form->tags->new_tags as $tag_id => $tag_name ) { - if ( ! $tag = $this->tags->findByName( $tag_name ) ) { - $tag = BlogTag::create( $tag_name, Inflector::slug( $tag_name, '_' ) ); - $this->tags->save( $tag ); - } - $post->assignTag( $tag->id ); - } - } - $this->posts->save( $post ); - }); - } - - public function activate($id): void - { - $post = $this->posts->get($id); - $post->activate(); - $this->posts->save($post); - } - - public function draft($id): void - { - $post = $this->posts->get($id); - $post->draft(); - $this->posts->save($post); - } - - public function remove($id): void - { - $post = $this->posts->get($id); - // Remove revisions - $this->clearHistory($post); - // Remove preview - $this->removePreviews(); - - $this->posts->remove($post); - } - - public function removePreviews(): void - { - $posts = BlogPost::find()->andWhere(['type' => BlogPost::TYPE_PREVIEW])->all(); - foreach ($posts as $post) { - $post->delete(); - } - } - - public function clearHistory(BlogPost $post): void - { - BlogPost::deleteAll(['revision_id' => $post->id]); - } - - public function restoreHistory($from_id, $id): int - { - $post = $this->posts->get($id); - $from = $this->posts->get($from_id); - - // update revision id - BlogPost::updateAll(['revision_id' => $from->id], ['revision_id' => $post->id]); - - $this->posts->remove($post); - $from->revision_id = null; - $from->type = BlogPost::TYPE_PUBLIC; - $this->posts->save($from); - - // delete never revisions - BlogPost::deleteAll(['AND', ['revision_id' => $from->id], ['>', 'revision_at', $from->revision_at]]); - - return $from->id; - } -} \ No newline at end of file diff --git a/common/modules/blog/services/BlogTagManageService.php b/common/modules/blog/services/BlogTagManageService.php deleted file mode 100644 index 7fe0c2c..0000000 --- a/common/modules/blog/services/BlogTagManageService.php +++ /dev/null @@ -1,43 +0,0 @@ -tags = $tags; - } - - public function create(BlogTagSingleForm $form): BlogTag - { - $tag = BlogTag::create( - $form->name, - $form->slug - ); - $this->tags->save($tag); - return $tag; - } - - public function edit($id, BlogTagSingleForm $form): void - { - $tag = $this->tags->get($id); - $tag->edit( - $form->name, - $form->slug - ); - $this->tags->save($tag); - } - - public function remove($id): void - { - $tag = $this->tags->get($id); - $this->tags->remove($tag); - } -} diff --git a/common/modules/blog/urls/BlogCategoryUrlRule.php b/common/modules/blog/urls/BlogCategoryUrlRule.php deleted file mode 100644 index 41f3ca0..0000000 --- a/common/modules/blog/urls/BlogCategoryUrlRule.php +++ /dev/null @@ -1,92 +0,0 @@ -repository = $repository; - $this->cache = $cache; - } - - public function parseRequest($manager, $request) - { - $uri = ltrim(LanguageHelper::processLangInUrl($request->pathInfo), '/'); - if (preg_match('#^' . $this->prefix . '/(.*[a-z])$#is', $uri, $matches)) { - $path = $matches['1']; - - $result = $this->cache->getOrSet( [ 'blog_category_route', 'path' => $path ], function () use ( $path ) { - if ( ! $post = $this->repository->findBySlug( $this->getPathSlug( $path ) ) ) { - return [ 'id' => null, 'path' => null ]; - } - return [ 'id' => $post->id, 'path' => $post->slug ]; - }, null, new TagDependency(['tags' => ['blog']]) ); - - if ( empty( $result['id'] ) ) { - return false; - } - - if ( $path != $result['path'] ) { - throw new UrlNormalizerRedirectException( [ - 'blog/post/category', - 'id' => $result['id'], - ], 301 ); - } - - return [ 'blog/post/category', [ 'id' => $result['id'] ] ]; - } - return false; - } - - public function createUrl($manager, $route, $params) - { - if ($route == 'blog/post/category') { - if (empty($params['id'])) { - throw new \InvalidArgumentException('Empty id.'); - } - $id = $params['id']; - - $url = $this->cache->getOrSet(['blog_category_route', 'id' => $id], function () use ($id) { - if (!$post = $this->repository->find($id)) { - return null; - } - return $post->slug; - //return $this->getPagePath($post); - }, null, new TagDependency(['tags' => ['blog']])); - - if (!$url) { - throw new \InvalidArgumentException('Undefined id.'); - } - - $url = $this->prefix . '/' . $url; - unset($params['id']); - if (!empty($params) && ($query = http_build_query($params)) !== '') { - $url .= '?' . $query; - } - //return $url; - return LanguageHelper::addLangToUrl($url, isset($params['language']) ? $params['language'] : null); - } - return false; - } - - private function getPathSlug($path): string - { - $chunks = explode('/', $path); - return end($chunks); - } -} \ No newline at end of file diff --git a/common/modules/blog/urls/BlogMainUrlRule.php b/common/modules/blog/urls/BlogMainUrlRule.php deleted file mode 100644 index a60db6b..0000000 --- a/common/modules/blog/urls/BlogMainUrlRule.php +++ /dev/null @@ -1,90 +0,0 @@ -repository = $repository; - $this->cache = $cache; - } - - public function parseRequest($manager, $request) - { - $uri = ltrim(LanguageHelper::processLangInUrl($request->pathInfo), '/'); - if (preg_match('#^' . $this->prefix . '/(.*[a-z])$#is', $uri, $matches)) { - $path = $matches['1']; - - $result = $this->cache->getOrSet( [ 'blog_main_route', 'path' => $path ], function () use ( $path ) { - if ( ! $post = $this->repository->findBySlug($this->getPathSlug( $path ) ) ) { - return [ 'id' => null, 'path' => null ]; - } - return [ 'id' => $post->id, 'path' => $post->slug ]; - }, null, new TagDependency(['tags' => ['blog']]) ); - - if ( empty( $result['id'] ) ) { - return false; - } - - if ( $path != $result['path'] ) { - throw new UrlNormalizerRedirectException( [ 'blog/post/post', 'id' => $result['id'] ], 301 ); - } - - return ['blog/post/post', ['id' => $result['id']]]; - } - return false; - } - - public function createUrl($manager, $route, $params) - { - if ($route == 'blog/post/post') { - if (empty($params['id'])) { - throw new InvalidArgumentException('Empty id.'); - } - $id = $params['id']; - - $url = $this->cache->getOrSet(['post_main_route', 'id' => $id], function () use ($id) { - if (!$post = $this->repository->find($id)) { - return null; - } - return $post->slug; - }, null, new TagDependency(['tags' => ['blog']])); - - if (!$url) { - return '#'; - //throw new InvalidArgumentException('Undefined id.'); - } - - $url = $this->prefix . '/' . $url; - unset($params['id']); - if (!empty($params) && ($query = http_build_query($params)) !== '') { - $url .= '?' . $query; - } - //return $url; - return LanguageHelper::addLangToUrl($url, isset($params['language']) ? $params['language'] : null); - } - return false; - } - - private function getPathSlug($path): string - { - $chunks = explode('/', $path); - return end($chunks); - } -} \ No newline at end of file diff --git a/common/modules/blog/urls/BlogTagUrlRule.php b/common/modules/blog/urls/BlogTagUrlRule.php deleted file mode 100644 index 672cc15..0000000 --- a/common/modules/blog/urls/BlogTagUrlRule.php +++ /dev/null @@ -1,91 +0,0 @@ -repository = $repository; - $this->cache = $cache; - } - - public function parseRequest($manager, $request) - { - if (preg_match('#^' . $this->prefix . '/(.*[a-z])$#is', $request->pathInfo, $matches)) { - $path = $matches['1']; - - $result = $this->cache->getOrSet( [ 'blog_tag_route', 'path' => $path ], function () use ( $path ) { - if ( ! $post = $this->repository->findBySlug( $this->getPathSlug( $path ) ) ) { - return [ 'id' => null, 'path' => null ]; - } - return [ 'id' => $post->id, 'path' => $post->slug ]; - }, null, new TagDependency(['tags' => ['blog']]) ); - - if ( empty( $result['id'] ) ) { - return false; - } - - if ( $path != $result['path'] ) { - throw new UrlNormalizerRedirectException( [ - 'blog/post/tag', - 'id' => $result['id'], - ], 301 ); - } - - return [ 'blog/post/tag', [ 'id' => $result['id'] ] ]; - } - return false; - } - - public function createUrl($manager, $route, $params) - { - if ($route == 'blog/post/tag') { - if (empty($params['id'])) { - throw new \InvalidArgumentException('Empty id.'); - } - $id = $params['id']; - - $url = $this->cache->getOrSet(['blog_tag_route', 'id' => $id], function () use ($id) { - if (!$post = $this->repository->find($id)) { - return null; - } - return $post->slug; - //return $this->getPagePath($post); - }, null, new TagDependency(['tags' => ['blog']])); - - if (!$url) { - throw new \InvalidArgumentException('Undefined id.'); - } - - $url = $this->prefix . '/' . $url; - unset($params['id']); - if (!empty($params) && ($query = http_build_query($params)) !== '') { - $url .= '?' . $query; - } - - return $url; - } - return false; - } - - private function getPathSlug($path): string - { - $chunks = explode('/', $path); - return end($chunks); - } -} \ No newline at end of file diff --git a/common/modules/blog/views/manage/category/_form.php b/common/modules/blog/views/manage/category/_form.php deleted file mode 100644 index ea92762..0000000 --- a/common/modules/blog/views/manage/category/_form.php +++ /dev/null @@ -1,73 +0,0 @@ -\'); - label.addClass("help").popover({ - html: true, - trigger: "hover", - placement: "bottom", - content: $hint.html() - }); - $(this).hide(); -}); -'; -$this->registerJs($js2); -?> - -
- - - -
-
-
- -
-
- field($model, 'sort')->textInput(['maxlength' => true]) ?> -
-
- field($model, 'slug')->textInput(['maxlength' => true]) ?> -
-
- - params['translatedLanguages'] as $language => $language_name) { - $items[] = [ - 'label' => $language_name, - 'content' => $this->render('_form_tab', [ - 'form' => $form, - 'model' => $model, - 'language' => $language, - ]), - ]; - } - ?> - - - -
-
- -
- 'btn btn-success']) ?> -
- - - -
diff --git a/common/modules/blog/views/manage/category/_form_tab.php b/common/modules/blog/views/manage/category/_form_tab.php deleted file mode 100644 index 2a3dffd..0000000 --- a/common/modules/blog/views/manage/category/_form_tab.php +++ /dev/null @@ -1,35 +0,0 @@ -params['defaultLanguage'] ? '' : '_' . $language; -?> - -
-
- field($model, 'name' . $postfix)->textInput(['maxlength' => true]) ?> - field($model, 'title' . $postfix)->textInput(['maxlength' => true]) ?> - field($model, 'description' . $postfix)->widget(CKEditor::class) ?> -
-
- - -
-
-
- field($model, 'meta_title' . $postfix)->textInput() ?> - field($model, 'meta_description' . $postfix)->textarea(['rows' => 2]) ?> - field($model, 'meta_keywords' . $postfix)->textInput() ?> -
-
diff --git a/common/modules/blog/views/manage/category/_view_tab.php b/common/modules/blog/views/manage/category/_view_tab.php deleted file mode 100644 index eeeed04..0000000 --- a/common/modules/blog/views/manage/category/_view_tab.php +++ /dev/null @@ -1,77 +0,0 @@ - - - $category, - 'attributes' => [ - [ - 'label' => Yii::t('blog', 'Name'), - 'value' => function(BlogCategory $entity) use ($language) { - return $entity->findTranslation($language)->name; - } - ], - [ - 'label' => Yii::t('blog', 'Title'), - 'value' => function(BlogCategory $entity) use ($language) { - return $entity->findTranslation($language)->title; - } - ], - ], -]) ?> - -
-
-
- - $category, - 'attributes' => [ - [ - 'label' => Yii::t('blog', 'META Title'), - 'value' => function(BlogCategory $entity) use ($language) { - return $entity->findTranslation($language)->meta_title; - } - ], - [ - 'label' => Yii::t('blog', 'META Description'), - 'value' => function(BlogCategory $entity) use ($language) { - return $entity->findTranslation($language)->meta_description; - } - ], - [ - 'label' => Yii::t('blog', 'META Keywords'), - 'value' => function(BlogCategory $entity) use ($language) { - return $entity->findTranslation($language)->meta_keywords; - } - ], - ], -]) ?> -
-
- -
-
-
- formatter->asHtml($category->findTranslation($language)->description, [ - 'Attr.AllowedRel' => array('nofollow'), - 'HTML.SafeObject' => true, - 'Output.FlashCompat' => true, - 'HTML.SafeIframe' => true, - 'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%', - ]) ?> -
-
\ No newline at end of file diff --git a/common/modules/blog/views/manage/category/create.php b/common/modules/blog/views/manage/category/create.php deleted file mode 100644 index 600af3f..0000000 --- a/common/modules/blog/views/manage/category/create.php +++ /dev/null @@ -1,17 +0,0 @@ -title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $title; -?> -
- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/blog/views/manage/category/index.php b/common/modules/blog/views/manage/category/index.php deleted file mode 100644 index f6e5420..0000000 --- a/common/modules/blog/views/manage/category/index.php +++ /dev/null @@ -1,59 +0,0 @@ -title = $title; -$this->params['breadcrumbs'][] = $title; -?> -
- -

- 'btn btn-success']) ?> -

- -
-
- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - [ - 'attribute' => 'sort', - 'options' => ['style' => 'width: 100px;'], - ], - [ - 'attribute' => 'name', - 'value' => function (BlogCategory $model) { - return Html::a(Html::encode($model->translation->name), ['view', 'id' => $model->id]); - }, - 'format' => 'raw', - ], - [ - 'attribute' => 'slug', - ], - [ - 'attribute' => 'title', - 'value' => function (BlogCategory $model) { - $title = isset($model->findTranslation(Yii::$app->language)->title) ? $model->findTranslation(Yii::$app->language)->title : $model->findTranslation(Yii::$app->params['defaultLanguage'])->title; - return Html::a(Html::encode($title), ['view', 'id' => $model->id]); - }, - 'format' => 'raw', - ], - [ - 'class' => ActionColumn::class, - 'options' => ['style' => 'width: 100px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - ], - ]); ?> -
-
-
diff --git a/common/modules/blog/views/manage/category/update.php b/common/modules/blog/views/manage/category/update.php deleted file mode 100644 index 55b2e49..0000000 --- a/common/modules/blog/views/manage/category/update.php +++ /dev/null @@ -1,19 +0,0 @@ - $category->translation->name]); -$this->title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $category->translation->name, 'url' => ['view', 'id' => $category->id]]; -$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing'); -?> -
- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/blog/views/manage/category/view.php b/common/modules/blog/views/manage/category/view.php deleted file mode 100644 index 9a991aa..0000000 --- a/common/modules/blog/views/manage/category/view.php +++ /dev/null @@ -1,69 +0,0 @@ -translation->name; -$this->title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $title; - -$css = <<registerCss($css); -?> - -
- -

- 'btn btn-default']) ?> - $category->id], ['class' => 'btn btn-primary']) ?> - $category->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> -

- -
-
-
- $category, - 'attributes' => [ - 'id', - 'slug', - 'sort', - ], - ]) ?> -
-
- - params['translatedLanguages'] as $language => $language_name) { - $items[] = [ - 'label' => $language_name, - 'content' => $this->render('_view_tab', [ - 'category' => $category, - 'language' => $language, - ]), - ]; - } - ?> - - - -
diff --git a/common/modules/blog/views/manage/comment/index.php b/common/modules/blog/views/manage/comment/index.php deleted file mode 100644 index a14ebbb..0000000 --- a/common/modules/blog/views/manage/comment/index.php +++ /dev/null @@ -1,54 +0,0 @@ -title = Yii::t('blog', 'Comments'); -$this->params['breadcrumbs'][] = $this->title; -?> -
-
-
- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - [ - 'attribute' => 'id', - 'options' => ['style' => 'width: 40px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - [ - 'attribute' => 'text', - 'value' => function (BlogComment $model) { - return StringHelper::truncate(strip_tags($model->text), 100); - }, - ], - [ - 'attribute' => 'created_at', - 'format' => ['datetime', 'php:d.m.Y H:i'], - 'options' => ['style' => 'width: 60px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - [ - 'attribute' => 'active', - 'filter' => $searchModel->activeList(), - 'format' => 'boolean', - 'contentOptions' => ['style' => 'width: 150px'], - ], - [ - 'class' => ActionColumn::class, - 'options' => ['style' => 'width: 100px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - ], - ]); ?> -
-
-
diff --git a/common/modules/blog/views/manage/comment/update.php b/common/modules/blog/views/manage/comment/update.php deleted file mode 100644 index 966d77e..0000000 --- a/common/modules/blog/views/manage/comment/update.php +++ /dev/null @@ -1,34 +0,0 @@ -title = Yii::t('blog', 'Update Post Comment: {name}', ['name' => $post->title]); -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Comment'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $post->title, 'url' => ['view', 'id' => $post->id]]; -$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing'); -?> -
- - ['enctype'=>'multipart/form-data'] - ]); ?> - -
-
-
- field($model, 'parentId')->textInput() ?> - field($model, 'text')->textarea(['rows' => 20]) ?> -
-
- -
- 'btn btn-success']) ?> -
- - -
diff --git a/common/modules/blog/views/manage/comment/view.php b/common/modules/blog/views/manage/comment/view.php deleted file mode 100644 index 0c78863..0000000 --- a/common/modules/blog/views/manage/comment/view.php +++ /dev/null @@ -1,71 +0,0 @@ -title = $post->title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Comments'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

- 'btn btn-default']) ?> - $post->id, 'id' => $comment->id], ['class' => 'btn btn-primary']) ?> - isActive()): ?> - $post->id, 'id' => $comment->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> - - $post->id, 'id' => $comment->id], [ - 'class' => 'btn btn-success', - 'data' => [ - 'confirm' => Yii::t('buttons', 'Are you sure you want to activate this item?'), - 'method' => 'post', - ], - ]) ?> - -

- -
-
- $comment, - 'attributes' => [ - 'id', - 'created_at:boolean', - 'active:boolean', - [ - 'attribute' => 'user_id', - 'value' => function(BlogComment $comment) { - return User::findOne($comment->user_id)->username; - }, - ], - 'parent_id', - [ - 'attribute' => 'post_id', - 'value' => $post->title, - ], - ], - ]) ?> -
-
- -
-
- formatter->asNtext($comment->text) ?> -
-
- -
diff --git a/common/modules/blog/views/manage/post/_form.php b/common/modules/blog/views/manage/post/_form.php deleted file mode 100644 index ee8f63b..0000000 --- a/common/modules/blog/views/manage/post/_form.php +++ /dev/null @@ -1,222 +0,0 @@ -_post)) { - $tagsJson = Json::encode( Json::encode( ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) ); - - $js = <<"+value+""); - }); - $('#posttagform-new_tags').trigger('change'); -JS; - $this->registerJs( $js, $this::POS_READY ); -} - -$js2 = ' -$(".hint-block").each(function () { - var $hint = $(this); - var label = $hint.parent().find("label"); - label.html(label.html() + \' \'); - label.addClass("help").popover({ - html: true, - trigger: "hover", - placement: "bottom", - content: $hint.html() - }); - $(this).hide(); -}); -'; -$this->registerJs($js2); -?> - -
- - ['enctype'=>'multipart/form-data'] - ]); ?> - - -
-
- - -
-
-
-
- field($model, 'category_id')->dropDownList($model->categoriesList()) ?> -
-
-
-
-
-
- field($model->tags, 'new_tags')->widget(Select2::class, [ - 'options' => [ - 'placeholder' => Yii::t('blog','Set tags...'), - 'multiple' => true, - ], - 'pluginOptions' => [ - 'tags' => true, - 'tokenSeparators' => [',', ' '], - 'maximumInputLength' => 12, - 'ajax' => [ - 'url' => $fetchUrl, - 'dataType' => 'json', - 'data' => new JsExpression('function(params) { return {q:params.term}; }') - ], - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), - 'templateResult' => new JsExpression('function(tag) { return tag.text; }'), - 'templateSelection' => new JsExpression('function (tag) { return tag.text; }'), - ], - ])->label(Yii::t('blog', 'Tags')); ?> -
-
-
-
- -
-
- - field($model, 'slug')->textInput(['maxlength' => true]) ?> - -
-
- - params['translatedLanguages'] as $language => $language_name) { - $items[] = [ - 'label' => $language_name, - 'content' => $this->render('_form_tab', [ - 'form' => $form, - 'model' => $model, - 'language' => $language, - ]), - ]; - } - ?> - - - -
-
- - - -
-
- field($model, 'image')->label(false)->widget(FileInput::class, [ - 'options' => [ - 'accept' => 'image/*', - ], - 'pluginOptions' => [ - 'showUpload' => false, - ], - ]) ?> - - _post) && $model->_post->image): ?> - _post->getThumbFileUrl('image', 'thumb_gallery_view'), [ - 'class' => 'thumbnail', - 'width' => 300, - ]) ?> - - field($model, 'reset_image')->checkbox() ?> - -
-
- field($model, 'video')->textInput()->label(Yii::t('blog', 'Video URL'))->hint(Yii::t('blog', 'If a video link is specified, the image will be used as a preview image')) ?> -
-
- -
-
- -
- 'btn btn-success', - 'value'=>'save', - 'name'=>'submit_save', - 'formaction' => Yii::$app->request->getUrl(), - 'formtarget' => '_self', - ]) ?> -
- - -
-
-
-
-
- -
- - - -
- - - - - -
- field($model, 'status')->radioList(BlogPostHelper::statusList()) ?> -
- field($model, 'published_at')->widget(DateTimePicker::class, [ - 'options' => [], - 'removeButton' => false, - 'pluginOptions' => [ - 'autoclose' => true, - 'format' => 'dd.mm.yyyy hh:ii:ss', - ] - ])->label(Yii::t('blog', 'Publish Date')); ?> -
-
-
-
- - - -
diff --git a/common/modules/blog/views/manage/post/_form_tab.php b/common/modules/blog/views/manage/post/_form_tab.php deleted file mode 100644 index cc8e756..0000000 --- a/common/modules/blog/views/manage/post/_form_tab.php +++ /dev/null @@ -1,35 +0,0 @@ -params['defaultLanguage'] ? '' : '_' . $language; -?> - -
-
- field($model, 'title' . $postfix)->textInput(['maxlength' => true]) ?> - field($model, 'description' . $postfix)->textarea(['rows' => 5]) ?> - field($model, 'content' . $postfix)->widget(CKEditor::class) ?> -
-
- - -
-
-
- field($model, 'meta_title' . $postfix)->textInput() ?> - field($model, 'meta_description' . $postfix)->textarea(['rows' => 2]) ?> - field($model, 'meta_keywords' . $postfix)->textInput() ?> -
-
diff --git a/common/modules/blog/views/manage/post/_view_tab.php b/common/modules/blog/views/manage/post/_view_tab.php deleted file mode 100644 index b564a19..0000000 --- a/common/modules/blog/views/manage/post/_view_tab.php +++ /dev/null @@ -1,78 +0,0 @@ - - - $post, - 'attributes' => [ - [ - 'label' => Yii::t('blog', 'Title'), - 'value' => function(BlogPost $entity) use ($language) { - return $entity->findTranslation($language)->title; - } - ], - ], -]) ?> - -
-
-
- - $post, - 'attributes' => [ - [ - 'label' => Yii::t('blog', 'META Title'), - 'value' => function(BlogPost $entity) use ($language) { - return $entity->findTranslation($language)->meta_title; - } - ], - [ - 'label' => Yii::t('blog', 'META Description'), - 'value' => function(BlogPost $entity) use ($language) { - return $entity->findTranslation($language)->meta_description; - } - ], - [ - 'label' => Yii::t('blog', 'META Keywords'), - 'value' => function(BlogPost $entity) use ($language) { - return $entity->findTranslation($language)->meta_keywords; - } - ], - ], -]) ?> -
-
- -
-
-
- formatter->asNtext($post->findTranslation($language)->description) ?> -
-
- -
-
-
- formatter->asHtml($post->findTranslation($language)->content, [ - 'Attr.AllowedRel' => array('nofollow'), - 'HTML.SafeObject' => true, - 'Output.FlashCompat' => true, - 'HTML.SafeIframe' => true, - 'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%', - ]) ?> -
-
\ No newline at end of file diff --git a/common/modules/blog/views/manage/post/create.php b/common/modules/blog/views/manage/post/create.php deleted file mode 100644 index 005e579..0000000 --- a/common/modules/blog/views/manage/post/create.php +++ /dev/null @@ -1,17 +0,0 @@ -title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Posts'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $title; -?> -
- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/blog/views/manage/post/index.php b/common/modules/blog/views/manage/post/index.php deleted file mode 100644 index 2d4b151..0000000 --- a/common/modules/blog/views/manage/post/index.php +++ /dev/null @@ -1,80 +0,0 @@ -title = $title; -$this->params['breadcrumbs'][] = $title; -?> -
- -

- 'btn btn-success']) ?> -

- -
-
- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - [ - 'attribute' => 'id', - 'options' => ['style' => 'width: 40px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - [ - 'attribute' => 'title', - 'value' => function (BlogPost $model) { - $title = isset($model->translation->title) ? $model->findTranslation(Yii::$app->language)->title : $model->findTranslation(Yii::$app->params['defaultLanguage'])->title; - - return Html::a(Html::encode($title), ['view', 'id' => $model->id]); - }, - 'format' => 'raw', - ], - [ - 'attribute' => 'category_id', - 'filter' => $searchModel->categoriesList(), - 'value' => function (BlogPost $model) { - return $model->category->translation->name; - }, - ], - [ - 'attribute' => 'published_at', - 'format' => ['datetime', 'php:d.m.Y H:i'], - 'options' => ['style' => 'width: 60px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - [ - 'attribute' => 'status', - 'filter' => $searchModel->statusList(), - 'value' => function (BlogPost $model) { - return BlogPostHelper::statusLabel($model->status); - }, - 'format' => 'raw', - 'options' => ['style' => 'width: 120px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - [ - 'class' => ActionColumn::class, - /*'urlCreator' => function($action, BlogPost $model, $key, $index, $column) { - $params = is_array($key) ? $key : ['id' => (string) $key]; - $params[0] = $column->controller ? $column->controller . '/' . $action : $action; - return Url::toRoute($params); - },*/ - 'options' => ['style' => 'width: 100px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - ], - ]); ?> -
-
-
diff --git a/common/modules/blog/views/manage/post/update.php b/common/modules/blog/views/manage/post/update.php deleted file mode 100644 index 9f53453..0000000 --- a/common/modules/blog/views/manage/post/update.php +++ /dev/null @@ -1,21 +0,0 @@ - StringHelper::truncateWords($post->translation->title, 6, '...')]); -$this->title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Posts'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => StringHelper::truncateWords($post->translation->title, 4, '...'), 'url' => ['view', 'id' => $post->id]]; -$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing'); -?> -
- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/blog/views/manage/post/view.php b/common/modules/blog/views/manage/post/view.php deleted file mode 100644 index 4cde14b..0000000 --- a/common/modules/blog/views/manage/post/view.php +++ /dev/null @@ -1,183 +0,0 @@ -translation->title; -$this->title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Posts'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $title; - -$css = <<registerCss($css); -?> -
- -

- 'btn btn-default']) ?> - isActive()): ?> - $post->id], ['class' => 'btn btn-primary', 'data-method' => 'post']) ?> - - $post->id], ['class' => 'btn btn-success', 'data-method' => 'post']) ?> - - $post->id], ['class' => 'btn btn-primary']) ?> - $post->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> -

- - -
-
- -
-
-
- $post, - 'attributes' => [ - 'id', - [ - 'attribute' => 'status', - 'value' => BlogPostHelper::statusLabel($post->status), - 'format' => 'raw', - ], - [ - 'attribute' => 'category_id', - 'value' => $post->category->translation->name, //ArrayHelper::getValue($post, 'category.name'), - ], - [ - 'label' => Yii::t('post', 'Tags'), - 'format' => 'raw', - 'value' => ' ' . implode(' ', ArrayHelper::getColumn($post->tags, 'name')), - ], - 'slug' - ], - ]) ?> -
-
- - params['translatedLanguages'] as $language => $language_name) { - $items[] = [ - 'label' => $language_name, - 'content' => $this->render('_view_tab', [ - 'post' => $post, - 'language' => $language, - ]), - ]; - } - ?> - - - - image): ?> -
-
-
- getThumbFileUrl('image', 'thumb_gallery_view'), [ - 'class' => 'thumbnail', - 'width' => 300, - ]) ?> -
-
- - - image && $post->video): ?> -
-
-
- - video), [ - 'width' => 300, - 'class' => 'thumbnail', - ]) ?> -
-
- - - video): ?> -
-
-
- $post->video, - 'style' => '', - ]) ?> -
-
- -
-
-
-
-
- -
    - -
  • - revision_id): ?> - revision_at) ?> - → - get('frontendUrlManager')->createAbsoluteUrl(['/blog/post/preview', 'id' => $item->id])), [ - 'style' => 'font-size:11px;', - 'target' => '_blank', - ]) ?> - | - - $item->id], [ - 'style' => 'font-size:11px; color: red', - 'data' => [ - 'confirm' => Yii::t('blog', 'Are you sure you want to restore this history item?'), - 'method' => 'post', - ], - ]) ?> - - - - -
  • - -
- $post->id], [ - 'class' => 'btn btn-danger btn-sm pull-right', - 'data' => [ - 'confirm' => Yii::t('blog', 'Are you sure you want to remove this history?'), - 'method' => 'post', - ], - ]) ?> - -
- - -
-
-
-
- - - -
\ No newline at end of file diff --git a/common/modules/blog/views/manage/tag/_form.php b/common/modules/blog/views/manage/tag/_form.php deleted file mode 100644 index f7aa329..0000000 --- a/common/modules/blog/views/manage/tag/_form.php +++ /dev/null @@ -1,45 +0,0 @@ -\'); - label.addClass("help").popover({ - html: true, - trigger: "hover", - placement: "bottom", - content: $hint.html() - }); - $(this).hide(); -}); -'; -$this->registerJs($js2); -?> - -
- - - -
-
- field($model, 'name')->textInput(['maxlength' => true]) ?> - field($model, 'slug')->textInput(['maxlength' => true]) ?> - -
-
- -
- 'btn btn-success']) ?> -
- - - -
diff --git a/common/modules/blog/views/manage/tag/create.php b/common/modules/blog/views/manage/tag/create.php deleted file mode 100644 index df64950..0000000 --- a/common/modules/blog/views/manage/tag/create.php +++ /dev/null @@ -1,17 +0,0 @@ -title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Tags'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/blog/views/manage/tag/index.php b/common/modules/blog/views/manage/tag/index.php deleted file mode 100644 index 5eeb278..0000000 --- a/common/modules/blog/views/manage/tag/index.php +++ /dev/null @@ -1,47 +0,0 @@ -title = $title; -$this->params['breadcrumbs'][] = $title; -?> -
- -

- 'btn btn-success']) ?> -

- -
-
- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - [ - 'attribute' => 'name', - 'value' => function (BlogTag $model) { - return Html::a(Html::encode($model->name), ['view', 'id' => $model->id]); - }, - 'format' => 'raw', - ], - [ - 'attribute' => 'slug', - ], - [ - 'class' => ActionColumn::class, - 'options' => ['style' => 'width: 100px;'], - 'contentOptions' => ['class' => 'text-center'], - ], - ], - ]); ?> -
-
-
diff --git a/common/modules/blog/views/manage/tag/update.php b/common/modules/blog/views/manage/tag/update.php deleted file mode 100644 index 0c11b68..0000000 --- a/common/modules/blog/views/manage/tag/update.php +++ /dev/null @@ -1,19 +0,0 @@ - $tag->name]); -$this->title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Tags'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $tag->name, 'url' => ['view', 'id' => $tag->id]]; -$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing'); -?> -
- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/blog/views/manage/tag/view.php b/common/modules/blog/views/manage/tag/view.php deleted file mode 100644 index a748b1f..0000000 --- a/common/modules/blog/views/manage/tag/view.php +++ /dev/null @@ -1,39 +0,0 @@ -name; -$this->title = $title; -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Tags'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $title; -?> -
- -

- 'btn btn-default']) ?> - $tag->id], ['class' => 'btn btn-primary']) ?> - $tag->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> -

- -
-
- $tag, - 'attributes' => [ - 'name', - 'slug', - ], - ]) ?> -
-
-
diff --git a/common/modules/blog/views/post/_list.php b/common/modules/blog/views/post/_list.php deleted file mode 100644 index 8417d3c..0000000 --- a/common/modules/blog/views/post/_list.php +++ /dev/null @@ -1,42 +0,0 @@ - - -
-
-
-
-
- - $dataProvider, - 'layout' => "
{items}
\n", - 'itemView' => '_post', - 'pager' => [ - //'pagination' => null, - 'maxButtonCount' => 7, - 'pageCssClass' => 'page-item', - 'options' => [ - 'class' => 'pagination', - ], - 'disabledListItemSubTagOptions' => ['tag' => 'div', 'class' => 'disabled'], - 'activePageCssClass' => 'active', - 'linkOptions' => [ - 'class' => 'page-link', - ], - 'prevPageLabel' => '', - 'nextPageLabel' => '', - ], - 'itemOptions' => [ - 'tag' => false - ], - 'options' => [ - 'tag' => false, - 'class' => 'row row-30', - 'id' => false, - ], -]) ?> - diff --git a/common/modules/blog/views/post/_post.php b/common/modules/blog/views/post/_post.php deleted file mode 100644 index 825ecf5..0000000 --- a/common/modules/blog/views/post/_post.php +++ /dev/null @@ -1,51 +0,0 @@ -$model->id]); -$url_full = Yii::$app->params['frontendHostInfo'] . Url::to(['blog/post/post', 'id' =>$model->id]); -?> - - -
-
- - <?= Html::encode($model->title) ?> - -
-

title) ?>

-
- -
category->name ?>
-
- -
-
-
-
-

description), 12, '...') ?>

-
-
-
-
-
-
-
    -
  • -
  • -
  • -
  • -
  • -
-
-
-
-
-
-
-
diff --git a/common/modules/blog/views/post/category.php b/common/modules/blog/views/post/category.php deleted file mode 100644 index 7acc5a8..0000000 --- a/common/modules/blog/views/post/category.php +++ /dev/null @@ -1,40 +0,0 @@ -title = $category->getSeoTitle(); - -$this->registerMetaTag(['name' =>'description', 'content' => $category->meta->description]); -$this->registerMetaTag(['name' =>'keywords', 'content' => $category->meta->keywords]); - -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Blog'), 'url' => ['blog/post/index']]; -$this->params['breadcrumbs'][] = $category->name; - -$this->params['active_category'] = $category; -?> - -

getHeadingTile()) ?>

- -description)): ?> -
-
- formatter->asHtml($category->description, [ - 'Attr.AllowedRel' => array('nofollow'), - 'HTML.SafeObject' => true, - 'Output.FlashCompat' => true, - 'HTML.SafeIframe' => true, - 'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%', - ]) ?> -
-
- - -render('_list', [ - 'dataProvider' => $dataProvider -]) ?> - - diff --git a/common/modules/blog/views/post/index.php b/common/modules/blog/views/post/index.php deleted file mode 100644 index f348c3e..0000000 --- a/common/modules/blog/views/post/index.php +++ /dev/null @@ -1,13 +0,0 @@ -title = Yii::t('blog', 'Blog'); -$this->params['breadcrumbs'][] = $this->title; -?> - -render('_list', [ - 'dataProvider' => $dataProvider -]) ?> \ No newline at end of file diff --git a/common/modules/blog/views/post/post.php b/common/modules/blog/views/post/post.php deleted file mode 100644 index 8b5c305..0000000 --- a/common/modules/blog/views/post/post.php +++ /dev/null @@ -1,113 +0,0 @@ -title = $post->getSeoTitle(); - -$this->registerMetaTag(['name' =>'description', 'content' => $post->meta->description]); -$this->registerMetaTag(['name' =>'keywords', 'content' => $post->meta->keywords]); - -$this->params['breadcrumbs'][] = ['label' => Yii::t('blog', 'Blog'), 'url' => ['blog/post/index']]; -$this->params['breadcrumbs'][] = ['label' => $post->category->name, 'url' => ['blog/post/category', 'id' => $post->category->id]]; -$this->params['breadcrumbs'][] = $post->title; - -$this->params['active_category'] = $post->category; - -$tagLinks = []; -foreach ($post->tags as $tag) { - $tagLinks[] = '
  • ' . Html::a(Html::encode($tag->name), ['tag', 'slug' => $tag->slug]) . '
  • '; -} - -$url = Url::to(['blog/post/post', 'id' =>$post->id]); -$url_full = Yii::$app->params['frontendHostInfo'] . Url::to(['blog/post/post', 'id' =>$post->id]); - -$js = <<registerJs($js, $this::POS_READY); -?> - - -
    - -
    category->name ?> -
    -

    title) ?>

    -
    - -
    - -
    -

    -
      -
    • -
    • -
    • -
    • -
    -
    -
    - - <?= Html::encode($post->title) ?> - - formatter->asHtml($post->content, [ - 'Attr.AllowedRel' => array('nofollow'), - 'HTML.SafeObject' => true, - 'Output.FlashCompat' => true, - 'HTML.SafeIframe' => true, - 'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%', - ]) ?> - -
    -
    - - 10, - 'view' => 'slider-relative', - 'post' => $post, -]) ?> - -
    - - $post, -]) ?> - - diff --git a/common/modules/blog/widgets/CategoriesWidget.php b/common/modules/blog/widgets/CategoriesWidget.php deleted file mode 100644 index e4bafd3..0000000 --- a/common/modules/blog/widgets/CategoriesWidget.php +++ /dev/null @@ -1,29 +0,0 @@ -categories = $categories; - } - - public function run(): string - { - return $this->render('categories/categories', [ - 'categories' => $this->categories->getAll(), - ]); - } -} \ No newline at end of file diff --git a/common/modules/blog/widgets/CommentView.php b/common/modules/blog/widgets/CommentView.php deleted file mode 100644 index a9a9be5..0000000 --- a/common/modules/blog/widgets/CommentView.php +++ /dev/null @@ -1,20 +0,0 @@ -comment = $comment; - $this->children = $children; - } -} \ No newline at end of file diff --git a/common/modules/blog/widgets/CommentsWidget.php b/common/modules/blog/widgets/CommentsWidget.php deleted file mode 100644 index fbf5a91..0000000 --- a/common/modules/blog/widgets/CommentsWidget.php +++ /dev/null @@ -1,57 +0,0 @@ -post) { - throw new InvalidConfigException('Specify the post.'); - } - } - - public function run(): string - { - $form = new BlogCommentForm(); - - $comments = $this->post->getBlogComments() - ->orderBy(['parent_id' => SORT_ASC, 'id' => SORT_ASC]) - ->all(); - - $items = $this->treeRecursive($comments, null); - - return $this->render('comments/comments', [ - 'post' => $this->post, - 'items' => $items, - 'commentForm' => $form, - ]); - } - - /** - * @param BlogComment[] $comments - * @param integer $parentId - * @return CommentView[] - */ - public function treeRecursive(&$comments, $parentId): array - { - $items = []; - foreach ($comments as $comment) { - if ($comment->parent_id == $parentId) { - $items[] = new CommentView($comment, $this->treeRecursive($comments, $comment->id)); - } - } - return $items; - } -} \ No newline at end of file diff --git a/common/modules/blog/widgets/MenuItemCreatorWidget.php b/common/modules/blog/widgets/MenuItemCreatorWidget.php deleted file mode 100644 index f554b51..0000000 --- a/common/modules/blog/widgets/MenuItemCreatorWidget.php +++ /dev/null @@ -1,30 +0,0 @@ -module = 'blog'; - $form->name = \Yii::t('blog', 'Blog'); - $form->title_attr = \Yii::t('blog', 'Blog'); - $form->menu_id = $this->menu_id; - $form->url = '/blog/post/index'; - - return $this->render('menu-item/creator', [ - 'model' => $form, - ]); - } -} \ No newline at end of file diff --git a/common/modules/blog/widgets/PostByTagsWidget.php b/common/modules/blog/widgets/PostByTagsWidget.php deleted file mode 100644 index 50f1003..0000000 --- a/common/modules/blog/widgets/PostByTagsWidget.php +++ /dev/null @@ -1,42 +0,0 @@ -count = $this->count ? $this->count : 5; - $this->posts = $posts; - } - - public function run(): string - { - $tag_ids = ArrayHelper::getColumn(BlogTagAssignment::find()->andWhere(['post_id' => $this->post->id])->all(), 'tag_id'); - $posts = $this->posts->getByTagsId($this->post, $tag_ids, $this->count)->getModels(); - - return $this->render($this->view, [ - 'posts' => $posts, - 'view' => $this->view, - 'url' => Url::canonical(), - ]); - } -} \ No newline at end of file diff --git a/common/modules/blog/widgets/TagWidget.php b/common/modules/blog/widgets/TagWidget.php deleted file mode 100644 index 2613461..0000000 --- a/common/modules/blog/widgets/TagWidget.php +++ /dev/null @@ -1,39 +0,0 @@ -select('t.name as name, count(t.id) as cnt, t.id as id') - ->from('blog_posts as p, blog_tag_assignments as a, blog_tags as t') - ->andWhere('p.id = a.post_id') - ->andWhere('t.id = a.tag_id') - ->andWhere(isset($this->post_id) ? 'p.id = ' . $this->post_id : '') - ->groupBy('t.id') - ->orderBy('cnt DESC') - ->limit(20) - ->asArray() - ->all(); - - if ($tags) { - return $this->render( 'tags/tags', [ - 'tags' => $tags, - ] ); - } - else { - return ''; - } - } -} \ No newline at end of file diff --git a/common/modules/blog/widgets/views/categories/categories.php b/common/modules/blog/widgets/views/categories/categories.php deleted file mode 100644 index 94344f8..0000000 --- a/common/modules/blog/widgets/views/categories/categories.php +++ /dev/null @@ -1,32 +0,0 @@ - - - -
    -
    -
    -
    -
    -
      - -
    • - translation->name, ['/blog/post/category', 'id' => $category->id]) ?> -
    • - -
    -
    -
    -
    -
    diff --git a/common/modules/blog/widgets/views/comments/_comment.php b/common/modules/blog/widgets/views/comments/_comment.php deleted file mode 100644 index 6cb3501..0000000 --- a/common/modules/blog/widgets/views/comments/_comment.php +++ /dev/null @@ -1,78 +0,0 @@ - - -
    - -
    - -
    - -
    comment->user->username ?> - -
    -

    - comment->isActive()): ?> - formatter->asNtext($item->comment->text) ?> - - Comment is deleted. - -

    - -
    -
    -
    - - - -
    - - - -children as $children): ?> - render('_comment', ['item' => $children, 'child' => $child + 1]) ?> - diff --git a/common/modules/blog/widgets/views/comments/comments.php b/common/modules/blog/widgets/views/comments/comments.php deleted file mode 100644 index fb0de05..0000000 --- a/common/modules/blog/widgets/views/comments/comments.php +++ /dev/null @@ -1,103 +0,0 @@ -registerCss( $css ); -?> - -
    -
    - -
    -
    -
    - $post->comments_count ] ) ?> - - user->isGuest ): ?> - - -
    -
    -
    - - 0 ): ?> -
    - - render( '_comment', [ 'item' => $item, 'child' => 0 ] ) ?> - -
    - - - user->isGuest ): ?> - -
    - -
    - - [ 'comment', 'id' => $post->id ], - ] ); ?> - - - field( $commentForm, 'text' )->textarea( [ 'rows' => 5 ] )->label( Yii::t( 'post', 'Comment' ) ) ?> - -
    - 'btn btn-primary' ] ) ?> -
    - - -
    -
    - -
    - Html::a(Yii::t('auth', 'Log in'), ['/auth/auth/login'])]) ?> -
    - - - -
    -
    - -registerJs( " - jQuery(document).on('click', '.blog-post-comments .blog-comment-reply', function () { - var link = jQuery(this); - var form = jQuery('#reply-block'); - var comment = link.closest('.blog-comment'); - jQuery('#blogcommentform-parentid').val(comment.data('id')); - form.detach().appendTo(comment.find('.reply-block:first')); - return false; - }); - - jQuery(document).on('click', '#send-comment', function () { - var form = jQuery('#reply-block'); - jQuery('#blogcommentform-parentid').val(''); - form.detach().appendTo('#reply-container'); - //return false; - }); -" ); ?> - - - \ No newline at end of file diff --git a/common/modules/blog/widgets/views/menu-item/creator.php b/common/modules/blog/widgets/views/menu-item/creator.php deleted file mode 100644 index 6e93ca0..0000000 --- a/common/modules/blog/widgets/views/menu-item/creator.php +++ /dev/null @@ -1,128 +0,0 @@ -registerJs($js, $this::POS_HEAD); - -$fetchUrl = Url::to( [ '/blog/manage/post/post-search' ] ); -?> - - \ No newline at end of file diff --git a/common/modules/blog/widgets/views/slider-relative.php b/common/modules/blog/widgets/views/slider-relative.php deleted file mode 100644 index c06485b..0000000 --- a/common/modules/blog/widgets/views/slider-relative.php +++ /dev/null @@ -1,38 +0,0 @@ - - -
    - -
    \ No newline at end of file diff --git a/common/modules/blog/widgets/views/tags/tags.php b/common/modules/blog/widgets/views/tags/tags.php deleted file mode 100644 index 6e05db0..0000000 --- a/common/modules/blog/widgets/views/tags/tags.php +++ /dev/null @@ -1,21 +0,0 @@ - - -
    -
      - -
    • $tag['id']]) ?>
    • - -
    \ No newline at end of file