diff --git a/plugins/bedard/blogtags/Plugin.php b/plugins/bedard/blogtags/Plugin.php index 843e83c65..5e38c842c 100644 --- a/plugins/bedard/blogtags/Plugin.php +++ b/plugins/bedard/blogtags/Plugin.php @@ -104,21 +104,21 @@ class Plugin extends PluginBase 'label' => 'Tags ru', 'mode' => 'relation', 'dependsOn' => 'locale', - 'tab' => 'rainlab.blog::lang.post.tab_categories', + 'tab' => 'Language and Tag', 'type' => 'taglist' ], 'tags_en' => [ 'label' => 'Tags en', 'mode' => 'relation', 'dependsOn' => 'locale', - 'tab' => 'rainlab.blog::lang.post.tab_categories', + 'tab' => 'Language and Tag', 'type' => 'taglist' ], 'tags_tm' => [ 'label' => 'Tags tm', 'mode' => 'relation', 'dependsOn' => 'locale', - 'tab' => 'rainlab.blog::lang.post.tab_categories', + 'tab' => 'Language and Tag', 'type' => 'taglist' ] ]); diff --git a/plugins/rainlab/blog/models/Post.php b/plugins/rainlab/blog/models/Post.php index ba04f66ac..5d2c37802 100644 --- a/plugins/rainlab/blog/models/Post.php +++ b/plugins/rainlab/blog/models/Post.php @@ -12,6 +12,7 @@ use Markdown; use BackendAuth; use Carbon\Carbon; use Backend\Models\User; +use Tps\Tps\Models\Authors; use Cms\Classes\Page as CmsPage; use Cms\Classes\Theme; use Cms\Classes\Controller; @@ -35,14 +36,15 @@ class Post extends Model * Validation */ public $rules = [ - 'title' => 'required', + 'title' => ['required', 'unique:rainlab_blog_posts'], 'slug' => ['required', 'regex:/^[a-z0-9\/\:_\-\*\[\]\+\?\|]*$/i', 'unique:rainlab_blog_posts'], 'content' => 'required', 'powerseo_title' => 'required', 'powerseo_description' => 'required', 'powerseo_keywords' => 'required', 'excerpt' => 'required', - // 'type_post' => 'required', + 'category_groups' => 'required', + 'awtor' => 'required', ]; /** @@ -89,6 +91,10 @@ class Post extends Model */ public $belongsTo = [ 'user' => ['Backend\Models\User'], + 'awtor' => ['Tps\Tps\Models\Authors', + 'key' => 'author_id', + 'table' => 'tps_tps_authors' + ], ]; public $belongsToMany = [ @@ -170,6 +176,18 @@ class Post extends Model public function filterFields($fields, $context = null) { + if($this->awtor){ + if($this->awtor->type == 'other'){ + $fields->author_name->hidden = false; + }else{ + $fields->author_name->value = null; + $fields->author_name->hidden = true; + } + }else{ + $fields->author_name->value = null; + $fields->author_name->hidden = true; + } + if(isset($fields->category_groups)){ if($this->category_groups->where('type', 'news')->count()){ $fields->type_post->hidden = false; @@ -177,12 +195,6 @@ class Post extends Model $fields->type_post->hidden = true; } - // if($this->category_groups->where('type', 'media')->count()){ - // $fields->video_file->hidden = false; - // }else{ - // $fields->video_file->hidden = true; - // } - if($this->category_groups->where('type', 'afisha')->count()){ $fields->afisha_phone->hidden = false; $fields->afisha_address->hidden = false; @@ -191,6 +203,7 @@ class Post extends Model $fields->afisha_address->hidden = true; } } + if(isset($fields->locale)){ if($this->locale == 'en') { diff --git a/plugins/rainlab/blog/models/post/fields.yaml b/plugins/rainlab/blog/models/post/fields.yaml index fa91ceb7e..f0a49f5ef 100644 --- a/plugins/rainlab/blog/models/post/fields.yaml +++ b/plugins/rainlab/blog/models/post/fields.yaml @@ -1,19 +1,22 @@ fields: title: label: 'rainlab.blog::lang.post.title' + span: full placeholder: 'rainlab.blog::lang.post.title_placeholder' type: text slug: label: 'rainlab.blog::lang.post.slug' + span: full placeholder: 'rainlab.blog::lang.post.slug_placeholder' preset: field: title type: slug type: text toolbar: - type: partial - path: post_toolbar + span: full cssClass: collapse-visible + path: post_toolbar + type: partial secondaryTabs: fields: content: @@ -32,37 +35,45 @@ secondaryTabs: span: left default: 'rainlab.blog::lang.ru' type: dropdown - tab: 'rainlab.blog::lang.post.tab_categories' + tab: 'Language and Tag' id_en: label: 'Translated Post ID En' span: right dependsOn: - locale type: number - tab: 'rainlab.blog::lang.post.tab_categories' + tab: 'Language and Tag' id_tm: label: 'Translated Post ID Tm' span: right dependsOn: - locale type: number - tab: 'rainlab.blog::lang.post.tab_categories' + tab: 'Language and Tag' id_ru: label: 'Translated Post ID Ru' span: right dependsOn: - locale type: number - tab: 'rainlab.blog::lang.post.tab_categories' - author: - label: 'Post author' + tab: 'Language and Tag' + awtor: + label: Authors + nameFrom: name + descriptionFrom: description span: auto - default: 'ORIENT news' + type: relation + tab: 'rainlab.blog::lang.post.tab_manage' + author_name: + label: 'Author Name' + span: auto + dependsOn: + - awtor type: text tab: 'rainlab.blog::lang.post.tab_manage' featured: label: 'показать в слайдере на главной странице' - span: auto + span: right type: checkbox comment: 'не отмечать если не нужно выставлять на слайдере' tab: 'rainlab.blog::lang.post.tab_manage' diff --git a/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_14.php b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_14.php new file mode 100644 index 000000000..9f5a558ee --- /dev/null +++ b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_14.php @@ -0,0 +1,23 @@ +integer('author_id')->nullable(); + }); + } + + public function down() + { + Schema::table('rainlab_blog_posts', function($table) + { + $table->dropColumn('author_id'); + }); + } +} diff --git a/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_15.php b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_15.php new file mode 100644 index 000000000..113a51e15 --- /dev/null +++ b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_15.php @@ -0,0 +1,23 @@ +string('author_name')->nullable(); + }); + } + + public function down() + { + Schema::table('rainlab_blog_posts', function($table) + { + $table->dropColumn('author_name'); + }); + } +} diff --git a/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_16.php b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_16.php new file mode 100644 index 000000000..628d90947 --- /dev/null +++ b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_16.php @@ -0,0 +1,23 @@ +integer('author_id')->unsigned()->change(); + }); + } + + public function down() + { + Schema::table('rainlab_blog_posts', function($table) + { + $table->integer('author_id')->unsigned(false)->change(); + }); + } +} diff --git a/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_17.php b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_17.php new file mode 100644 index 000000000..df85d7c3a --- /dev/null +++ b/plugins/rainlab/blog/updates/builder_table_update_rainlab_blog_posts_17.php @@ -0,0 +1,23 @@ +integer('author_id')->unsigned(false)->change(); + }); + } + + public function down() + { + Schema::table('rainlab_blog_posts', function($table) + { + $table->integer('author_id')->unsigned()->change(); + }); + } +} diff --git a/plugins/rainlab/blog/updates/version.yaml b/plugins/rainlab/blog/updates/version.yaml index 2faa2400a..473ed4a70 100644 --- a/plugins/rainlab/blog/updates/version.yaml +++ b/plugins/rainlab/blog/updates/version.yaml @@ -159,3 +159,15 @@ 1.5.33: - 'Updated table rainlab_blog_posts' - builder_table_update_rainlab_blog_posts_13.php +1.5.34: + - 'Updated table rainlab_blog_posts' + - builder_table_update_rainlab_blog_posts_14.php +1.5.35: + - 'Updated table rainlab_blog_posts' + - builder_table_update_rainlab_blog_posts_15.php +1.5.36: + - 'Updated table rainlab_blog_posts' + - builder_table_update_rainlab_blog_posts_16.php +1.5.37: + - 'Updated table rainlab_blog_posts' + - builder_table_update_rainlab_blog_posts_17.php diff --git a/plugins/tps/tps/controllers/Authors.php b/plugins/tps/tps/controllers/Authors.php new file mode 100644 index 000000000..e02f35577 --- /dev/null +++ b/plugins/tps/tps/controllers/Authors.php @@ -0,0 +1,18 @@ + + + + diff --git a/plugins/tps/tps/controllers/authors/config_form.yaml b/plugins/tps/tps/controllers/authors/config_form.yaml new file mode 100644 index 000000000..2fd24afa7 --- /dev/null +++ b/plugins/tps/tps/controllers/authors/config_form.yaml @@ -0,0 +1,10 @@ +name: Authors +form: $/tps/tps/models/authors/fields.yaml +modelClass: Tps\Tps\Models\Authors +defaultRedirect: tps/tps/authors +create: + redirect: 'tps/tps/authors/update/:id' + redirectClose: tps/tps/authors +update: + redirect: tps/tps/authors + redirectClose: tps/tps/authors diff --git a/plugins/tps/tps/controllers/authors/config_list.yaml b/plugins/tps/tps/controllers/authors/config_list.yaml new file mode 100644 index 000000000..bd553f342 --- /dev/null +++ b/plugins/tps/tps/controllers/authors/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/tps/models/authors/columns.yaml +modelClass: Tps\Tps\Models\Authors +title: Authors +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/tps/authors/update/:id' diff --git a/plugins/tps/tps/controllers/authors/create.htm b/plugins/tps/tps/controllers/authors/create.htm new file mode 100644 index 000000000..7728899bc --- /dev/null +++ b/plugins/tps/tps/controllers/authors/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/controllers/authors/index.htm b/plugins/tps/tps/controllers/authors/index.htm new file mode 100644 index 000000000..ea43a3636 --- /dev/null +++ b/plugins/tps/tps/controllers/authors/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/plugins/tps/tps/controllers/authors/preview.htm b/plugins/tps/tps/controllers/authors/preview.htm new file mode 100644 index 000000000..93b7fceed --- /dev/null +++ b/plugins/tps/tps/controllers/authors/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/tps/tps/controllers/authors/update.htm b/plugins/tps/tps/controllers/authors/update.htm new file mode 100644 index 000000000..f663aff6a --- /dev/null +++ b/plugins/tps/tps/controllers/authors/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/models/Authors.php b/plugins/tps/tps/models/Authors.php new file mode 100644 index 000000000..e4d578dd8 --- /dev/null +++ b/plugins/tps/tps/models/Authors.php @@ -0,0 +1,35 @@ + [ + 'RainLab\Blog\Models\Post' + ], + ]; + + + /** + * @var array Validation rules + */ + public $rules = [ + 'name' => 'required', + ]; +} diff --git a/plugins/tps/tps/models/authors/columns.yaml b/plugins/tps/tps/models/authors/columns.yaml new file mode 100644 index 000000000..fbd025cf3 --- /dev/null +++ b/plugins/tps/tps/models/authors/columns.yaml @@ -0,0 +1,24 @@ +columns: + id: + label: id + type: number + name: + label: name + type: text + searchable: true + sortable: true + note: + label: note + type: text + searchable: true + sortable: true + created_at: + label: created_at + type: datetime + searchable: true + sortable: true + type: + label: type + type: text + searchable: true + sortable: true diff --git a/plugins/tps/tps/models/authors/fields.yaml b/plugins/tps/tps/models/authors/fields.yaml new file mode 100644 index 000000000..a71867c44 --- /dev/null +++ b/plugins/tps/tps/models/authors/fields.yaml @@ -0,0 +1,19 @@ +fields: + name: + label: Name + span: auto + required: 1 + type: text + note: + label: Note + size: '' + span: auto + type: textarea + type: + label: 'Author Type' + options: + author: Author + other: Other + span: auto + default: author + type: balloon-selector diff --git a/plugins/tps/tps/plugin.yaml b/plugins/tps/tps/plugin.yaml index 75000c418..9ac05ef6b 100644 --- a/plugins/tps/tps/plugin.yaml +++ b/plugins/tps/tps/plugin.yaml @@ -9,3 +9,8 @@ navigation: label: 'Media Category' url: tps/tps/media icon: icon-film + sideMenu: + side-menu-item: + label: Authors + url: tps/tps/authors + icon: icon-users diff --git a/plugins/tps/tps/updates/builder_table_create_tps_tps_authors.php b/plugins/tps/tps/updates/builder_table_create_tps_tps_authors.php new file mode 100644 index 000000000..128a2db9b --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_create_tps_tps_authors.php @@ -0,0 +1,26 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('name'); + $table->text('note'); + $table->timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + $table->timestamp('deleted_at')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('tps_tps_authors'); + } +} diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_authors.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_authors.php new file mode 100644 index 000000000..a078c8511 --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_authors.php @@ -0,0 +1,23 @@ +string('type'); + }); + } + + public function down() + { + Schema::table('tps_tps_authors', function($table) + { + $table->dropColumn('type'); + }); + } +} diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_authors_2.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_authors_2.php new file mode 100644 index 000000000..deaf40a14 --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_authors_2.php @@ -0,0 +1,23 @@ +string('type', 191)->default('author')->change(); + }); + } + + public function down() + { + Schema::table('tps_tps_authors', function($table) + { + $table->string('type', 191)->default(null)->change(); + }); + } +} diff --git a/plugins/tps/tps/updates/version.yaml b/plugins/tps/tps/updates/version.yaml index ff57b46e1..b590c3809 100644 --- a/plugins/tps/tps/updates/version.yaml +++ b/plugins/tps/tps/updates/version.yaml @@ -6,3 +6,12 @@ 1.0.3: - 'Created table tps_tps_media' - builder_table_create_tps_tps_media.php +1.0.4: + - 'Created table tps_tps_authors' + - builder_table_create_tps_tps_authors.php +1.0.5: + - 'Updated table tps_tps_authors' + - builder_table_update_tps_tps_authors.php +1.0.6: + - 'Updated table tps_tps_authors' + - builder_table_update_tps_tps_authors_2.php