From 326af91906814cb519afeb0bc752c70e0be82b79 Mon Sep 17 00:00:00 2001 From: diver90 Date: Fri, 28 May 2021 16:52:28 +0300 Subject: [PATCH] add artbox-core to repo --- artweb/artbox-core/CHANGELOG.md | 7 +++++++ artweb/artbox-core/LICENSE.md | 32 ++++++++++++++++++++++++++++++++ artweb/artbox-core/README.md | 34 ++++++++++++++++++++++++++++++++++ artweb/artbox-core/assets/ArtboxAmChartAsset.php | 26 ++++++++++++++++++++++++++ artweb/artbox-core/assets/ArtboxCoreAsset.php | 35 +++++++++++++++++++++++++++++++++++ artweb/artbox-core/assets/GalleryAsset.php | 23 +++++++++++++++++++++++ artweb/artbox-core/assets/src/js/galleryWidget.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/behaviors/BitMaskBehavior.php | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/behaviors/GalleryBehavior.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/behaviors/LinkBehavior.php | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/behaviors/ManyToManyBehavior.php | 33 +++++++++++++++++++++++++++++++++ artweb/artbox-core/behaviors/SlugBehavior.php | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/AliasCache.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/LanguageRequest.php | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/SeoComponent.php | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/SeoUrlManager.php | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/Sitemap.php | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/.gitignore | 1 + artweb/artbox-core/components/imagemanager/Module.php | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/assets/ImageManagerInputAsset.php | 22 ++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/assets/ImageManagerModuleAsset.php | 24 ++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/assets/source/css/cropper.min.css | 9 +++++++++ artweb/artbox-core/components/imagemanager/assets/source/css/imagemanager.input.css | 33 +++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/assets/source/css/imagemanager.module.css | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/assets/source/img/img_no-image.png | Bin 0 -> 8459 bytes artweb/artbox-core/components/imagemanager/assets/source/js/cropper.min.js | 10 ++++++++++ artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.input.js | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.module.js | 474 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/components/ImageManagerGetPath.php | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/components/ImageManagerInputWidget.php | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/controllers/DefaultController.php | 21 +++++++++++++++++++++ artweb/artbox-core/components/imagemanager/controllers/ManagerController.php | 451 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager-crop.jpg | Bin 0 -> 77494 bytes artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager.jpg | Bin 0 -> 64429 bytes artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget-popup.jpg | Bin 0 -> 69405 bytes artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget.jpg | Bin 0 -> 10259 bytes artweb/artbox-core/components/imagemanager/messages/de/imagemanager.php | 17 +++++++++++++++++ artweb/artbox-core/components/imagemanager/messages/en/imagemanager.php | 17 +++++++++++++++++ artweb/artbox-core/components/imagemanager/messages/fr/imagemanager.php | 17 +++++++++++++++++ artweb/artbox-core/components/imagemanager/messages/it/imagemanager.php | 17 +++++++++++++++++ artweb/artbox-core/components/imagemanager/messages/nl/imagemanager.php | 20 ++++++++++++++++++++ artweb/artbox-core/components/imagemanager/messages/ru/imagemanager.php | 18 ++++++++++++++++++ artweb/artbox-core/components/imagemanager/migrations/m160622_085710_create_ImageManager_table.php | 42 ++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/migrations/m170223_113221_addBlameableBehavior.php | 33 +++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/models/ImageManager.php | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/models/ImageManagerLang.php | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/models/ImageManagerSearch.php | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/views/default/index.php | 10 ++++++++++ artweb/artbox-core/components/imagemanager/views/layouts/blank.php | 28 ++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/views/manager/_image_info.php | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imagemanager/views/manager/_item.php | 4 ++++ artweb/artbox-core/components/imagemanager/views/manager/index.php | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/components/imageresize/ImageResize.php | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/composer.json | 23 +++++++++++++++++++++++ artweb/artbox-core/controllers/AliasController.php | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/FeedbackController.php | 219 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/PageCategoryController.php | 246 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/PageController.php | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/ProfileController.php | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/SeoController.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/SitemapController.php | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/SlideController.php | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/controllers/SliderController.php | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/exceptions/AliasOverwriteException.php | 21 +++++++++++++++++++++ artweb/artbox-core/filters/IsAjaxFilter.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/helpers/ImageHelper.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/helpers/ImageManipulator.php | 463 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/helpers/SlugHelper.php | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/helpers/SlugifyDecorator.php | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/helpers/UnificatorHelper.php | 29 +++++++++++++++++++++++++++++ artweb/artbox-core/language_instruction.txt | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/messages/en/core.php | 3 +++ artweb/artbox-core/messages/ru/core.php | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000000_user.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000001_feedback.php | 31 +++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000002_language.php | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000003_alias.php | 22 ++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000004_page.php | 22 ++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000005_page_lang.php | 32 ++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170309_000006_relations.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170313_092544_create_user_data_table.php | 38 ++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170316_103134_page_lang_drop_not_null.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170316_180155_alias_seo_fields.php | 26 ++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170316_181841_page_lang_remove_seo_fields.php | 22 ++++++++++++++++++++++ artweb/artbox-core/migrations/m170317_104310_alias_add_entity_column.php | 16 ++++++++++++++++ artweb/artbox-core/migrations/m170317_155203_alias_add_fields_column.php | 16 ++++++++++++++++ artweb/artbox-core/migrations/m170317_155204_create_ImageManager_table.php | 37 +++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170317_155205_addBlameableBehavior.php | 32 ++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170327_134400_alias_add_language_column.php | 18 ++++++++++++++++++ artweb/artbox-core/migrations/m170405_095957_page_add_column_sort.php | 21 +++++++++++++++++++++ artweb/artbox-core/migrations/m170502_151419_insert_aliases.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170619_095632_create_ImageManagerLang_table.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170717_142042_add_gallery_column_to_page_table.php | 25 +++++++++++++++++++++++++ artweb/artbox-core/migrations/m170718_134346_create_page_category_table.php | 32 ++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170718_134355_create_page_category_lang_table.php | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/migrations/m170718_155356_create_page_to_category_table.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/Alias.php | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/AliasSearch.php | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/ChangePassword.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/DummyAlias.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/Feedback.php | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/FeedbackSearch.php | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/Image.php | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/ImageLang.php | 21 +++++++++++++++++++++ artweb/artbox-core/models/Language.php | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/LoginForm.php | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/Page.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/PageCategory.php | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/PageCategoryLang.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/PageCategorySearch.php | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/PageLang.php | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/PageSearch.php | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/SitemapDynamic.php | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/SitemapStatic.php | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/Slide.php | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/SlideLang.php | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/SlideSearch.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/Slider.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/SliderSearch.php | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/User.php | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/UserData.php | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/models/interfaces/AliasInterface.php | 27 +++++++++++++++++++++++++++ artweb/artbox-core/views/alias/_form_create.php | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/alias/_form_update.php | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/alias/_search.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/alias/create.php | 41 +++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/alias/index.php | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/alias/update.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/alias/view.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/feedback/_form.php | 43 +++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/feedback/create.php | 26 ++++++++++++++++++++++++++ artweb/artbox-core/views/feedback/index.php | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/feedback/update.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/feedback/view.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page-category/_form.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page-category/_form_language.php | 18 ++++++++++++++++++ artweb/artbox-core/views/page-category/create.php | 40 ++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page-category/index.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page-category/update.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page-category/view.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/_form.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/_form_common.php | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/_form_language.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/_gallery.php | 20 ++++++++++++++++++++ artweb/artbox-core/views/page/create.php | 41 +++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/index.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/update.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/page/view.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/profile/_change_password.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/profile/_profile_info.php | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/profile/index.php | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/seo/index.php | 20 ++++++++++++++++++++ artweb/artbox-core/views/seo/sitemap.php | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/_form.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/_form_language.php | 30 ++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/_search.php | 37 +++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/create.php | 36 ++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/index.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/update.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slide/view.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slider/_form.php | 33 +++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slider/_search.php | 35 +++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slider/create.php | 27 +++++++++++++++++++++++++++ artweb/artbox-core/views/slider/index.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slider/update.php | 40 ++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/views/slider/view.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/web/css/styles.css | 380 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/web/css/styles.css.map | 7 +++++++ artweb/artbox-core/web/css/styles.scss | 475 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/web/js/script.js | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/BitMaskWidget.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/FeedbackWidget.php | 31 +++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/FlashWidget.php | 41 +++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/GalleryWidget.php | 28 ++++++++++++++++++++++++++++ artweb/artbox-core/widgets/LangLink.php | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/LanguageForm.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/LanguagePicker.php | 35 +++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/views/_feedback.php | 16 ++++++++++++++++ artweb/artbox-core/widgets/views/_flash.php | 9 +++++++++ artweb/artbox-core/widgets/views/_gallery_view.php | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/views/_langLink.php | 7 +++++++ artweb/artbox-core/widgets/views/language_form_frame.php | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ artweb/artbox-core/widgets/views/view.php | 35 +++++++++++++++++++++++++++++++++++ 183 files changed, 16055 insertions(+), 0 deletions(-) create mode 100755 artweb/artbox-core/CHANGELOG.md create mode 100755 artweb/artbox-core/LICENSE.md create mode 100755 artweb/artbox-core/README.md create mode 100755 artweb/artbox-core/assets/ArtboxAmChartAsset.php create mode 100755 artweb/artbox-core/assets/ArtboxCoreAsset.php create mode 100644 artweb/artbox-core/assets/GalleryAsset.php create mode 100755 artweb/artbox-core/assets/src/js/galleryWidget.js create mode 100755 artweb/artbox-core/behaviors/BitMaskBehavior.php create mode 100755 artweb/artbox-core/behaviors/GalleryBehavior.php create mode 100755 artweb/artbox-core/behaviors/LinkBehavior.php create mode 100755 artweb/artbox-core/behaviors/ManyToManyBehavior.php create mode 100755 artweb/artbox-core/behaviors/SlugBehavior.php create mode 100755 artweb/artbox-core/components/AliasCache.php create mode 100755 artweb/artbox-core/components/LanguageRequest.php create mode 100644 artweb/artbox-core/components/SeoComponent.php create mode 100755 artweb/artbox-core/components/SeoUrlManager.php create mode 100755 artweb/artbox-core/components/Sitemap.php create mode 100755 artweb/artbox-core/components/imagemanager/.gitignore create mode 100755 artweb/artbox-core/components/imagemanager/Module.php create mode 100755 artweb/artbox-core/components/imagemanager/assets/ImageManagerInputAsset.php create mode 100755 artweb/artbox-core/components/imagemanager/assets/ImageManagerModuleAsset.php create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/css/cropper.min.css create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/css/imagemanager.input.css create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/css/imagemanager.module.css create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/img/img_no-image.png create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/js/cropper.min.js create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.input.js create mode 100755 artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.module.js create mode 100755 artweb/artbox-core/components/imagemanager/components/ImageManagerGetPath.php create mode 100755 artweb/artbox-core/components/imagemanager/components/ImageManagerInputWidget.php create mode 100755 artweb/artbox-core/components/imagemanager/controllers/DefaultController.php create mode 100755 artweb/artbox-core/components/imagemanager/controllers/ManagerController.php create mode 100755 artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager-crop.jpg create mode 100755 artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager.jpg create mode 100755 artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget-popup.jpg create mode 100755 artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget.jpg create mode 100755 artweb/artbox-core/components/imagemanager/messages/de/imagemanager.php create mode 100755 artweb/artbox-core/components/imagemanager/messages/en/imagemanager.php create mode 100755 artweb/artbox-core/components/imagemanager/messages/fr/imagemanager.php create mode 100755 artweb/artbox-core/components/imagemanager/messages/it/imagemanager.php create mode 100755 artweb/artbox-core/components/imagemanager/messages/nl/imagemanager.php create mode 100755 artweb/artbox-core/components/imagemanager/messages/ru/imagemanager.php create mode 100755 artweb/artbox-core/components/imagemanager/migrations/m160622_085710_create_ImageManager_table.php create mode 100755 artweb/artbox-core/components/imagemanager/migrations/m170223_113221_addBlameableBehavior.php create mode 100755 artweb/artbox-core/components/imagemanager/models/ImageManager.php create mode 100755 artweb/artbox-core/components/imagemanager/models/ImageManagerLang.php create mode 100755 artweb/artbox-core/components/imagemanager/models/ImageManagerSearch.php create mode 100755 artweb/artbox-core/components/imagemanager/views/default/index.php create mode 100755 artweb/artbox-core/components/imagemanager/views/layouts/blank.php create mode 100755 artweb/artbox-core/components/imagemanager/views/manager/_image_info.php create mode 100755 artweb/artbox-core/components/imagemanager/views/manager/_item.php create mode 100755 artweb/artbox-core/components/imagemanager/views/manager/index.php create mode 100755 artweb/artbox-core/components/imageresize/ImageResize.php create mode 100755 artweb/artbox-core/composer.json create mode 100755 artweb/artbox-core/controllers/AliasController.php create mode 100755 artweb/artbox-core/controllers/FeedbackController.php create mode 100644 artweb/artbox-core/controllers/PageCategoryController.php create mode 100755 artweb/artbox-core/controllers/PageController.php create mode 100755 artweb/artbox-core/controllers/ProfileController.php create mode 100755 artweb/artbox-core/controllers/SeoController.php create mode 100755 artweb/artbox-core/controllers/SitemapController.php create mode 100755 artweb/artbox-core/controllers/SlideController.php create mode 100755 artweb/artbox-core/controllers/SliderController.php create mode 100644 artweb/artbox-core/exceptions/AliasOverwriteException.php create mode 100755 artweb/artbox-core/filters/IsAjaxFilter.php create mode 100755 artweb/artbox-core/helpers/ImageHelper.php create mode 100755 artweb/artbox-core/helpers/ImageManipulator.php create mode 100755 artweb/artbox-core/helpers/SlugHelper.php create mode 100755 artweb/artbox-core/helpers/SlugifyDecorator.php create mode 100755 artweb/artbox-core/helpers/UnificatorHelper.php create mode 100755 artweb/artbox-core/language_instruction.txt create mode 100755 artweb/artbox-core/messages/en/core.php create mode 100755 artweb/artbox-core/messages/ru/core.php create mode 100755 artweb/artbox-core/migrations/m170309_000000_user.php create mode 100755 artweb/artbox-core/migrations/m170309_000001_feedback.php create mode 100755 artweb/artbox-core/migrations/m170309_000002_language.php create mode 100755 artweb/artbox-core/migrations/m170309_000003_alias.php create mode 100755 artweb/artbox-core/migrations/m170309_000004_page.php create mode 100755 artweb/artbox-core/migrations/m170309_000005_page_lang.php create mode 100755 artweb/artbox-core/migrations/m170309_000006_relations.php create mode 100755 artweb/artbox-core/migrations/m170313_092544_create_user_data_table.php create mode 100755 artweb/artbox-core/migrations/m170316_103134_page_lang_drop_not_null.php create mode 100755 artweb/artbox-core/migrations/m170316_180155_alias_seo_fields.php create mode 100755 artweb/artbox-core/migrations/m170316_181841_page_lang_remove_seo_fields.php create mode 100755 artweb/artbox-core/migrations/m170317_104310_alias_add_entity_column.php create mode 100755 artweb/artbox-core/migrations/m170317_155203_alias_add_fields_column.php create mode 100755 artweb/artbox-core/migrations/m170317_155204_create_ImageManager_table.php create mode 100755 artweb/artbox-core/migrations/m170317_155205_addBlameableBehavior.php create mode 100755 artweb/artbox-core/migrations/m170327_134400_alias_add_language_column.php create mode 100755 artweb/artbox-core/migrations/m170405_095957_page_add_column_sort.php create mode 100755 artweb/artbox-core/migrations/m170502_151419_insert_aliases.php create mode 100755 artweb/artbox-core/migrations/m170619_095632_create_ImageManagerLang_table.php create mode 100644 artweb/artbox-core/migrations/m170717_142042_add_gallery_column_to_page_table.php create mode 100644 artweb/artbox-core/migrations/m170718_134346_create_page_category_table.php create mode 100644 artweb/artbox-core/migrations/m170718_134355_create_page_category_lang_table.php create mode 100644 artweb/artbox-core/migrations/m170718_155356_create_page_to_category_table.php create mode 100755 artweb/artbox-core/models/Alias.php create mode 100755 artweb/artbox-core/models/AliasSearch.php create mode 100755 artweb/artbox-core/models/ChangePassword.php create mode 100755 artweb/artbox-core/models/DummyAlias.php create mode 100755 artweb/artbox-core/models/Feedback.php create mode 100755 artweb/artbox-core/models/FeedbackSearch.php create mode 100755 artweb/artbox-core/models/Image.php create mode 100755 artweb/artbox-core/models/ImageLang.php create mode 100755 artweb/artbox-core/models/Language.php create mode 100755 artweb/artbox-core/models/LoginForm.php create mode 100755 artweb/artbox-core/models/Page.php create mode 100644 artweb/artbox-core/models/PageCategory.php create mode 100644 artweb/artbox-core/models/PageCategoryLang.php create mode 100644 artweb/artbox-core/models/PageCategorySearch.php create mode 100755 artweb/artbox-core/models/PageLang.php create mode 100755 artweb/artbox-core/models/PageSearch.php create mode 100755 artweb/artbox-core/models/SitemapDynamic.php create mode 100755 artweb/artbox-core/models/SitemapStatic.php create mode 100755 artweb/artbox-core/models/Slide.php create mode 100755 artweb/artbox-core/models/SlideLang.php create mode 100755 artweb/artbox-core/models/SlideSearch.php create mode 100755 artweb/artbox-core/models/Slider.php create mode 100755 artweb/artbox-core/models/SliderSearch.php create mode 100755 artweb/artbox-core/models/User.php create mode 100755 artweb/artbox-core/models/UserData.php create mode 100755 artweb/artbox-core/models/interfaces/AliasInterface.php create mode 100755 artweb/artbox-core/views/alias/_form_create.php create mode 100755 artweb/artbox-core/views/alias/_form_update.php create mode 100755 artweb/artbox-core/views/alias/_search.php create mode 100755 artweb/artbox-core/views/alias/create.php create mode 100755 artweb/artbox-core/views/alias/index.php create mode 100755 artweb/artbox-core/views/alias/update.php create mode 100755 artweb/artbox-core/views/alias/view.php create mode 100755 artweb/artbox-core/views/feedback/_form.php create mode 100755 artweb/artbox-core/views/feedback/create.php create mode 100755 artweb/artbox-core/views/feedback/index.php create mode 100755 artweb/artbox-core/views/feedback/update.php create mode 100755 artweb/artbox-core/views/feedback/view.php create mode 100644 artweb/artbox-core/views/page-category/_form.php create mode 100755 artweb/artbox-core/views/page-category/_form_language.php create mode 100644 artweb/artbox-core/views/page-category/create.php create mode 100644 artweb/artbox-core/views/page-category/index.php create mode 100644 artweb/artbox-core/views/page-category/update.php create mode 100644 artweb/artbox-core/views/page-category/view.php create mode 100755 artweb/artbox-core/views/page/_form.php create mode 100644 artweb/artbox-core/views/page/_form_common.php create mode 100755 artweb/artbox-core/views/page/_form_language.php create mode 100644 artweb/artbox-core/views/page/_gallery.php create mode 100755 artweb/artbox-core/views/page/create.php create mode 100755 artweb/artbox-core/views/page/index.php create mode 100755 artweb/artbox-core/views/page/update.php create mode 100755 artweb/artbox-core/views/page/view.php create mode 100755 artweb/artbox-core/views/profile/_change_password.php create mode 100755 artweb/artbox-core/views/profile/_profile_info.php create mode 100755 artweb/artbox-core/views/profile/index.php create mode 100755 artweb/artbox-core/views/seo/index.php create mode 100755 artweb/artbox-core/views/seo/sitemap.php create mode 100755 artweb/artbox-core/views/slide/_form.php create mode 100755 artweb/artbox-core/views/slide/_form_language.php create mode 100755 artweb/artbox-core/views/slide/_search.php create mode 100755 artweb/artbox-core/views/slide/create.php create mode 100755 artweb/artbox-core/views/slide/index.php create mode 100755 artweb/artbox-core/views/slide/update.php create mode 100755 artweb/artbox-core/views/slide/view.php create mode 100755 artweb/artbox-core/views/slider/_form.php create mode 100755 artweb/artbox-core/views/slider/_search.php create mode 100755 artweb/artbox-core/views/slider/create.php create mode 100755 artweb/artbox-core/views/slider/index.php create mode 100755 artweb/artbox-core/views/slider/update.php create mode 100755 artweb/artbox-core/views/slider/view.php create mode 100755 artweb/artbox-core/web/css/styles.css create mode 100755 artweb/artbox-core/web/css/styles.css.map create mode 100755 artweb/artbox-core/web/css/styles.scss create mode 100755 artweb/artbox-core/web/js/script.js create mode 100755 artweb/artbox-core/widgets/BitMaskWidget.php create mode 100755 artweb/artbox-core/widgets/FeedbackWidget.php create mode 100755 artweb/artbox-core/widgets/FlashWidget.php create mode 100755 artweb/artbox-core/widgets/GalleryWidget.php create mode 100755 artweb/artbox-core/widgets/LangLink.php create mode 100755 artweb/artbox-core/widgets/LanguageForm.php create mode 100755 artweb/artbox-core/widgets/LanguagePicker.php create mode 100755 artweb/artbox-core/widgets/views/_feedback.php create mode 100755 artweb/artbox-core/widgets/views/_flash.php create mode 100755 artweb/artbox-core/widgets/views/_gallery_view.php create mode 100755 artweb/artbox-core/widgets/views/_langLink.php create mode 100755 artweb/artbox-core/widgets/views/language_form_frame.php create mode 100755 artweb/artbox-core/widgets/views/view.php diff --git a/artweb/artbox-core/CHANGELOG.md b/artweb/artbox-core/CHANGELOG.md new file mode 100755 index 0000000..1b50467 --- /dev/null +++ b/artweb/artbox-core/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log +All notable changes to this project will be documented in this file. + +## 1.0.0 - 2017-03-21 +### Added +- This CHANGELOG file to hopefully serve as an evolving example of a standardized open source project CHANGELOG. +- Added initial Artbox Core extension. \ No newline at end of file diff --git a/artweb/artbox-core/LICENSE.md b/artweb/artbox-core/LICENSE.md new file mode 100755 index 0000000..e98f03d --- /dev/null +++ b/artweb/artbox-core/LICENSE.md @@ -0,0 +1,32 @@ +The Yii framework is free software. It is released under the terms of +the following BSD License. + +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Yii Software LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/artweb/artbox-core/README.md b/artweb/artbox-core/README.md new file mode 100755 index 0000000..919d79d --- /dev/null +++ b/artweb/artbox-core/README.md @@ -0,0 +1,34 @@ +Artbox Core +=============================== + +Artbox Core is a core extension of light-weight CMS developed by Artweb written with +[Yii 2 framework](http://www.yiiframework.com/). + +Core extension includes functionality for app Internationalization, basic SEO optimization, +feedback, image manipulation, user data and static pages control. Also provides events +notifications. + +This extension is enough to develop landings or small websites with static pages. + +To prepare your application you should run migrations: + + php yii migrate --migationPath=vendor/artweb/artbox-core/migrations + +DIRECTORY STRUCTURE +------------------- + +``` +assets contains AssetBundles +behaviors contains Behaviors classes +components contains custom Classes, which don't belong to other groups +controllers contains controllers for core models +helpers contains helper classes to manipulate, for example static files + and HTML +messages contains translations for core strings +migrations contains migrations, which should be applied after extension + installation +models contains core models +views contains views files for core controllers +web contains assets and other files, which should be web available +widgets contains widgets +``` diff --git a/artweb/artbox-core/assets/ArtboxAmChartAsset.php b/artweb/artbox-core/assets/ArtboxAmChartAsset.php new file mode 100755 index 0000000..386b1d3 --- /dev/null +++ b/artweb/artbox-core/assets/ArtboxAmChartAsset.php @@ -0,0 +1,26 @@ + ' + '
' + '

' + ''; + $('.gw-container') + .append(content); + // if (document.querySelectorAll(".gw-container > .gw-item").length % 3 === 0) { + // $('.gw-container').append('
'); + // } + } + ); + $(document) + .on( + 'click', '.remove-img', function() { + $(this) + .parent() + .remove(); + } + ) + } +); \ No newline at end of file diff --git a/artweb/artbox-core/behaviors/BitMaskBehavior.php b/artweb/artbox-core/behaviors/BitMaskBehavior.php new file mode 100755 index 0000000..2f5e8d8 --- /dev/null +++ b/artweb/artbox-core/behaviors/BitMaskBehavior.php @@ -0,0 +1,108 @@ +owner; + $maskField = $this->maskField; + if (isset($request->post($this->getModelName())[ 'masks' ])) { + $masks = $request->post($this->getModelName())[ 'masks' ]; + } else { + if ($request->isPost) { + $owner->$maskField = 0; + return; + } else { + return; + } + } + + $owner->$maskField = 0; + foreach ($masks as $mask => $value) { + if ($value == '1') { + $owner->$maskField += 2 ** (int) $this->fields[ $mask ]; + } + } + } + + /** + * Get the value of the owners mask field + * + * @return mixed + */ + public function getMaskInt() + { + $maskField = $this->maskField; + return $this->owner->$maskField; + } + + /** + * Return the name of the owner's model + * without namespaces + * + * @return string + */ + public function getModelName() + { + $owner = $this->owner; + $arr = explode('\\', get_class($owner)); + return array_pop($arr); + } + + /** + * Checks the value + * + * @param string $field + * + * @return bool + */ + public function is(string $field) + { + if (array_key_exists($field, $this->fields)) { + $result = $this->getMaskInt() & 2 ** $this->fields[ $field ]; + if ($result === 0) { + return false; + } else { + return true; + } + } else { + return false; + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/behaviors/GalleryBehavior.php b/artweb/artbox-core/behaviors/GalleryBehavior.php new file mode 100755 index 0000000..65a2ecd --- /dev/null +++ b/artweb/artbox-core/behaviors/GalleryBehavior.php @@ -0,0 +1,62 @@ +gallery_field; + + if (empty(Json::decode($this->owner->$gallery_field))) { + return []; + } + + return Image::find() + ->filterWhere([ 'id' => Json::decode($this->owner->$gallery_field)]) + ->all(); + } + + /** + * @param array $post + * + * @return bool + */ + public function saveImages(array $post): bool + { + $gallery_field = $this->gallery_field; + + $to_save = []; + foreach ($post[ 'images' ] as $image) { + /** + * Can make additional validation here + */ + if (!empty($image)) { + $to_save[] = $image; + } + } + + $this->owner->$gallery_field = Json::encode($to_save); + + return $this->owner->save(); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/behaviors/LinkBehavior.php b/artweb/artbox-core/behaviors/LinkBehavior.php new file mode 100755 index 0000000..1a633b8 --- /dev/null +++ b/artweb/artbox-core/behaviors/LinkBehavior.php @@ -0,0 +1,198 @@ + 'linkObject', + ]; + } + + /** + * @inheritdoc + */ + public function attach($owner) + { + parent::attach($owner); + $this->checkValidity(); + } + + /** + * Save link object. + * + * @param Event $event Handler for insertion success + * + * @return \yii\db\ActiveRecord + * @throws \yii\base\InvalidConfigException + */ + public function linkObject($event = null) + { + $owner = $this->owner; + /** + * @var ActiveRecord $linkClassInstance + */ + $linkClassInstance = $this->linkClassInstance; + $value = null; + if ($owner->canGetProperty($this->parentKey, true, false)) { + $key = $this->parentKey; + $value = $owner->$key; + } else { + throw new InvalidConfigException(\Yii::t('core', 'Can\'t get $parentKey property')); + } + if (empty( $value )) { + throw new InvalidConfigException(\Yii::t('core', "Can't get parent key {$key}")); + } + $linkClassInstance->setAttribute($this->linkKey, $value); + foreach ($this->detachBehaviors as $name) { + if (is_string($name)) { + $linkClassInstance->detachBehavior($name); + } + } + $linkClassInstance->save(); + return $linkClassInstance; + } + + /** + * Check if $linkClassInstance ready to be inserted, otherwise throw exception + * + * @throws \yii\base\InvalidConfigException + */ + protected function checkValidity() + { + $owner = $this->owner; + if (empty( $this->linkClass )) { + throw new InvalidConfigException(\Yii::t('core', 'Link class must be set')); + } else { + $this->linkClassInstance = \Yii::createObject($this->linkClass); + if (!$this->linkClassInstance instanceof ActiveRecord) { + throw new InvalidConfigException( + \Yii::t('core', 'Link class must be instance of yii\db\ActiveRecord') + ); + } + } + /** @noinspection PhpParamsInspection */ + $this->ensureAttribute('parentKey', $owner); + /** @noinspection PhpParamsInspection */ + $this->ensureAttribute('linkKey', $this->linkClassInstance); + if (empty( $this->parentKey ) || empty( $this->linkKey )) { + throw new InvalidConfigException( + \Yii::t( + 'core', + '$parentKey and $linkKey must be set or use ActiveRecord to get its primaryKey()[0] attributes.' + ) + ); + } + if (!$owner->canGetProperty($this->parentKey, true, false)) { + throw new InvalidConfigException(\Yii::t('core', 'Can\'t get $parentKey property')); + } + } + + /** + * Bind keys to default properties if keys empty. + * + * @param string $property Property to bind + * @param Object $object Property owner + */ + protected function ensureAttribute(string $property, Object $object) + { + if (empty( $this->$property )) { + if ($object instanceof ActiveRecord) { + $pks = $object->primaryKey(); + if (!empty( $pks )) { + $this->$property = $pks[ 0 ]; + } + } + } + } + + /** + * Generate link object an d save it directly. + * + * @return ActiveRecord + */ + public function ensureExistance() + { + $link = $this->getLinkObject(); + if (!$link) { + $link = $this->linkObject(); + } + return $link; + } + + /** + * Get link object + * + * @param bool $throw Whether to throw exception if link object not found + * + * @return null|\yii\db\ActiveRecord + * @throws \yii\web\NotFoundHttpException + */ + public function getLinkObject(bool $throw = false) + { + /** + * @var ActiveRecord $linkClassInstance + */ + $linkClassInstance = $this->linkClassInstance; + $owner = $this->owner; + $parentKey = $this->parentKey; + /** + * @var ActiveRecord $result + */ + $result = $linkClassInstance::find() + ->where([ $this->linkKey => $this->owner->$parentKey ]) + ->one(); + if ($throw && !$result) { + throw new NotFoundHttpException(\Yii::t('core', "Linked object for {$owner::className()} not found")); + } + return $result; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/behaviors/ManyToManyBehavior.php b/artweb/artbox-core/behaviors/ManyToManyBehavior.php new file mode 100755 index 0000000..bb0fb1d --- /dev/null +++ b/artweb/artbox-core/behaviors/ManyToManyBehavior.php @@ -0,0 +1,33 @@ +owner; + + $owner->unlinkAll($name, true); + + foreach ($models as $model) { + $owner->link($name, $model, $extraColumns); + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/behaviors/SlugBehavior.php b/artweb/artbox-core/behaviors/SlugBehavior.php new file mode 100755 index 0000000..53736ac --- /dev/null +++ b/artweb/artbox-core/behaviors/SlugBehavior.php @@ -0,0 +1,376 @@ + 'getSlug', + ActiveRecord::EVENT_AFTER_UPDATE => 'getSlug', + ActiveRecord::EVENT_BEFORE_DELETE => 'deleteSlug', + ]; + } + + /** + * @inheritdoc + */ + public function attach($owner) + { + parent::attach($owner); + if (!$owner instanceof ActiveRecord) { + throw new yii\base\InvalidConfigException( + \Yii::t('core', 'SlugBeahvior can only be attached to the instance of ActiveRecord') + ); + } + } + + /** + * Generate slug + * + * @param yii\base\Event $event + * + * @return void + */ + public function getSlug($event) + { + /** + * @var string $attribute_value + */ + $attribute_value = $this->owner->getAttribute($this->inAttribute); + if (!empty($attribute_value)) { + /** + * @var string $alias_value + */ + $alias_value = $this->aliasValue; + $this->currentAlias = $this->findCurrentAlias(); + if (empty($alias_value)) { + $result = $this->generateSlug($attribute_value); + } else { + $result = $this->generateSlug($alias_value); + } + $this->saveSlug($result); + } + } + + /** + * Delete slug + * + * @param yii\base\Event $event + * + * @return void + */ + public function deleteSlug($event) + { + if (!empty($current = $this->findCurrentAlias())) { + $current->delete(); + } + } + + /** + * Get current Alias. Db query will be made first time or if $force flag is set. + * + * @param bool $force + * + * @return \artbox\core\models\Alias|null + */ + public function findCurrentAlias($force = false) + { + if ($force || !$this->executed) { + /** + * @var int $alias_id + */ + $alias_id = $this->owner->getAttribute($this->outAttribute); + $currentAlias = null; + if (!empty($alias_id)) { + /** + * @var Alias|null $currentAlias + */ + $currentAlias = Alias::find() + ->where( + [ + 'id' => $alias_id, + ] + ) + ->one(); + } + $this->executed = true; + return $currentAlias; + } else { + return $this->currentAlias; + } + } + + /** + * Generate unique slug. + * + * @param string $slug + * + * @return string + */ + private function generateSlug($slug) + { + $slug = $this->slugify($slug); + $languageId = null; + if ($this->owner->hasAttribute('language_id')) { + $languageId = $this->owner->getAttribute('language_id'); + } + return SlugHelper::unify($slug, $this->currentAlias, $languageId); + } + + /** + * Generate slug from string according to $translit flag. + * + * @param string $slug + * + * @return string + */ + private function slugify($slug) + { + if ($this->translit) { + return SlugHelper::slugify($slug); + } else { + return $this->slug($slug, '-', true); + } + } + + /** + * Replace non-alphabetic symbols with $replcement symbol. + * + * @param string $string + * @param string $replacement + * @param bool $lowercase + * + * @return string + */ + private function slug($string, $replacement = '-', $lowercase = true) + { + $string = preg_replace('/[^\p{L}\p{Nd}]+/u', $replacement, $string); + $string = trim($string, $replacement); + return $lowercase ? strtolower($string) : $string; + } + + /** + * Check if $slug differs from current Alias value + * + * @param $slug + * + * @return bool + */ + private function hasChanged($slug) + { + if (!empty($this->currentAlias) && $this->currentAlias->value === $slug) { + return false; + } else { + return true; + } + } + + /** + * If $slug differs from Db Alias value, updates current if exists or create new Alias row. + * + * @param $slug + * + * @throws \yii\base\ErrorException + */ + protected function saveSlug($slug) + { + if (!$this->hasChanged($slug)) { + return; + } else { + $route = $this->buildRoute(); + $owner = $this->owner; + if (empty($alias = $this->findCurrentAlias())) { + /** + * @var Alias $alias + */ + $alias = \Yii::createObject( + Alias::className(), + [ + [ + 'value' => $slug, + 'route' => $route, + 'entity' => $owner::className(), + 'title' => $owner->getAttribute($this->inAttribute), + 'h1' => $owner->getAttribute($this->inAttribute), + 'fields' => Json::encode($this->fields), + 'language_id' => $owner->getAttribute('language_id'), + ], + ] + ); + + } else { + $alias->value = $slug; + $alias->route = $route; + $alias->entity = $owner::className(); + $alias->language_id = $owner->getAttribute('language_id'); + } + if ($alias->save()) { + $owner->{$this->outAttribute} = $alias->id; + $this->detach(); + $owner->save(false, [ $this->outAttribute ]); + } else { + $alias = Alias::find() + ->where( + [ + 'route' => $alias->route, + 'language_id' => $alias->language_id, + ] + ) + ->one(); + if ($alias) { + $owner->{$this->outAttribute} = $alias->id; + $this->detach(); + $owner->save(false, [ $this->outAttribute ]); + } else { + throw new ErrorException( + \Yii::t( + 'core', + 'Alias cannot be saved: ' . Json::encode($alias) . '. Errors: ' . Json::encode( + $alias->getErrors() + ) + ) + ); + } + } + } + } + + /** + * Get $aliasValue. Try to get from cached value and tries to get from Db if empty. + * + * @return string + */ + public function getAliasValue() + { + if (empty($this->aliasValue) && !$this->executed) { + $currentAlias = $this->findCurrentAlias(); + if (!empty($currentAlias)) { + $this->aliasValue = $currentAlias->value; + return $currentAlias->value; + } + } + return $this->aliasValue; + } + + /** + * Set $aliasValue + * + * @param $value + */ + public function setAliasValue($value) + { + $this->aliasValue = $value; + } + + /** + * Build Json route from $action and $params fields. + * + * @return null|string + */ + protected function buildRoute() + { + $owner = $this->owner; + $route = []; + $action = $this->action; + if (empty($action)) { + return null; + } else { + $route[ 0 ] = $action; + } + $params = $this->params; + if (!empty($params) && is_array($params)) { + foreach ($params as $param => $attribute) { + $attributeValue = $owner->getAttribute($attribute); + if (!empty($attributeValue)) { + $route[ $param ] = $attributeValue; + } + } + } + return Json::encode($route); + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/components/AliasCache.php b/artweb/artbox-core/components/AliasCache.php new file mode 100755 index 0000000..73a496d --- /dev/null +++ b/artweb/artbox-core/components/AliasCache.php @@ -0,0 +1,51 @@ +aliases) && array_key_exists( + $language->id, + $this->aliases[ $paramString ] + ) + ) { + return $this->aliases[ $paramString ][ $language->id ]; + } else { + /** + * @var \artbox\core\models\Alias $result + */ + $result = $callback(); + $this->aliases[ $paramString ][ $language->id ] = $result; + return $result; + } + } catch (InvalidParamException $exception) { + } + return null; + } + + public function cache(Alias $alias) + { + $this->aliases[ Json::encode($alias->route) ][ $alias->language_id ] = $alias; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/components/LanguageRequest.php b/artweb/artbox-core/components/LanguageRequest.php new file mode 100755 index 0000000..97142c9 --- /dev/null +++ b/artweb/artbox-core/components/LanguageRequest.php @@ -0,0 +1,113 @@ +languageUrl === null) { + $this->languageUrl = $this->getUrl(); + + $url_list = explode('/', $this->languageUrl); + + $language_url = isset($url_list[ 1 ]) ? $url_list[ 1 ] : null; + if ($paramsPos = strpos($language_url, '?')) { + $language_url = substr($language_url, 0, $paramsPos); + } + + $is_language = Language::setCurrent($language_url); + if (!$is_language && !$this->isAjax) { + if (strpos($language_url, '.') === false && count(Language::getActive()) !== 1) { + \Yii::$app->response->redirect('/' . Language::getCurrent()->url . $this->url, 302, false); + } else { + \Yii::getLogger() + ->log( + "Url $language_url has extension '.' symbol in name. No language redirect applied.", + Logger::LEVEL_INFO, + 'artbox' + ); + } + } + + if ($language_url !== null && $language_url === Language::getCurrent()->url && strpos( + $this->languageUrl, + Language::getCurrent()->url + ) === 1 + ) { + $this->languageUrl = substr($this->languageUrl, strlen(Language::getCurrent()->url) + 1); + if (count(Language::getActive()) === 1 && !$this->isAjax) { + \Yii::$app->response->redirect('/', 302, false); + } + } + } + return $this->languageUrl; + } + + /** + * @inheritdoc + */ + protected function resolvePathInfo() + { + $pathInfo = $this->getLanguageUrl(); + + if (( $pos = strpos($pathInfo, '?') ) !== false) { + $pathInfo = substr($pathInfo, 0, $pos); + } + + $pathInfo = urldecode($pathInfo); + + if (!preg_match( + '%^(?: + [\x09\x0A\x0D\x20-\x7E] + | [\xC2-\xDF][\x80-\xBF] + | \xE0[\xA0-\xBF][\x80-\xBF] + | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} + | \xED[\x80-\x9F][\x80-\xBF] + | \xF0[\x90-\xBF][\x80-\xBF]{2} + | [\xF1-\xF3][\x80-\xBF]{3} + | \xF4[\x80-\x8F][\x80-\xBF]{2} + )*$%xs', + $pathInfo + ) + ) { + $pathInfo = utf8_encode($pathInfo); + } + + $scriptUrl = $this->getScriptUrl(); + $baseUrl = $this->getBaseUrl(); + + if (strpos($pathInfo, $scriptUrl) === 0) { + $pathInfo = substr($pathInfo, strlen($scriptUrl)); + } elseif ($baseUrl === '' || strpos($pathInfo, $baseUrl) === 0) { + $pathInfo = substr($pathInfo, strlen($baseUrl)); + } elseif (isset($_SERVER[ 'PHP_SELF' ]) && strpos($_SERVER[ 'PHP_SELF' ], $scriptUrl) === 0) { + $pathInfo = substr($_SERVER[ 'PHP_SELF' ], strlen($scriptUrl)); + } else { + throw new InvalidConfigException('Unable to determine the path info of the current request.'); + } + + if ($pathInfo === '/') { + $pathInfo = substr($pathInfo, 1); + } + + return (string) $pathInfo; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/components/SeoComponent.php b/artweb/artbox-core/components/SeoComponent.php new file mode 100644 index 0000000..20475cf --- /dev/null +++ b/artweb/artbox-core/components/SeoComponent.php @@ -0,0 +1,233 @@ +loaded; + } + + /** + * Setting alias model + * + * @param \artbox\core\models\interfaces\AliasInterface $alias + * + * @throws \artbox\core\exceptions\AliasOverwriteException + */ + public function setAlias(AliasInterface $alias) + { + if ($this->loaded) { + throw new AliasOverwriteException(); + } + + $this->alias = $alias; + + $this->title = $alias->getTitle(); + $this->desc = $alias->getDesc(); + $this->h1 = $alias->getH1(); + $this->text = $alias->getText(); + + $this->loaded = true; + } + + /** + * @return int + */ + public function getAliasId() + { + return $this->alias->getId(); + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @return string + */ + public function getDesc() + { + return $this->desc; + } + + /** + * @return string + */ + public function getH1() + { + return $this->h1; + } + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @return string + */ + public function getRobots() + { + if (!empty($this->alias) && !empty($this->alias->getRobots())) { + return $this->alias->getRobots(); + } + + return 'all'; + } + + /** + * Setting up ActiveRecord model and starting to generate data + * + * @param \yii\db\ActiveRecord $model + */ + public function setModel(ActiveRecord $model) + { + $this->model = $model; + + $this->generateData(); + } + + /** + * Trying to get field values with all dependecies + * if it fails fill it with empty string + * + * @return void + */ + protected function populateFields() + { + $fields = array_keys(Json::decode($this->alias->getFields()) ? : []); + foreach ($fields as $field) { + $params = explode('.', $field); + + $chain = $this->model; + + foreach ($params as $param) { + if (!empty($chain->$param)) { + $chain = $chain->$param; + } else { + $chain = ''; + break; + } + } + $this->fields[ '[[' . $field . ']]' ] = $chain; + } + } + + /** + * Populating self data with modified information from Alias model + * + * @return void + */ + protected function generateData() + { + $this->populateFields(); + + $title = $this->alias->getTitle(); + $desc = $this->alias->getDesc(); + $h1 = $this->alias->getH1(); + $text = $this->alias->getSeoText(); + + foreach ($this->fields as $search => $replace) { + $title = str_replace($search, $replace, $title); + $desc = str_replace($search, $replace, $desc); + $h1 = str_replace($search, $replace, $h1); + $text = str_replace($search, $replace, $text); + } + + $this->title = $title; + $this->desc = $desc; + $this->h1 = $h1; + $this->text = $text; + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/components/SeoUrlManager.php b/artweb/artbox-core/components/SeoUrlManager.php new file mode 100755 index 0000000..36acd2d --- /dev/null +++ b/artweb/artbox-core/components/SeoUrlManager.php @@ -0,0 +1,198 @@ +get('seo'); + + // This function called before url parsed by LanguageRequest, so $language is null + $request->getLanguageUrl(); + $language = Language::getCurrent(); + if ($request->pathInfo === '') { + // Do redirect if no active alias for homepage + $alias = Alias::findRoute([ 'site/index' ], $language); + if ($alias) { + $seo->setAlias($alias); + + $route = Json::decode($alias->route); + + $result[] = array_shift($route); + $result[] = $route; + + + return $result; + } + } else { + $alias = Alias::findUrl($request->pathInfo, $language); + } + if ($this->forceRedirect && empty($alias)) { + $get = $request->get(); + foreach ($get as $index => $item) { + if ($value = intval($item)) { + $get[ $index ] = $value; + } + } + $alias = Alias::findRoute(array_merge([ $request->pathInfo ], $get), $language); + if ($alias) { + \Yii::$app->response->redirect(Json::decode($alias->route)); + } + } + + if (!empty($alias)) { + /** + */ + $seo->setAlias($alias); + + $route = Json::decode($alias->route); + + $result[] = array_shift($route); + $result[] = $route; + + return $result; + } + + return parent::parseRequest($request); + } + + /** + * #1 Decide set or not language in the beginning of url (is there one active or more) + * #2 Add hash or not (is there $params['#'] or not) + * #3 Create url by ready alias or not + * #4 Does language setted from param ( $language_id ) + * +*@inheritdoc + */ + public function createUrl($params) + { + /** + * Decide how much active languages (1) + */ + $count = count(Language::getActive()); + + if ($params[ 0 ] === 'site/index') { + if ($count > 1) { + return '/'; + } else { + return '/' . Language::getCurrent()->url; + } + } + + /** + * (1,2,3) + */ + if (!empty($params[ 'alias' ]) && $params[ 'alias' ] instanceof Alias) { + /** + * @var Alias $alias + */ + $alias = $params[ 'alias' ]; + $language = Language::getCurrent(); + $hash = isset($params[ '#' ]) ? '#' . $params[ '#' ] : ''; + return ( $count > 1 ) ? ( '/' . $language->url . '/' . $alias->value ) : ( '/' . $alias->value ) . $hash; + } + + /** + * (4) + */ + if (!empty($params[ 'language_id' ])) { + $language = Language::findOne($params[ 'language_id' ]); + unset($params[ 'language_id' ]); + } + if (empty($language)) { + $language = Language::getCurrent(); + } + /** + * @var \artbox\core\components\AliasCache $cacheModel + */ + $cacheModel = \Yii::$app->get('aliasCache', false); + $rules = []; + foreach ($this->rules as $rule) { + if (!in_array($rule->route, $this->skipRoute)) { + $rules[] = $rule->route; + } + } + $diff = null; + if (!in_array($params[ 0 ], $rules)) { + if (count($params) > 2 && !empty($params[ 'id' ])) { + $aliasParams = [ + $params[ 0 ], + 'id' => $params[ 'id' ], + ]; + } else { + $aliasParams = $params; + } + if ($cacheModel) { + $alias = $cacheModel->getOrSet( + $aliasParams, + $language, + function () use ($aliasParams, $language) { + return Alias::findRoute($aliasParams, $language); + } + ); + } else { + $alias = Alias::findRoute($aliasParams, $language); + } + if (!empty($alias)) { + $diff = array_diff($params, $aliasParams); + } + } else { + $alias = null; + } + if (!empty($alias)) { + $value = $alias->value; + return ( $count > 1 ) ? ( '/' . $language->url . '/' . $value ) : ( '/' . $value ) . ( $diff ? ( '?' . http_build_query( + $diff + ) ) : '' ); + } else { + $url = parent::createUrl($params); + /** + * @var FilterHelper $filter + */ + if (class_exists('artbox\catalog\helpers\FilterHelper')) { + $filter = \Yii::$app->get('filter'); + $result = ( $count > 1 ) ? ( '/' . $language->url . $filter->filterObj->replaceFilterUrl( + $url + ) ) : $filter->filterObj->replaceFilterUrl($url); + } else { + $result = ( $count > 1 ) ? ( '/' . $language->url . $url ) : $url; + } + return $result; + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/components/Sitemap.php b/artweb/artbox-core/components/Sitemap.php new file mode 100755 index 0000000..973ed5c --- /dev/null +++ b/artweb/artbox-core/components/Sitemap.php @@ -0,0 +1,150 @@ +get('urlManagerFrontend'); + return $urlManager->createAbsoluteUrl('/' . $this->url); + } + + /** + * Check whether sitemap.xml exist + * + * @return bool + */ + public function checkFileExist(): bool + { + return file_exists(\Yii::getAlias($this->path)); + } + /** + * Generate sitemap XML in $path + * + * @return bool + */ + public function generateXML(): bool + { + return $this->saveXML($this->generateOneShot()); + } + + /** + * Save generated xml to $path file + * + * @param string $xml + * + * @return bool + */ + protected function saveXML(string $xml): bool + { + $realpath = \Yii::getAlias($this->path); + if (file_put_contents($realpath, $xml)) { + return true; + } else { + return false; + } + } + + /** + * Generate xml from configs + * + * @return string + */ + public function generateOneShot(): string + { + /** + * @var UrlManager $urlManager + */ + $urlManager = \Yii::$app->get('urlManagerFrontend'); + $content = ''; + $content .= ''; + /** + * @var SitemapStatic[] $static + */ + // ***** Begin generating static pages + $static = SitemapStatic::find() + ->all(); + foreach ($static as $item) { + $content .= Html::tag( + 'url', + Html::tag('loc', $item->url) . Html::tag('lastmod', date('Y-m-d')) . Html::tag( + 'changefreq', + $item->frequency + ) . Html::tag('priority', $item->priority) + ); + } + // ***** <<< End + /** + * @var SitemapDynamic $dynamic + */ + $dynamic = SitemapDynamic::find() + ->indexBy('entity') + ->where([ 'status' => 1 ]) + ->all(); + $entities = $this->entities; + foreach ($entities as $entity) { + /** + * @var string $class + */ + $class = $entity[ 'class' ]; + /** + * @var ActiveRecord $classInstance + */ + $classInstance = new $class(); + if (is_subclass_of($classInstance, ActiveRecord::className())) { + if (!empty($dynamic[ $class ])) { + /** + * @var SitemapDynamic $model + */ + $model = $dynamic[ $class ]; + $query = $classInstance::find(); + if (isset($entity[ 'conditions' ])) { + foreach ($entity[ 'conditions' ] as $condition) { + $query->where($condition); + } + } + $result = $query->all(); + foreach ($result as $record) { + $content .= Html::tag( + 'url', + Html::tag( + 'loc', + $urlManager->createAbsoluteUrl( + [ + $entity[ 'url' ], + 'id' => $record->getAttribute('id'), + ] + ) + ) . Html::tag('lastmod', date('Y-m-d')) . Html::tag( + 'changefreq', + $model->frequency + ) . Html::tag('priority', $model->priority) + ); + } + } + } + } + $content .= ''; + return $content; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/.gitignore b/artweb/artbox-core/components/imagemanager/.gitignore new file mode 100755 index 0000000..00495dc --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/.gitignore @@ -0,0 +1 @@ +/nbproject \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/Module.php b/artweb/artbox-core/components/imagemanager/Module.php new file mode 100755 index 0000000..07bc446 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/Module.php @@ -0,0 +1,187 @@ +i18n->translations[ 'imagemanager' ])) { + Yii::$app->i18n->translations[ 'imagemanager' ] = [ + 'class' => 'yii\i18n\PhpMessageSource', + 'sourceLanguage' => 'en', + 'basePath' => '@artbox/core/components/imagemanager/messages', + ]; + } + //check extensions + $this->_checkExtensionsExists(); + //check mediaPath isset + if (Yii::$app->imagemanager->mediaPath === null) { + throw new InvalidConfigException("Component param 'mediaPath' need to be set to a location"); + } + //set asset path + $this->assetPublishedUrl = ( new AssetManager )->getPublishedUrl( + "@artbox/core/components/imagemanager/assets/source" + ); + + // Check if the canRemoveImage variable is callable + if (is_callable($this->canRemoveImage)) { + $this->canRemoveImage = call_user_func($this->canRemoveImage); + } + + // Check if the canUploadImage variable is callable + if (is_callable($this->canUploadImage)) { + $this->canUploadImage = call_user_func($this->canUploadImage); + } + + // Check if blameable behavior is callable + if (is_callable($this->setBlameableBehavior)) { + $this->setBlameableBehavior = call_user_func($this->setBlameableBehavior); + } + + // Check if the variable configuration is correct in order for the module to function + $this->_checkVariableConfiguration(); + } + + /** + * @inheritdoc + */ + public function beforeAction($action) + { + if (parent::beforeAction($action)) { + //set view + $view = $action->controller->getView(); + + //set asset + ImageManagerModuleAsset::register($view); + + //get parameters + $viewMode = Yii::$app->request->get("view-mode", "page"); + + /* @var $action \yii\base\Action */ + if ($viewMode == "iframe") { + //set stylesheet for modal + if (is_array($this->cssFiles) && count($this->cssFiles) > 0) { + //if exists loop through files and add them to iframe mode + foreach ($this->cssFiles AS $cssFile) { + //registrate file + $view->registerCssFile($cssFile, [ 'depends' => 'yii\bootstrap\BootstrapAsset' ]); + } + } + } + return true; + } + return false; + } + + /** + * Check if extensions exists + * + * @throws UnknownClassException Throw error if extension is not found + */ + private function _checkExtensionsExists() + { + //kartik file uploaded is installed + if (!class_exists('kartik\file\FileInput')) { + throw new UnknownClassException( + "Can't find: kartik\\file\FileInput. Install \"kartik-v/yii2-widget-fileinput\": \"@dev\"" + ); + } + //check Yii imagine is installed + if (!class_exists('yii\imagine\Image')) { + throw new UnknownClassException( + "Can't find: yii\imagine\Image. Install \"yiisoft/yii2-imagine\": \"~2.0.0\"" + ); + } + } + + /** + * Check if the module variables have the content that is expected + * + * @throws InvalidConfigException + */ + private function _checkVariableConfiguration() + { + // Check if the canUploadImage is boolean + if (!is_bool($this->canUploadImage)) { + throw new InvalidConfigException( + '$canUploadImage variable only supports a boolean value, if you have a custom function you must return a boolean' + ); + } + // Check if the canRemoveImage is boolean + if (!is_bool($this->canRemoveImage)) { + throw new InvalidConfigException( + '$removeImageAllowed variable only supports a boolean value, if you have a custom function you must return a boolean' + ); + } + // Check if the setBlamableBehavior is boolean + if (!is_bool($this->setBlameableBehavior)) { + throw new InvalidConfigException( + '$setBlameableBehavior only supports a boolean value, if you have a customer function make sure that you return a boolean' + ); + } + + // Check if the blameable behavior is set to true + if ($this->setBlameableBehavior) { + // Get the migration record + $mRecordMigrationRun = Yii::$app->db->createCommand( + 'SELECT * FROM `migration` WHERE `version` = \'m170223_113221_addBlameableBehavior\'' + ) + ->queryOne(); + if ($mRecordMigrationRun === false) { + throw new InvalidConfigException( + 'Image Manager: You have not run the latest migration, see the documentation how to do this.' + ); + } + } + } + + } diff --git a/artweb/artbox-core/components/imagemanager/assets/ImageManagerInputAsset.php b/artweb/artbox-core/components/imagemanager/assets/ImageManagerInputAsset.php new file mode 100755 index 0000000..497cc6e --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/assets/ImageManagerInputAsset.php @@ -0,0 +1,22 @@ + .row { + margin: 0; +} + +#module-imagemanager.tinymce, +#module-imagemanager.ckeditor { + padding: 15px; +} + +/*overview*/ +#module-imagemanager > .row .col-overview { + padding-left: 0; + padding-right: 0; + border-right: 1px solid #ddd; + height: 100%; + overflow: auto; +} + +#module-imagemanager > .row .col-overview .item-overview { + max-height: 500px; + overflow: auto; +} + +#module-imagemanager > .row .col-overview .item-overview .item { + position: relative; + overflow: hidden; + width: 128px; + height: 128px; + cursor: pointer; +} + +#module-imagemanager > .row .col-overview .item-overview .item.selected { + background: #00ac24; +} + +#module-imagemanager > .row .col-overview .item-overview .item .thumbnail { + margin-bottom: 0; +} + +#module-imagemanager > .row .col-overview .item-overview .item .thumbnail img { + max-height: 118px; + background: #dadada; +} + +#module-imagemanager > .row .col-overview .item-overview .item .thumbnail .filename { + background-color: rgba(255, 255, 255, 0.9); + position: absolute; + bottom: 4px; + left: 4px; + right: 4px; + max-height: 100%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + padding: 0 10px; +} + +/*edit column*/ +#module-imagemanager > .row .col-image-editor { + padding-left: 0; + display: none; +} + +/*cropper*/ +#module-imagemanager > .row .col-image-editor .image-cropper .image-wrapper { + max-height: 460px; +} + +#module-imagemanager > .row .col-image-editor .image-cropper .image-wrapper img#image-cropper { + max-width: 100%; +} + +/*options*/ +#module-imagemanager > .row .col-options { + padding-right: 0; +} + +/*File upload*/ +#module-imagemanager > .row .col-options .file-input .form-control { + display: none; +} + +#module-imagemanager > .row .col-options .form-group .file-input .input-group, +#module-imagemanager > .row .col-options .form-group .file-input .input-group .input-group-btn { + float: left; +} + +#module-imagemanager > .row .col-options .form-group .btn-add-flyleaf { + float: left; +} + +/*details*/ +#module-imagemanager > .row .col-options .image-info { + margin-top: 10px; +} + +#module-imagemanager > .row .col-options .image-info .thumbnail { + margin-bottom: 10px; +} + +#module-imagemanager > .row .col-options .image-info .thumbnail img { + max-width: 100%; + background: #dadada; +} + +#module-imagemanager > .row .col-options .image-info .edit-buttons { + margin-bottom: 10px; +} + +#module-imagemanager > .row .col-options .image-info .details { +} + +#module-imagemanager > .row .col-options .image-info .details .fileName { + font-weight: bold; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +#module-imagemanager > .row .col-options .image-info .pick-image-item { + margin-top: 10px; +} + +#module-imagemanager a.delete-image-item { + margin-top: 5px; +} \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/assets/source/img/img_no-image.png b/artweb/artbox-core/components/imagemanager/assets/source/img/img_no-image.png new file mode 100755 index 0000000..db21bde Binary files /dev/null and b/artweb/artbox-core/components/imagemanager/assets/source/img/img_no-image.png differ diff --git a/artweb/artbox-core/components/imagemanager/assets/source/js/cropper.min.js b/artweb/artbox-core/components/imagemanager/assets/source/js/cropper.min.js new file mode 100755 index 0000000..ded4bb1 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/assets/source/js/cropper.min.js @@ -0,0 +1,10 @@ +/*! + * Cropper v2.3.2 + * https://github.com/fengyuanchen/cropper + * + * Copyright (c) 2014-2016 Fengyuan Chen and contributors + * Released under the MIT license + * + * Date: 2016-06-08T12:14:46.286Z + */ +!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){"use strict";function i(t){return"number"==typeof t&&!isNaN(t)}function e(t){return"undefined"==typeof t}function s(t,e){var s=[];return i(e)&&s.push(e),s.slice.apply(t,s)}function a(t,i){var e=s(arguments,2);return function(){return t.apply(i,e.concat(s(arguments)))}}function o(t){var i=t.match(/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i);return i&&(i[1]!==C.protocol||i[2]!==C.hostname||i[3]!==C.port)}function h(t){var i="timestamp="+(new Date).getTime();return t+(-1===t.indexOf("?")?"?":"&")+i}function n(t){return t?' crossOrigin="'+t+'"':""}function r(t,i){var e;return t.naturalWidth&&!mt?i(t.naturalWidth,t.naturalHeight):(e=document.createElement("img"),e.onload=function(){i(this.width,this.height)},void(e.src=t.src))}function p(t){var e=[],s=t.rotate,a=t.scaleX,o=t.scaleY;return i(a)&&i(o)&&e.push("scale("+a+","+o+")"),i(s)&&e.push("rotate("+s+"deg)"),e.length?e.join(" "):"none"}function c(t,i){var e,s,a=Ct(t.degree)%180,o=(a>90?180-a:a)*Math.PI/180,h=bt(o),n=Bt(o),r=t.width,p=t.height,c=t.aspectRatio;return i?(e=r/(n+h/c),s=e/c):(e=r*n+p*h,s=r*h+p*n),{width:e,height:s}}function l(e,s){var a,o,h,n=t("")[0],r=n.getContext("2d"),p=0,l=0,d=s.naturalWidth,g=s.naturalHeight,u=s.rotate,f=s.scaleX,m=s.scaleY,v=i(f)&&i(m)&&(1!==f||1!==m),w=i(u)&&0!==u,x=w||v,C=d*Ct(f||1),b=g*Ct(m||1);return v&&(a=C/2,o=b/2),w&&(h=c({width:C,height:b,degree:u}),C=h.width,b=h.height,a=C/2,o=b/2),n.width=C,n.height=b,x&&(p=-d/2,l=-g/2,r.save(),r.translate(a,o)),v&&r.scale(f,m),w&&r.rotate(u*Math.PI/180),r.drawImage(e,$t(p),$t(l),$t(d),$t(g)),x&&r.restore(),n}function d(i){var e=i.length,s=0,a=0;return e&&(t.each(i,function(t,i){s+=i.pageX,a+=i.pageY}),s/=e,a/=e),{pageX:s,pageY:a}}function g(t,i,e){var s,a="";for(s=i,e+=i;e>s;s++)a+=Lt(t.getUint8(s));return a}function u(t){var i,e,s,a,o,h,n,r,p,c,l=new D(t),d=l.byteLength;if(255===l.getUint8(0)&&216===l.getUint8(1))for(p=2;d>p;){if(255===l.getUint8(p)&&225===l.getUint8(p+1)){n=p;break}p++}if(n&&(e=n+4,s=n+10,"Exif"===g(l,e,4)&&(h=l.getUint16(s),o=18761===h,(o||19789===h)&&42===l.getUint16(s+2,o)&&(a=l.getUint32(s+4,o),a>=8&&(r=s+a)))),r)for(d=l.getUint16(r,o),c=0;d>c;c++)if(p=r+12*c+2,274===l.getUint16(p,o)){p+=8,i=l.getUint16(p,o),mt&&l.setUint16(p,1,o);break}return i}function f(t){var i,e=t.replace(G,""),s=atob(e),a=s.length,o=new B(a),h=new y(o);for(i=0;a>i;i++)h[i]=s.charCodeAt(i);return o}function m(t){var i,e=new y(t),s=e.length,a="";for(i=0;s>i;i++)a+=Lt(e[i]);return"data:image/jpeg;base64,"+$(a)}function v(i,e){this.$element=t(i),this.options=t.extend({},v.DEFAULTS,t.isPlainObject(e)&&e),this.isLoaded=!1,this.isBuilt=!1,this.isCompleted=!1,this.isRotated=!1,this.isCropped=!1,this.isDisabled=!1,this.isReplaced=!1,this.isLimited=!1,this.wheeling=!1,this.isImg=!1,this.originalUrl="",this.canvas=null,this.cropBox=null,this.init()}var w=t(window),x=t(document),C=window.location,b=window.navigator,B=window.ArrayBuffer,y=window.Uint8Array,D=window.DataView,$=window.btoa,L="cropper",T="cropper-modal",X="cropper-hide",Y="cropper-hidden",k="cropper-invisible",M="cropper-move",W="cropper-crop",H="cropper-disabled",R="cropper-bg",z="mousedown touchstart pointerdown MSPointerDown",O="mousemove touchmove pointermove MSPointerMove",P="mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",E="wheel mousewheel DOMMouseScroll",U="dblclick",I="load."+L,F="error."+L,j="resize."+L,A="build."+L,S="built."+L,N="cropstart."+L,_="cropmove."+L,q="cropend."+L,K="crop."+L,Z="zoom."+L,Q=/e|w|s|n|se|sw|ne|nw|all|crop|move|zoom/,V=/^data\:/,G=/^data\:([^\;]+)\;base64,/,J=/^data\:image\/jpeg.*;base64,/,tt="preview",it="action",et="e",st="w",at="s",ot="n",ht="se",nt="sw",rt="ne",pt="nw",ct="all",lt="crop",dt="move",gt="zoom",ut="none",ft=t.isFunction(t("")[0].getContext),mt=b&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(b.userAgent),vt=Number,wt=Math.min,xt=Math.max,Ct=Math.abs,bt=Math.sin,Bt=Math.cos,yt=Math.sqrt,Dt=Math.round,$t=Math.floor,Lt=String.fromCharCode;v.prototype={constructor:v,init:function(){var t,i=this.$element;if(i.is("img")){if(this.isImg=!0,this.originalUrl=t=i.attr("src"),!t)return;t=i.prop("src")}else i.is("canvas")&&ft&&(t=i[0].toDataURL());this.load(t)},trigger:function(i,e){var s=t.Event(i,e);return this.$element.trigger(s),s},load:function(i){var e,s,a=this.options,n=this.$element;if(i&&(n.one(A,a.build),!this.trigger(A).isDefaultPrevented())){if(this.url=i,this.image={},!a.checkOrientation||!B)return this.clone();if(e=t.proxy(this.read,this),V.test(i))return J.test(i)?e(f(i)):this.clone();s=new XMLHttpRequest,s.onerror=s.onabort=t.proxy(function(){this.clone()},this),s.onload=function(){e(this.response)},a.checkCrossOrigin&&o(i)&&n.prop("crossOrigin")&&(i=h(i)),s.open("get",i),s.responseType="arraybuffer",s.send()}},read:function(t){var i,e,s,a=this.options,o=u(t),h=this.image;if(o>1)switch(this.url=m(t),o){case 2:e=-1;break;case 3:i=-180;break;case 4:s=-1;break;case 5:i=90,s=-1;break;case 6:i=90;break;case 7:i=90,e=-1;break;case 8:i=-90}a.rotatable&&(h.rotate=i),a.scalable&&(h.scaleX=e,h.scaleY=s),this.clone()},clone:function(){var i,e,s=this.options,a=this.$element,r=this.url,p="";s.checkCrossOrigin&&o(r)&&(p=a.prop("crossOrigin"),p?i=r:(p="anonymous",i=h(r))),this.crossOrigin=p,this.crossOriginUrl=i,this.$clone=e=t("'),this.isImg?a[0].complete?this.start():a.one(I,t.proxy(this.start,this)):e.one(I,t.proxy(this.start,this)).one(F,t.proxy(this.stop,this)).addClass(X).insertAfter(a)},start:function(){var i=this.$element,e=this.$clone;this.isImg||(e.off(F,this.stop),i=e),r(i[0],t.proxy(function(i,e){t.extend(this.image,{naturalWidth:i,naturalHeight:e,aspectRatio:i/e}),this.isLoaded=!0,this.build()},this))},stop:function(){this.$clone.remove(),this.$clone=null},build:function(){var i,e,s,a=this.options,o=this.$element,h=this.$clone;this.isLoaded&&(this.isBuilt&&this.unbuild(),this.$container=o.parent(),this.$cropper=i=t(v.TEMPLATE),this.$canvas=i.find(".cropper-canvas").append(h),this.$dragBox=i.find(".cropper-drag-box"),this.$cropBox=e=i.find(".cropper-crop-box"),this.$viewBox=i.find(".cropper-view-box"),this.$face=s=e.find(".cropper-face"),o.addClass(Y).after(i),this.isImg||h.removeClass(X),this.initPreview(),this.bind(),a.aspectRatio=xt(0,a.aspectRatio)||NaN,a.viewMode=xt(0,wt(3,Dt(a.viewMode)))||0,a.autoCrop?(this.isCropped=!0,a.modal&&this.$dragBox.addClass(T)):e.addClass(Y),a.guides||e.find(".cropper-dashed").addClass(Y),a.center||e.find(".cropper-center").addClass(Y),a.cropBoxMovable&&s.addClass(M).data(it,ct),a.highlight||s.addClass(k),a.background&&i.addClass(R),a.cropBoxResizable||e.find(".cropper-line, .cropper-point").addClass(Y),this.setDragMode(a.dragMode),this.render(),this.isBuilt=!0,this.setData(a.data),o.one(S,a.built),setTimeout(t.proxy(function(){this.trigger(S),this.trigger(K,this.getData()),this.isCompleted=!0},this),0))},unbuild:function(){this.isBuilt&&(this.isBuilt=!1,this.isCompleted=!1,this.initialImage=null,this.initialCanvas=null,this.initialCropBox=null,this.container=null,this.canvas=null,this.cropBox=null,this.unbind(),this.resetPreview(),this.$preview=null,this.$viewBox=null,this.$cropBox=null,this.$dragBox=null,this.$canvas=null,this.$container=null,this.$cropper.remove(),this.$cropper=null)},render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.isCropped&&this.renderCropBox()},initContainer:function(){var t=this.options,i=this.$element,e=this.$container,s=this.$cropper;s.addClass(Y),i.removeClass(Y),s.css(this.container={width:xt(e.width(),vt(t.minContainerWidth)||200),height:xt(e.height(),vt(t.minContainerHeight)||100)}),i.addClass(Y),s.removeClass(Y)},initCanvas:function(){var i,e=this.options.viewMode,s=this.container,a=s.width,o=s.height,h=this.image,n=h.naturalWidth,r=h.naturalHeight,p=90===Ct(h.rotate),c=p?r:n,l=p?n:r,d=c/l,g=a,u=o;o*d>a?3===e?g=o*d:u=a/d:3===e?u=a/d:g=o*d,i={naturalWidth:c,naturalHeight:l,aspectRatio:d,width:g,height:u},i.oldLeft=i.left=(a-g)/2,i.oldTop=i.top=(o-u)/2,this.canvas=i,this.isLimited=1===e||2===e,this.limitCanvas(!0,!0),this.initialImage=t.extend({},h),this.initialCanvas=t.extend({},i)},limitCanvas:function(t,i){var e,s,a,o,h=this.options,n=h.viewMode,r=this.container,p=r.width,c=r.height,l=this.canvas,d=l.aspectRatio,g=this.cropBox,u=this.isCropped&&g;t&&(e=vt(h.minCanvasWidth)||0,s=vt(h.minCanvasHeight)||0,n&&(n>1?(e=xt(e,p),s=xt(s,c),3===n&&(s*d>e?e=s*d:s=e/d)):e?e=xt(e,u?g.width:0):s?s=xt(s,u?g.height:0):u&&(e=g.width,s=g.height,s*d>e?e=s*d:s=e/d)),e&&s?s*d>e?s=e/d:e=s*d:e?s=e/d:s&&(e=s*d),l.minWidth=e,l.minHeight=s,l.maxWidth=1/0,l.maxHeight=1/0),i&&(n?(a=p-l.width,o=c-l.height,l.minLeft=wt(0,a),l.minTop=wt(0,o),l.maxLeft=xt(0,a),l.maxTop=xt(0,o),u&&this.isLimited&&(l.minLeft=wt(g.left,g.left+g.width-l.width),l.minTop=wt(g.top,g.top+g.height-l.height),l.maxLeft=g.left,l.maxTop=g.top,2===n&&(l.width>=p&&(l.minLeft=wt(0,a),l.maxLeft=xt(0,a)),l.height>=c&&(l.minTop=wt(0,o),l.maxTop=xt(0,o))))):(l.minLeft=-l.width,l.minTop=-l.height,l.maxLeft=p,l.maxTop=c))},renderCanvas:function(t){var i,e,s=this.canvas,a=this.image,o=a.rotate,h=a.naturalWidth,n=a.naturalHeight;this.isRotated&&(this.isRotated=!1,e=c({width:a.width,height:a.height,degree:o}),i=e.width/e.height,i!==s.aspectRatio&&(s.left-=(e.width-s.width)/2,s.top-=(e.height-s.height)/2,s.width=e.width,s.height=e.height,s.aspectRatio=i,s.naturalWidth=h,s.naturalHeight=n,o%180&&(e=c({width:h,height:n,degree:o}),s.naturalWidth=e.width,s.naturalHeight=e.height),this.limitCanvas(!0,!1))),(s.width>s.maxWidth||s.widths.maxHeight||s.heighte.width?o.height=o.width/s:o.width=o.height*s),this.cropBox=o,this.limitCropBox(!0,!0),o.width=wt(xt(o.width,o.minWidth),o.maxWidth),o.height=wt(xt(o.height,o.minHeight),o.maxHeight),o.width=xt(o.minWidth,o.width*a),o.height=xt(o.minHeight,o.height*a),o.oldLeft=o.left=e.left+(e.width-o.width)/2,o.oldTop=o.top=e.top+(e.height-o.height)/2,this.initialCropBox=t.extend({},o)},limitCropBox:function(t,i){var e,s,a,o,h=this.options,n=h.aspectRatio,r=this.container,p=r.width,c=r.height,l=this.canvas,d=this.cropBox,g=this.isLimited;t&&(e=vt(h.minCropBoxWidth)||0,s=vt(h.minCropBoxHeight)||0,e=wt(e,p),s=wt(s,c),a=wt(p,g?l.width:p),o=wt(c,g?l.height:c),n&&(e&&s?s*n>e?s=e/n:e=s*n:e?s=e/n:s&&(e=s*n),o*n>a?o=a/n:a=o*n),d.minWidth=wt(e,a),d.minHeight=wt(s,o),d.maxWidth=a,d.maxHeight=o),i&&(g?(d.minLeft=xt(0,l.left),d.minTop=xt(0,l.top),d.maxLeft=wt(p,l.left+l.width)-d.width,d.maxTop=wt(c,l.top+l.height)-d.height):(d.minLeft=0,d.minTop=0,d.maxLeft=p-d.width,d.maxTop=c-d.height))},renderCropBox:function(){var t=this.options,i=this.container,e=i.width,s=i.height,a=this.cropBox;(a.width>a.maxWidth||a.widtha.maxHeight||a.height'),this.$viewBox.html(i),this.$preview.each(function(){var i=t(this);i.data(tt,{width:i.width(),height:i.height(),html:i.html()}),i.html("')})},resetPreview:function(){this.$preview.each(function(){var i=t(this),e=i.data(tt);i.css({width:e.width,height:e.height}).html(e.html).removeData(tt)})},preview:function(){var i=this.image,e=this.canvas,s=this.cropBox,a=s.width,o=s.height,h=i.width,n=i.height,r=s.left-e.left-i.left,c=s.top-e.top-i.top;this.isCropped&&!this.isDisabled&&(this.$clone2.css({width:h,height:n,marginLeft:-r,marginTop:-c,transform:p(i)}),this.$preview.each(function(){var e=t(this),s=e.data(tt),l=s.width,d=s.height,g=l,u=d,f=1;a&&(f=l/a,u=o*f),o&&u>d&&(f=d/o,g=a*f,u=d),e.css({width:g,height:u}).find("img").css({width:h*f,height:n*f,marginLeft:-r*f,marginTop:-c*f,transform:p(i)})}))},bind:function(){var i=this.options,e=this.$element,s=this.$cropper;t.isFunction(i.cropstart)&&e.on(N,i.cropstart),t.isFunction(i.cropmove)&&e.on(_,i.cropmove),t.isFunction(i.cropend)&&e.on(q,i.cropend),t.isFunction(i.crop)&&e.on(K,i.crop),t.isFunction(i.zoom)&&e.on(Z,i.zoom),s.on(z,t.proxy(this.cropStart,this)),i.zoomable&&i.zoomOnWheel&&s.on(E,t.proxy(this.wheel,this)),i.toggleDragModeOnDblclick&&s.on(U,t.proxy(this.dblclick,this)),x.on(O,this._cropMove=a(this.cropMove,this)).on(P,this._cropEnd=a(this.cropEnd,this)),i.responsive&&w.on(j,this._resize=a(this.resize,this))},unbind:function(){var i=this.options,e=this.$element,s=this.$cropper;t.isFunction(i.cropstart)&&e.off(N,i.cropstart),t.isFunction(i.cropmove)&&e.off(_,i.cropmove),t.isFunction(i.cropend)&&e.off(q,i.cropend),t.isFunction(i.crop)&&e.off(K,i.crop),t.isFunction(i.zoom)&&e.off(Z,i.zoom),s.off(z,this.cropStart),i.zoomable&&i.zoomOnWheel&&s.off(E,this.wheel),i.toggleDragModeOnDblclick&&s.off(U,this.dblclick),x.off(O,this._cropMove).off(P,this._cropEnd),i.responsive&&w.off(j,this._resize)},resize:function(){var i,e,s,a=this.options.restore,o=this.$container,h=this.container;!this.isDisabled&&h&&(s=o.width()/h.width,1===s&&o.height()===h.height||(a&&(i=this.getCanvasData(),e=this.getCropBoxData()),this.render(),a&&(this.setCanvasData(t.each(i,function(t,e){i[t]=e*s})),this.setCropBoxData(t.each(e,function(t,i){e[t]=i*s})))))},dblclick:function(){this.isDisabled||(this.$dragBox.hasClass(W)?this.setDragMode(dt):this.setDragMode(lt))},wheel:function(i){var e=i.originalEvent||i,s=vt(this.options.wheelZoomRatio)||.1,a=1;this.isDisabled||(i.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(t.proxy(function(){this.wheeling=!1},this),50),e.deltaY?a=e.deltaY>0?1:-1:e.wheelDelta?a=-e.wheelDelta/120:e.detail&&(a=e.detail>0?1:-1),this.zoom(-a*s,i)))},cropStart:function(i){var e,s,a=this.options,o=i.originalEvent,h=o&&o.touches,n=i;if(!this.isDisabled){if(h){if(e=h.length,e>1){if(!a.zoomable||!a.zoomOnTouch||2!==e)return;n=h[1],this.startX2=n.pageX,this.startY2=n.pageY,s=gt}n=h[0]}if(s=s||t(n.target).data(it),Q.test(s)){if(this.trigger(N,{originalEvent:o,action:s}).isDefaultPrevented())return;i.preventDefault(),this.action=s,this.cropping=!1,this.startX=n.pageX||o&&o.pageX,this.startY=n.pageY||o&&o.pageY,s===lt&&(this.cropping=!0,this.$dragBox.addClass(T))}}},cropMove:function(t){var i,e=this.options,s=t.originalEvent,a=s&&s.touches,o=t,h=this.action;if(!this.isDisabled){if(a){if(i=a.length,i>1){if(!e.zoomable||!e.zoomOnTouch||2!==i)return;o=a[1],this.endX2=o.pageX,this.endY2=o.pageY}o=a[0]}if(h){if(this.trigger(_,{originalEvent:s,action:h}).isDefaultPrevented())return;t.preventDefault(),this.endX=o.pageX||s&&s.pageX,this.endY=o.pageY||s&&s.pageY,this.change(o.shiftKey,h===gt?t:null)}}},cropEnd:function(t){var i=t.originalEvent,e=this.action;this.isDisabled||e&&(t.preventDefault(),this.cropping&&(this.cropping=!1,this.$dragBox.toggleClass(T,this.isCropped&&this.options.modal)),this.action="",this.trigger(q,{originalEvent:i,action:e}))},change:function(t,i){var e,s,a=this.options,o=a.aspectRatio,h=this.action,n=this.container,r=this.canvas,p=this.cropBox,c=p.width,l=p.height,d=p.left,g=p.top,u=d+c,f=g+l,m=0,v=0,w=n.width,x=n.height,C=!0;switch(!o&&t&&(o=c&&l?c/l:1),this.isLimited&&(m=p.minLeft,v=p.minTop,w=m+wt(n.width,r.left+r.width),x=v+wt(n.height,r.top+r.height)),s={x:this.endX-this.startX,y:this.endY-this.startY},o&&(s.X=s.y*o,s.Y=s.x/o),h){case ct:d+=s.x,g+=s.y;break;case et:if(s.x>=0&&(u>=w||o&&(v>=g||f>=x))){C=!1;break}c+=s.x,o&&(l=c/o,g-=s.Y/2),0>c&&(h=st,c=0);break;case ot:if(s.y<=0&&(v>=g||o&&(m>=d||u>=w))){C=!1;break}l-=s.y,g+=s.y,o&&(c=l*o,d+=s.X/2),0>l&&(h=at,l=0);break;case st:if(s.x<=0&&(m>=d||o&&(v>=g||f>=x))){C=!1;break}c-=s.x,d+=s.x,o&&(l=c/o,g+=s.Y/2),0>c&&(h=et,c=0);break;case at:if(s.y>=0&&(f>=x||o&&(m>=d||u>=w))){C=!1;break}l+=s.y,o&&(c=l*o,d-=s.X/2),0>l&&(h=ot,l=0);break;case rt:if(o){if(s.y<=0&&(v>=g||u>=w)){C=!1;break}l-=s.y,g+=s.y,c=l*o}else s.x>=0?w>u?c+=s.x:s.y<=0&&v>=g&&(C=!1):c+=s.x,s.y<=0?g>v&&(l-=s.y,g+=s.y):(l-=s.y,g+=s.y);0>c&&0>l?(h=nt,l=0,c=0):0>c?(h=pt,c=0):0>l&&(h=ht,l=0);break;case pt:if(o){if(s.y<=0&&(v>=g||m>=d)){C=!1;break}l-=s.y,g+=s.y,c=l*o,d+=s.X}else s.x<=0?d>m?(c-=s.x,d+=s.x):s.y<=0&&v>=g&&(C=!1):(c-=s.x,d+=s.x),s.y<=0?g>v&&(l-=s.y,g+=s.y):(l-=s.y,g+=s.y);0>c&&0>l?(h=ht,l=0,c=0):0>c?(h=rt,c=0):0>l&&(h=nt,l=0);break;case nt:if(o){if(s.x<=0&&(m>=d||f>=x)){C=!1;break}c-=s.x,d+=s.x,l=c/o}else s.x<=0?d>m?(c-=s.x,d+=s.x):s.y>=0&&f>=x&&(C=!1):(c-=s.x,d+=s.x),s.y>=0?x>f&&(l+=s.y):l+=s.y;0>c&&0>l?(h=rt,l=0,c=0):0>c?(h=ht,c=0):0>l&&(h=pt,l=0);break;case ht:if(o){if(s.x>=0&&(u>=w||f>=x)){C=!1;break}c+=s.x,l=c/o}else s.x>=0?w>u?c+=s.x:s.y>=0&&f>=x&&(C=!1):c+=s.x,s.y>=0?x>f&&(l+=s.y):l+=s.y;0>c&&0>l?(h=pt,l=0,c=0):0>c?(h=nt,c=0):0>l&&(h=rt,l=0);break;case dt:this.move(s.x,s.y),C=!1;break;case gt:this.zoom(function(t,i,e,s){var a=yt(t*t+i*i),o=yt(e*e+s*s);return(o-a)/a}(Ct(this.startX-this.startX2),Ct(this.startY-this.startY2),Ct(this.endX-this.endX2),Ct(this.endY-this.endY2)),i),this.startX2=this.endX2,this.startY2=this.endY2,C=!1;break;case lt:if(!s.x||!s.y){C=!1;break}e=this.$cropper.offset(),d=this.startX-e.left,g=this.startY-e.top,c=p.minWidth,l=p.minHeight,s.x>0?h=s.y>0?ht:rt:s.x<0&&(d-=c,h=s.y>0?nt:pt),s.y<0&&(g-=l),this.isCropped||(this.$cropBox.removeClass(Y),this.isCropped=!0,this.isLimited&&this.limitCropBox(!0,!0))}C&&(p.width=c,p.height=l,p.left=d,p.top=g,this.action=h,this.renderCropBox()),this.startX=this.endX,this.startY=this.endY},crop:function(){this.isBuilt&&!this.isDisabled&&(this.isCropped||(this.isCropped=!0,this.limitCropBox(!0,!0),this.options.modal&&this.$dragBox.addClass(T),this.$cropBox.removeClass(Y)),this.setCropBoxData(this.initialCropBox))},reset:function(){this.isBuilt&&!this.isDisabled&&(this.image=t.extend({},this.initialImage),this.canvas=t.extend({},this.initialCanvas),this.cropBox=t.extend({},this.initialCropBox),this.renderCanvas(),this.isCropped&&this.renderCropBox())},clear:function(){this.isCropped&&!this.isDisabled&&(t.extend(this.cropBox,{left:0,top:0,width:0,height:0}),this.isCropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),this.$dragBox.removeClass(T),this.$cropBox.addClass(Y))},replace:function(t,i){!this.isDisabled&&t&&(this.isImg&&this.$element.attr("src",t),i?(this.url=t,this.$clone.attr("src",t),this.isBuilt&&this.$preview.find("img").add(this.$clone2).attr("src",t)):(this.isImg&&(this.isReplaced=!0),this.options.data=null,this.load(t)))},enable:function(){this.isBuilt&&(this.isDisabled=!1,this.$cropper.removeClass(H))},disable:function(){this.isBuilt&&(this.isDisabled=!0,this.$cropper.addClass(H))},destroy:function(){var t=this.$element;this.isLoaded?(this.isImg&&this.isReplaced&&t.attr("src",this.originalUrl),this.unbuild(),t.removeClass(Y)):this.isImg?t.off(I,this.start):this.$clone&&this.$clone.remove(),t.removeData(L)},move:function(t,i){var s=this.canvas;this.moveTo(e(t)?t:s.left+vt(t),e(i)?i:s.top+vt(i))},moveTo:function(t,s){var a=this.canvas,o=!1;e(s)&&(s=t),t=vt(t),s=vt(s),this.isBuilt&&!this.isDisabled&&this.options.movable&&(i(t)&&(a.left=t,o=!0),i(s)&&(a.top=s,o=!0),o&&this.renderCanvas(!0))},zoom:function(t,i){var e=this.canvas;t=vt(t),t=0>t?1/(1-t):1+t,this.zoomTo(e.width*t/e.naturalWidth,i)},zoomTo:function(t,i){var e,s,a,o,h,n=this.options,r=this.canvas,p=r.width,c=r.height,l=r.naturalWidth,g=r.naturalHeight;if(t=vt(t),t>=0&&this.isBuilt&&!this.isDisabled&&n.zoomable){if(s=l*t,a=g*t,i&&(e=i.originalEvent),this.trigger(Z,{originalEvent:e,oldRatio:p/l,ratio:s/l}).isDefaultPrevented())return;e?(o=this.$cropper.offset(),h=e.touches?d(e.touches):{pageX:i.pageX||e.pageX||0,pageY:i.pageY||e.pageY||0},r.left-=(s-p)*((h.pageX-o.left-r.left)/p),r.top-=(a-c)*((h.pageY-o.top-r.top)/c)):(r.left-=(s-p)/2,r.top-=(a-c)/2),r.width=s,r.height=a,this.renderCanvas(!0)}},rotate:function(t){this.rotateTo((this.image.rotate||0)+vt(t))},rotateTo:function(t){t=vt(t),i(t)&&this.isBuilt&&!this.isDisabled&&this.options.rotatable&&(this.image.rotate=t%360,this.isRotated=!0,this.renderCanvas(!0))},scale:function(t,s){var a=this.image,o=!1;e(s)&&(s=t),t=vt(t),s=vt(s),this.isBuilt&&!this.isDisabled&&this.options.scalable&&(i(t)&&(a.scaleX=t,o=!0),i(s)&&(a.scaleY=s,o=!0),o&&this.renderImage(!0))},scaleX:function(t){var e=this.image.scaleY;this.scale(t,i(e)?e:1)},scaleY:function(t){var e=this.image.scaleX;this.scale(i(e)?e:1,t)},getData:function(i){var e,s,a=this.options,o=this.image,h=this.canvas,n=this.cropBox;return this.isBuilt&&this.isCropped?(s={x:n.left-h.left,y:n.top-h.top,width:n.width,height:n.height},e=o.width/o.naturalWidth,t.each(s,function(t,a){a/=e,s[t]=i?Dt(a):a})):s={x:0,y:0,width:0,height:0},a.rotatable&&(s.rotate=o.rotate||0),a.scalable&&(s.scaleX=o.scaleX||1,s.scaleY=o.scaleY||1),s},setData:function(e){var s,a,o,h=this.options,n=this.image,r=this.canvas,p={};t.isFunction(e)&&(e=e.call(this.element)),this.isBuilt&&!this.isDisabled&&t.isPlainObject(e)&&(h.rotatable&&i(e.rotate)&&e.rotate!==n.rotate&&(n.rotate=e.rotate,this.isRotated=s=!0),h.scalable&&(i(e.scaleX)&&e.scaleX!==n.scaleX&&(n.scaleX=e.scaleX,a=!0),i(e.scaleY)&&e.scaleY!==n.scaleY&&(n.scaleY=e.scaleY,a=!0)),s?this.renderCanvas():a&&this.renderImage(),o=n.width/n.naturalWidth,i(e.x)&&(p.left=e.x*o+r.left),i(e.y)&&(p.top=e.y*o+r.top),i(e.width)&&(p.width=e.width*o),i(e.height)&&(p.height=e.height*o),this.setCropBoxData(p))},getContainerData:function(){return this.isBuilt?this.container:{}},getImageData:function(){return this.isLoaded?this.image:{}},getCanvasData:function(){var i=this.canvas,e={};return this.isBuilt&&t.each(["left","top","width","height","naturalWidth","naturalHeight"],function(t,s){e[s]=i[s]}),e},setCanvasData:function(e){var s=this.canvas,a=s.aspectRatio;t.isFunction(e)&&(e=e.call(this.$element)),this.isBuilt&&!this.isDisabled&&t.isPlainObject(e)&&(i(e.left)&&(s.left=e.left),i(e.top)&&(s.top=e.top),i(e.width)?(s.width=e.width,s.height=e.width/a):i(e.height)&&(s.height=e.height,s.width=e.height*a),this.renderCanvas(!0))},getCropBoxData:function(){var t,i=this.cropBox;return this.isBuilt&&this.isCropped&&(t={left:i.left,top:i.top,width:i.width,height:i.height}),t||{}},setCropBoxData:function(e){var s,a,o=this.cropBox,h=this.options.aspectRatio;t.isFunction(e)&&(e=e.call(this.$element)),this.isBuilt&&this.isCropped&&!this.isDisabled&&t.isPlainObject(e)&&(i(e.left)&&(o.left=e.left),i(e.top)&&(o.top=e.top),i(e.width)&&(s=!0,o.width=e.width),i(e.height)&&(a=!0,o.height=e.height),h&&(s?o.height=o.width/h:a&&(o.width=o.height*h)),this.renderCropBox())},getCroppedCanvas:function(i){var e,s,a,o,h,n,r,p,c,d,g;return this.isBuilt&&ft?this.isCropped?(t.isPlainObject(i)||(i={}),g=this.getData(),e=g.width,s=g.height,p=e/s,t.isPlainObject(i)&&(h=i.width,n=i.height,h?(n=h/p,r=h/e):n&&(h=n*p,r=n/s)),a=$t(h||e),o=$t(n||s),c=t("")[0],c.width=a,c.height=o,d=c.getContext("2d"),i.fillColor&&(d.fillStyle=i.fillColor,d.fillRect(0,0,a,o)),d.drawImage.apply(d,function(){var t,i,a,o,h,n,p=l(this.$clone[0],this.image),c=p.width,d=p.height,u=this.canvas,f=[p],m=g.x+u.naturalWidth*(Ct(g.scaleX||1)-1)/2,v=g.y+u.naturalHeight*(Ct(g.scaleY||1)-1)/2;return-e>=m||m>c?m=t=a=h=0:0>=m?(a=-m,m=0,t=h=wt(c,e+m)):c>=m&&(a=0,t=h=wt(e,c-m)),0>=t||-s>=v||v>d?v=i=o=n=0:0>=v?(o=-v,v=0,i=n=wt(d,s+v)):d>=v&&(o=0,i=n=wt(s,d-v)),f.push($t(m),$t(v),$t(t),$t(i)),r&&(a*=r,o*=r,h*=r,n*=r),h>0&&n>0&&f.push($t(a),$t(o),$t(h),$t(n)),f}.call(this)),c):l(this.$clone[0],this.image):void 0},setAspectRatio:function(t){var i=this.options;this.isDisabled||e(t)||(i.aspectRatio=xt(0,t)||NaN,this.isBuilt&&(this.initCropBox(),this.isCropped&&this.renderCropBox()))},setDragMode:function(t){var i,e,s=this.options;this.isLoaded&&!this.isDisabled&&(i=t===lt,e=s.movable&&t===dt,t=i||e?t:ut,this.$dragBox.data(it,t).toggleClass(W,i).toggleClass(M,e),s.cropBoxMovable||this.$face.data(it,t).toggleClass(W,i).toggleClass(M,e))}},v.DEFAULTS={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,build:null,built:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},v.setDefaults=function(i){t.extend(v.DEFAULTS,i)},v.TEMPLATE='
',v.other=t.fn.cropper,t.fn.cropper=function(i){var a,o=s(arguments,1);return this.each(function(){var e,s,h=t(this),n=h.data(L);if(!n){if(/destroy/.test(i))return;e=t.extend({},h.data(),t.isPlainObject(i)&&i),h.data(L,n=new v(this,e))}"string"==typeof i&&t.isFunction(s=n[i])&&(a=s.apply(n,o))}),e(a)?this:a},t.fn.cropper.Constructor=v,t.fn.cropper.setDefaults=v.setDefaults,t.fn.cropper.noConflict=function(){return t.fn.cropper=v.other,this}}); \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.input.js b/artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.input.js new file mode 100755 index 0000000..ad5ad4d --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.input.js @@ -0,0 +1,121 @@ +var imageManagerInput = { + baseUrl: null, //language + message: null, //init imageManagerInput + init: function() { + //create modal + imageManagerInput.initModal(); + }, //creat image Manager modal + initModal: function() { + //check if modal not jet exists + if ($("#modal-imagemanager").length === 0) { + //set html modal in var + var sModalHtml = ''; + //prepend data to body + $('body') + .prepend(sModalHtml); + } + }, //open media manager modal + openModal: function(inputId, aspectRatio, cropViewMode) { + //get selected item + var iImageId = $("#" + inputId) + .val(); + var srcImageIdQueryString = ""; + if (iImageId !== "") { + srcImageIdQueryString = "&image-id=" + iImageId; + } + //create iframe url + var queryStringStartCharacter = ((imageManagerInput.baseUrl).indexOf('?') == -1) ? '?' : '&'; + var imageManagerUrl = imageManagerInput.baseUrl + queryStringStartCharacter + "view-mode=iframe&input-id=" + inputId + "&aspect-ratio=" + aspectRatio + "&crop-view-mode=" + cropViewMode + srcImageIdQueryString; + //set iframe path + $("#modal-imagemanager iframe") + .attr("src", imageManagerUrl); + //set translation title for modal header + $("#modal-imagemanager .modal-dialog .modal-header h4") + .text(imageManagerInput.message.imageManager); + //open modal + $("#modal-imagemanager") + .modal("show"); + }, //close media manager modal + closeModal: function() { + $("#modal-imagemanager") + .modal("hide"); + }, //delete picked image + deletePickedImage: function(inputId) { + //remove value of the input field + var sFieldId = inputId; + var sFieldNameId = sFieldId + "_name"; + var sImagePreviewId = sFieldId + "_image"; + var bShowConfirm = JSON.parse( + $(".delete-selected-image[data-input-id='" + inputId + "']") + .data("show-delete-confirm") + ); + //show warning if bShowConfirm == true + if (bShowConfirm) { + if (confirm(imageManagerInput.message.detachWarningMessage) == false) { + return false; + } + } + //set input data + $('#' + sFieldId) + .val(""); + $('#' + sFieldNameId) + .val(""); + //trigger change + $('#' + sFieldId) + .trigger("change"); + //hide image + $('#' + sImagePreviewId) + .attr("src", "") + .parent() + .addClass("hide"); + //delete hide class + $(".delete-selected-image[data-input-id='" + inputId + "']") + .addClass("hide"); + } +}; + +$(document) + .ready( + function() { + //init Image manage + imageManagerInput.init(); + + //open media manager modal + $(document) + .on( + "click", ".open-modal-imagemanager", function() { + var aspectRatio = $(this) + .data("aspect-ratio"); + var cropViewMode = $(this) + .data("crop-view-mode"); + var inputId = $(this) + .data("input-id"); + //open selector id + imageManagerInput.openModal(inputId, aspectRatio, cropViewMode); + } + ); + + //delete picked image + $(document) + .on( + "click", ".delete-selected-image", function() { + var inputId = $(this) + .data("input-id"); + //open selector id + imageManagerInput.deletePickedImage(inputId); + } + ); + } + ); \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.module.js b/artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.module.js new file mode 100755 index 0000000..b58edab --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/assets/source/js/script.imagemanager.module.js @@ -0,0 +1,474 @@ +var imageManagerModule = { + //params for input selector + fieldId: null, + cropRatio: null, + cropViewMode: 1, + defaultImageId: null, + selectType: null, //current selected image + selectedImage: null, //language + message: null, //init imageManager + init: function() { + //init cropper + $('#module-imagemanager > .row .col-image-editor .image-cropper .image-wrapper img#image-cropper') + .cropper( + { + viewMode: imageManagerModule.cropViewMode + } + ); + + //preselect image if image-id isset + if (imageManagerModule.defaultImageId !== "") { + imageManagerModule.selectImage(imageManagerModule.defaultImageId); + } + + //set selected after pjax complete + $('#pjax-mediamanager') + .on( + 'pjax:complete', function() { + if (imageManagerModule.selectedImage !== null) { + imageManagerModule.selectImage(imageManagerModule.selectedImage.id); + } + } + ); + + $(document) + .on( + 'click', '#save-image-info', function() { + var form = $('#save-image-info-form'); + $.ajax( + { + url: imageManagerModule.baseUrl + "/save-image-info", + type: "POST", + data: form.serialize(), + success: function(data) { + new PNotify( + { + title: "Notification", + text: "Image info saved", + type: "info", + styling: "bootstrap3", + icon: "glyphicon glyphicon-exclamation-sign" + } + ); + } + } + ); + } + ); + }, //filter result + filterImageResult: function(searchTerm) { + //set new url + var newUrl = window.queryStringParameter.set(window.location.href, "ImageManagerSearch[globalSearch]", searchTerm); + //set pjax + $.pjax( + { + url: newUrl, + container: "#pjax-mediamanager", + push: false, + replace: false, + timeout: 5000, + scrollTo: false + } + ); + }, //select an image + selectImage: function(id) { + //set selected class + $("#module-imagemanager .item-overview .item") + .removeClass("selected"); + $("#module-imagemanager .item-overview .item[data-key='" + id + "']") + .addClass("selected"); + //get details + imageManagerModule.getDetails(id); + }, //pick the selected image + pickImage: function() { + //switch between select type + switch (imageManagerModule.selectType) { + //default widget selector + case "input": + //get id data + var sFieldId = imageManagerModule.fieldId; + var sFieldNameId = sFieldId + "_name"; + var sFieldImageId = sFieldId + "_image"; + //set input data + $('#' + sFieldId, window.parent.document) + .val(imageManagerModule.selectedImage.id); + $('#' + sFieldNameId, window.parent.document) + .val(imageManagerModule.selectedImage.fileName); + $('#' + sFieldImageId, window.parent.document) + .attr("src", imageManagerModule.selectedImage.image) + .parent() + .removeClass("hide"); + //trigger change + parent.$('#' + sFieldId) + .trigger('change'); + //show delete button + $(".delete-selected-image[data-input-id='" + sFieldId + "']", window.parent.document) + .removeClass("hide"); + //close the modal + window.parent.imageManagerInput.closeModal(); + break; + //CKEditor selector + case "ckeditor": + //TinyMCE Selector + case "tinymce": + //check if isset image + if (imageManagerModule.selectedImage !== null) { + //call action by ajax + $.ajax( + { + url: imageManagerModule.baseUrl + "/get-original-image", + type: "POST", + data: { + ImageManager_id: imageManagerModule.selectedImage.id, + _csrf: $('meta[name=csrf-token]') + .prop('content') + }, + dataType: "json", + success: function(responseData, textStatus, jqXHR) { + //set attributes for each selector + if (imageManagerModule.selectType == "ckeditor") { + var sField = window.queryStringParameter.get(window.location.href, "CKEditorFuncNum"); + window.top.opener.CKEDITOR.tools.callFunction(sField, responseData); + window.self.close(); + } else if (imageManagerModule.selectType == "tinymce") { + var sField = window.queryStringParameter.get(window.location.href, "tag_name"); + window.opener.document.getElementById(sField).value = responseData; + window.close(); + window.opener.focus(); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("Error: can't get item"); + } + } + ); + } else { + alert("Error: image can't picked"); + } + break; + } + + }, //delete the selected image + deleteSelectedImage: function() { + //confirm message + if (confirm(imageManagerModule.message.deleteMessage)) { + //close editor + imageManagerModule.editor.close(); + //check if isset image + if (imageManagerModule.selectedImage !== null) { + //call action by ajax + $.ajax( + { + url: imageManagerModule.baseUrl + "/delete", + type: "POST", + data: { + ImageManager_id: imageManagerModule.selectedImage.id, + _csrf: $('meta[name=csrf-token]') + .prop('content') + }, + dataType: "json", + success: function(responseData, textStatus, jqXHR) { + //check if delete is true + if (responseData.delete === true) { + //delete item element + $("#module-imagemanager .item-overview .item[data-key='" + imageManagerModule.selectedImage.id + "']") + .remove(); + //add hide class to info block + $("#module-imagemanager .image-info") + .addClass("hide"); + //set selectedImage to null + imageManagerModule.selectedImage = null; + //close edit + } else { + alert("Error: item is not deleted"); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("Error: can't delete item"); + } + } + ); + } else { + alert("Error: image can't delete, no image isset set"); + } + } + }, //get image details + getDetails: function(id, pickAfterGetDetails) { + //set propertie if not set + pickAfterGetDetails = pickAfterGetDetails !== undefined ? pickAfterGetDetails : false; + //call action by ajax + $.ajax( + { + url: imageManagerModule.baseUrl + "/view", + type: "POST", + data: { + ImageManager_id: id, + _csrf: $('meta[name=csrf-token]') + .prop('content') + }, + dataType: "json", + success: function(responseData, textStatus, jqXHR) { + //set imageManagerModule.selectedImage property + imageManagerModule.selectedImage = responseData; + + //if need to pick image? + if (pickAfterGetDetails) { + imageManagerModule.pickImage(); + //else set data + } else { + //set text elements + $("#module-imagemanager .image-info .fileName") + .text(responseData.fileName) + .attr("title", responseData.fileName); + $("#module-imagemanager .image-info .created") + .text(responseData.created); + $("#module-imagemanager .image-info .fileSize") + .text(responseData.fileSize); + $("#module-imagemanager .image-info .dimensions .dimension-width") + .text(responseData.dimensionWidth); + $("#module-imagemanager .image-info .dimensions .dimension-height") + .text(responseData.dimensionHeight); + $("#module-imagemanager .image-info .thumbnail") + .html("" + responseData.fileName + ""); + $("#module-imagemanager .image-info .seo-info") + .html(responseData.div); + //remove hide class + $("#module-imagemanager .image-info") + .removeClass("hide"); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("Error: can't get ''data''"); + } + } + ); + }, //upload file + uploadSuccess: function(uploadResponse) { + //close editor + imageManagerModule.editor.close(); + //reload pjax container + $.pjax.reload( + '#pjax-mediamanager', { + push: false, + replace: false, + timeout: 5000, + scrollTo: false + } + ); + }, //editor functions + editor: { + //open editor block + open: function() { + //show editer / hide overview + $("#module-imagemanager > .row .col-image-editor") + .show(); + $("#module-imagemanager > .row .col-overview") + .hide(); + }, //close editor block + close: function() { + //show overview / hide editer + $("#module-imagemanager > .row .col-overview") + .show(); + $("#module-imagemanager > .row .col-image-editor") + .hide(); + }, //open cropper + openCropper: function() { + //check if isset image + if (imageManagerModule.selectedImage !== null) { + //call action by ajax + $.ajax( + { + url: imageManagerModule.baseUrl + "/get-original-image", + type: "POST", + data: { + ImageManager_id: imageManagerModule.selectedImage.id, + _csrf: $('meta[name=csrf-token]') + .prop('content') + }, + dataType: "json", + success: function(responseData, textStatus, jqXHR) { + //hide cropper + $("#module-imagemanager > .row .col-image-cropper") + .css("visibility", "hidden"); + //set image in cropper + $('#module-imagemanager > .row .col-image-editor .image-cropper .image-wrapper img#image-cropper') + .one( + 'built.cropper', function() { + //show cropper + $("#module-imagemanager > .row .col-image-cropper") + .css("visibility", "visible"); + } + ) + .cropper('reset') + .cropper('setAspectRatio', parseFloat(imageManagerModule.cropRatio)) + .cropper('replace', responseData); + //open editor + imageManagerModule.editor.open(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("Error: can't get item"); + } + } + ); + } else { + alert("Error: image can't crop, no image isset set"); + } + }, //apply crop + applyCrop: function(pickAfterCrop) { + //set propertie if not set + pickAfterCrop = pickAfterCrop !== undefined ? pickAfterCrop : false; + //check if isset image + if (imageManagerModule.selectedImage !== null) { + //set image in cropper + var oCropData = $('#module-imagemanager > .row .col-image-editor .image-cropper .image-wrapper img#image-cropper') + .cropper("getData"); + //call action by ajax + $.ajax( + { + url: imageManagerModule.baseUrl + "/crop", + type: "POST", + data: { + ImageManager_id: imageManagerModule.selectedImage.id, + CropData: oCropData, + _csrf: $('meta[name=csrf-token]') + .prop('content') + }, + dataType: "json", + success: function(responseData, textStatus, jqXHR) { + //set cropped image + if (responseData !== null) { + //if pickAfterCrop is true? select directly else + if (pickAfterCrop) { + imageManagerModule.getDetails(responseData, true); + //else select the image only + } else { + //set new image + imageManagerModule.selectImage(responseData); + //reload pjax container + $.pjax.reload( + '#pjax-mediamanager', { + push: false, + replace: false, + timeout: 5000, + scrollTo: false + } + ); + } + } + //close editor + imageManagerModule.editor.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("Error: item is not cropped"); + } + } + ); + } else { + alert("Error: image can't crop, no image isset set"); + } + } + } +}; + +$(document) + .ready( + function() { + //init Image manage + imageManagerModule.init(); + //on click select item (open view) + $(document) + .on( + "click", "#module-imagemanager .item-overview .item", function() { + //get id + var ImageManager_id = $(this) + .data("key"); + //select image + imageManagerModule.selectImage(ImageManager_id); + } + ); + //on click pick image + $(document) + .on( + "click", "#module-imagemanager .image-info .pick-image-item", function() { + imageManagerModule.pickImage(); + return false; + } + ); + //on click delete call "delete" + $(document) + .on( + "click", "#module-imagemanager .image-info .delete-image-item", function() { + imageManagerModule.deleteSelectedImage(); + return false; + } + ); + //on click crop call "crop" + $(document) + .on( + "click", "#module-imagemanager .image-info .crop-image-item", function() { + imageManagerModule.editor.openCropper(); + return false; + } + ); + //on click apply crop + $(document) + .on( + "click", "#module-imagemanager .image-cropper .apply-crop", function() { + imageManagerModule.editor.applyCrop(); + return false; + } + ); + //on click apply crop + $(document) + .on( + "click", "#module-imagemanager .image-cropper .apply-crop-select", function() { + imageManagerModule.editor.applyCrop(true); + return false; + } + ); + //on click cancel crop + $(document) + .on( + "click", "#module-imagemanager .image-cropper .cancel-crop", function() { + imageManagerModule.editor.close(); + return false; + } + ); + //on keyup change set filter + $(document) + .on( + "keyup change", "#input-mediamanager-search", function() { + imageManagerModule.filterImageResult( + $(this) + .val() + ); + } + ); + + } + ); + +/* + * return new get param to url + */ +window.queryStringParameter = { + get: function(uri, key) { + var reParam = new RegExp('(?:[\?&]|&)' + key + '=([^&]+)', 'i'); + var match = uri.match(reParam); + return (match && match.length > 1) ? match[ 1 ] : null; + }, + set: function(uri, key, value) { + //replace brackets + var keyReplace = key.replace("[]", "") + .replace(/\[/g, "%5B") + .replace(/\]/g, "%5D"); + //replace data + var re = new RegExp("([?&])" + keyReplace + "=.*?(&|$)", "i"); + var separator = uri.indexOf('?') !== -1 ? "&" : "?"; + if (uri.match(re)) { + return uri.replace(re, '$1' + keyReplace + "=" + value + '$2'); + } else { + return uri + separator + keyReplace + "=" + value; + } + } +}; \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/components/ImageManagerGetPath.php b/artweb/artbox-core/components/imagemanager/components/ImageManagerGetPath.php new file mode 100755 index 0000000..84b7095 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/components/ImageManagerGetPath.php @@ -0,0 +1,96 @@ +set( + 'imageresize', + [ + 'class' => 'artbox\core\components\imageresize\ImageResize', + 'cachePath' => $this->cachePath, + 'useFilename' => $this->useFilename, + 'absoluteUrl' => $this->absoluteUrl, + ] + ); + } + + /** + * Get the path for the given ImageManager_id record + * + * @param int $ImageManager_id ImageManager record for which the path needs to be generated + * @param int $width Thumbnail image width + * @param int $height Thumbnail image height + * @param string $thumbnailMode Thumbnail mode + * + * @return null|string Full path is returned when image is found, null if no image could be found + */ + public function getImagePath($ImageManager_id, $width = 400, $height = 400, $thumbnailMode = "outbound") + { + //default return + $return = null; + $mImageManager = ImageManager::findOne($ImageManager_id); + + //check if not empty + if ($mImageManager !== null) { + //set crop mode + $mode = $thumbnailMode == "outbound" ? "outbound" : "inset"; + + $sMediaPath = null; + if ($this->mediaPath !== null) { + $sMediaPath = $this->mediaPath; + } + + $sFileExtension = pathinfo($mImageManager->fileName, PATHINFO_EXTENSION); + //get image file path + $sImageFilePath = $sMediaPath . '/' . $mImageManager->id . '_' . $mImageManager->fileHash . '.' . $sFileExtension; + //check file exists + if (file_exists($sImageFilePath)) { + $return = \Yii::$app->imageresize->getUrl( + $sImageFilePath, + $width, + $height, + $mode, + null, + $mImageManager->fileName + ); + } else { + $return = null; //isset(\Yii::$app->controller->module->assetPublishedUrl) ? \Yii::$app->controller->module->assetPublishedUrl. "/img/img_no-image.png" : null; + } + } + return $return; + } + + } diff --git a/artweb/artbox-core/components/imagemanager/components/ImageManagerInputWidget.php b/artweb/artbox-core/components/imagemanager/components/ImageManagerInputWidget.php new file mode 100755 index 0000000..82a7c52 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/components/ImageManagerInputWidget.php @@ -0,0 +1,147 @@ +i18n->translations[ 'imagemanager' ])) { + Yii::$app->i18n->translations[ 'imagemanager' ] = [ + 'class' => 'yii\i18n\PhpMessageSource', + 'sourceLanguage' => 'en', + 'basePath' => '@artbox/core/components/imagemanager/messages', + ]; + } + } + + /** + * @inheritdoc + */ + public function run() + { + //default + $ImageManager_id = null; + $mImageManager = null; + $sFieldId = null; + //start input group + $field = "
"; + $field .= "
"; + //set input fields + if ($this->hasModel()) { + //get field id + $sFieldId = Html::getInputId($this->model, $this->attribute); + $sFieldNameId = $sFieldId . "_name"; + //get attribute name + $sFieldAttributeName = Html::getAttributeName($this->attribute); + //get filename from selected file + $ImageManager_id = $this->model->{$sFieldAttributeName}; + $ImageManager_fileName = null; + if($ImageManager_id) { + $mImageManager = ImageManager::findOne($ImageManager_id); + } else { + $mImageManager = null; + } + if ($mImageManager !== null) { + $ImageManager_fileName = $mImageManager->fileName; + } + //create field + $field .= Html::textInput( + $this->attribute, + $ImageManager_fileName, + [ + 'class' => 'form-control', + 'id' => $sFieldNameId, + 'readonly' => true, + ] + ); + $field .= Html::activeHiddenInput($this->model, $this->attribute, $this->options); + } else { + $field .= Html::textInput($this->name . "_name", null, [ 'readonly' => true ]); + $field .= Html::hiddenInput($this->name, $this->value, $this->options); + } + //end input group + $sHideClass = $ImageManager_id === null ? 'hide' : ''; + $field .= ""; + $field .= ""; + $field .= ""; + $field .= "
"; + + //show preview if is true + if ($this->showPreview == true) { + $sHideClass = ( $mImageManager == null ) ? "hide" : ""; + $sImageSource = isset($mImageManager->id) ? \Yii::$app->imagemanager->getImagePath( + $mImageManager->id, + 500, + 500, + 'inset' + ) : ""; + + $field .= '
' . 'Thumbnail' . '
'; + } + + //close image-manager-input div + $field .= "
"; + + echo $field; + + $this->registerClientScript(); + } + + /** + * Registers js Input + */ + public function registerClientScript() + { + $view = $this->getView(); + ImageManagerInputAsset::register($view); + + //set baseUrl from image manager + $sBaseUrl = Url::to([ '/imagemanager/manager' ]); + //set base url + $view->registerJs("imageManagerInput.baseUrl = '" . $sBaseUrl . "';"); + $view->registerJs( + "imageManagerInput.message = " . Json::encode( + [ + 'imageManager' => Yii::t('imagemanager', 'Image manager'), + 'detachWarningMessage' => Yii::t('imagemanager', 'Are you sure you want to detach the image?'), + ] + ) . ";" + ); + } + + } diff --git a/artweb/artbox-core/components/imagemanager/controllers/DefaultController.php b/artweb/artbox-core/components/imagemanager/controllers/DefaultController.php new file mode 100755 index 0000000..64996d7 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/controllers/DefaultController.php @@ -0,0 +1,21 @@ +render('index'); + } + } diff --git a/artweb/artbox-core/components/imagemanager/controllers/ManagerController.php b/artweb/artbox-core/components/imagemanager/controllers/ManagerController.php new file mode 100755 index 0000000..0c4f4dd --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/controllers/ManagerController.php @@ -0,0 +1,451 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function beforeAction($action) + { + //disable CSRF Validation + $this->enableCsrfValidation = false; + return parent::beforeAction($action); + } + + /** + * Lists all ImageManager models. + * + * @return mixed + */ + public function actionIndex() + { + //get iframe parameters + $viewMode = Yii::$app->request->get("view-mode", "page"); + $selectType = Yii::$app->request->get("select-type", "input"); + $inputFieldId = Yii::$app->request->get("input-id"); + $cropAspectRatio = Yii::$app->request->get("aspect-ratio"); + $cropViewMode = Yii::$app->request->get("crop-view-mode", 1); + $defaultImageId = Yii::$app->request->get("image-id"); + + //set blank layout if viewMode = iframe + if ($viewMode == "iframe") { + //set layout + $this->layout = "blank"; + + //set stylesheet for modal + $aCssFiles = \Yii::$app->controller->module->cssFiles; + if (is_array($aCssFiles) && count($aCssFiles) > 0) { + //if exists loop through files and add them to iframe mode + foreach ($aCssFiles AS $cssFile) { + //registrate file + $this->view->registerCssFile($cssFile, [ 'depends' => 'yii\bootstrap\BootstrapAsset' ]); + } + } + } + + //set baseUrl from image manager + $sBaseUrl = Url::to([ '/imagemanager/manager' ]); + //set base url + $this->view->registerJs("imageManagerModule.baseUrl = '" . $sBaseUrl . "';", 3); + $this->view->registerJs("imageManagerModule.defaultImageId = '" . $defaultImageId . "';", 3); + $this->view->registerJs("imageManagerModule.fieldId = '" . $inputFieldId . "';", 3); + $this->view->registerJs("imageManagerModule.cropRatio = '" . $cropAspectRatio . "';", 3); + $this->view->registerJs("imageManagerModule.cropViewMode = '" . $cropViewMode . "';", 3); + $this->view->registerJs("imageManagerModule.selectType = '" . $selectType . "';", 3); + $this->view->registerJs( + "imageManagerModule.message = " . Json::encode( + [ + 'deleteMessage' => Yii::t('imagemanager', 'Are you sure you want to delete this image?'), + ] + ) . ";", + 3 + ); + + $searchModel = new ImageManagerSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + //render template + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'viewMode' => $viewMode, + 'selectType' => $selectType, + ] + ); + } + + /** + * Creates a new ImageManager model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionUpload() + { + //set response header + Yii::$app->getResponse()->format = Response::FORMAT_JSON; + + // Check if the user is allowed to upload the image + if (Yii::$app->controller->module->canUploadImage == false) { + // Return the response array to prevent from the action being executed any further + return []; + } + + //disable Csrf + Yii::$app->controller->enableCsrfValidation = false; + //return default + $return = $_FILES; + //set media path + $sMediaPath = \Yii::$app->imagemanager->mediaPath; + //create the folder + BaseFileHelper::createDirectory($sMediaPath); + + //check file isset + if (isset($_FILES[ 'imagemanagerFiles' ][ 'tmp_name' ])) { + //loop through each uploaded file + foreach ($_FILES[ 'imagemanagerFiles' ][ 'tmp_name' ] AS $key => $sTempFile) { + //collect variables + $sFileName = $_FILES[ 'imagemanagerFiles' ][ 'name' ][ $key ]; + $sFileExtension = pathinfo($sFileName, PATHINFO_EXTENSION); + $iErrorCode = $_FILES[ 'imagemanagerFiles' ][ 'error' ][ $key ]; + //if uploaded file has no error code than continue; + if ($iErrorCode == 0) { + //create a file record + $model = new ImageManager(); + $model->fileName = str_replace("_", "-", $sFileName); + $model->fileHash = Yii::$app->getSecurity() + ->generateRandomString(32); + //if file is saved add record + if ($model->save()) { + //move file to dir + $sSaveFileName = $model->id . "_" . $model->fileHash . "." . $sFileExtension; + //move_uploaded_file($sTempFile, $sMediaPath."/".$sFileName); + //save with Imagine class + Image::getImagine() + ->open($sTempFile) + ->save($sMediaPath . "/" . $sSaveFileName,[ + 'quality' => 100, + ]); + } + } + } + } + //echo return json encoded + return $return; + } + + /** + * Crop image and create new ImageManager model. + * + * @return mixed + */ + public function actionCrop() + { + //return + $return = null; + //disable Csrf + Yii::$app->controller->enableCsrfValidation = false; + //set response header + Yii::$app->getResponse()->format = Response::FORMAT_JSON; + //set media path + $sMediaPath = \Yii::$app->imagemanager->mediaPath; + //get post + $ImageManager_id = Yii::$app->request->post("ImageManager_id"); + $aCropData = Yii::$app->request->post("CropData"); + //get details + $modelOriginal = $this->findModel($ImageManager_id); + //check if path is not null + if ($modelOriginal->imagePathPrivate !== null && $aCropData !== null) { + //dimension + $iDimensionWidth = round($aCropData[ 'width' ]); + $iDimensionHeight = round($aCropData[ 'height' ]); + //collect variables + $sFileNameReplace = preg_replace("/_crop_\d+x\d+/", "", $modelOriginal->fileName); + $sFileName = pathinfo($sFileNameReplace, PATHINFO_FILENAME); + $sFileExtension = pathinfo($sFileNameReplace, PATHINFO_EXTENSION); + $sDisplayFileName = $sFileName . "_crop_" . $iDimensionWidth . "x" . $iDimensionHeight . "." . $sFileExtension; + + //create a file record + $model = new ImageManager(); + $model->fileName = $sDisplayFileName; + $model->fileHash = Yii::$app->getSecurity() + ->generateRandomString(32); + //if file is saved add record + if ($model->save()) { + //create file to dir + $sSaveFileName = $model->id . "_" . $model->fileHash . "." . $sFileExtension; + + if ($aCropData[ 'x' ] < 0 || $aCropData[ 'y' ] < 0) { + //get position + $posX = $aCropData[ 'x' ]; + $posY = $aCropData[ 'y' ]; + //get image size + $sizeImage = getimagesize($modelOriginal->imagePathPrivate); + $sizeImageW = $sizeImage[ 0 ]; // natural width + $sizeImageH = $sizeImage[ 1 ]; // natural height + //get orignal image and crop it + $iCropWidth = $sizeImageW; + if ($sizeImageW > $aCropData[ 'width' ]) { + $iCropWidth = $aCropData[ 'width' ] - abs($posX); + } + $iCropHeight = $sizeImageH; + if ($sizeImageH > $aCropData[ 'height' ]) { + $iCropHeight = $aCropData[ 'height' ] - abs($posY); + } + + //crop image + $image = Image::getImagine() + ->open($modelOriginal->imagePathPrivate) + ->crop(new Point(0, 0), new Box($iCropWidth, $iCropHeight)); + + //create image + $size = new Box($aCropData[ 'width' ], $aCropData[ 'height' ]); + // $color = new Color('#FFF', 100); + Image::getImagine() + ->create($size, ( new RGB() )->color('#FFF')) + ->paste( + $image, + new Point(( $posX < 0 ? abs($posX) : $posX ), ( $posY < 0 ? abs($posY) : $posY )) + ) + ->crop( + new Point(( $posX < 0 ? 0 : $posX ), ( $posY < 0 ? 0 : $posY )), + new Box($aCropData[ 'width' ], $aCropData[ 'height' ]) + ) + ->save($sMediaPath . "/" . $sSaveFileName); + } else { + //save new image + Image::getImagine() + ->open($modelOriginal->imagePathPrivate) + ->crop( + new Point($aCropData[ 'x' ], $aCropData[ 'y' ]), + new Box($aCropData[ 'width' ], $aCropData[ 'height' ]) + ) + ->save($sMediaPath . "/" . $sSaveFileName); + } + + //set return id + $return = $model->id; + } + } + //echo return json encoded + return $return; + } + + /** + * Get view details + * + * @return mixed + */ + public function actionView() + { + //disable Csrf + Yii::$app->controller->enableCsrfValidation = false; + //return default + $return = []; + //set response header + Yii::$app->getResponse()->format = Response::FORMAT_JSON; + //get post + $ImageManager_id = Yii::$app->request->post("ImageManager_id"); + //get details + $model = $this->findModel($ImageManager_id); + //set return details + $return[ 'id' ] = $model->id; + $return[ 'fileName' ] = $model->fileName; + $return[ 'created' ] = Yii::$app->formatter->asDate($model->created); + $return[ 'fileSize' ] = $model->imageDetails[ 'size' ]; + $return[ 'dimensionWidth' ] = $model->imageDetails[ 'width' ]; + $return[ 'dimensionHeight' ] = $model->imageDetails[ 'height' ]; + $return[ 'image' ] = \Yii::$app->imagemanager->getImagePath($model->id, 400, 400, "inset") . "?t=" . time(); + + $languages = ImageManagerLang::find() + ->where([ 'image_id' => $model->id ]) + ->indexBy('language_id') + ->all(); + + $div = $this->renderPartial( + '_image_info', + [ + 'languages' => $languages, + 'model' => $model, + ] + ); + + $return[ 'div' ] = $div; + + //return json encoded + return $return; + } + + public function actionSaveImageInfo() + { + \Yii::$app->response->format = Response::FORMAT_JSON; + + if (\Yii::$app->request->isPost) { + $id = Yii::$app->request->post("image_id"); + + $model = $this->findModel($id); + + $languages = ImageManagerLang::find() + ->where([ 'image_id' => $model->id ]) + ->indexBy('language_id') + ->all(); + + foreach (Language::getActive() as $lang_id => $language) { + if (empty($languages[ $lang_id ])) { + $lang = new ImageManagerLang(); + } else { + $lang = $languages[ $lang_id ]; + } + /** + * @var ImageManagerLang $lang + */ + + $lang->alt = \Yii::$app->request->post('image_info')[ $lang_id ][ 'alt' ]; + $lang->title = \Yii::$app->request->post('image_info')[ $lang_id ][ 'title' ]; + $lang->description = \Yii::$app->request->post('image_info')[ $lang_id ][ 'description' ]; + $lang->image_id = $model->id; + $lang->language_id = $lang_id; + $lang->save(); + } + } + + return 'oki'; + } + + /** + * Get full image + * + * @return mixed + */ + public function actionGetOriginalImage() + { + //disable Csrf + Yii::$app->controller->enableCsrfValidation = false; + //set response header + Yii::$app->getResponse()->format = Response::FORMAT_JSON; + //get post + $ImageManager_id = Yii::$app->request->post("ImageManager_id"); + //get details + $model = $this->findModel($ImageManager_id); + //set return + $return = \Yii::$app->imagemanager->getImagePath( + $model->id, + $model->imageDetails[ 'width' ], + $model->imageDetails[ 'height' ], + "inset" + ); + //return json encoded + return $return; + } + + /** + * Deletes an existing ImageManager model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @return mixed + */ + public function actionDelete() + { + //return + $return = [ 'delete' => false ]; + //set response header + Yii::$app->getResponse()->format = Response::FORMAT_JSON; + + // Check if the user is allowed to delete the image + if (Yii::$app->controller->module->canRemoveImage == false) { + // Return the response array to prevent from the action being executed any further + return $return; + } + + //get post + $ImageManager_id = Yii::$app->request->post("ImageManager_id"); + //get details + $model = $this->findModel($ImageManager_id); + + //set some data + $sFileExtension = pathinfo($model->fileName, PATHINFO_EXTENSION); + $sMediaPath = \Yii::$app->imagemanager->mediaPath; + $sFileName = $model->id . "_" . $model->fileHash . "." . $sFileExtension; + //delete record + if ($model->delete()) { + //check if file exists? if it is delete file + if (file_exists($sMediaPath . "/" . $sFileName)) { + unlink($sMediaPath . "/" . $sFileName); + } + $return[ 'delete' ] = true; + } + return $return; + } + + /** + * Finds the ImageManager model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return ImageManager the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = ImageManager::findOne($id) ) !== null) { + /* @var $model ImageManager */ + // Get the module instance + $module = Module::getInstance(); + + // Check if the model belongs to this user + if ($module->setBlameableBehavior) { + // Check if the user and record ID match + if (Yii::$app->user->id != $model->createdBy) { + throw new NotFoundHttpException(Yii::t('imagemanager', 'The requested image does not exist.')); + } + } + + return $model; + } else { + throw new NotFoundHttpException(Yii::t('imagemanager', 'The requested image does not exist.')); + } + } + + } diff --git a/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager-crop.jpg b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager-crop.jpg new file mode 100755 index 0000000..a680844 Binary files /dev/null and b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager-crop.jpg differ diff --git a/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager.jpg b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager.jpg new file mode 100755 index 0000000..f3917b5 Binary files /dev/null and b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-manager.jpg differ diff --git a/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget-popup.jpg b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget-popup.jpg new file mode 100755 index 0000000..f76b2d2 Binary files /dev/null and b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget-popup.jpg differ diff --git a/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget.jpg b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget.jpg new file mode 100755 index 0000000..ed0a316 Binary files /dev/null and b/artweb/artbox-core/components/imagemanager/docs/images/img_doc-image-widget.jpg differ diff --git a/artweb/artbox-core/components/imagemanager/messages/de/imagemanager.php b/artweb/artbox-core/components/imagemanager/messages/de/imagemanager.php new file mode 100755 index 0000000..c39ba40 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/messages/de/imagemanager.php @@ -0,0 +1,17 @@ + 'Wollen Sie dieses Bild wirklich löschen?', + 'Are you sure you want to detach the image?' => 'Wollen Sie dieses Bild wirklich lösen?', + 'Cancel' => 'Annullieren', + 'Created' => 'Erstellt', + 'Crop' => 'Zuschneiden', + 'Crop and select' => 'Zuschneiden und auswählen', + 'Delete' => 'Löschen', + 'File hash' => 'File hash', + 'File name' => 'File Name', + 'Modified' => 'Geändert', + 'Search' => 'Suchen', + 'Select' => 'Auswählen', + 'Image manager' => 'Image manager', + 'Upload' => 'Upload', + ]; diff --git a/artweb/artbox-core/components/imagemanager/messages/en/imagemanager.php b/artweb/artbox-core/components/imagemanager/messages/en/imagemanager.php new file mode 100755 index 0000000..f4a77af --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/messages/en/imagemanager.php @@ -0,0 +1,17 @@ + 'Are you sure you want to delete this image?', + 'Are you sure you want to detach the image?' => 'Are you sure you want to detach the image?', + 'Cancel' => 'Cancel', + 'Created' => 'Created', + 'Crop' => 'Crop', + 'Crop and select' => 'Crop and select', + 'Delete' => 'Delete', + 'File hash' => 'File hash', + 'File name' => 'File name', + 'Modified' => 'Modified', + 'Search' => 'Search', + 'Select' => 'Select', + 'Image manager' => 'Image manager', + 'Upload' => 'Upload', + ]; diff --git a/artweb/artbox-core/components/imagemanager/messages/fr/imagemanager.php b/artweb/artbox-core/components/imagemanager/messages/fr/imagemanager.php new file mode 100755 index 0000000..c9b21f1 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/messages/fr/imagemanager.php @@ -0,0 +1,17 @@ + 'Voulez-vous vraiment effacer cet\'image?', + 'Are you sure you want to detach the image?' => 'Voules-vous détacher cet\'image?', + 'Cancel' => 'Annuler', + 'Created' => 'Crée', + 'Crop' => 'Ajuster', + 'Crop and select' => 'Ajuster et sélectionner', + 'Delete' => 'Effacer', + 'File hash' => 'Hash du fichier', + 'File name' => 'Nom du fichier', + 'Modified' => 'Modifié', + 'Search' => 'Rechercher', + 'Select' => 'Sélectionner', + 'Image manager' => 'Image manager', + 'Upload' => 'Upload', + ]; diff --git a/artweb/artbox-core/components/imagemanager/messages/it/imagemanager.php b/artweb/artbox-core/components/imagemanager/messages/it/imagemanager.php new file mode 100755 index 0000000..bcec60c --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/messages/it/imagemanager.php @@ -0,0 +1,17 @@ + 'Vuole veramente cancellare questa immagine?', + 'Are you sure you want to detach the image?' => 'Vuole distaccare questa immagine?', + 'Cancel' => 'Cancellre', + 'Created' => 'Creato', + 'Crop' => 'Tagliare a formato', + 'Crop and select' => 'Tagliare a formato e selezionare', + 'Delete' => 'Cancellare', + 'File hash' => 'File hash', + 'File name' => 'Nome del file', + 'Modified' => 'Modificato', + 'Search' => 'Ricerca', + 'Select' => 'Selezionare', + 'Image manager' => 'Image manager', + 'Upload' => 'Upload', + ]; diff --git a/artweb/artbox-core/components/imagemanager/messages/nl/imagemanager.php b/artweb/artbox-core/components/imagemanager/messages/nl/imagemanager.php new file mode 100755 index 0000000..5e44721 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/messages/nl/imagemanager.php @@ -0,0 +1,20 @@ + 'Weet je zeker dat je de afbeelding wilt verwijderen?', + 'Are you sure you want to detach the image?' => 'Weet je zeker dat je de afbeelding wilt losmaken?', + 'The requested image does not exist.' => 'De gevraagde afbeelding bestaat niet.', + 'Cancel' => 'Annuleer', + 'Created' => 'Aangemaakt', + 'Created by' => 'Gemaakt door', + 'Crop' => 'Bijsnijden', + 'Crop and select' => 'Bijsnijden en selecteren', + 'Delete' => 'Verwijderen', + 'File hash' => 'Bestand hash', + 'File name' => 'Bestandsnaam', + 'Modified' => 'Gewijzigd', + 'Modified by' => 'Gewijzigd door', + 'Search' => 'Zoeken', + 'Select' => 'Selecteer', + 'Image manager' => 'Image manager', + 'Upload' => 'Upload', + ]; \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/messages/ru/imagemanager.php b/artweb/artbox-core/components/imagemanager/messages/ru/imagemanager.php new file mode 100755 index 0000000..5a58b28 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/messages/ru/imagemanager.php @@ -0,0 +1,18 @@ + 'Вы действительно хотите удалить изображение?', + 'Are you sure you want to detach the image?' => 'Вы действительно хотите открепить изображение?', + 'Cancel' => 'Отменить', + 'Created' => 'Создано', + 'Crop' => 'Обрезать', + 'Crop and select' => 'Обрезать и выбрать', + 'Delete' => 'Удалить', + 'File hash' => 'Хеш файла', + 'File name' => 'Имя файла', + 'Modified' => 'Измененл', + 'Search' => 'Поиск', + 'Select' => 'Выбрать', + 'Image manager' => 'Менеджер изображений', + 'Upload' => 'Загрузить', + 'Save' => 'Сохранить', + ]; \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/migrations/m160622_085710_create_ImageManager_table.php b/artweb/artbox-core/components/imagemanager/migrations/m160622_085710_create_ImageManager_table.php new file mode 100755 index 0000000..cd4bfff --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/migrations/m160622_085710_create_ImageManager_table.php @@ -0,0 +1,42 @@ +createTable( + 'ImageManager', + [ + 'id' => $this->primaryKey(), + 'fileName' => $this->string(128) + ->notNull(), + 'fileHash' => $this->string(32) + ->notNull(), + 'created' => $this->datetime() + ->notNull(), + 'modified' => $this->datetime(), + ] + ); + + //ImageManager: alter id column + $this->alterColumn('ImageManager', 'id', 'INT(10) UNSIGNED NOT NULL AUTO_INCREMENT'); + + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('ImageManager'); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/components/imagemanager/migrations/m170223_113221_addBlameableBehavior.php b/artweb/artbox-core/components/imagemanager/migrations/m170223_113221_addBlameableBehavior.php new file mode 100755 index 0000000..4978667 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/migrations/m170223_113221_addBlameableBehavior.php @@ -0,0 +1,33 @@ +addColumn( + 'ImageManager', + 'createdBy', + $this->integer(10) + ->unsigned() + ->null() + ->defaultValue(null) + ); + $this->addColumn( + 'ImageManager', + 'modifiedBy', + $this->integer(10) + ->unsigned() + ->null() + ->defaultValue(null) + ); + } + + public function down() + { + echo "m170223_113221_addBlameableBehavior cannot be reverted.\n"; + + return false; + } + } diff --git a/artweb/artbox-core/components/imagemanager/models/ImageManager.php b/artweb/artbox-core/components/imagemanager/models/ImageManager.php new file mode 100755 index 0000000..90827c0 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/models/ImageManager.php @@ -0,0 +1,178 @@ + TimestampBehavior::className(), + 'createdAtAttribute' => 'created', + 'updatedAtAttribute' => 'modified', + 'value' => new Expression('NOW()'), + ]; + + // Check if we need blamable behavior + if (Yii::$app->getModule('imagemanager')->setBlameableBehavior) { + $aBehaviors[] = [ + 'class' => BlameableBehavior::className(), + 'createdByAttribute' => 'createdBy', + 'updatedByAttribute' => 'modifiedBy', + ]; + } + + return $aBehaviors; + } + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'ImageManager'; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'fileName', + 'fileHash', + ], + 'required', + ], + [ + [ + 'created', + 'modified', + ], + 'safe', + ], + [ + [ 'fileName' ], + 'string', + 'max' => 128, + ], + [ + [ 'fileHash' ], + 'string', + 'max' => 32, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('imagemanager', 'ID'), + 'fileName' => Yii::t('imagemanager', 'File Name'), + 'fileHash' => Yii::t('imagemanager', 'File Hash'), + 'created' => Yii::t('imagemanager', 'Created'), + 'modified' => Yii::t('imagemanager', 'Modified'), + 'createdBy' => Yii::t('imagemanager', 'Created by'), + 'modifiedBy' => Yii::t('imagemanager', 'Modified by'), + ]; + } + + /** + * Get image path private + * + * @return string|null If image file exists the path to the image, if file does not exists null + */ + public function getImagePathPrivate() + { + //set default return + $return = null; + //set media path + $sMediaPath = \Yii::$app->imagemanager->mediaPath; + $sFileExtension = pathinfo($this->fileName, PATHINFO_EXTENSION); + //get image file path + $sImageFilePath = $sMediaPath . '/' . $this->id . '_' . $this->fileHash . '.' . $sFileExtension; + //check file exists + if (file_exists($sImageFilePath)) { + $return = $sImageFilePath; + } + return $return; + } + + /** + * Get image data dimension/size + * + * @return array The image sizes + */ + public function getImageDetails() + { + //set default return + $return = [ + 'width' => 0, + 'height' => 0, + 'size' => 0, + ]; + //set media path + $sMediaPath = \Yii::$app->imagemanager->mediaPath; + $sFileExtension = pathinfo($this->fileName, PATHINFO_EXTENSION); + //get image file path + $sImageFilePath = $sMediaPath . '/' . $this->id . '_' . $this->fileHash . '.' . $sFileExtension; + //check file exists + if (file_exists($sImageFilePath)) { + $aImageDimension = getimagesize($sImageFilePath); + $return[ 'width' ] = isset($aImageDimension[ 0 ]) ? $aImageDimension[ 0 ] : 0; + $return[ 'height' ] = isset($aImageDimension[ 1 ]) ? $aImageDimension[ 1 ] : 0; + $return[ 'size' ] = Yii::$app->formatter->asShortSize(filesize($sImageFilePath), 2); + } + return $return; + } + + /** + * @return ActiveQuery + */ + public function getLanguages() + { + return ImageManagerLang::find() + ->where( + [ + 'image_id' => $this->id, + ] + ) + ->joinWith('language') + ->where( + [ + 'language.status' => true, + ] + ); + } + } diff --git a/artweb/artbox-core/components/imagemanager/models/ImageManagerLang.php b/artweb/artbox-core/components/imagemanager/models/ImageManagerLang.php new file mode 100755 index 0000000..f776509 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/models/ImageManagerLang.php @@ -0,0 +1,121 @@ + 255, + ], + [ + [ + 'language_id', + 'image_id', + ], + 'unique', + 'targetAttribute' => [ + 'language_id', + 'image_id', + ], + 'message' => 'The combination of Image ID and Language ID has already been taken.', + ], + [ + [ 'image_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => ImageManager::className(), + 'targetAttribute' => [ 'image_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'image_id' => Yii::t('app', 'Image ID'), + 'language_id' => Yii::t('app', 'Language ID'), + 'title' => Yii::t('app', 'Title'), + 'alt' => Yii::t('app', 'Alt'), + 'description' => Yii::t('app', 'Description'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getImage() + { + return $this->hasOne(ImageManager::className(), [ 'id' => 'image_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + } diff --git a/artweb/artbox-core/components/imagemanager/models/ImageManagerSearch.php b/artweb/artbox-core/components/imagemanager/models/ImageManagerSearch.php new file mode 100755 index 0000000..531984a --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/models/ImageManagerSearch.php @@ -0,0 +1,103 @@ + $query, + 'pagination' => [ + 'pagesize' => 100, + ], + 'sort' => [ 'defaultOrder' => [ 'created' => SORT_DESC ] ], + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // Get the module instance + $module = Module::getInstance(); + + if ($module->setBlameableBehavior) { + $query->andWhere([ 'createdBy' => Yii::$app->user->id ]); + } + + $query->orFilterWhere( + [ + 'like', + 'fileName', + $this->globalSearch, + ] + // ) + // ->orFilterWhere( + // [ + // 'like', + // 'created', + // $this->globalSearch, + // ] + // ) + // ->orFilterWhere( + // [ + // 'like', + // 'modified', + // $this->globalSearch, + // ] + ); + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/components/imagemanager/views/default/index.php b/artweb/artbox-core/components/imagemanager/views/default/index.php new file mode 100755 index 0000000..0aaa8eb --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/views/default/index.php @@ -0,0 +1,10 @@ +title = "Image manager"; +?> +
+

Welcome to image manager

+

Install run migrate:

+

yii migrate --migrationPath=@noam148/imagemanager/migrations

+ +

By noam148

+
diff --git a/artweb/artbox-core/components/imagemanager/views/layouts/blank.php b/artweb/artbox-core/components/imagemanager/views/layouts/blank.php new file mode 100755 index 0000000..dfa4201 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/views/layouts/blank.php @@ -0,0 +1,28 @@ + +beginPage() ?> + + + + + + + + <?= Html::encode($this->title) ?> + head() ?> + + + beginBody() ?> + + + + endBody() ?> + + +endPage() ?> diff --git a/artweb/artbox-core/components/imagemanager/views/manager/_image_info.php b/artweb/artbox-core/components/imagemanager/views/manager/_image_info.php new file mode 100755 index 0000000..611d541 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/views/manager/_image_info.php @@ -0,0 +1,89 @@ + + + +
+ + + $language) { ?> + + +
+ +
+
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+
+
+ + id + ); + + ?> + +
+ + + diff --git a/artweb/artbox-core/components/imagemanager/views/manager/_item.php b/artweb/artbox-core/components/imagemanager/views/manager/_item.php new file mode 100755 index 0000000..0838fdd --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/views/manager/_item.php @@ -0,0 +1,4 @@ +
+ <?= $model->fileName ?> +
fileName ?>
+
diff --git a/artweb/artbox-core/components/imagemanager/views/manager/index.php b/artweb/artbox-core/components/imagemanager/views/manager/index.php new file mode 100755 index 0000000..ec26c59 --- /dev/null +++ b/artweb/artbox-core/components/imagemanager/views/manager/index.php @@ -0,0 +1,169 @@ +title = Yii::t('imagemanager', 'Image manager'); + +?> + + $this->title, + ] +) ?> + +
+
+
+
+
+ +
+ +
+
+
+ 'pjax-mediamanager', + 'timeout' => '5000', + ] + ); ?> + $dataProvider, + 'itemOptions' => [ 'class' => 'item img-thumbnail' ], + 'layout' => "
{items}
{pager}", + 'itemView' => function ($model, $key, $index, $widget) { + return $this->render("_item", [ 'model' => $model ]); + }, + ] + ) ?> + +
+
+
+ 'input-mediamanager-search', + 'class' => 'form-control', + 'placeholder' => Yii::t('imagemanager', 'Search') . '...', + ] + ) ?> +
+ + controller->module->canUploadImage): + ?> + + 'imagemanagerFiles[]', + 'id' => 'imagemanager-files', + 'options' => [ + 'multiple' => true, + 'accept' => 'image/*', + ], + 'pluginOptions' => [ + 'uploadUrl' => Url::to([ 'manager/upload' ]), + 'allowedFileExtensions' => \Yii::$app->controller->module->allowedFileExtensions, + 'uploadAsync' => false, + 'showPreview' => false, + 'showRemove' => false, + 'showUpload' => false, + 'showCancel' => false, + 'browseClass' => 'btn btn-primary btn-block', + 'browseIcon' => ' ', + 'browseLabel' => Yii::t('imagemanager', 'Upload'), + ], + 'pluginEvents' => [ + "filebatchselected" => "function(event, files){ $('.msg-invalid-file-extension').addClass('hide'); $(this).fileinput('upload'); }", + "filebatchuploadsuccess" => "function(event, data, previewId, index) { + imageManagerModule.uploadSuccess(data.jqXHR.responseJSON.imagemanagerFiles); + }", + "fileuploaderror" => "function(event, data) { $('.msg-invalid-file-extension').removeClass('hide'); }", + ], + ] + ) ?> + + + +
+
+ +
+ +
+
+
+
+
× +
+ controller->module->canRemoveImage): + ?> + + + +
+
+ +
+ ' . \Yii::t('imagemanager', 'Save'), + [ + 'class' => 'btn btn-success btn-xs', + 'id' => 'save-image-info', + ] + ) ?> +
+
+ + + + + +
+
+
+
+ \ No newline at end of file diff --git a/artweb/artbox-core/components/imageresize/ImageResize.php b/artweb/artbox-core/components/imageresize/ImageResize.php new file mode 100755 index 0000000..cbd53e2 --- /dev/null +++ b/artweb/artbox-core/components/imageresize/ImageResize.php @@ -0,0 +1,172 @@ +cachePath); + //get fileinfo + $aFileInfo = pathinfo($filePath); + //set default filename + $sFileHash = md5($filePath . $width . $height . $resizeMode . filemtime($filePath)); + $imageFileName = null; + //if $this->useFilename set to true? use seo friendly name + if ($this->useFilename === true) { + //set hash and default name + $sFileHashShort = substr($sFileHash, 0, 6); + $sFileName = $aFileInfo[ 'filename' ]; + //set choosen filename if $chosenFileName not null. + if ($chosenFileName !== null) { + $sFileName = preg_replace('/(\.\w+)$/', '', $chosenFileName); + } + //replace for seo friendly file name + $sFilenameReplace = preg_replace("/[^\w\.\-]+/", '-', $sFileName); + //set filename + $imageFileName = $sFileHashShort . "_" . $sFilenameReplace; + //else use file hash as filename + } else { + $imageFileName = $sFileHash; + } + + $imageFileExt = "." . $aFileInfo[ 'extension' ]; + $imageFilePath = $cachePath . DIRECTORY_SEPARATOR . substr($imageFileName, 0, 2); + $imageFile = $imageFilePath . DIRECTORY_SEPARATOR . $imageFileName . $imageFileExt; + + if (file_exists($imageFile)) { + if ($this->cacheExpire !== 0 && ( time() - filemtime($imageFile) ) > $this->cacheExpire) { + unlink($imageFile); + } else { + return $imageFile; + } + } + //if dir not exist create cache edir + if (!is_dir($imageFilePath)) { + FileHelper::createDirectory($imageFilePath, 0755); + } + //create image + $box = new Box($width, $height); + $image = Image::getImagine() + ->open($filePath); + $image = $image->thumbnail($box, $resizeMode); + + $options = [ + 'quality' => 100, + ]; + $image->save($imageFile, $options); + return $imageFile; + } + + /** + * Creates and caches the image and returns URL from resized file. + * + * @param string $filePath to original file + * @param integer $width + * @param integer $height + * @param string $mode + * @param integer $quality (1 - 100 quality) + * @param string $fileName (custome filename) + * + * @return string + */ + public function getUrl($filePath, $width, $height, $mode = "outbound", $quality = null, $fileName = null) + { + //get original file + $normalizePath = FileHelper::normalizePath(Yii::getAlias($filePath)); + //get cache url + $cacheUrl = Yii::getAlias($this->cachePath); + //generate file + $resizedFilePath = self::generateImage($normalizePath, $width, $height, $mode, $quality, $fileName); + //get resized file + $normalizeResizedFilePath = FileHelper::normalizePath($resizedFilePath); + $resizedFileName = pathinfo($normalizeResizedFilePath, PATHINFO_BASENAME); + //get url + $sFileUrl = Url::to( + '@web/' . $cacheUrl . '/' . substr($resizedFileName, 0, 2) . '/' . $resizedFileName, + $this->absoluteUrl + ); + //return path + return $sFileUrl; + } + + /** + * Clear cache directory. + * + * @return bool + */ + public function clearCache() + { + $cachePath = Yii::getAlias('@webroot/' . $this->cachePath); + //remove dir + FileHelper::removeDirectory($cachePath); + //creat dir + return FileHelper::createDirectory($cachePath, 0755); + } + + } diff --git a/artweb/artbox-core/composer.json b/artweb/artbox-core/composer.json new file mode 100755 index 0000000..07a10ef --- /dev/null +++ b/artweb/artbox-core/composer.json @@ -0,0 +1,23 @@ +{ + "name": "artweb/artbox-core", + "description": "Artbox core extension", + "license": "BSD-3-Clause", + "minimum-stability": "dev", + "type": "yii2-extension", + "require": { + "php": ">=7.0", + "yiisoft/yii2": "~2.0", + "yiisoft/yii2-imagine": "~2.0", + "yiisoft/yii2-bootstrap": "~2.0", + "yiisoft/yii2-swiftmailer": "~2.0", + "yiister/yii2-gentelella": "~1.0", + "2amigos/yii2-tinymce-widget": "~1.0", + "bower-asset/amcharts": "*", + "kartik-v/yii2-widget-fileinput": "*" + }, + "autoload": { + "psr-4": { + "artbox\\core\\": "" + } + } +} \ No newline at end of file diff --git a/artweb/artbox-core/controllers/AliasController.php b/artweb/artbox-core/controllers/AliasController.php new file mode 100755 index 0000000..f711473 --- /dev/null +++ b/artweb/artbox-core/controllers/AliasController.php @@ -0,0 +1,262 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [// 'change-password' => [ 'post' ], + ], + ], + ]; + } + + /** + * Lists all Alias models. + * + * @return mixed + */ + public function actionIndex() + { + $languages = Language::find() + ->select( + [ + 'name', + 'id', + ] + ) + ->where([ 'status' => 1 ]) + ->asArray() + ->indexBy('id') + ->column(); + $entities = Alias::find() + ->select('entity') + ->where( + [ + 'not', + [ 'entity' => null ], + ] + ) + ->distinct() + ->indexBy('entity') + ->column(); + $searchModel = new AliasSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'languages' => $languages, + 'entities' => $entities, + ] + ); + } + + /** + * Displays a single Alias model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new Alias model. + * If creation is successful, the browser will be redirected to the 'view' alias. + * + * @param string $url + * +*@return mixed + */ + public function actionCreate(string $url = null) + { + $languages = Language::find() + ->select( + [ + 'name', + 'id', + ] + ) + ->where([ 'status' => 1 ]) + ->asArray() + ->indexBy('id') + ->column(); + $model = new Alias( + [ + 'scenario' => Alias::SCENARIO_CREATE, + ] + ); + if ($model->load(Yii::$app->request->post())) { + if ($model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + + if (!empty($url)) { + $urlArray = explode('/', trim($url, '/')); + + $route = Json::encode( + [ + 'category/view', + 'filter' => $urlArray[ 2 ], + 'category' => $urlArray[ 1 ], + ] + ); + + $model->route = $route; + $model->entity = Filter::className(); + $model->fields = $url; + } + + return $this->render( + 'create', + [ + 'model' => $model, + 'languages' => $languages, + ] + ); + } + + /** + * Updates an existing Alias model. + * If update is successful, the browser will be redirected to the 'view' alias. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->scenario = Alias::SCENARIO_UPDATE; + + if ($model->load(Yii::$app->request->post())) { + if ($model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + + return $this->render( + 'update', + [ + 'model' => $model, + ] + ); + } + + /** + * Deletes an existing Alias model. + * If deletion is successful, the browser will be redirected to the 'index' alias. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Get unique slug from $text + * + * @param $text + * @param int|null $languageId + * + * @return string + */ + public function actionSlugify($text, int $languageId = null) + { + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + $slug = SlugHelper::slugify($text); + return SlugHelper::unify($slug, null, $languageId); + } + + /** + * Finds the Alias model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Alias the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = Alias::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested alias does not exist.'); + } + } + } diff --git a/artweb/artbox-core/controllers/FeedbackController.php b/artweb/artbox-core/controllers/FeedbackController.php new file mode 100755 index 0000000..a7f3f93 --- /dev/null +++ b/artweb/artbox-core/controllers/FeedbackController.php @@ -0,0 +1,219 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [// 'change-password' => [ 'post' ], + ], + ], + ]; + } + + /** + * Lists all Feedback models. + * + * @return mixed + */ + public function actionIndex() + { + $dataProvider = new ActiveDataProvider( + [ + 'query' => Feedback::find()->orderBy('created_at DESC'), + ] + ); + + return $this->render( + 'index', + [ + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single Feedback model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + $model = $this->findModel($id); + + $model->status = true; + $model->save(false, [ 'status' ]); + + return $this->render( + 'view', + [ + 'model' => $model, + ] + ); + } + + /** + * Creates a new Feedback model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new Feedback(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'create', + [ + 'model' => $model, + ] + ); + } + } + + /** + * Updates an existing Feedback model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + $model->status = true; + $model->save(false, [ 'status' ]); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect('index'); + } else { + return $this->render( + 'update', + [ + 'model' => $model, + ] + ); + } + } + + /** + * Deletes an existing Feedback model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + public function actionViewed($id) + { + if (Yii::$app->request->isPost) { + $model = $this->findModel($id); + + Yii::$app->response->format = Response::FORMAT_JSON; + + $model->status = true; + if ($model->save(false, [ 'status' ])) { + + $widget = FeedbackWidget::widget(); + + return [ + 'text' => Html::tag( + 'span', + '', + [ + 'class' => 'glyphicon glyphicon-ok', + ] + ), + 'message' => [ + 'title' => Yii::t('core', 'Notification') . ':', + 'text' => Yii::t('core', 'Status changed'), + ], + 'widget' => $widget, + ]; + } + } + return []; + } + + /** + * Finds the Feedback model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Feedback the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = Feedback::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/artweb/artbox-core/controllers/PageCategoryController.php b/artweb/artbox-core/controllers/PageCategoryController.php new file mode 100644 index 0000000..7b4026b --- /dev/null +++ b/artweb/artbox-core/controllers/PageCategoryController.php @@ -0,0 +1,246 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + 'access' => [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function getViewPath() + { + return '@artbox/core/views/page-category'; + } + + /** + * Lists all PageCategory models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new PageCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single PageCategory model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new PageCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new PageCategory(); + $model->generateLangs(); + + if ($model->loadWithLangs(Yii::$app->request) && $model->saveWithLangs()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + } + } + + /** + * Updates an existing PageCategory model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + if ($model->loadWithLangs(Yii::$app->request) && $model->saveWithLangs()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + } + } + + /** + * Deletes an existing PageCategory model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the PageCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return PageCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = PageCategory::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + /** + * Returnes an array of matched categories, + * response must be in format: + * $out = [ + * 'results' => [ + * [ + * 'id' => 1, + * 'text' => 'First', + * ], + * [ + * 'id' => 2, + * 'text' => 'Second' + * ], + * ], + * ]; + * ! array key must be 'id' and 'text' ! + * + * @param null $q + * @return array + */ + public function actionList($q = null) + { + \Yii::$app->response->format = Response::FORMAT_JSON; + $out = [ + 'results' => [ + [ + 'id' => '', + 'text' => '', + ], + ], + ]; + if (!is_null($q)) { + $categories = PageCategory::find() + ->joinWith('lang') + ->select( + [ + 'id', + 'text' => 'page_category_lang.title', + ] + ) + ->andFilterWhere( + [ + 'ilike', + 'page_category_lang.title', + $q, + ] + ) + ->limit(20) + ->asArray() + ->all(); + + if (!empty($categories)) { + $out[ 'results' ] = $categories; + } + } + + return $out; + } + } diff --git a/artweb/artbox-core/controllers/PageController.php b/artweb/artbox-core/controllers/PageController.php new file mode 100755 index 0000000..05bde16 --- /dev/null +++ b/artweb/artbox-core/controllers/PageController.php @@ -0,0 +1,223 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [], + ], + ]; + } + + /** + * Lists all Page models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new PageSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single Page model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new Page model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new Page(); + $model->generateLangs(); + + $model->categoryIds = []; + + if ($model->loadWithLangs(\Yii::$app->request)) { + if ($model->saveWithLangs()) { + + $categories = PageCategory::find() + ->where([ 'id' => \Yii::$app->request->post('categoryIds') ]) + ->all(); + + $model->linkMany('categories', $categories); + + $model->saveImages(\Yii::$app->request->post()); + + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + } + + /** + * Updates an existing Page model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + $model->categoryIds = ArrayHelper::map( + $model->categories, + 'id', + 'lang.title' + ); + + if ($model->loadWithLangs(\Yii::$app->request)) { + if ($model->saveWithLangs()) { + + $categories = PageCategory::find() + ->where([ 'id' => \Yii::$app->request->post('categoryIds') ]) + ->all(); + + $model->linkMany('categories', $categories); + + $model->saveImages(\Yii::$app->request->post()); + + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + ] + ); + } + + /** + * Deletes an existing Page model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the Page model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return array|\yii\db\ActiveRecord|Page + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + $model = Page::find() + ->with( + [ + 'lang', + 'categories.lang', + ] + ) + ->where([ 'id' => $id ]) + ->one(); + + if ($model !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/artweb/artbox-core/controllers/ProfileController.php b/artweb/artbox-core/controllers/ProfileController.php new file mode 100755 index 0000000..a971f08 --- /dev/null +++ b/artweb/artbox-core/controllers/ProfileController.php @@ -0,0 +1,169 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [// 'change-password' => [ 'post' ], + ], + ], + ]; + } + /** + * @return bool|string + */ + public function getViewPath() + { + return \Yii::getAlias('@artbox/core/views/profile'); + } + + /** + * User profile page, that allows to change UserData and password. + * + * @param \artbox\core\models\ChangePassword|null $changePasswordModel + * @param \artbox\core\models\UserData|null $userData + * + * @return string + * @throws \yii\base\InvalidConfigException + */ + public function actionIndex(ChangePassword $changePasswordModel = null, UserData $userData = null) + { + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + /** + * @var LinkBehavior $userDataBehavior + */ + if (empty( $userData )) { + if (( $userDataBehavior = $user->getBehavior('userData') ) === null) { + throw new InvalidConfigException( + \Yii::t('core', '$app->user->identity class must have LinkBehavior to UserData model') + ); + } + $userDataBehavior->ensureExistance(); + $userData = $userDataBehavior->getLinkObject(); + } + if (empty( $changePasswordModel )) { + /** + * @var ChangePassword $changePasswordModel + */ + $changePasswordModel = \Yii::createObject(ChangePassword::className()); + } + return $this->render( + 'index', + [ + 'user' => $user, + 'userData' => $userData, + 'changePasswordModel' => $changePasswordModel, + ] + ); + } + + /** + * Change User password + * + * @return string|\yii\web\Response + */ + public function actionChangePassword() + { + if (empty( \Yii::$app->request->post() )) { + return $this->redirect([ 'index' ]); + } + /** + * @var ChangePassword $model + */ + $model = \Yii::createObject(ChangePassword::className()); + $success = false; + if ($model->load(\Yii::$app->request->post()) && $model->validate()) { + if ($model->validatePassword()) { + if (( $success = $model->saveChanges() ) === true) { + \Yii::$app->session->setFlash('success', \Yii::t('core', 'Password was successfully changed.')); + } + } + } + if (!$success) { + \Yii::$app->session->setFlash('error', \Yii::t('core', 'Password change failed.')); + } + $model->oldPassword = $model->newPassword = $model->newPasswordRepeat = null; + return $this->actionIndex($model); + } + + /** + * Update UserData + * + * @return string|\yii\web\Response + * @throws \yii\base\InvalidConfigException + */ + public function actionUpdate() + { + if (empty( \Yii::$app->request->post() )) { + return $this->redirect([ 'index' ]); + } + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + /** + * @var LinkBehavior $userDataBehavior + */ + if (( $userDataBehavior = $user->getBehavior('userData') ) === null) { + throw new InvalidConfigException( + \Yii::t('core', '$app->user->identity class must have LinkBehavior to UserData model') + ); + } + $userDataBehavior->ensureExistance(); + $model = $userDataBehavior->getLinkObject(); + $success = false; + if ($model->load(\Yii::$app->request->post()) && $model->validate()) { + if (( $success = $model->save() ) === true) { + \Yii::$app->session->setFlash( + 'success', + \Yii::t('core', 'Personal information was successfully changed.') + ); + } + } + if (!$success) { + \Yii::$app->session->setFlash('error', \Yii::t('core', 'Personal information change failed.')); + } + return $this->actionIndex(null, $model); + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/controllers/SeoController.php b/artweb/artbox-core/controllers/SeoController.php new file mode 100755 index 0000000..95a0dbe --- /dev/null +++ b/artweb/artbox-core/controllers/SeoController.php @@ -0,0 +1,59 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [], + ], + ]; + } + + /** + * To be done. + * + * @return mixed + */ + public function actionIndex() + { + return $this->render('index'); + } + } diff --git a/artweb/artbox-core/controllers/SitemapController.php b/artweb/artbox-core/controllers/SitemapController.php new file mode 100755 index 0000000..42fe511 --- /dev/null +++ b/artweb/artbox-core/controllers/SitemapController.php @@ -0,0 +1,270 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + ]; + } + + /** + * Action to configure sitemap of the website + * + * @return string + */ + public function actionIndex() + { + return $this->render('index'); + } + + /** + * Action to configure sitemap of the website + * + * @return string + */ + public function actionUpdate() + { + /** + * @var Sitemap $sitemap + */ + $request = \Yii::$app->request; + // ***** Generate SitemapDynamic models for every entity in Sitemap component + $sitemap = \Yii::$app->get('sitemap'); + $entities = $sitemap->entities; + /** + * @var SitemapDynamic[] $entity_models + */ + $entity_models = []; + foreach ($entities as $entity) { + $entity_model = new SitemapDynamic(); + $entity_model->entity = $entity[ 'class' ]; + $entity_model->status = SitemapDynamic::STATUS_DISABLED; + $entity_models[] = $entity_model; + } + // ***** <<< End + if ($request->isPost) { + $success = false; + // ***** Create SitemapStatic models from POST and delete existing + $models = []; + $index = 1; + foreach ($request->post('SitemapStatic') as $item) { + $model = new SitemapStatic(); + if ($model->load($item, '') && $model->validate()) { + $model->id = $index++; + $models[] = $model; + } + } + if (!empty($models)) { + $old = SitemapStatic::find() + ->all(); + foreach ($old as $item) { + $item->delete(); + } + foreach ($models as $model) { + $model->save(false); + $success = true; + } + } + // ***** <<< End + // ***** Create SitemapDynamic models from POST and delete existing + + /** + * @var SitemapDynamic[] $old_entity_models + */ + $old_entity_models = SitemapDynamic::find() + ->all(); + foreach ($old_entity_models as $old_entity_model) { + $old_entity_model->delete(); + } + $index = 1; + $entity_models = []; + foreach ($request->post('SitemapDynamic') as $item) { + $entity = new SitemapDynamic(); + if ($entity->load($item, '') && $entity->validate()) { + $entity->id = $index++; + $entity->save(false); + $entity_models[] = $entity; + $success = true; + } + } + if ($success) { + if ($request->post('action', '') == 'generate') { + if ($sitemap->generateXML()) { + \Yii::$app->session->setFlash( + 'success', + \Yii::t( + 'core', + 'Карта сайта сгенерированна в ' . \Yii::getAlias( + $sitemap->path . '.' + ) + ) + ); + } + } + return $this->redirect([ 'index' ]); + } + // ***** <<< End + } else { + // ***** Find existing SitemapStatic models + $models = SitemapStatic::find() + ->all(); + if (empty($models)) { + $models = [ new SitemapStatic() ]; + } + // ***** <<< End + // ***** Fill SitemapDynamic models from Sitemap component with existing models + /** + * @var SitemapDynamic[] $old_entity_models + */ + $old_entity_models = SitemapDynamic::find() + ->indexBy('entity') + ->all(); + foreach ($entity_models as $index => $entity_model) { + if (isset($old_entity_models[ $entity_model->entity ])) { + $entity_model->status = $old_entity_models[ $entity_model->entity ]->status; + $entity_model->priority = $old_entity_models[ $entity_model->entity ]->priority; + $entity_model->frequency = $old_entity_models[ $entity_model->entity ]->frequency; + } + } + // ***** <<< End + } + return $this->render( + 'update', + [ + 'models' => $models, + 'entity_models' => $entity_models, + ] + ); + } + + /** + * Create activeField for static sitemap + * + * @return string + */ + public function actionCreateStatic() + { + $content = ''; + $request = \Yii::$app->request; + $formId = $request->get('formId'); + $count = $request->get('count'); + if (empty($formId) || empty($count)) { + return $this->renderContent($content); + } + $model = new SitemapStatic(); + $form = new ActiveForm(); + $content .= $form->field( + $model, + "[$count]url", + [ + 'options' => [ + 'class' => 'form-group col-xs-5 col-sm-6', + ], + ] + ) + ->textInput() + ->render(); + $content .= $form->field( + $model, + "[$count]frequency", + [ + 'options' => [ + 'class' => 'form-group col-xs-3 col-sm-3', + ], + ] + ) + ->dropDownList( + [ + 'always' => 'always', + 'hourly' => 'hourly', + 'daily' => 'daily', + 'weekly' => 'weekly', + 'monthly' => 'monthly', + 'yearly' => 'yearly', + 'never' => 'never', + ] + ) + ->render(); + $content .= $form->field( + $model, + "[$count]priority", + [ + 'options' => [ + 'class' => 'form-group col-xs-3 col-sm-2', + ], + ] + ) + ->textInput() + ->render(); + $content .= Html::icon( + 'minus', + [ + 'class' => 'col-xs-1 field-group-remove', + 'onclick' => 'sitemap_remove(this)', + ] + ); + foreach ($form->attributes as $index => $attribute) { + $content .= Html::script("$('#w0').yiiActiveForm('add', " . Json::htmlEncode($attribute) . ");"); + } + $content = Html::tag( + 'div', + $content, + [ + 'class' => 'row field-group', + ] + ); + $this->layout = false; + return $this->renderContent($content); + } + + /** + * Generate sitemap XML to Sitemap::$path + * + * @return bool + */ + public function actionGenerate() + { + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + /** + * @var Sitemap $sitemap + */ + $sitemap = \Yii::$app->get('sitemap'); + return $sitemap->generateXML(); + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/controllers/SlideController.php b/artweb/artbox-core/controllers/SlideController.php new file mode 100755 index 0000000..f164746 --- /dev/null +++ b/artweb/artbox-core/controllers/SlideController.php @@ -0,0 +1,211 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all Slide models. + * + * @param int $slider_id + * + * @return mixed + */ + public function actionIndex($slider_id) + { + $slider = $this->findSlider($slider_id); + $searchModel = new SlideSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $slider); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'slider' => $slider, + ] + ); + } + + /** + * Displays a single Slide model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new Slide model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @param int $slider_id + * + * @return mixed + */ + public function actionCreate(int $slider_id) + { + $slider = $this->findSlider($slider_id); + + $model = new Slide(); + $model->generateLangs(); + + if ($model->loadWithLangs(\Yii::$app->request)) { + if ($model->saveWithLangs()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'create', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'slider' => $slider, + ] + ); + } + + /** + * Updates an existing Slide model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + $model->generateLangs(); + + $slider = $this->findSlider($model->slider_id); + + if ($model->loadWithLangs(\Yii::$app->request)) { + if ($model->saveWithLangs()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } + } + return $this->render( + 'update', + [ + 'model' => $model, + 'modelLangs' => $model->modelLangs, + 'slider' => $slider, + ] + ); + } + + /** + * Deletes an existing Slide model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the Slide model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Slide the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = Slide::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + /** + * Finds the Slider model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Slider the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findSlider($id) + { + if (( $model = Slider::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/artweb/artbox-core/controllers/SliderController.php b/artweb/artbox-core/controllers/SliderController.php new file mode 100755 index 0000000..85831be --- /dev/null +++ b/artweb/artbox-core/controllers/SliderController.php @@ -0,0 +1,174 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], + ], + ]; + } + + /** + * Lists all Slider models. + * + * @return mixed + */ + public function actionIndex() + { + $searchModel = new SliderSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render( + 'index', + [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ] + ); + } + + /** + * Displays a single Slider model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render( + 'view', + [ + 'model' => $this->findModel($id), + ] + ); + } + + /** + * Creates a new Slider model. + * If creation is successful, the browser will be redirected to the 'view' page. + * + * @return mixed + */ + public function actionCreate() + { + $model = new Slider(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'create', + [ + 'model' => $model, + ] + ); + } + } + + /** + * Updates an existing Slider model. + * If update is successful, the browser will be redirected to the 'view' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect( + [ + 'view', + 'id' => $model->id, + ] + ); + } else { + return $this->render( + 'update', + [ + 'model' => $model, + ] + ); + } + } + + /** + * Deletes an existing Slider model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * + * @param integer $id + * + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id) + ->delete(); + + return $this->redirect([ 'index' ]); + } + + /** + * Finds the Slider model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Slider the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (( $model = Slider::findOne($id) ) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + } diff --git a/artweb/artbox-core/exceptions/AliasOverwriteException.php b/artweb/artbox-core/exceptions/AliasOverwriteException.php new file mode 100644 index 0000000..b7e7c4e --- /dev/null +++ b/artweb/artbox-core/exceptions/AliasOverwriteException.php @@ -0,0 +1,21 @@ + 'beforeAction' ]; + } + + /** + * @param ActionEvent $event + * + * @return bool + * @throws MethodNotAllowedHttpException when the request method is not allowed. + */ + public function beforeAction($event) + { + $action = $event->action->id; + if (!in_array($action, $this->actions)) { + return $event->isValid; + } + + if (!Yii::$app->request->isAjax) { + $event->isValid = false; + throw new MethodNotAllowedHttpException('Must be AJAX request only'); + } + + return $event->isValid; + } + } diff --git a/artweb/artbox-core/helpers/ImageHelper.php b/artweb/artbox-core/helpers/ImageHelper.php new file mode 100755 index 0000000..b06bc8f --- /dev/null +++ b/artweb/artbox-core/helpers/ImageHelper.php @@ -0,0 +1,68 @@ + ImageManipulator::className(), + 'fullPath' => $matches[ 0 ], + 'path' => $matches[ 1 ], + 'name' => $matches[ 2 ], + 'extension' => $matches[ 3 ], + + ] + ); + + return $obj; + } + + /** + * Check if helper directory exists, if not - create it + */ + protected static function checkDir() + { + $dir = Yii::getAlias('@storage/helper'); + $stor = Yii::getAlias('@storage'); + + if (!is_dir($stor)) { + mkdir($stor); + } + if (!is_dir($dir)) { + mkdir($dir); + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/helpers/ImageManipulator.php b/artweb/artbox-core/helpers/ImageManipulator.php new file mode 100755 index 0000000..4e1e19b --- /dev/null +++ b/artweb/artbox-core/helpers/ImageManipulator.php @@ -0,0 +1,463 @@ +image is null + */ + if ($force) { + $this->image = Image::getImagine() + ->open($this->fullPath); + } + + return $this->image->getSize(); + } + + /** + * Open the image and store it, set initial width and height + */ + public function init() + { + // $this->image = Image::getImagine() + // ->open($this->fullPath); + // $this->width = $this->image->getSize() + // ->getWidth(); + // $this->height = $this->image->getSize() + // ->getHeight(); + } + + /** + * Resize image, keeping aspect ratio + * + * @param int $width + * @param int $height + * + * @return $this + */ + public function resize(int $width, int $height) + { + $this->prefix = $width . '_x_' . $height; + + $this->action = self::ACTION_RESIZE; + + $this->actionWidth = $width; + $this->actionHeight = $height; + + return $this; + } + + protected function perfomResize(int $width, int $height) + { + $this->image = $this->image->thumbnail(new Box($width, $height)); + + return $this; + + } + + /** + * Resize to needed width, saving the proportion + * + * @param int $width + * + * @return $this + */ + public function setWidth(int $width) + { + $this->prefix = 'w_' . $width; + + $this->action = self::ACTION_SET_WIDTH; + + $this->actionHeight = $width; + + return $this; + } + + protected function performSetWidth(int $width) + { + $height = round($this->height * $width / $this->width); + + $this->image = $this->image->thumbnail(new Box($width, $height)); + + return $this; + } + + /** + * Resize to needed height, saving the proportion + * + * @param int $height + * + * @return $this + */ + public function setHeight(int $height) + { + $this->prefix = 'h_' . $height; + + $this->action = self::ACTION_SET_HEIGHT; + + $this->actionHeight = $height; + + return $this; + } + + protected function performSetHeight(int $height) + { + $width = round($this->width * $height / $this->height); + + $this->image = $this->image->thumbnail(new Box($width, $height)); + + return $this; + } + + /** + * First resize image by closest side, the crop out the rests + * + * @param int $width + * @param int $height + * + * @return $this + */ + public function cropResize(int $width, int $height) + { + $this->prefix = 'cr_' . $width . '_x_' . $height; + + $this->action = self::ACTION_CROP_RESIZE; + + $this->actionHeight = $height; + $this->actionWidth = $width; + + return $this; + } + + protected function performCropResize(int $width, int $height) + { + if ($this->width / $this->height > $width / $height) { + + $this->image = $this->performSetHeight($height)->image; + $newWidth = $this->image->getSize() + ->getWidth(); + + if ($newWidth - $width >= 0) { + $this->image = $this->image->crop( + new Point(round(( $newWidth - $width ) / 2), 0), + new Box($width, $height) + ); + } + } else { + $this->image = $this->performSetWidth($width)->image; + $newHeight = $this->image->getSize() + ->getHeight(); + + if ($newHeight - $height >= 0) { + $this->image = $this->image->crop( + new Point(0, round(( $newHeight - $height ) / 2)), + new Box($width, $height) + ); + } + } + + return $this; + } + + /** + * Croup out needed box from the middle of image + * + * @param int $width + * @param int $height + * + * @return $this + */ + public function crop(int $width, int $height) + { + $this->prefix = 'c_' . $width . '_x_' . $height; + + $this->action = self::ACTION_CROP; + + $this->actionWidth = $width; + $this->actionHeight = $height; + + return $this; + } + + protected function performCrop(int $width, int $height) + { + $this->image = $this->image->copy() + ->crop( + new Point(round($this->width - $width), round($this->height - $height)), + new Box($width, $height) + ); + + return $this; + } + + /** + * Fits image in needed dimensions, empty area fiils with chosen color, default is white + * + * @param int $width + * @param int $height + * @param string $color + * + * @return $this + */ + public function fillResize(int $width, int $height, string $color = '#FFFFFF') + { + $this->prefix = 'cf_' . $width . '_x_' . $height; + + $this->action = self::ACTION_FILL_RESIZE; + + $this->actionHeight = $height; + $this->actionWidth = $width; + $this->actionColor = $color; + + return $this; + } + + protected function performFillResize(int $width, int $height, string $color = '#FFFFFF') + { + $parent = Image::getImagine() + ->create(new Box($width, $height), ( new RGB() )->color($color)); + + if ($this->width / $this->height > $width / $height) { + $this->performSetWidth($width); + $newHeight = $this->image->getSize() + ->getHeight(); + + $this->image = $parent->paste( + $this->image, + new Point( + 0, round( + ( $height - $newHeight ) / 2 + ) + ) + ); + + } else { + $this->performSetHeight($height); + $newWidth = $this->image->getSize() + ->getWidth(); + + $this->image = $parent->paste( + $this->image, + new Point( + round( + ( $width - $newWidth ) / 2 + ), 0 + ) + ); + } + + return $this; + } + + /** + * Resize image to needed size, without saving aspect ratio + * + * @param int $width + * @param int $height + * + * @return $this + */ + public function strictResize(int $width, int $height) + { + $this->prefix = 'sr_' . $width . '_x_' . $height; + + $this->action = self::ACTION_STRICT_RESIZE; + + $this->actionWidth = $width; + $this->actionHeight = $height; + + return $this; + } + + protected function performStrictResize(int $width, int $height) + { + $this->image = $this->image->resize(new Box($width, $height)); + + return $this; + } + + /** + * Sets the output image quality in percents, default is 100% + * + * @param int $quality + * + * @return $this + * @throws \yii\base\InvalidConfigException + */ + public function quality(int $quality) + { + if ($quality <= 0 || $quality > 100) { + throw new InvalidConfigException('Wrong quality value'); + } + + $this->qualityValue = $quality; + + $this->prefix .= '_q' . $quality; + + return $this; + } + + /** + * Save the image, and return path to it + * + * @return string + */ + public function render() + { + $name = $this->name; + if (isset($this->prefix)) { + $name .= '_' . $this->prefix; + } + $path = \Yii::getAlias('@storage/helper/') . $name . '.' . $this->extension; + if (file_exists($path)) { + return '/storage/helper/' . $name . '.' . $this->extension; + } + + $this->performAction(); + + $this->image->save( + $path, + [ + 'quality' => $this->qualityValue, + ] + ); + + unset($this->image); + + return '/storage/helper/' . $name . '.' . $this->extension; + } + + /** + * Save and return the image as html img string + * + * @param array $options + * + * @return string + */ + public function renderImage(array $options = []) + { + return Html::img($this->render(), $options); + } + + protected function performAction() + { + $this->image = Image::getImagine() + ->open($this->fullPath); + $this->width = $this->image->getSize() + ->getWidth(); + $this->height = $this->image->getSize() + ->getHeight(); + + if ($this->action === self::ACTION_CROP) { + $this->performCrop($this->actionWidth, $this->actionHeight); + } elseif ($this->action === self::ACTION_STRICT_RESIZE) { + $this->performStrictResize($this->actionWidth, $this->actionHeight); + } elseif ($this->action === self::ACTION_CROP_RESIZE) { + $this->performCropResize($this->actionWidth, $this->actionHeight); + } elseif ($this->action === self::ACTION_FILL_RESIZE) { + $this->performFillResize($this->actionWidth, $this->actionHeight, $this->actionColor); + } elseif ($this->action === self::ACTION_RESIZE) { + $this->perfomResize($this->actionWidth, $this->actionHeight); + } elseif ($this->action === self::ACTION_SET_HEIGHT) { + $this->performSetHeight($this->actionHeight); + } elseif ($this->action === self::ACTION_SET_WIDTH) { + $this->performSetWidth($this->actionWidth); + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/helpers/SlugHelper.php b/artweb/artbox-core/helpers/SlugHelper.php new file mode 100755 index 0000000..494f195 --- /dev/null +++ b/artweb/artbox-core/helpers/SlugHelper.php @@ -0,0 +1,226 @@ + 'a', + 'б' => 'b', + 'в' => 'v', + 'г' => 'g', + 'д' => 'd', + 'е' => 'e', + 'ё' => 'e', + 'ж' => 'zh', + 'з' => 'z', + 'и' => 'i', + 'й' => 'y', + 'к' => 'k', + 'л' => 'l', + 'м' => 'm', + 'н' => 'n', + 'о' => 'o', + 'п' => 'p', + 'р' => 'r', + 'с' => 's', + 'т' => 't', + 'у' => 'u', + 'ф' => 'f', + 'х' => 'h', + 'ц' => 'c', + 'ч' => 'ch', + 'ш' => 'sh', + 'щ' => 'sch', + 'ь' => "", + 'ы' => 'y', + 'ъ' => "", + 'э' => 'e', + 'ю' => 'yu', + 'я' => 'ya', + 'ї' => 'yi', + 'є' => 'ye', + 'і' => 'ee', + + 'А' => 'A', + 'Б' => 'B', + 'В' => 'V', + 'Г' => 'G', + 'Д' => 'D', + 'Е' => 'E', + 'Ё' => 'E', + 'Ж' => 'Zh', + 'З' => 'Z', + 'И' => 'I', + 'Й' => 'Y', + 'К' => 'K', + 'Л' => 'L', + 'М' => 'M', + 'Н' => 'N', + 'О' => 'O', + 'П' => 'P', + 'Р' => 'R', + 'С' => 'S', + 'Т' => 'T', + 'У' => 'U', + 'Ф' => 'F', + 'Х' => 'H', + 'Ц' => 'C', + 'Ч' => 'Ch', + 'Ш' => 'Sh', + 'Щ' => 'Sch', + 'Ь' => "", + 'Ы' => 'Y', + 'Ъ' => "", + 'Э' => 'E', + 'Ю' => 'Yu', + 'Я' => 'Ya', + 'Ї' => 'Yi', + 'Є' => 'Ye', + 'І' => 'Ee', + ]; + + $symbol = [ + ' ' => '-', + "'" => '', + '"' => '', + '!' => '', + "@" => '', + '#' => '', + '$' => '', + "%" => '', + '^' => '', + ';' => '', + "*" => '', + '(' => '', + ')' => '', + "+" => '', + '~' => '', + '.' => '', + ',' => '-', + '?' => '', + '…' => '', + '№' => 'N', + '°' => '', + '`' => '', + '|' => '', + '&' => '-and-', + '<' => '', + '>' => '', + ]; + + if ($setting == 'letter') { + $converter = $letter; + } else if ($setting == 'symbol') { + $converter = $symbol; + } else { + $converter = $letter + $symbol; + } + + $url = strtr($string, $converter); + + $url = str_replace("---", '-', $url); + $url = str_replace("--", '-', $url); + + return $url; + } + + /** + * Generate slug + * + * @param string $string string to translit + * @param bool $translit whether to use custom translit + * @param string $replacement + * @param bool $lowercase whether to lowercase result + * + * @see Inflector::slug() + * @return string + */ + static function slugify( + string $string, + bool $translit = true, + string $replacement = '-', + bool $lowercase = true + ): string { + return Inflector::slug($translit ? SlugHelper::translit($string) : $string, $replacement, $lowercase); + } + + /** + * Get unique to alias table slug + * + * @param string $string string to translit + * @param \artbox\core\models\Alias $alias Current alias + * @param int|null $languageId + * + * @return string + */ + static function unify(string $string, Alias $alias = null, int $languageId = null): string + { + $new_string = $string; + $suffix = 2; + while (!self::checkUnique($new_string, $alias, $languageId)) { + $new_string = $string . '-' . $suffix; + $suffix++; + } + return $new_string; + } + + /** + * Checks uniqueness of the slug + * + * @param string $string + * @param \artbox\core\models\Alias $alias + * @param int|null $languageId + * + * @return bool + */ + private static function checkUnique(string $string, Alias $alias = null, int $languageId = null): bool + { + if (empty($languageId)) { + $languageId = Language::$current->id; + } + $query = Alias::find() + ->where( + [ + 'value' => $string, + 'language_id' => $languageId, + ] + ); + if (!empty($alias) && !$alias->isNewRecord) { + $query->andWhere( + [ + 'not', + [ 'id' => $alias->id ], + ] + ); + } + return !$query->exists(); + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/helpers/SlugifyDecorator.php b/artweb/artbox-core/helpers/SlugifyDecorator.php new file mode 100755 index 0000000..4dea0ed --- /dev/null +++ b/artweb/artbox-core/helpers/SlugifyDecorator.php @@ -0,0 +1,149 @@ +template; + $input = self::INPUT_FIELD; + if (( $posBegin = strpos($template, $input) ) !== false) { + $posEnd = $posBegin + strlen($input); + $divBegin = Html::beginTag( + 'div', + [ + 'class' => 'input-group', + ] + ); + $divEnd = Html::tag( + 'span', + self::createButton( + $field, + $url, + $attribute, + $languageId + ) . ( $enableCancel ? self::createCancel( + $field + ) : '' ), + [ + 'class' => 'input-group-btn', + ] + ) . Html::endTag('div'); + $template = substr_replace($template, $divEnd, $posEnd, 0); + $template = substr_replace($template, $divBegin, $posBegin, 0); + $field->template = $template; + } + return $field; + } + + /** + * Create 'Slugify' button + * + * @param \yii\widgets\ActiveField $field + * @param array $url + * @param \yii\widgets\ActiveField $attribute + * @param int $languageId + * + * @return string + */ + private static function createButton( + ActiveField $field, + array $url, + ActiveField $attribute, + int $languageId + ): string { + $options = [ + 'data' => [ + 'id' => Html::getInputId($field->model, $field->attribute), + 'attribute-id' => Html::getInputId($attribute->model, $attribute->attribute), + 'url' => Url::to($url), + 'language-id' => $languageId, + ], + 'class' => 'btn btn-info slugify_button', + ]; + if ($field !== $attribute) { + $options[ 'data' ] = array_merge( + $options[ 'data' ], + [ + 'toggle' => 'tooltip', + 'placement' => 'top', + 'original-title' => \Yii::t( + 'core', + 'Create slug from {field} field', + [ + 'field' => $attribute->model->getAttributeLabel( + Html::getAttributeName($attribute->attribute) + ), + ] + ), + ] + ); + } + return Html::button( + \Yii::t('core', 'Slugify'), + $options + ); + } + + /** + * Create 'Cancel' button + * + * @param \yii\widgets\ActiveField $field + * + * @return string + */ + private static function createCancel( + ActiveField $field + ): string { + /** + * @var ActiveRecord $model + */ + $model = $field->model; + $options = [ + 'data' => [ + 'id' => Html::getInputId($model, $field->attribute), + 'value' => $model->getAttribute(Html::getAttributeName($field->attribute)), + ], + 'class' => 'btn btn-default slugify_cancel_button', + ]; + return Html::button( + \Yii::t('core', 'Cancel'), + $options + ); + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/helpers/UnificatorHelper.php b/artweb/artbox-core/helpers/UnificatorHelper.php new file mode 100755 index 0000000..06f2eb5 --- /dev/null +++ b/artweb/artbox-core/helpers/UnificatorHelper.php @@ -0,0 +1,29 @@ + [ + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'class'=>'artweb\artbox\language\components\LanguageUrlManager', + 'rules'=>[ + '/' => 'site/index', + '//*'=>'/', + ] +], +3. Добавляем в файл конфигурации: +'request' => [ + 'class' => 'artweb\artbox\language\components\LanguageRequest' +], +4. Добавляем в файл конфигурации: +'language'=>'ru-RU', +'i18n' => [ + 'translations' => [ + '*' => [ + 'class' => 'yii\i18n\PhpMessageSource', + 'basePath' => '@frontend/messages', + 'sourceLanguage' => 'en', + 'fileMap' => [ + ], + ], + ], +], +5. Переводы писать в файл frontend\messages\{language}\app.php, где {language} - нужный язык, например ru. +6. Для вывода на странице сообщения с переводом используем функцию: Yii::t('app', {message}, $params = [], $language = null), + где {message} - нужное сообщение, $params - массив параметров, $language - нужный язык (по умолчанию используется текущий язык). +7. В наличие также виджет переключения языка: LanguagePicker::widget() + + +Как использовать мультиязычность для Active Record: +1. Создаем для таблицы {table} таблицу с языками {table_lang}. +2. Создаем для класса {Table} класс с языками {TableLang}. +3. Подключаеи для класса {Table} поведение LanguageBehavior: +public function behaviors() { + return [ + 'language' => [ + 'class' => LanguageBehavior::className(), + 'objectLang' => {TableLang}::className() // optional, default to {TableLang}::className() + 'ownerKey' => {Table}->id //optional, default to {Table}->primaryKey()[0] + 'langKey' => {TableLang}->table_id //optional, default to {Table}->tableName().'_id' + ], + ]; +} +3.1. PHPDoc для {Table}: + * * From language behavior * + * @property {TableLang} $lang + * @property {TableLang}[] $langs + * @property {TableLang} $objectLang + * @property string $ownerKey + * @property string $langKey + * @property {TableLang}[] $modelLangs + * @property bool $transactionStatus + * @method string getOwnerKey() + * @method void setOwnerKey(string $value) + * @method string getLangKey() + * @method void setLangKey(string $value) + * @method ActiveQuery getLangs() + * @method ActiveQuery getLang( integer $language_id ) + * @method {TableLang}[] generateLangs() + * @method void loadLangs(Request $request) + * @method bool linkLangs() + * @method bool saveLangs() + * @method bool getTransactionStatus() + * @method bool loadWithLangs( Request $request ) + * @method bool saveWithLangs() + * * End language behavior * + * @see LanguageBehavior +3.2. Убрать language behavior с наследуемых таблиц от {Table} ({TableSearch}...) +4. Доступные полезные методы: + {Table}->getLangs() - получить все текущие {TableLang} для {Table} проиндексированные по language_id + {Table}->getLang($language_id = NULL) - получить {TableLang} для определенного языка (default: текущий язык) для {Table} + {Table}->generateLangs() - получить массив {TableLang} под каждый язык, включая существующие записи, для {Table} + {Table}->loadLangs($request) - заполнить массив {TableLang} данными с POST + {Table}->linkLangs() - связать каждый элемент массива {TableLang} с текущей {Table} + {Table}->saveLangs() - провалидировать и сохранить каждый элемент массива {TableLang} +5. Добавить поля в форму (к примеру через Bootstrap Tabs). + В наличии: + LanguageForm::widget([ + 'modelLangs' => {TableLang}[], + 'formView' => string, + 'form' => ActiveForm, + ]); +6. Обрабатывать данные в контроллере. + 1. После создания/поиска {Table} создаем/находим языковые модели {Table}->generateLangs() + 2. При POST запросе загружаем данные в языковые модели {Table}->loadWithLangs(Request $request) + 3. Для сохранения используем метод {Table}->saveWithLangs(). Он вернет true если сохранение модели и всех языковых моделей прошло успешно. +7. Получать данные на публичной части сайта через {Table}->lang. diff --git a/artweb/artbox-core/messages/en/core.php b/artweb/artbox-core/messages/en/core.php new file mode 100755 index 0000000..f6cb348 --- /dev/null +++ b/artweb/artbox-core/messages/en/core.php @@ -0,0 +1,3 @@ + 'Мой вебсайт', + 'Main' => 'Главная', + 'Static pages' => 'Статические страницы', + 'SEO' => 'SEO', + 'Seo pages' => 'Seo страницы', + 'Robots' => 'Роботы', + 'Codes' => 'Коды', + 'Sitemap' => 'Карта сайта', + 'Welcome,' => 'Добро пожаловать,', + 'Change name' => 'Изменить имя', + 'Change image' => 'Изменить изображение', + 'Google Analytics Key' => 'Ключ Google аналитики', + 'Google analytics code' => 'Код Google аналитики', + 'Yandex metrics code' => 'Код Яндекс метрики', + 'Tag Manager code' => 'Код Tag Manager', + 'Phone' => 'Телефон', + 'Additional phone' => 'Дополнительный телефон', + 'Skype' => 'Skype', + 'Company name' => 'Название компании', + 'Email' => 'Email', + 'House' => 'Дом', + 'Street' => 'Улица', + 'Office' => 'Офис', + 'City' => 'Город', + 'Country' => 'Страна', + 'Latitude' => 'Широта', + 'Longitude' => 'Долгота', + 'Facebook' => 'Facebook', + 'VK' => 'VK', + 'Google' => 'Google', + 'Twitter' => 'Твиттер', + 'Company logo' => 'Логотип компании', + 'About us' => 'О нас', + 'Odnoklassniki' => 'Одноклассники', + 'ID' => 'ID', + 'Model' => 'Модель', + 'Status' => 'Статус', + 'Priority' => 'Приоритет', + 'Frequency' => 'Частота', + 'Url' => 'Url', + 'Contact phone for website' => 'Контактный телефон для сайта', + 'Contact email for website' => 'Контактный email для сайта', + 'Save' => 'Сохранить', + 'Social' => 'Соц. сети', + 'Contact' => 'Контактная информация', + 'Feedbacks' => 'Обратная связь', + 'Create Feedback' => 'Написать отзыв', + 'Pages' => 'Страницы', + 'Settings saved' => 'Настройки сохранены', + 'Robots saved' => 'Роботы сохранены', + 'Codes saved successfully' => 'Коды успешно сохранены', + 'Update sitemap' => 'Обновить карту сайта', + 'Dynamic pages' => 'Динамические страницы', + 'Save and generate' => 'Сохранить и сгенерировать', + 'Add field' => 'Добавить поле', + 'Title' => 'Заголовок', + 'Aliases' => "Псевдонимы", + 'Create {item}' => 'Создать {item}', + 'Value' => 'Значение', + 'Route' => 'Путь', + 'Search' => 'Поиск', + 'View generated sitemap.xml' => 'Посмотреть сгенерированный sitemap.xml', + 'Generate' => 'Сгенерировать', + 'Edit' => 'Редактировать', + 'Use in menu' => 'Отображение в меню', + 'Sort' => 'Сортировка', + "Doesn't look like robots" => 'Не похоже на робота', + 'Meta robots' => 'Meta роботы', + 'H1' => 'H1', + 'Description' => 'Описание', + 'Seo text' => 'Seo текст', + 'Entity' => 'Entity', + 'Available fields' => 'Доступные поля', + 'Language' => 'Язык', + 'Old password' => 'Старый пароль', + 'New password' => 'Новый пароль', + 'New password repeat' => 'Повторите новый пароль', + 'Provided old password doesn\'t match real password.' => 'При условии, что старый пароль не соответствует нынешнему.', + 'id' => 'ID', + 'name' => 'Имя', + 'phone' => 'Телефон', + 'created_at' => 'Создано', + 'ip' => 'IP', + 'url' => 'Url', + 'status' => 'Статус', + 'message' => 'Сообщение', + 'email' => 'Email', + 'Language ID' => 'ID языка', + 'Local' => 'Локально', + 'Name' => 'Имя', + 'Default' => 'По-умолчанию', + 'Date Create' => 'Дата создания', + 'Date Update' => 'Дата обновления', + 'The combination of Page ID and Language ID has already been taken.' => 'Комбинация из ID страницы и ID языка уже имеется.', + 'page_id' => 'ID страницы', + 'language_id' => 'ID языка', + 'Body' => 'Тело', + 'Alias' => 'псевдоним', + 'Mr.' => 'Г-н.', + 'Anonymous' => 'Аноним', + 'User ID' => 'ID пользователя', + 'Surname' => 'Фамилия', + 'Image' => 'Изображение', + 'Created At' => 'Создано', + 'Updated At' => 'Обновлено', + 'Visited At' => 'Последнее посещение', + 'Page' => 'страницу', + 'page_title' => 'Заголовок', + 'page_in_menu' => 'Отображение в меню', + 'page_sort' => 'Сортировка', + 'Create slug from {field} field' => 'Сгенерировать псевдоним из поля "{field}"', + 'Slugify' => 'Сгенерировать', + 'Create' => 'Создать', + 'Creating aliases by hand may cause bugs for your website. Use it only if you know what are you doing!' => 'Собственноручное создание псевдонимов может отразиться на работе вашего сайта. Используйте это, если вы действительно понимаете что делаете!', + 'Notification' => 'Оповещение', + 'Alias Value' => 'Значение псевдонима', + 'Update Category' => 'Обновить категорию', + 'Brand Title' => 'Заголовок бренда', + 'Upload Document' => 'Загрузить документ', + 'Send' => 'Отправить', + 'Common' => 'Общее', + 'Options' => 'Опции', + 'Gallery' => 'Галерея', + 'Add' => 'Добавить', + 'Product option group complementary' => 'Дополнительные группы опций товара', + 'Is Filter' => 'Является фильтром', + 'Search for a categories ...' => 'Поиск категорий ..', + 'Product option group exclude' => 'Исключения группы опций товара', + 'Variant option group exclude' => 'Исключения группы варианта товара', + 'Option Groups' => 'Группы опций', + 'Image Id' => 'ID изображения', + 'Body Preview' => 'Предпросмотр', + 'Author ID' => 'ID автора', + 'Parent ID' => 'Родительский ID', + 'Count' => 'Количество', + + ]; \ No newline at end of file diff --git a/artweb/artbox-core/migrations/m170309_000000_user.php b/artweb/artbox-core/migrations/m170309_000000_user.php new file mode 100755 index 0000000..6da9d2b --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000000_user.php @@ -0,0 +1,48 @@ +db->driverName === 'mysql') { + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + $this->createTable( + 'user', + [ + 'id' => $this->primaryKey(), + 'username' => $this->string() + ->notNull() + ->unique(), + 'auth_key' => $this->string(32) + ->notNull(), + 'password_hash' => $this->string() + ->notNull(), + 'password_reset_token' => $this->string() + ->unique(), + 'email' => $this->string() + ->notNull() + ->unique(), + + 'status' => $this->smallInteger() + ->notNull() + ->defaultValue(10), + 'created_at' => $this->integer() + ->notNull(), + 'updated_at' => $this->integer() + ->notNull(), + ], + $tableOptions + ); + } + + public function safeDown() + { + $this->dropTable('user'); + } + } diff --git a/artweb/artbox-core/migrations/m170309_000001_feedback.php b/artweb/artbox-core/migrations/m170309_000001_feedback.php new file mode 100755 index 0000000..c99d9ec --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000001_feedback.php @@ -0,0 +1,31 @@ +createTable( + 'feedback', + [ + 'id' => $this->primaryKey(), + 'name' => $this->string(255), + 'email' => $this->string(255), + 'phone' => $this->string(255), + 'message' => $this->text(), + 'created_at' => $this->integer(32), + 'ip' => $this->string(255), + 'url' => $this->string(255), + 'status' => $this->boolean() + ->notNull() + ->defaultValue(false), + ] + ); + } + + public function safeDown() + { + $this->dropTable('feedback'); + } + } diff --git a/artweb/artbox-core/migrations/m170309_000002_language.php b/artweb/artbox-core/migrations/m170309_000002_language.php new file mode 100755 index 0000000..d66a9cc --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000002_language.php @@ -0,0 +1,79 @@ +createTable( + 'language', + [ + 'id' => $this->primaryKey(), + 'url' => $this->string(255) + ->notNull(), + 'local' => $this->string(255) + ->notNull(), + 'name' => $this->string(255) + ->notNull(), + 'default' => $this->boolean() + ->notNull() + ->defaultValue(false), + 'created_at' => $this->integer(32) + ->notNull(), + 'updated_at' => $this->integer(32) + ->notNull(), + 'status' => $this->boolean() + ->notNull() + ->defaultValue(false), + ] + ); + + $this->batchInsert( + 'language', + [ + 'url', + 'local', + 'name', + 'default', + 'created_at', + 'updated_at', + 'status', + ], + [ + [ + 'en', + 'en-EN', + 'English', + true, + 0, + 0, + true, + ], + [ + 'ru', + 'ru-RU', + 'Русский', + false, + 0, + 0, + true, + ], + [ + 'ua', + 'ua-UA', + 'Українська', + false, + 0, + 0, + false, + ], + ] + ); + } + + public function safeDown() + { + $this->dropTable('language'); + } + } diff --git a/artweb/artbox-core/migrations/m170309_000003_alias.php b/artweb/artbox-core/migrations/m170309_000003_alias.php new file mode 100755 index 0000000..484501e --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000003_alias.php @@ -0,0 +1,22 @@ +createTable( + 'alias', + [ + 'id'=> $this->primaryKey(), + 'value'=> $this->string()->notNull(), + ] + ); + } + + public function safeDown() + { + $this->dropTable('alias'); + } +} diff --git a/artweb/artbox-core/migrations/m170309_000004_page.php b/artweb/artbox-core/migrations/m170309_000004_page.php new file mode 100755 index 0000000..98b8def --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000004_page.php @@ -0,0 +1,22 @@ +createTable( + 'page', + [ + 'id'=> $this->primaryKey(), + 'in_menu'=> $this->boolean()->notNull()->defaultValue(false), + ] + ); + } + + public function safeDown() + { + $this->dropTable('page'); + } +} diff --git a/artweb/artbox-core/migrations/m170309_000005_page_lang.php b/artweb/artbox-core/migrations/m170309_000005_page_lang.php new file mode 100755 index 0000000..3d98134 --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000005_page_lang.php @@ -0,0 +1,32 @@ +createTable( + 'page_lang', + [ + 'page_id'=> $this->integer(32)->notNull(), + 'language_id'=> $this->integer(32)->notNull(), + 'title'=> $this->string(255)->notNull(), + 'body'=> $this->text()->notNull(), + 'meta_title'=> $this->string(255)->null()->defaultValue(null), + 'meta_description'=> $this->string(255)->null()->defaultValue(null), + 'seo_text'=> $this->text()->null()->defaultValue(null), + 'h1'=> $this->string(255)->null()->defaultValue(null), + 'alias_id'=> $this->integer()->notNull(), + 'PRIMARY KEY(page_id, language_id)', + ] + ); + $this->createIndex('page_lang_alias_id','page_lang','alias_id',true); + } + + public function safeDown() + { + $this->dropIndex('page_lang_alias_id', 'page_lang'); + $this->dropTable('page_lang'); + } +} diff --git a/artweb/artbox-core/migrations/m170309_000006_relations.php b/artweb/artbox-core/migrations/m170309_000006_relations.php new file mode 100755 index 0000000..789c38b --- /dev/null +++ b/artweb/artbox-core/migrations/m170309_000006_relations.php @@ -0,0 +1,44 @@ +addForeignKey( + 'fk_page_lang_alias_id', + 'page_lang', + 'alias_id', + 'alias', + 'id', + 'RESTRICT', + 'CASCADE' + ); + $this->addForeignKey( + 'fk_page_lang_language_id', + 'page_lang', + 'language_id', + 'language', + 'id', + 'CASCADE', + 'CASCADE' + ); + $this->addForeignKey( + 'fk_page_lang_page_id', + 'page_lang', + 'page_id', + 'page', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + public function safeDown() + { + $this->dropForeignKey('fk_page_lang_alias_id', 'page_lang'); + $this->dropForeignKey('fk_page_lang_language_id', 'page_lang'); + $this->dropForeignKey('fk_page_lang_page_id', 'page_lang'); + } + } diff --git a/artweb/artbox-core/migrations/m170313_092544_create_user_data_table.php b/artweb/artbox-core/migrations/m170313_092544_create_user_data_table.php new file mode 100755 index 0000000..2cba5e7 --- /dev/null +++ b/artweb/artbox-core/migrations/m170313_092544_create_user_data_table.php @@ -0,0 +1,38 @@ +createTable('user_data', [ + 'user_id' => $this->integer()->notNull(), + 'name' => $this->string(), + 'surname' => $this->string(), + 'image' => $this->string(), + 'email' => $this->string(), + 'phone' => $this->string(), + 'created_at' => $this->integer(), + 'updated_at' => $this->integer(), + 'visited_at' => $this->integer(), + ]); + + $this->addForeignKey('user_data_to_user', 'user_data', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE'); + $this->createIndex('user_id_uk', 'user_data', 'user_id', true); + } + + /** + * @inheritdoc + */ + public function safeDown() + { + $this->dropTable('user_data'); + } +} diff --git a/artweb/artbox-core/migrations/m170316_103134_page_lang_drop_not_null.php b/artweb/artbox-core/migrations/m170316_103134_page_lang_drop_not_null.php new file mode 100755 index 0000000..6e548f8 --- /dev/null +++ b/artweb/artbox-core/migrations/m170316_103134_page_lang_drop_not_null.php @@ -0,0 +1,48 @@ +dropForeignKey( + 'fk_page_lang_alias_id', + 'page_lang' + ); + $this->execute("ALTER TABLE public.page_lang ALTER COLUMN alias_id DROP NOT NULL"); + $this->addForeignKey( + 'fk_page_lang_alias_id', + 'page_lang', + 'alias_id', + 'alias', + 'id', + 'SET NULL', + 'CASCADE' + ); + } + + public function safeDown() + { + PageLang::deleteAll( + [ + 'alias_id' => null, + ] + ); + $this->dropForeignKey( + 'fk_page_lang_alias_id', + 'page_lang' + ); + $this->addForeignKey( + 'fk_page_lang_alias_id', + 'page_lang', + 'alias_id', + 'alias', + 'id', + 'RESTRICT', + 'CASCADE' + ); + $this->execute("ALTER TABLE public.page_lang ALTER COLUMN alias_id SET NOT NULL"); + } + } diff --git a/artweb/artbox-core/migrations/m170316_180155_alias_seo_fields.php b/artweb/artbox-core/migrations/m170316_180155_alias_seo_fields.php new file mode 100755 index 0000000..5c0a152 --- /dev/null +++ b/artweb/artbox-core/migrations/m170316_180155_alias_seo_fields.php @@ -0,0 +1,26 @@ +addColumn('alias', 'route', $this->string()); + $this->addColumn('alias', 'title', $this->string()); + $this->addColumn('alias', 'description', $this->text()); + $this->addColumn('alias', 'h1', $this->string()); + $this->addColumn('alias', 'robots', $this->string()); + $this->addColumn('alias', 'seo_text', $this->text()); + } + + public function safeDown() + { + $this->dropColumn('alias', 'route'); + $this->dropColumn('alias', 'title'); + $this->dropColumn('alias', 'description'); + $this->dropColumn('alias', 'h1'); + $this->dropColumn('alias', 'robots'); + $this->dropColumn('alias', 'seo_text'); + } + } diff --git a/artweb/artbox-core/migrations/m170316_181841_page_lang_remove_seo_fields.php b/artweb/artbox-core/migrations/m170316_181841_page_lang_remove_seo_fields.php new file mode 100755 index 0000000..ca6c527 --- /dev/null +++ b/artweb/artbox-core/migrations/m170316_181841_page_lang_remove_seo_fields.php @@ -0,0 +1,22 @@ +dropColumn('page_lang', 'meta_title'); + $this->dropColumn('page_lang', 'meta_description'); + $this->dropColumn('page_lang', 'seo_text'); + $this->dropColumn('page_lang', 'h1'); + } + + public function safeDown() + { + $this->addColumn('page_lang', 'meta_title', $this->string()); + $this->addColumn('page_lang', 'meta_description', $this->string()); + $this->addColumn('page_lang', 'seo_text', $this->text()); + $this->addColumn('page_lang', 'h1', $this->string()); + } + } diff --git a/artweb/artbox-core/migrations/m170317_104310_alias_add_entity_column.php b/artweb/artbox-core/migrations/m170317_104310_alias_add_entity_column.php new file mode 100755 index 0000000..41d5b4e --- /dev/null +++ b/artweb/artbox-core/migrations/m170317_104310_alias_add_entity_column.php @@ -0,0 +1,16 @@ +addColumn('alias', 'entity', $this->string()); + } + + public function safeDown() + { + $this->dropColumn('alias', 'entity'); + } + } diff --git a/artweb/artbox-core/migrations/m170317_155203_alias_add_fields_column.php b/artweb/artbox-core/migrations/m170317_155203_alias_add_fields_column.php new file mode 100755 index 0000000..bd50765 --- /dev/null +++ b/artweb/artbox-core/migrations/m170317_155203_alias_add_fields_column.php @@ -0,0 +1,16 @@ +addColumn('alias', 'fields', $this->text()); + } + + public function safeDown() + { + $this->dropColumn('alias', 'fields'); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/migrations/m170317_155204_create_ImageManager_table.php b/artweb/artbox-core/migrations/m170317_155204_create_ImageManager_table.php new file mode 100755 index 0000000..8c48de4 --- /dev/null +++ b/artweb/artbox-core/migrations/m170317_155204_create_ImageManager_table.php @@ -0,0 +1,37 @@ +createTable( + 'ImageManager', + [ + 'id' => $this->primaryKey(), + 'fileName' => $this->string(128) + ->notNull(), + 'fileHash' => $this->string(32) + ->notNull(), + 'created' => $this->dateTime() + ->notNull(), + 'modified' => $this->dateTime(), + ] + ); + } + + /** + * @inheritdoc + */ + public function safeDown() + { + $this->dropTable('ImageManager'); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/migrations/m170317_155205_addBlameableBehavior.php b/artweb/artbox-core/migrations/m170317_155205_addBlameableBehavior.php new file mode 100755 index 0000000..9b2a050 --- /dev/null +++ b/artweb/artbox-core/migrations/m170317_155205_addBlameableBehavior.php @@ -0,0 +1,32 @@ +addColumn( + 'ImageManager', + 'createdBy', + $this->integer(10) + ->unsigned() + ->null() + ->defaultValue(null) + ); + $this->addColumn( + 'ImageManager', + 'modifiedBy', + $this->integer(10) + ->unsigned() + ->null() + ->defaultValue(null) + ); + } + + public function safeDown() + { + $this->dropColumn('ImageManager', 'createdBy'); + $this->dropColumn('ImageManager', 'modifiedBy'); + } + } diff --git a/artweb/artbox-core/migrations/m170327_134400_alias_add_language_column.php b/artweb/artbox-core/migrations/m170327_134400_alias_add_language_column.php new file mode 100755 index 0000000..9ce40b6 --- /dev/null +++ b/artweb/artbox-core/migrations/m170327_134400_alias_add_language_column.php @@ -0,0 +1,18 @@ +addColumn('alias', 'language_id', $this->integer()); + $this->addForeignKey('alias_to_language', 'alias', 'language_id', 'language', 'id', 'SET NULL', 'CASCADE'); + } + + public function safeDown() + { + $this->dropForeignKey('alias_to_language', 'alias'); + $this->dropColumn('alias', 'language_id'); + } + } diff --git a/artweb/artbox-core/migrations/m170405_095957_page_add_column_sort.php b/artweb/artbox-core/migrations/m170405_095957_page_add_column_sort.php new file mode 100755 index 0000000..0b83dc7 --- /dev/null +++ b/artweb/artbox-core/migrations/m170405_095957_page_add_column_sort.php @@ -0,0 +1,21 @@ +addColumn( + 'page', + 'sort', + $this->integer() + ->defaultValue(0) + ); + } + + public function safeDown() + { + $this->dropColumn('page', 'sort'); + } + } diff --git a/artweb/artbox-core/migrations/m170502_151419_insert_aliases.php b/artweb/artbox-core/migrations/m170502_151419_insert_aliases.php new file mode 100755 index 0000000..86c4085 --- /dev/null +++ b/artweb/artbox-core/migrations/m170502_151419_insert_aliases.php @@ -0,0 +1,52 @@ +batchInsert( + 'alias', + [ + 'value', + 'route', + 'title', + 'description', + 'h1', + 'language_id', + ], + [ + [ + 'home', + '{"0":"site/index"}', + 'Home page title', + 'Home page description', + 'Home page header', + 1, + ], + [ + 'domashnyaya', + '{"0":"site/index"}', + 'Домашняя страница', + 'Описание домашней страницы', + 'Заголовок домашней страницы', + 2, + ], + [ + 'domashnya', + '{"0":"site/index"}', + 'Домашня сторінка', + 'Опис домашньої сторінки', + 'Заголовок домашньої сторінки', + 3, + ], + ] + ); + } + + public function safeDown() + { + + } + } diff --git a/artweb/artbox-core/migrations/m170619_095632_create_ImageManagerLang_table.php b/artweb/artbox-core/migrations/m170619_095632_create_ImageManagerLang_table.php new file mode 100755 index 0000000..ad8f21c --- /dev/null +++ b/artweb/artbox-core/migrations/m170619_095632_create_ImageManagerLang_table.php @@ -0,0 +1,64 @@ +createTable( + 'ImageManagerLang', + [ + 'image_id' => $this->integer(), + 'language_id' => $this->integer(), + 'title' => $this->string(), + 'alt' => $this->string(), + 'description' => $this->string(), + ] + ); + + $this->addForeignKey( + 'image_fk', + 'ImageManagerLang', + 'image_id', + 'ImageManager', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'language_fk', + 'ImageManagerLang', + 'language_id', + 'language', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->createIndex( + 'img_lang_uk', + 'ImageManagerLang', + [ + 'language_id', + 'image_id', + ], + true + ); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('ImageManagerLang'); + } + } diff --git a/artweb/artbox-core/migrations/m170717_142042_add_gallery_column_to_page_table.php b/artweb/artbox-core/migrations/m170717_142042_add_gallery_column_to_page_table.php new file mode 100644 index 0000000..cd28dc4 --- /dev/null +++ b/artweb/artbox-core/migrations/m170717_142042_add_gallery_column_to_page_table.php @@ -0,0 +1,25 @@ +addColumn('page', 'gallery', $this->string()); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropColumn('page', 'gallery'); + } +} diff --git a/artweb/artbox-core/migrations/m170718_134346_create_page_category_table.php b/artweb/artbox-core/migrations/m170718_134346_create_page_category_table.php new file mode 100644 index 0000000..51ffe0a --- /dev/null +++ b/artweb/artbox-core/migrations/m170718_134346_create_page_category_table.php @@ -0,0 +1,32 @@ +createTable( + 'page_category', + [ + 'id' => $this->primaryKey(), + 'sort' => $this->integer(), + 'status' => $this->boolean(), + ] + ); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropTable('page_category'); + } + } diff --git a/artweb/artbox-core/migrations/m170718_134355_create_page_category_lang_table.php b/artweb/artbox-core/migrations/m170718_134355_create_page_category_lang_table.php new file mode 100644 index 0000000..74c669a --- /dev/null +++ b/artweb/artbox-core/migrations/m170718_134355_create_page_category_lang_table.php @@ -0,0 +1,77 @@ +createTable( + 'page_category_lang', + [ + 'title' => $this->string(), + 'language_id' => $this->integer(), + 'page_category_id' => $this->integer(), + ] + ); + + $this->addForeignKey( + 'lang_fk', + 'page_category_lang', + 'language_id', + 'language', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->addForeignKey( + 'category_fk', + 'page_category_lang', + 'page_category_id', + 'page_category', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->createIndex( + 'pcat_lang_uk', + 'page_category_lang', + [ + 'language_id', + 'page_category_id', + ], + true + ); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropIndex( + 'pcat_lang_uk', + 'page_category_lang' + ); + + $this->dropForeignKey( + 'category_fk', + 'page_category_lang' + ); + + $this->dropForeignKey( + 'lang_fk', + 'page_category_lang' + ); + + $this->dropTable('page_category_lang'); + } + } diff --git a/artweb/artbox-core/migrations/m170718_155356_create_page_to_category_table.php b/artweb/artbox-core/migrations/m170718_155356_create_page_to_category_table.php new file mode 100644 index 0000000..1d2c13f --- /dev/null +++ b/artweb/artbox-core/migrations/m170718_155356_create_page_to_category_table.php @@ -0,0 +1,64 @@ +createTable( + 'page_to_category', + [ + 'page_id' => $this->integer(), + 'category_id' => $this->integer(), + ] + ); + + $this->addForeignKey('page_fk', 'page_to_category', 'page_id', 'page', 'id', 'CASCADE', 'CASCADE'); + + $this->addForeignKey( + 'cat_fk', + 'page_to_category', + 'category_id', + 'page_category', + 'id', + 'CASCADE', + 'CASCADE' + ); + + $this->createIndex( + 'page_cat_uk', + 'page_to_category', + [ + 'page_id', + 'category_id', + ], + true + ); + } + + /** + * @inheritdoc + */ + public function down() + { + $this->dropIndex( + 'page_cat_uk', + 'page_to_category' + ); + + $this->dropForeignKey( + 'cat_fk', + 'page_to_category' + ); + $this->dropForeignKey('page_fk', 'page_to_category'); + + $this->dropTable('page_to_category'); + } + } diff --git a/artweb/artbox-core/models/Alias.php b/artweb/artbox-core/models/Alias.php new file mode 100755 index 0000000..0811bf0 --- /dev/null +++ b/artweb/artbox-core/models/Alias.php @@ -0,0 +1,283 @@ + 255, + ], + [ + [ + 'description', + 'seo_text', + ], + 'string', + ], + [ + [ 'value' ], + 'filter', + 'filter' => function ($value) { + return SlugHelper::slugify($value); + }, + ], + [ + [ 'robots' ], + 'match', + 'pattern' => '~^(no)?index\s?\,\s?(no)?follow$~', + 'message' => Yii::t('core', "Doesn't look like robots"), + ], + [ + [ 'robots' ], + 'match', + 'pattern' => '~^(no)?index\s?\,\s?(no)?follow$~', + 'message' => Yii::t('core', "Doesn't look like robots"), + ], + [ + [ 'language_id' ], + 'integer', + ], + [ + [ 'language_id' ], + 'exist', + 'targetClass' => Language::className(), + 'targetAttribute' => 'id', + ], + // [ + // [ 'route' ], + // 'match', + // 'pattern' => '/^{[\'"]0[\'"]:["\'][\w-\/]+["\'][,\w\s\'":]*}$/', + // ], + [ + [ + 'route', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'route', + 'language_id', + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'ID'), + 'value' => Yii::t('core', 'Value'), + 'route' => Yii::t('core', 'Route'), + 'title' => Yii::t('core', 'Title'), + 'robots' => Yii::t('core', 'Meta robots'), + 'h1' => Yii::t('core', 'H1'), + 'description' => Yii::t('core', 'Description'), + 'seo_text' => Yii::t('core', 'Seo text'), + 'entity' => Yii::t('core', 'Entity'), + 'fields' => Yii::t('core', 'Available fields'), + 'language_id' => Yii::t('core', 'Language'), + ]; + } + + /** + * Check $fields property availability in $entity class and return only validated fields. + * + * @return array + */ + public function getCheckedFields() + { + /** + * @var ActiveRecord $model + */ + + $model = \Yii::createObject($this->entity); + $fields = Json::decode($this->fields); + + $checked = []; + if ($fields !== null) { + foreach ($fields as $field => $fieldTitle) { + $currentField = explode('.', $field); + $result = $model; + foreach ($currentField as $index => $item) { + if (($index + 1) < count($currentField)) { + $result = $result->getRelation($item, false); + if (empty($result)) { + break; + } else { + $result = \Yii::createObject($result->modelClass); + } + } else { + if ($result->canGetProperty($item)) { + $checked[$field] = $fieldTitle; + } + } + } + } + } + return $checked; + } + + /** + * Find one alias model by url + * + * @param string $url + * @param \artbox\core\models\Language $language + * + * @return array|\artbox\core\models\Alias|null + */ + public static function findUrl(string $url, Language $language) + { + return self::find() + ->where([ 'value' => ltrim($url, '/') ]) + ->andWhere([ 'language_id' => $language->id ]) + ->andWhere([ + '!=', + 'value', 'home' + ]) + ->one(); + } + + /** + * @param array $route + * @param \artbox\core\models\Language $language + * + * @return array|\artbox\core\models\Alias|null + */ + public static function findRoute(array $route, Language $language) + { + try { + $encodedRoute = Json::encode( + $route, + JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE + ); + } catch (InvalidParamException $exception) { + return null; + } + $query = self::find() + ->where( + [ + 'route' => $encodedRoute, + ] + ); + $query->andWhere([ 'language_id' => $language->id ]); + return $query->one(); + } + + public function getTitle(): string + { + return strval($this->title); + } + + public function getDesc(): string + { + return strval($this->description); + } + + public function getH1(): string + { + return strval($this->h1); + } + + public function getText(): string + { + return strval($this->seo_text); + } + + public function getRobots(): string + { + return strval($this->robots); + } + public function getFields(): string + { + return strval($this->fields); + } + public function getSeoText(): string + { + return strval($this->seo_text); + } + public function getId() + { + return $this->id; + } + } diff --git a/artweb/artbox-core/models/AliasSearch.php b/artweb/artbox-core/models/AliasSearch.php new file mode 100755 index 0000000..34b75ed --- /dev/null +++ b/artweb/artbox-core/models/AliasSearch.php @@ -0,0 +1,136 @@ + $query, + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'entity' => $this->entity, + ] + ); + + $query->andFilterWhere( + [ + 'ilike', + 'value', + $this->search, + ] + ); + + // If language_id == 0, search for records with null language + if ($this->language_id === '0') { + $query->andWhere( + [ + 'language_id' => null, + ] + ); + } else { + $query->andFilterWhere( + [ + 'language_id' => $this->language_id, + ] + ); + } + + // If language_id == 0, search for records without entities + if ($this->static === '0') { + $query->andWhere( + [ + 'entity' => null, + ] + ); + } elseif ($this->static === '1') { + $query->andWhere( + [ + 'not', + [ + 'entity' => null, + ], + ] + ); + } + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/models/ChangePassword.php b/artweb/artbox-core/models/ChangePassword.php new file mode 100755 index 0000000..848d806 --- /dev/null +++ b/artweb/artbox-core/models/ChangePassword.php @@ -0,0 +1,100 @@ + \Yii::t('core', 'Old password'), + 'newPassword' => \Yii::t('core', 'New password'), + 'newPasswordRepeat' => \Yii::t('core', 'New password repeat'), + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'oldPassword', + 'newPassword', + 'newPasswordRepeat', + ], + 'required', + ], + [ + [ + 'oldPassword', + 'newPassword', + 'newPasswordRepeat', + ], + 'string', + 'length' => [ + 6, + 255, + ], + ], + [ + [ 'newPasswordRepeat' ], + 'compare', + 'compareAttribute' => 'newPassword', + ], + ]; + } + + /** + * Validate old password. + * + * @return bool True if password valid, otherwise false + */ + public function validatePassword() + { + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + $result = $user->validatePassword($this->oldPassword); + if (!$result) { + $this->addError('oldPassword', \Yii::t('core', 'Provided old password doesn\'t match real password.')); + } + return $result; + } + + /** + * Save new password + * + * @return bool True if successfully saved + */ + public function saveChanges() + { + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + $user->setPassword($this->newPassword); + $user->generateAuthKey(); + return $user->save(); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/models/DummyAlias.php b/artweb/artbox-core/models/DummyAlias.php new file mode 100755 index 0000000..4697bb8 --- /dev/null +++ b/artweb/artbox-core/models/DummyAlias.php @@ -0,0 +1,58 @@ +title; + } + + public function getDesc(): string + { + return $this->desc; + } + + public function getH1(): string + { + return $this->h1; + } + + public function getText(): string + { + return $this->text; + } + + public function getRobots(): string + { + return $this->robots; + } + public function getFields(): string + { + return ''; + } + public function getSeoText(): string + { + return $this->seoText; + } + public function getId() + { + return null; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/models/Feedback.php b/artweb/artbox-core/models/Feedback.php new file mode 100755 index 0000000..da30c09 --- /dev/null +++ b/artweb/artbox-core/models/Feedback.php @@ -0,0 +1,165 @@ + [ + 'name', + 'email', + 'message', + ], + self::SCENARIO_CALLBACK => [ + 'name', + 'phone', + 'message', + ], + self::SCENARIO_CONTACT => [ + 'name', + 'phone', + 'email', + 'message', + ], + ] + ); + return $scenarios; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::className(), + 'updatedAtAttribute' => false, + ], + [ + 'class' => AttributeBehavior::className(), + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => 'ip', + ], + 'value' => function ($event) { + return \Yii::$app->request->userIP; + }, + ], + [ + 'class' => AttributeBehavior::className(), + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => 'url', + ], + 'value' => function ($event) { + return \Yii::$app->request->referrer; + }, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'phone', + 'name', + 'email', + ], + 'required', + ], + [ + [ 'email' ], + 'email', + ], + // [ + // [ 'phone' ], + // 'match', + // 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', + // ], + [ + [ + 'name', + 'phone', + 'email', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'message', + ], + 'string', + ], + [ + [ + 'status', + ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'id'), + 'name' => Yii::t('core', 'name'), + 'phone' => Yii::t('core', 'phone'), + 'created_at' => Yii::t('core', 'created_at'), + 'ip' => Yii::t('core', 'ip'), + 'url' => Yii::t('core', 'url'), + 'status' => Yii::t('core', 'status'), + 'message' => Yii::t('core', 'message'), + 'email' => Yii::t('core', 'email'), + ]; + } + } diff --git a/artweb/artbox-core/models/FeedbackSearch.php b/artweb/artbox-core/models/FeedbackSearch.php new file mode 100755 index 0000000..3330f19 --- /dev/null +++ b/artweb/artbox-core/models/FeedbackSearch.php @@ -0,0 +1,127 @@ + $query, + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'id' => $this->id, + 'status' => $this->status, + ] + ); + + $query->andFilterWhere( + [ + 'like', + 'name', + $this->name, + ] + ) + ->andFilterWhere( + [ + 'like', + 'phone', + $this->phone, + ] + ) + ->andFilterWhere( + [ + 'like', + 'ip', + $this->ip, + ] + ) + ->andFilterWhere( + [ + 'like', + 'url', + $this->url, + ] + ) + ->andFilterWhere( + [ + 'like', + 'email', + $this->email, + ] + ) + ->andFilterWhere( + [ + 'like', + 'message', + $this->message, + ] + ); + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/models/Image.php b/artweb/artbox-core/models/Image.php new file mode 100755 index 0000000..867d82d --- /dev/null +++ b/artweb/artbox-core/models/Image.php @@ -0,0 +1,111 @@ + TimestampBehavior::className(), + 'createdAtAttribute' => 'created', + 'updatedAtAttribute' => 'modified', + 'value' => new Expression('NOW()'), + ], + ]; + } + + /** + * Path to stored image + * + * @return string + */ + public function getPath(): string + { + /** + * @var ImageManagerGetPath $manager + */ + $manager = \Yii::$app->get('imagemanager'); + + $path = $manager->mediaPath . '/' . $this->id . '_' . $this->fileHash . '.' . $this->extension; + + if (file_exists($path)) { + return $path; + } else { + return \Yii::getAlias('@frontend/web/img/no-image.png'); + } + } + + /** + * Url to stored image + * + * @return string + */ + public function getUrl(): string + { + return '/storage/' . $this->id . '_' . $this->fileHash . '.' . $this->extension; + } + + /** + * Gets image tag + * + * @param array $options + * + * @return string + */ + public function getImg(array $options = []): string + { + return Html::img($this->getUrl(), $options); + } + + /** + * Gets file extension + * + * @return string + */ + public function getExtension() + { + return pathinfo($this->fileName, PATHINFO_EXTENSION); + } + + /** + * Multy language model with image's alt, title and description + * + * @return null|ActiveQuery + */ + public function getLang() + { + return $this->hasOne(ImageLang::className(), [ 'image_id' => 'id' ]) + ->inverseOf('image'); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/models/ImageLang.php b/artweb/artbox-core/models/ImageLang.php new file mode 100755 index 0000000..54c72ce --- /dev/null +++ b/artweb/artbox-core/models/ImageLang.php @@ -0,0 +1,21 @@ +hasOne(Image::className(), ['id' => 'image_id']) + ->inverseOf('lang'); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/models/Language.php b/artweb/artbox-core/models/Language.php new file mode 100755 index 0000000..fb0b09a --- /dev/null +++ b/artweb/artbox-core/models/Language.php @@ -0,0 +1,229 @@ + [ + 'class' => 'yii\behaviors\TimestampBehavior', + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => [ + 'created_at', + 'updated_at', + ], + ActiveRecord::EVENT_BEFORE_UPDATE => [ + 'updated_at', + ], + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'url', + 'local', + 'name', + 'created_at', + 'updated_at', + ], + 'required', + ], + [ + [ 'default' ], + 'boolean', + ], + [ + [ + 'created_at', + 'updated_at', + ], + 'integer', + ], + [ + [ + 'url', + 'local', + 'name', + ], + 'string', + 'max' => 255, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'Language ID'), + 'url' => Yii::t('core', 'Url'), + 'local' => Yii::t('core', 'Local'), + 'name' => Yii::t('core', 'Name'), + 'default' => Yii::t('core', 'Default'), + 'created_at' => Yii::t('core', 'Date Create'), + 'updated_at' => Yii::t('core', 'Date Update'), + ]; + } + + /** + * Get current language + * + * @return null|Language + */ + public static function getCurrent() + { + if (self::$current === null) { + self::$current = self::getDefaultLanguage(); + } + return self::$current; + } + + /** + * Set current language by Url param + * + * @param null|string $url Language url param + * + * @return bool + */ + public static function setCurrent($url = null) + { + $language = self::getLanguageByUrl($url); + self::$current = ( $language === null ) ? self::getDefaultLanguage() : $language; + Yii::$app->language = self::getCurrent()->local; + if ($language === null) { + return false; + } else { + return true; + } + } + + /** + * Get default language + * + * @return null|Language + */ + public static function getDefaultLanguage() + { + if (\Yii::$app->request->hasMethod('getPreferredLanguage')) { + $preferred = \Yii::$app->request->getPreferredLanguage( + self::find() + ->select([ 'local' ]) + ->where( + [ + 'status' => true, + ] + ) + ->asArray() + ->column() + ); + } + if (!empty($preferred)) { + return self::getLanguageByUrl(strtolower(substr($preferred, -2, 2))); + } else { + /** + * @var null|Language $language + */ + $language = self::find() + ->where([ 'default' => true ]) + ->one(); + return $language; + } + } + + /** + * Get language by Url param + * + * @param null|string $url Language url param + * + * @return null|Language + */ + public static function getLanguageByUrl($url = null) + { + if ($url === null) { + return null; + } else { + /** + * @var null|Language $language + */ + $language = self::find() + ->where( + [ + 'url' => $url, + 'status' => true, + ] + ) + ->one(); + if ($language === null) { + return null; + } else { + return $language; + } + } + } + + /** + * Get active Languages and cache them + * + * @return array|\artbox\core\models\Language[]|null|\yii\db\ActiveRecord[] + */ + public static function getActive() + { + if (empty(self::$active)) { + self::$active = self::find() + ->where([ 'status' => true ]) + ->indexBy('id') + ->all(); + } + return self::$active; + } + } diff --git a/artweb/artbox-core/models/LoginForm.php b/artweb/artbox-core/models/LoginForm.php new file mode 100755 index 0000000..f7b6e97 --- /dev/null +++ b/artweb/artbox-core/models/LoginForm.php @@ -0,0 +1,109 @@ +hasErrors()) { + $user = $this->getUser(); + if (!$user || !$user->validatePassword($this->password)) { + $this->addError($attribute, 'Incorrect username or password.'); + } + } + } + + /** + * Logs in a user using the provided username and password. + * + * @return bool whether the user is logged in successfully + */ + public function login() + { + if ($this->validate()) { + return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); + } else { + return false; + } + } + + /** + * Finds user by [[username]] + * + * @return User|null + */ + protected function getUser() + { + if ($this->_user === null) { + $this->_user = User::findByUsername($this->username); + } + + return $this->_user; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'username' => Yii::t('app', 'Логин'), + 'password' => Yii::t('app', 'Пароль'), + 'rememberMe' => Yii::t('app', 'Запомнить'), + ]; + } + } diff --git a/artweb/artbox-core/models/Page.php b/artweb/artbox-core/models/Page.php new file mode 100755 index 0000000..3f3e457 --- /dev/null +++ b/artweb/artbox-core/models/Page.php @@ -0,0 +1,124 @@ + [ + 'class' => LanguageBehavior::className(), + ], + 'gallery' => [ + 'class' => GalleryBehavior::className(), + ], + 'manyToMany' => [ + 'class' => ManyToManyBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'in_menu', + ], + 'boolean', + ], + [ + [ + 'sort', + ], + 'integer', + 'min' => 0, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'page_id'), + 'in_menu' => Yii::t('core', 'page_in_menu'), + 'sort' => Yii::t('core', 'page_sort'), + 'title' => Yii::t('core', 'page_title'), + ]; + } + + /** + * @return ActiveQuery + */ + public function getCategories() + { + return $this->hasMany(PageCategory::className(), [ 'id' => 'category_id' ]) + ->viaTable('page_to_category', [ 'page_id' => 'id' ]); + } + } diff --git a/artweb/artbox-core/models/PageCategory.php b/artweb/artbox-core/models/PageCategory.php new file mode 100644 index 0000000..b2b5fa0 --- /dev/null +++ b/artweb/artbox-core/models/PageCategory.php @@ -0,0 +1,119 @@ + [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'sort' ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'sort' => 'Sort', + 'status' => 'Status', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPageCategoryLangs() + { + return $this->hasMany(PageCategoryLang::className(), [ 'page_category_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguages() + { + return $this->hasMany(Language::className(), [ 'id' => 'language_id' ]) + ->viaTable('page_category_lang', [ 'page_category_id' => 'id' ]); + } + + /** + * @return ActiveQuery + */ + public function getPages() + { + return $this->hasMany(Page::className(), [ 'id' => 'page_id' ]) + ->viaTable('page_to_category', [ 'category_id' => 'id' ]); + } + } diff --git a/artweb/artbox-core/models/PageCategoryLang.php b/artweb/artbox-core/models/PageCategoryLang.php new file mode 100644 index 0000000..7e04dd7 --- /dev/null +++ b/artweb/artbox-core/models/PageCategoryLang.php @@ -0,0 +1,100 @@ + 255, + ], + [ + [ + 'language_id', + 'page_category_id', + ], + 'unique', + 'targetAttribute' => [ + 'language_id', + 'page_category_id', + ], + 'message' => 'The combination of Language ID and Page Category ID has already been taken.', + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + [ + [ 'page_category_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => PageCategory::className(), + 'targetAttribute' => [ 'page_category_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'title' => 'Title', + 'language_id' => 'Language ID', + 'page_category_id' => 'Page Category ID', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPageCategory() + { + return $this->hasOne(PageCategory::className(), [ 'id' => 'page_category_id' ]); + } + } diff --git a/artweb/artbox-core/models/PageCategorySearch.php b/artweb/artbox-core/models/PageCategorySearch.php new file mode 100644 index 0000000..fbd56c4 --- /dev/null +++ b/artweb/artbox-core/models/PageCategorySearch.php @@ -0,0 +1,100 @@ +joinWith('lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'id' => $this->id, + 'sort' => $this->sort, + 'status' => $this->status, + ] + ); + + $query->andFilterWhere( + [ + 'ilike', + 'page_category_lang.title', + $this->title, + ] + ); + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/models/PageLang.php b/artweb/artbox-core/models/PageLang.php new file mode 100755 index 0000000..0612001 --- /dev/null +++ b/artweb/artbox-core/models/PageLang.php @@ -0,0 +1,162 @@ + [ + 'class' => SlugBehavior::className(), + 'action' => 'page/view', + 'params' => [ + 'id' => 'page_id', + ], + 'fields' => [ + 'title' => 'Page title', + 'page.id' => 'Page id', + 'body' => 'Page body', + 'page.lang.title' => 'Page title 2', + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'title', + 'body', + ], + 'required', + ], + [ + [ + 'body', + 'aliasValue', + ], + 'string', + ], + [ + [ + 'title', + 'aliasValue', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'page_id', + 'language_id', + ], + 'unique', + 'targetAttribute' => [ + 'page_id', + 'language_id', + ], + 'message' => \Yii::t( + 'core', + 'The combination of Page ID and Language ID has already been taken.' + ), + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + [ + [ 'page_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Page::className(), + 'targetAttribute' => [ 'page_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'page_id' => Yii::t('core', 'page_id'), + 'language_id' => Yii::t('core', 'language_id'), + 'title' => Yii::t('core', 'Title'), + 'body' => Yii::t('core', 'Body'), + 'alias_id' => Yii::t('core', 'Alias'), + 'aliasValue' => Yii::t('core', 'Alias'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getPage() + { + return $this->hasOne(Page::className(), [ 'id' => 'page_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getAlias() + { + return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]); + } + } diff --git a/artweb/artbox-core/models/PageSearch.php b/artweb/artbox-core/models/PageSearch.php new file mode 100755 index 0000000..9740bd6 --- /dev/null +++ b/artweb/artbox-core/models/PageSearch.php @@ -0,0 +1,106 @@ +joinWith('lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'sort' => [ + 'attributes' => [ + 'title' => [ + 'asc' => [ 'page_lang.title' => SORT_ASC ], + 'desc' => [ 'page_lang.title' => SORT_DESC ], + ], + 'id', + 'in_menu', + ], + ], + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'id' => $this->id, + 'in_menu' => $this->in_menu, + ] + ) + ->andFilterWhere( + [ + 'ilike', + 'page_lang.title', + $this->title, + ] + ); + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/models/SitemapDynamic.php b/artweb/artbox-core/models/SitemapDynamic.php new file mode 100755 index 0000000..261565c --- /dev/null +++ b/artweb/artbox-core/models/SitemapDynamic.php @@ -0,0 +1,121 @@ +get('sitemapdb'); + } + + /** + * @inheritdoc + */ + public function attributes() + { + return [ + 'id', + 'entity', + 'status', + 'priority', + 'frequency', + ]; + } + + /** + * @inheritdoc + */ + public static function primaryKey() + { + return [ 'id' ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'entity', + 'status', + 'priority', + 'frequency', + ], + 'required', + ], + [ + [ + 'status', + ], + 'boolean', + ], + [ + [ + 'entity', + 'frequency', + ], + 'string', + ], + [ + [ + 'priority', + ], + 'double', + 'min' => 0, + 'max' => 1, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'ID'), + 'entity' => Yii::t('core', 'Model'), + 'status' => Yii::t('core', 'Status'), + 'priority' => Yii::t('core', 'Priority'), + 'frequency' => Yii::t('core', 'Frequency'), + ]; + } + + /** + * Find maximum ID value from SitemapStatic models + */ + public static function max(): int + { + $models = self::find() + ->all(); + $array = ArrayHelper::getColumn($models, self::primaryKey()[ 0 ], false); + if (empty($array)) { + return 0; + } else { + return max($array); + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/models/SitemapStatic.php b/artweb/artbox-core/models/SitemapStatic.php new file mode 100755 index 0000000..cd4faaa --- /dev/null +++ b/artweb/artbox-core/models/SitemapStatic.php @@ -0,0 +1,106 @@ +get('sitemapdb'); + } + + /** + * @inheritdoc + */ + public function attributes() + { + return [ + 'id', + 'url', + 'priority', + 'frequency', + ]; + } + + /** + * @inheritdoc + */ + public static function primaryKey() + { + return [ 'id' ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'url', + 'priority', + ], + 'required', + ], + [ + [ + 'priority', + ], + 'double', + 'min' => 0, + 'max' => 1, + ], + [ + [ + 'url', + 'frequency', + ], + 'string', + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'ID'), + 'url' => Yii::t('core', 'Url'), + 'priority' => Yii::t('core', 'Priority'), + 'frequency' => Yii::t('core', 'Frequency'), + ]; + } + + /** + * Find maximum ID value from SitemapStatic models + */ + public static function max(): int + { + $models = self::find() + ->all(); + $array = ArrayHelper::getColumn($models, self::primaryKey()[ 0 ], false); + if (empty($array)) { + return 0; + } else { + return max($array); + } + } + } \ No newline at end of file diff --git a/artweb/artbox-core/models/Slide.php b/artweb/artbox-core/models/Slide.php new file mode 100755 index 0000000..1f72742 --- /dev/null +++ b/artweb/artbox-core/models/Slide.php @@ -0,0 +1,127 @@ + [ + 'class' => LanguageBehavior::className(), + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'slider_id' ], + 'required', + ], + [ + [ + 'slider_id', + 'sort', + ], + 'integer', + ], + [ + [ 'status' ], + 'boolean', + ], + [ + [ 'slider_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Slider::className(), + 'targetAttribute' => [ 'slider_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('core', 'ID'), + 'slider_id' => Yii::t('core', 'Slider ID'), + 'status' => Yii::t('core', 'Status'), + 'sort' => Yii::t('core', 'Sort'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSlider() + { + return $this->hasOne(Slider::className(), [ 'id' => 'slider_id' ]) + ->inverseOf('slides'); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSlideLangs() + { + return $this->hasMany(SlideLang::className(), [ 'slide_id' => 'id' ]) + ->inverseOf('slide'); + } + } diff --git a/artweb/artbox-core/models/SlideLang.php b/artweb/artbox-core/models/SlideLang.php new file mode 100755 index 0000000..40b15eb --- /dev/null +++ b/artweb/artbox-core/models/SlideLang.php @@ -0,0 +1,128 @@ + 255, + ], + [ + [ 'image_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Image::className(), + 'targetAttribute' => [ 'image_id' => 'id' ], + ], + [ + [ 'language_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Language::className(), + 'targetAttribute' => [ 'language_id' => 'id' ], + ], + [ + [ 'slide_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => Slide::className(), + 'targetAttribute' => [ 'slide_id' => 'id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'slide_id' => Yii::t('core', 'Slide ID'), + 'language_id' => Yii::t('core', 'Language ID'), + 'link' => Yii::t('core', 'Link'), + 'image_id' => Yii::t('core', 'Image ID'), + 'title' => Yii::t('core', 'Title'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getImage() + { + return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getLanguage() + { + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSlide() + { + return $this->hasOne(Slide::className(), [ 'id' => 'slide_id' ]) + ->inverseOf('slideLangs'); + } + + public static function primaryKey() + { + return ['slide_id', 'language_id']; + } + + } diff --git a/artweb/artbox-core/models/SlideSearch.php b/artweb/artbox-core/models/SlideSearch.php new file mode 100755 index 0000000..93a7632 --- /dev/null +++ b/artweb/artbox-core/models/SlideSearch.php @@ -0,0 +1,92 @@ +where([ 'slider_id' => $slider->id ]); + + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'id' => $this->id, + 'slider_id' => $this->slider_id, + 'status' => $this->status, + 'sort' => $this->sort, + ] + ); + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/models/Slider.php b/artweb/artbox-core/models/Slider.php new file mode 100755 index 0000000..69ca789 --- /dev/null +++ b/artweb/artbox-core/models/Slider.php @@ -0,0 +1,63 @@ + Yii::t('core', 'ID'), + 'status' => Yii::t('core', 'Status'), + 'sort' => Yii::t('core', 'Sort'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getSlides() + { + return $this->hasMany(Slide::className(), [ 'slider_id' => 'id' ]) + ->inverseOf('slider'); + } + } diff --git a/artweb/artbox-core/models/SliderSearch.php b/artweb/artbox-core/models/SliderSearch.php new file mode 100755 index 0000000..0952d17 --- /dev/null +++ b/artweb/artbox-core/models/SliderSearch.php @@ -0,0 +1,80 @@ + $query, + ] + ); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere( + [ + 'id' => $this->id, + 'status' => $this->status, + 'sort' => $this->sort, + ] + ); + + return $dataProvider; + } + } diff --git a/artweb/artbox-core/models/User.php b/artweb/artbox-core/models/User.php new file mode 100755 index 0000000..e005ba6 --- /dev/null +++ b/artweb/artbox-core/models/User.php @@ -0,0 +1,242 @@ + [ + 'class' => LinkBehavior::className(), + 'linkClass' => UserData::className(), + 'linkKey' => 'user_id', + 'detachBehaviors' => [ + 'blameable', + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + 'status', + 'default', + 'value' => self::STATUS_ACTIVE, + ], + [ + 'status', + 'in', + 'range' => [ + self::STATUS_ACTIVE, + self::STATUS_DELETED, + ], + ], + ]; + } + + /** + * @inheritdoc + */ + public static function findIdentity($id) + { + return static::findOne( + [ + 'id' => $id, + 'status' => self::STATUS_ACTIVE, + ] + ); + } + + /** + * @inheritdoc + */ + public static function findIdentityByAccessToken($token, $type = null) + { + throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); + } + + /** + * Finds user by username + * + * @param string $username + * + * @return static|null + */ + public static function findByUsername($username) + { + return static::findOne( + [ + 'username' => $username, + 'status' => self::STATUS_ACTIVE, + ] + ); + } + + /** + * Finds user by password reset token + * + * @param string $token password reset token + * + * @return static|null + */ + public static function findByPasswordResetToken($token) + { + if (!static::isPasswordResetTokenValid($token)) { + return null; + } + + return static::findOne( + [ + 'password_reset_token' => $token, + 'status' => self::STATUS_ACTIVE, + ] + ); + } + + /** + * Finds out if password reset token is valid + * + * @param string $token password reset token + * + * @return bool + */ + public static function isPasswordResetTokenValid($token) + { + if (empty( $token )) { + return false; + } + + $timestamp = (int) substr($token, strrpos($token, '_') + 1); + $expire = Yii::$app->params[ 'user.passwordResetTokenExpire' ]; + return $timestamp + $expire >= time(); + } + + /** + * @inheritdoc + */ + public function getId() + { + return $this->getPrimaryKey(); + } + + /** + * @inheritdoc + */ + public function getAuthKey() + { + return $this->auth_key; + } + + /** + * @inheritdoc + */ + public function validateAuthKey($authKey) + { + return $this->getAuthKey() === $authKey; + } + + /** + * Validates password + * + * @param string $password password to validate + * + * @return bool if password provided is valid for current user + */ + public function validatePassword($password) + { + return Yii::$app->security->validatePassword($password, $this->password_hash); + } + + /** + * Generates password hash from password and sets it to the model + * + * @param string $password + */ + public function setPassword($password) + { + $this->password_hash = Yii::$app->security->generatePasswordHash($password); + } + + /** + * Generates "remember me" authentication key + */ + public function generateAuthKey() + { + $this->auth_key = Yii::$app->security->generateRandomString(); + } + + /** + * Generates new password reset token + */ + public function generatePasswordResetToken() + { + $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time(); + } + + /** + * Removes password reset token + */ + public function removePasswordResetToken() + { + $this->password_reset_token = null; + } + + /** + * Link for user data model + * + * @return \yii\db\ActiveQuery + */ + public function getData() + { + return $this->hasOne(UserData::className(), [ 'user_id' => 'id' ]); + } + } diff --git a/artweb/artbox-core/models/UserData.php b/artweb/artbox-core/models/UserData.php new file mode 100755 index 0000000..7155ba9 --- /dev/null +++ b/artweb/artbox-core/models/UserData.php @@ -0,0 +1,165 @@ + [ + 'class' => BlameableBehavior::className(), + 'createdByAttribute' => 'user_id', + 'updatedByAttribute' => false, + ], + [ + 'class' => AttributeBehavior::className(), + 'attributes' => [ + ActiveRecord::EVENT_AFTER_FIND => 'visited_at', + ], + 'value' => function ($event) { + return time(); + }, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'name', + 'surname', + 'image', + 'email', + 'phone', + ], + 'string', + 'max' => 255, + ], + [ + [ 'email' ], + 'email', + ], + [ + [ 'phone' ], + 'match', + 'pattern' => '/^\+\d{1,3}\(\d+\)\d+-\d+-\d+$/', + ], + [ + [ 'user_id' ], + 'unique', + ], + [ + [ 'user_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => User::className(), + 'targetAttribute' => [ 'user_id' => 'id' ], + ], + [ + [ 'image' ], + 'filter', + 'filter' => function ($value) { + if (!$value) { + return null; + } else { + return $value; + } + }, + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'user_id' => Yii::t('core', 'User ID'), + 'name' => Yii::t('core', 'Name'), + 'surname' => Yii::t('core', 'Surname'), + 'image' => Yii::t('core', 'Image'), + 'email' => Yii::t('core', 'Email'), + 'phone' => Yii::t('core', 'Phone'), + 'created_at' => Yii::t('core', 'Created At'), + 'updated_at' => Yii::t('core', 'Updated At'), + 'visited_at' => Yii::t('core', 'Visited At'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getUser() + { + return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); + } + + /** + * Get fullname + * + * @return string + */ + public function getFullname() + { + if (empty( $this->name ) && empty( $this->surname )) { + return \Yii::t('core', 'Anonymous'); + } else { + return implode( + ' ', + [ + $this->name ? : \Yii::t('core', 'Mr.'), + $this->surname, + ] + ); + } + } + } diff --git a/artweb/artbox-core/models/interfaces/AliasInterface.php b/artweb/artbox-core/models/interfaces/AliasInterface.php new file mode 100755 index 0000000..8153c2d --- /dev/null +++ b/artweb/artbox-core/models/interfaces/AliasInterface.php @@ -0,0 +1,27 @@ + + +
+ + + + field($model, 'route') + ->textInput() ?> + + field($model, 'value') + ->textInput() ?> + + field($model, 'language_id') + ->dropDownList($languages) ?> + + field($model, 'title') + ->textInput() ?> + + field($model, 'description') + ->textarea() ?> + + field($model, 'h1') + ->textInput() ?> + + field($model, 'seo_text') + ->widget( + TinyMce::className(), + [ + 'options' => [ 'rows' => 30 ], + 'language' => 'ru', + 'clientOptions' => [ + 'file_browser_callback' => new yii\web\JsExpression( + "function(field_name, url, type, win) { +window.open('" . yii\helpers\Url::to( + [ + 'imagemanager/manager', + 'view-mode' => 'iframe', + 'select-type' => 'tinymce', + ] + ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no'); +}" + ), + 'plugins' => [ + "advlist autolink lists link charmap print preview anchor", + "searchreplace visualblocks code fullscreen", + "insertdatetime media table contextmenu paste image", + ], + 'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code", + 'image_advtab' => true, + ], + ] + ); + ?> + + field($model, 'entity') + ->textInput([ 'readonly' => true ]) ?> + + field($model, 'robots') + ->dropDownList( + [ + 'index, follow' => 'index, follow', + 'index, nofollow' => 'index, nofollow', + 'noindex, follow' => 'noindex, follow', + 'noindex, nofollow' => 'noindex, nofollow', + ] + ) ?> + +
+ isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/artweb/artbox-core/views/alias/_form_update.php b/artweb/artbox-core/views/alias/_form_update.php new file mode 100755 index 0000000..f30e69d --- /dev/null +++ b/artweb/artbox-core/views/alias/_form_update.php @@ -0,0 +1,146 @@ + + +
+ + + + field( + $model, + 'value' + ) + ->hint( + \Yii::t( + 'core', + '{field} field would be slugified.', + [ + 'field' => $model->getAttributeLabel('value'), + ] + ) + ); + echo SlugifyDecorator::decorate( + $valueField, + [ '/alias/slugify' ], + $valueField, + true, + $model->language_id + ) + ->textInput() ?> + +
+
+

+ +

+ entity)) { + ?> +
+ + getCheckedFields() as $field => $fieldTitle) { + ?> + + + + + +
-
+
+
+
+

+ +

+
Your text with custom [[example]] field.
+
+
+ +
+
+ field($model, 'title') + ->textInput() ?> + + field($model, 'description') + ->textarea() ?> + + field($model, 'h1') + ->textInput() ?> + + field($model, 'seo_text') + ->widget( + TinyMce::className(), + [ + 'options' => [ 'rows' => 30 ], + 'language' => 'ru', + 'clientOptions' => [ + 'file_browser_callback' => new yii\web\JsExpression( + "function(field_name, url, type, win) { +window.open('" . yii\helpers\Url::to( + [ + 'imagemanager/manager', + 'view-mode' => 'iframe', + 'select-type' => 'tinymce', + ] + ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no'); +}" + ), + 'plugins' => [ + "advlist autolink lists link charmap print preview anchor", + "searchreplace visualblocks code fullscreen", + "insertdatetime media table contextmenu paste image", + ], + 'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code", + 'image_advtab' => true, + ], + ] + ); + ?> +
+
+ + field($model, 'robots') + ->dropDownList( + [ + 'index, follow' => 'index, follow', + 'index, nofollow' => 'index, nofollow', + 'noindex, follow' => 'noindex, follow', + 'noindex, nofollow' => 'noindex, nofollow', + ] + ) ?> + +
+ isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/artweb/artbox-core/views/alias/_search.php b/artweb/artbox-core/views/alias/_search.php new file mode 100755 index 0000000..7bd394f --- /dev/null +++ b/artweb/artbox-core/views/alias/_search.php @@ -0,0 +1,63 @@ + + diff --git a/artweb/artbox-core/views/alias/create.php b/artweb/artbox-core/views/alias/create.php new file mode 100755 index 0000000..6329510 --- /dev/null +++ b/artweb/artbox-core/views/alias/create.php @@ -0,0 +1,41 @@ +title = \Yii::t('core', 'Create {item}', [ 'item' => 'Alias' ]); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('core', 'Aliases'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ $this->title, + ] + ); + ?> + + render( + '_form_create', + [ + 'model' => $model, + 'languages' => $languages, + ] + ) ?> + + + +
diff --git a/artweb/artbox-core/views/alias/index.php b/artweb/artbox-core/views/alias/index.php new file mode 100755 index 0000000..5629fe3 --- /dev/null +++ b/artweb/artbox-core/views/alias/index.php @@ -0,0 +1,114 @@ +title = \Yii::t('core', 'Aliases'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ + \Yii::t('core', 'Create filter alias'), + 'collapsable' => true, + ] + ); ?> + +

+ Example: http://domain.com/catalog/category/filter1_filter2 +

+ + 'form-horizontal form-label-left', + ] + ) ?> +
+ +
+
+ 'form-control', + ] + ) ?> + + 'btn btn-primary', + ] + ) ?> + + +
+
+
+ + + + + $this->title, + ] + ); + ?> + render( + '_search', + [ + 'model' => $searchModel, + 'languages' => $languages, + 'entities' => $entities, + ] + ); + ?> +

+ \Yii::t('core', 'Alias') ]), + [ 'create' ], + [ + 'class' => 'btn btn-danger', + 'data-confirm' => \Yii::t( + 'core', + 'Creating aliases by hand may cause bugs for your website. Use it only if you know what are you doing!' + ), + ] + ) ?> +

+
+ $dataProvider, + 'columns' => [ + 'id', + 'value', + 'route', + 'title', + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ] + ); ?> + +
diff --git a/artweb/artbox-core/views/alias/update.php b/artweb/artbox-core/views/alias/update.php new file mode 100755 index 0000000..4aa0b12 --- /dev/null +++ b/artweb/artbox-core/views/alias/update.php @@ -0,0 +1,52 @@ +title = \Yii::t( + 'core', + 'Update {item}', + [ + 'item' => \Yii::t('core', 'Alias'), + ] + ) . ': ' . $model->value; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('core', 'Aliases'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->value, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = \Yii::t('core', 'Update'); +?> +
+ + $this->title, + ] + ) + ?> + + render( + '_form_update', + [ + 'model' => $model, + ] + ) ?> + + +
diff --git a/artweb/artbox-core/views/alias/view.php b/artweb/artbox-core/views/alias/view.php new file mode 100755 index 0000000..e51b2d4 --- /dev/null +++ b/artweb/artbox-core/views/alias/view.php @@ -0,0 +1,74 @@ +title = $model->value; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('core', 'Aliases'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ + $this->title, + ] + ); + ?> + +

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

+ + $model, + 'attributes' => [ + 'id', + 'value', + 'route', + 'title', + 'description', + 'h1', + 'robots', + 'seo_text', + ], + ] + ) ?> + + +
diff --git a/artweb/artbox-core/views/feedback/_form.php b/artweb/artbox-core/views/feedback/_form.php new file mode 100755 index 0000000..30b9a46 --- /dev/null +++ b/artweb/artbox-core/views/feedback/_form.php @@ -0,0 +1,43 @@ + + + diff --git a/artweb/artbox-core/views/feedback/create.php b/artweb/artbox-core/views/feedback/create.php new file mode 100755 index 0000000..5453996 --- /dev/null +++ b/artweb/artbox-core/views/feedback/create.php @@ -0,0 +1,26 @@ +title = Yii::t('core', 'Create Feedback'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Feedbacks'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + diff --git a/artweb/artbox-core/views/feedback/index.php b/artweb/artbox-core/views/feedback/index.php new file mode 100755 index 0000000..657c549 --- /dev/null +++ b/artweb/artbox-core/views/feedback/index.php @@ -0,0 +1,88 @@ +title = Yii::t('core', 'Feedbacks'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + + $this->title, + 'options' => [ + 'class' => 'x_panel feedback-index', + ], + ] +) ?> + + $dataProvider, + 'rowOptions' => function (Feedback $model) { + if ($model->status) { + return []; + } else { + return [ + 'class' => 'success', + ]; + } + }, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + + 'name', + 'email', + 'phone', + [ + 'attribute' => 'created_at', + 'format' => [ + 'datetime', + 'php:d.m.Y H:i', + ], + ], + [ + 'class' => 'yii\grid\ActionColumn', + 'buttons' => [ + 'viewed' => function (string $url, Feedback $model) { + if ($model->status) { + return Html::tag( + 'span', + '', + [ + 'class' => 'glyphicon glyphicon-ok', + ] + ); + } else { + return Html::a( + Html::tag( + 'span', + '', + [ + 'class' => 'glyphicon glyphicon-flag', + ] + ), + $url, + [ + 'class' => 'viewed-toggle', + ] + ); + } + }, + ], + 'template' => '{viewed} {view} {update} {delete}', + ], + ], + ] +); ?> + + diff --git a/artweb/artbox-core/views/feedback/update.php b/artweb/artbox-core/views/feedback/update.php new file mode 100755 index 0000000..dcc15dc --- /dev/null +++ b/artweb/artbox-core/views/feedback/update.php @@ -0,0 +1,45 @@ +title = Yii::t( + 'core', + 'Update {modelClass}: ', + [ + 'modelClass' => 'Feedback', + ] + ) . $model->name; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Feedbacks'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->name, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); +?> + + $this->title, + 'options' => [ + 'class' => 'x_panel feedback-update', + ], + ] +) ?> + +render( + '_form', + [ + 'model' => $model, + ] +) ?> + + diff --git a/artweb/artbox-core/views/feedback/view.php b/artweb/artbox-core/views/feedback/view.php new file mode 100755 index 0000000..71f2b62 --- /dev/null +++ b/artweb/artbox-core/views/feedback/view.php @@ -0,0 +1,69 @@ +title = $model->name; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Feedbacks'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + + $this->title, + 'options' => [ + 'class' => 'x_panel feedback-view', + ], + ] +); ?> + +

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

+ + $model, + 'attributes' => [ + 'id', + 'name', + 'email:email', + 'phone', + 'message:ntext', + 'created_at', + 'ip', + 'url:url', + 'status:boolean', + ], + ] +) ?> + + diff --git a/artweb/artbox-core/views/page-category/_form.php b/artweb/artbox-core/views/page-category/_form.php new file mode 100644 index 0000000..7d0944a --- /dev/null +++ b/artweb/artbox-core/views/page-category/_form.php @@ -0,0 +1,47 @@ + + +
+ + + + $modelLangs, + 'formView' => '@artbox/core/views/page-category/_form_language', + 'form' => $form, + ] + ) ?> + + field($model, 'sort') + ->textInput() ?> + + field($model, 'status') + ->checkbox([ + 'class' => 'flat', + ]) ?> + +
+ isNewRecord ? 'Create' : 'Update', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/artweb/artbox-core/views/page-category/_form_language.php b/artweb/artbox-core/views/page-category/_form_language.php new file mode 100755 index 0000000..e96c8d3 --- /dev/null +++ b/artweb/artbox-core/views/page-category/_form_language.php @@ -0,0 +1,18 @@ + + +field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); +?> + diff --git a/artweb/artbox-core/views/page-category/create.php b/artweb/artbox-core/views/page-category/create.php new file mode 100644 index 0000000..a20d310 --- /dev/null +++ b/artweb/artbox-core/views/page-category/create.php @@ -0,0 +1,40 @@ +title = 'Create Page Category'; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Page Categories', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + +
+ + $this->title, + ] + ) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?> + + + +
diff --git a/artweb/artbox-core/views/page-category/index.php b/artweb/artbox-core/views/page-category/index.php new file mode 100644 index 0000000..b112649 --- /dev/null +++ b/artweb/artbox-core/views/page-category/index.php @@ -0,0 +1,51 @@ +title = 'Page Categories'; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ + $this->title, + ] + ) ?> + +

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + + [ + 'attribute' => 'title', + 'value' => 'lang.title' + ], + 'sort', + 'status:boolean', + + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ] + ); ?> + + + +
diff --git a/artweb/artbox-core/views/page-category/update.php b/artweb/artbox-core/views/page-category/update.php new file mode 100644 index 0000000..5ac7c3e --- /dev/null +++ b/artweb/artbox-core/views/page-category/update.php @@ -0,0 +1,46 @@ +title = 'Update Page Category: ' . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Page Categories', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = 'Update'; +?> +
+ + $this->title, + ] + ) ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?> + + + +
diff --git a/artweb/artbox-core/views/page-category/view.php b/artweb/artbox-core/views/page-category/view.php new file mode 100644 index 0000000..551c137 --- /dev/null +++ b/artweb/artbox-core/views/page-category/view.php @@ -0,0 +1,60 @@ +title = $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => 'Page Categories', + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id, + ], + [ 'class' => 'btn btn-primary' ] + ) ?> + $model->id, + ], + [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ] + ) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'sort', + 'status:boolean', + ], + ] + ) ?> + +
diff --git a/artweb/artbox-core/views/page/_form.php b/artweb/artbox-core/views/page/_form.php new file mode 100755 index 0000000..0d983da --- /dev/null +++ b/artweb/artbox-core/views/page/_form.php @@ -0,0 +1,64 @@ + + +
+ + + + + [ + [ + 'label' => \Yii::t('core', 'Common'), + 'content' => $this->render( + '_form_common', + [ + 'form' => $form, + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ), + ], + [ + 'label' => \Yii::t('core', 'Gallery'), + 'content' => $this->render( + '_gallery', + [ + 'model' => $model, + ] + ), + ], + ], + 'options' => [ + 'class' => 'bar_tabs', + ], + ] + ); + ?> + +
+ isNewRecord ? 'Создать' : 'Обновить', + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/artweb/artbox-core/views/page/_form_common.php b/artweb/artbox-core/views/page/_form_common.php new file mode 100644 index 0000000..3a9da7b --- /dev/null +++ b/artweb/artbox-core/views/page/_form_common.php @@ -0,0 +1,89 @@ + + + $modelLangs, + 'formView' => '@artbox/core/views/page/_form_language', + 'form' => $form, + ] +) ?> + +
+ + 'categoryIds', + 'options' => [ + 'placeholder' => \Yii::t('core', 'Search for a categories ...'), + 'multiple' => true, + ], + 'value' => array_keys($model->categoryIds), + 'data' => $model->categoryIds, + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'language' => [ + 'errorLoading' => new JsExpression( + "function () { return 'Waiting for results...'; }" + ), + ], + 'ajax' => [ + 'url' => Url::to([ '/page-category/list' ]), + 'dataType' => 'json', + 'data' => new JsExpression( + 'function(params) { + return { + q:params.term + }; + }' + ), + ], + 'escapeMarkup' => new JsExpression( + 'function (markup) { + return markup; + }' + ), + 'templateResult' => new JsExpression( + 'function (brand) { + return brand.text; + }' + ), + 'templateSelection' => new JsExpression( + 'function (brand) { + return brand.text; + }' + ), + ], + ] + ); + ?> +
+ +field($model, 'in_menu') + ->checkbox( + [ + 'class' => 'flat', + ] + ) ?> + +field($model, 'sort') + ->input('number') ?> \ No newline at end of file diff --git a/artweb/artbox-core/views/page/_form_language.php b/artweb/artbox-core/views/page/_form_language.php new file mode 100755 index 0000000..187aaf1 --- /dev/null +++ b/artweb/artbox-core/views/page/_form_language.php @@ -0,0 +1,59 @@ + +field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); + echo $attributeField; +?> + +field($model_lang, '[' . $language->id . ']aliasValue'), + [ '/alias/slugify' ], + $attributeField, + false, + $language->id +) + ->textInput([ 'maxlength' => true ]); ?> + +field($model_lang, '[' . $language->id . ']body') + ->widget( + TinyMce::className(), + [ + 'options' => [ 'rows' => 6 ], + 'language' => 'ru', + 'clientOptions' => [ + 'file_browser_callback' => new yii\web\JsExpression( + "function(field_name, url, type, win) { +window.open('" . yii\helpers\Url::to( + [ + 'imagemanager/manager', + 'view-mode' => 'iframe', + 'select-type' => 'tinymce', + ] + ) . "&tag_name='+field_name,'','width=800,height=540 ,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no'); +}" + ), + 'plugins' => [ + "advlist autolink lists link charmap print preview anchor", + "searchreplace visualblocks code fullscreen", + "insertdatetime media table contextmenu paste image", + ], + 'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code", + ], + ] + ); +?> \ No newline at end of file diff --git a/artweb/artbox-core/views/page/_gallery.php b/artweb/artbox-core/views/page/_gallery.php new file mode 100644 index 0000000..2499927 --- /dev/null +++ b/artweb/artbox-core/views/page/_gallery.php @@ -0,0 +1,20 @@ + + + $model, + ] + ); +?> \ No newline at end of file diff --git a/artweb/artbox-core/views/page/create.php b/artweb/artbox-core/views/page/create.php new file mode 100755 index 0000000..b326b6f --- /dev/null +++ b/artweb/artbox-core/views/page/create.php @@ -0,0 +1,41 @@ +title = \Yii::t('core', 'Создать страницу'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('core', 'Pages'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ $this->title, + ] + ); + ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?> + + + +
diff --git a/artweb/artbox-core/views/page/index.php b/artweb/artbox-core/views/page/index.php new file mode 100755 index 0000000..968c1b7 --- /dev/null +++ b/artweb/artbox-core/views/page/index.php @@ -0,0 +1,65 @@ +title = \Yii::t('core', 'Pages'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ $this->title, + ] + ); + ?> + + +

+ \Yii::t('core', 'Page') ]), + [ 'create' ], + [ 'class' => 'btn btn-success' ] + ) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + 'id', + [ + 'attribute' => 'title', + 'value' => 'lang.title', + ], + [ + 'attribute' => 'in_menu', + 'value' => function ($model) { + /** + * @var Page $model + */ + return ( !$model->in_menu ) ? \Yii::t('core', 'Не в меню') : \Yii::t('core', 'В меню'); + }, + 'filter' => [ + 0 => \Yii::t('core', 'Не в меню'), + 1 => \Yii::t('core', 'В меню'), + ], + ], + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ] + ); ?> + +
diff --git a/artweb/artbox-core/views/page/update.php b/artweb/artbox-core/views/page/update.php new file mode 100755 index 0000000..7f7a780 --- /dev/null +++ b/artweb/artbox-core/views/page/update.php @@ -0,0 +1,55 @@ +title = \Yii::t( + 'core', + 'Update {item}', + [ + 'item' => \Yii::t('core', 'Page'), + ] + ) . ': ' . $model->lang->title; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('core', 'Pages'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->lang->title, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = \Yii::t('core', 'Update'); +?> +
+ + $this->title, + ] + ) + ?> + + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + ] + ) ?> + + +
diff --git a/artweb/artbox-core/views/page/view.php b/artweb/artbox-core/views/page/view.php new file mode 100755 index 0000000..f377992 --- /dev/null +++ b/artweb/artbox-core/views/page/view.php @@ -0,0 +1,73 @@ +title = $model->lang->title; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => \Yii::t('core', 'Pages'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ + $this->title, + ] + ); + ?> + +

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

+ + $model, + 'attributes' => [ + 'id', + 'lang.title', + [ + 'attribute' => 'in_menu', + 'value' => $model->in_menu ? Yii::t('app', 'В меню') : Yii::t('app', 'Не в меню'), + ], + 'lang.body:html', + ], + ] + ) ?> + + +
diff --git a/artweb/artbox-core/views/profile/_change_password.php b/artweb/artbox-core/views/profile/_change_password.php new file mode 100755 index 0000000..d47ca77 --- /dev/null +++ b/artweb/artbox-core/views/profile/_change_password.php @@ -0,0 +1,63 @@ + [ 'change-password' ], + 'method' => 'POST', + 'errorCssClass' => 'has-error bad', + ] + ); + echo $form->field( + $changePasswordModel, + 'oldPassword', + [ + 'options' => [ + 'class' => 'form-group item', + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->passwordInput(); + echo $form->field( + $changePasswordModel, + 'newPassword', + [ + 'options' => [ + 'class' => 'form-group item', + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->passwordInput(); + echo $form->field( + $changePasswordModel, + 'newPasswordRepeat', + [ + 'options' => [ + 'class' => 'form-group item', + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->passwordInput(); + echo Html::submitButton( + \Yii::t('core', 'Submit'), + [ + 'class' => 'btn btn-default', + ] + ); + $form::end(); diff --git a/artweb/artbox-core/views/profile/_profile_info.php b/artweb/artbox-core/views/profile/_profile_info.php new file mode 100755 index 0000000..f593e9e --- /dev/null +++ b/artweb/artbox-core/views/profile/_profile_info.php @@ -0,0 +1,192 @@ + Yii::getAlias('@storage'), + ] + ); +?> + [ 'update' ], + 'method' => 'POST', + 'errorCssClass' => 'has-error bad', + ] + ); + if (!empty( $userData->image )) { + echo Html::tag( + 'div', + Html::img($imageSearch->getImagePath($userData->image)), + [ + 'class' => 'col-xs-6 col-xs-offset-3 profile_edit_image', + ] + ); + } + echo $form->field($userData, 'image') + ->label(false) + ->widget( + ImageManagerInputWidget::className(), + [ + 'showPreview' => true, + 'showDeletePickedImageConfirm' => false, + ] + ); + echo $form->field( + $userData, + 'name', + [ + 'inputTemplate' => '{input}' . Html::icon( + 'user', + [ + 'prefix' => 'fa fa-', + 'class' => 'form-control-feedback left', + ] + ), + 'options' => [ + 'class' => 'col-sm-6 col-xs-12 has-feedback item', + ], + 'inputOptions' => [ + 'class' => 'form-control has-feedback-left', + 'placeholder' => $userData->getAttributeLabel('name'), + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->label(false) + ->textInput(); + echo $form->field( + $userData, + 'surname', + [ + 'inputTemplate' => '{input}' . Html::icon( + 'user', + [ + 'prefix' => 'fa fa-', + 'class' => 'form-control-feedback right', + ] + ), + 'options' => [ + 'class' => 'col-sm-6 col-xs-12 has-feedback item', + ], + 'inputOptions' => [ + 'placeholder' => $userData->getAttributeLabel('surname'), + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->label(false) + ->textInput(); + echo $form->field( + $userData, + 'email', + [ + 'inputTemplate' => '{input}' . Html::icon( + 'envelope', + [ + 'prefix' => 'fa fa-', + 'class' => 'form-control-feedback left', + ] + ), + 'options' => [ + 'class' => 'col-sm-6 col-xs-12 has-feedback item', + ], + 'inputOptions' => [ + 'class' => 'form-control has-feedback-left', + 'placeholder' => $userData->getAttributeLabel('email'), + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->label(false) + ->textInput(); + echo $form->field( + $userData, + 'phone', + [ + 'inputTemplate' => '{input}' . Html::icon( + 'phone', + [ + 'prefix' => 'fa fa-', + 'class' => 'form-control-feedback right', + ] + ), + 'options' => [ + 'class' => 'col-sm-6 col-xs-12 has-feedback item', + ], + 'inputOptions' => [ + 'placeholder' => '+38(000)000-00-00', + ], + 'errorOptions' => [ + 'class' => 'help-block alert', + ], + ] + ) + ->label(false) + ->textInput(); + echo Html::tag( + 'div', + '', + [ + 'class' => 'clearfix', + ] + ); + echo Html::submitButton( + \Yii::t('core', 'Submit'), + [ + 'class' => 'btn btn-default col-xs-4 col-sm-3 col-md-2 personal_info_submit_button', + ] + ); + echo Html::tag( + 'div', + '', + [ + 'class' => 'clearfix', + ] + ); + $form::end(); + echo Html::tag('hr'); + echo Html::tag( + 'p', + \Yii::t( + 'core', + 'Registered on {date}', + [ + 'date' => \Yii::$app->formatter->asDate($userData->created_at), + ] + ), + [ + 'class' => 'small col-xs-6', + ] + ); + echo Html::tag( + 'p', + \Yii::t( + 'core', + 'Last update on {date}', + [ + 'date' => \Yii::$app->formatter->asDatetime($userData->updated_at, 'php:d.m.Y H:i'), + ] + ), + [ + 'class' => 'small col-xs-6 text-right', + ] + ); diff --git a/artweb/artbox-core/views/profile/index.php b/artweb/artbox-core/views/profile/index.php new file mode 100755 index 0000000..12e3a5d --- /dev/null +++ b/artweb/artbox-core/views/profile/index.php @@ -0,0 +1,76 @@ +title = 'Profile'; + + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+
+ \Yii::t('core', 'Profile information'), + ] + ); + echo Collapse::widget( + [ + 'items' => [ + [ + 'label' => Html::tag( + 'p', + \Yii::t('core', 'Personal information'), + [ + 'class' => 'collapse_toggle_text', + ] + ), + 'content' => $this->render( + '_profile_info', + [ + 'user' => $user, + 'userData' => $userData, + ] + ), + 'contentOptions' => [ 'class' => $changePasswordModel->hasErrors() ? '' : 'in' ], + ], + [ + 'label' => Html::tag( + 'p', + \Yii::t('core', 'Change password'), + [ + 'class' => 'collapse_toggle_text', + ] + ), + 'content' => $this->render( + '_change_password', + [ + 'changePasswordModel' => $changePasswordModel, + ] + ), + 'contentOptions' => [ 'class' => $changePasswordModel->hasErrors() ? 'in' : '' ], + ], + ], + 'options' => [ + 'class' => 'accordion profile_info_accordion', + ], + 'encodeLabels' => false, + ] + ); + $xPanel::end(); + ?> +
+
+
\ No newline at end of file diff --git a/artweb/artbox-core/views/seo/index.php b/artweb/artbox-core/views/seo/index.php new file mode 100755 index 0000000..92b19c3 --- /dev/null +++ b/artweb/artbox-core/views/seo/index.php @@ -0,0 +1,20 @@ + +
+

To be done!

+

...

+

'btn btn-primary btn-lg', + 'role' => 'button', + ] + ); ?>

+
+ \Yii::t('core', 'Static pages'), + 'collapsable' => true, + 'options' => [ + 'class' => 'x_panel dynamic_fields', + ], + ] + ); + foreach ($models as $index => $model) { + echo Html::tag( + 'div', + $form->field( + $model, + "[$index]url", + [ + 'options' => [ + 'class' => 'form-group col-xs-5', + ], + ] + ) + ->textInput() . $form->field( + $model, + "[$index]priority", + [ + 'options' => [ + 'class' => 'form-group col-xs-2', + ], + ] + ) + ->textInput() . Html::icon( + 'minus', + [ + 'class' => 'col-xs-1 field-group-remove', + 'onclick' => 'sitemap_remove(this)', + ] + ), + [ + 'class' => 'row field-group', + ] + ); + } + echo Html::button( + \Yii::t('core', 'Add field'), + [ + 'class' => 'btn btn-default', + 'onclick' => 'sitemap_add(this)', + 'data' => [ + 'url' => Url::to([ 'seo/create-static' ]), + ], + ] + ); + $xPanel::end(); + $xPanel2 = Panel::begin( + [ + 'header' => \Yii::t('core', 'Dynamic pages'), + 'collapsable' => true, + ] + ); + echo Html::tag('h3', 'To be done...'); + $xPanel2::end(); + echo Html::submitButton( + \Yii::t('core', 'Generate'), + [ + 'class' => 'btn btn-primary', + ] + ); + $form::end(); + $js = << 1) { + $(e) + .parents('.field-group') + .remove(); + } + } +JS; + $this->registerJs($js, $this::POS_END); \ No newline at end of file diff --git a/artweb/artbox-core/views/slide/_form.php b/artweb/artbox-core/views/slide/_form.php new file mode 100755 index 0000000..d5deba2 --- /dev/null +++ b/artweb/artbox-core/views/slide/_form.php @@ -0,0 +1,52 @@ + + +
+ + + + field($model, 'slider_id') + ->hiddenInput([ 'value' => $slider->id ]) + ->label(false) ?> + + $modelLangs, + 'formView' => '@artbox/core/views/slide/_form_language', + 'form' => $form, + ] + ) ?> + + field($model, 'status') + ->checkbox( + [ + 'class' => 'flat', + ] + ) ?> + + field($model, 'sort') + ->input('number') ?> + +
+ isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'), + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/artweb/artbox-core/views/slide/_form_language.php b/artweb/artbox-core/views/slide/_form_language.php new file mode 100755 index 0000000..0e8c46c --- /dev/null +++ b/artweb/artbox-core/views/slide/_form_language.php @@ -0,0 +1,30 @@ +field($model_lang, '[' . $language->id . ']image_id') + ->widget( + ImageManagerInputWidget::className(), + [ + 'aspectRatio' => ( 16 / 9 ), + //set the aspect ratio + 'showPreview' => true, + //false to hide the preview + 'showDeletePickedImageConfirm' => false, + //on true show warning before detach image + ] + ); + echo $form->field($model_lang, '[' . $language->id . ']title') + ->textInput([ 'maxlength' => true ]); + echo $form->field($model_lang, '[' . $language->id . ']link') + ->textInput([ 'maxlength' => true ]); +?> \ No newline at end of file diff --git a/artweb/artbox-core/views/slide/_search.php b/artweb/artbox-core/views/slide/_search.php new file mode 100755 index 0000000..004b118 --- /dev/null +++ b/artweb/artbox-core/views/slide/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/artweb/artbox-core/views/slide/create.php b/artweb/artbox-core/views/slide/create.php new file mode 100755 index 0000000..b0a65b1 --- /dev/null +++ b/artweb/artbox-core/views/slide/create.php @@ -0,0 +1,36 @@ +title = Yii::t('core', 'Create Slide'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Slides'), + 'url' => [ + 'index', + 'slider_id' => $slider->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'slider' => $slider, + ] + ) ?> + +
diff --git a/artweb/artbox-core/views/slide/index.php b/artweb/artbox-core/views/slide/index.php new file mode 100755 index 0000000..c356555 --- /dev/null +++ b/artweb/artbox-core/views/slide/index.php @@ -0,0 +1,45 @@ +title = Yii::t('core', 'Slides'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ $slider->id, + ], + [ 'class' => 'btn btn-success' ] + ) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + + 'id', + 'slider_id', + 'status:boolean', + 'sort', + + [ 'class' => 'yii\grid\ActionColumn' ], + ], + ] + ); ?> +
diff --git a/artweb/artbox-core/views/slide/update.php b/artweb/artbox-core/views/slide/update.php new file mode 100755 index 0000000..a889880 --- /dev/null +++ b/artweb/artbox-core/views/slide/update.php @@ -0,0 +1,49 @@ +title = Yii::t( + 'core', + 'Update {modelClass}: ', + [ + 'modelClass' => 'Slide', + ] + ) . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Slides'), + 'url' => [ + 'index', + 'slider_id' => $slider->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + 'modelLangs' => $modelLangs, + 'slider' => $slider, + ] + ) ?> + +
diff --git a/artweb/artbox-core/views/slide/view.php b/artweb/artbox-core/views/slide/view.php new file mode 100755 index 0000000..2b98b54 --- /dev/null +++ b/artweb/artbox-core/views/slide/view.php @@ -0,0 +1,58 @@ +title = $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Slides'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'slider_id', + 'status:boolean', + 'sort', + ], + ] + ) ?> + +
diff --git a/artweb/artbox-core/views/slider/_form.php b/artweb/artbox-core/views/slider/_form.php new file mode 100755 index 0000000..a8bb67b --- /dev/null +++ b/artweb/artbox-core/views/slider/_form.php @@ -0,0 +1,33 @@ + + +
+ + + + field($model, 'status') + ->checkbox([ + 'class' => 'flat', + ]) ?> + + field($model, 'sort') + ->input('number') ?> + +
+ isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'), + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] + ) ?> +
+ + + +
diff --git a/artweb/artbox-core/views/slider/_search.php b/artweb/artbox-core/views/slider/_search.php new file mode 100755 index 0000000..6242edc --- /dev/null +++ b/artweb/artbox-core/views/slider/_search.php @@ -0,0 +1,35 @@ + + + diff --git a/artweb/artbox-core/views/slider/create.php b/artweb/artbox-core/views/slider/create.php new file mode 100755 index 0000000..e1c7385 --- /dev/null +++ b/artweb/artbox-core/views/slider/create.php @@ -0,0 +1,27 @@ +title = Yii::t('core', 'Create Slider'); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Sliders'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + ] + ) ?> + +
diff --git a/artweb/artbox-core/views/slider/index.php b/artweb/artbox-core/views/slider/index.php new file mode 100755 index 0000000..2efc8a6 --- /dev/null +++ b/artweb/artbox-core/views/slider/index.php @@ -0,0 +1,68 @@ +title = Yii::t('core', 'Sliders'); + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], + + 'id', + 'status:boolean', + [ + 'attribute' => 'sort', + 'filter' => false, + ], + [ + 'class' => 'yii\grid\ActionColumn', + 'buttons' => [ + 'slides' => function ($url, $model, $key) { + /** + * @var \artbox\core\models\Slider $model + */ + return Html::a( + Html::tag( + 'i', + '', + [ + 'class' => 'glyphicon glyphicon-picture', + ] + ), + [ + 'slide/index', + 'slider_id' => $model->id, + ], + [ + 'title' => \Yii::t('core', 'Slides'), + 'data' => [ + 'pjax' => 0, + ], + ] + ); + }, + ], + 'template' => '{slides} {view} {update} {delete}', + ], + ], + ] + ); ?> +
diff --git a/artweb/artbox-core/views/slider/update.php b/artweb/artbox-core/views/slider/update.php new file mode 100755 index 0000000..2485a80 --- /dev/null +++ b/artweb/artbox-core/views/slider/update.php @@ -0,0 +1,40 @@ +title = Yii::t( + 'core', + 'Update {modelClass}: ', + [ + 'modelClass' => 'Slider', + ] + ) . $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Sliders'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->id, + 'url' => [ + 'view', + 'id' => $model->id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); +?> +
+ +

title) ?>

+ + render( + '_form', + [ + 'model' => $model, + ] + ) ?> + +
diff --git a/artweb/artbox-core/views/slider/view.php b/artweb/artbox-core/views/slider/view.php new file mode 100755 index 0000000..310962d --- /dev/null +++ b/artweb/artbox-core/views/slider/view.php @@ -0,0 +1,57 @@ +title = $model->id; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('core', 'Sliders'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'status:boolean', + 'sort', + ], + ] + ) ?> + +
diff --git a/artweb/artbox-core/web/css/styles.css b/artweb/artbox-core/web/css/styles.css new file mode 100755 index 0000000..0bb7e67 --- /dev/null +++ b/artweb/artbox-core/web/css/styles.css @@ -0,0 +1,380 @@ +.profile_custom_title.x_title h2 { + float: none; + text-align: center; } + @media (max-width: 1200px) { + .profile_custom_title.x_title h2 { + width: 100%; } } + +.profile_info_accordion .form-group { + position: relative; } + .profile_info_accordion .form-group .help-block.alert { + position: relative; + top: 0; + margin-bottom: 10px; + left: -20px; + border-radius: 0 0 4px 3px; + white-space: nowrap; + overflow: hidden; + width: 100%; + max-width: inherit; + text-overflow: ellipsis; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper-new { + cursor: default; + position: relative; + overflow: hidden; + border-radius: 50%; + width: 170px; + height: 170px; + display: block; + margin: 0 auto; + margin-bottom: 20px; + border: 5px solid #fff; + box-shadow: 0 0 3px 1px #ddd; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper-new .add_image { + cursor: pointer; + position: absolute; + background-color: rgba(0, 0, 0, 0.5); + width: 100%; + height: 100%; + bottom: -100%; + transition: 0.2s; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper-new .add_image i.glyphicon-folder-open { + color: white; + font-size: 24px; + position: absolute; + top: calc(50% - 12px); + left: calc(50% - 12px); } + .profile_info_accordion .form-group .image-manager-input .image-wrapper-new:hover .add_image { + bottom: 0; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper-new:after { + content: ''; + display: block; + background: #dadada; + width: 165px; + height: 165px; } + .profile_info_accordion .form-group .image-manager-input .input-group { + display: none; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper { + cursor: default; + position: relative; + overflow: hidden; + border-radius: 50%; + width: 170px; + height: 170px; + display: block; + margin: 0 auto; + margin-bottom: 20px; + border: 5px solid #fff; + box-shadow: 0 0 3px 1px #ddd; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper .delete_image { + position: absolute; + background-color: rgba(0, 0, 0, 0.5); + width: 30%; + height: 30%; + display: block; + top: -30%; + right: -30%; + border-radius: 0 0 0 5px; + transition: 0.2s; + cursor: pointer; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper .delete_image i.glyphicon-remove { + color: white; + font-size: 15px; + position: absolute; + top: 27px; + left: 7px; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); } + .profile_info_accordion .form-group .image-manager-input .image-wrapper .add_image { + content: ''; + width: 100%; + height: 30%; + background-color: rgba(0, 0, 0, 0.5); + position: absolute; + bottom: -30%; + left: 0; + transition: 0.3s; + cursor: pointer; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper .add_image i.glyphicon-folder-open { + color: white; + font-size: 15px; + position: absolute; + top: 25%; + left: calc(50% - 7px); + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); } + .profile_info_accordion .form-group .image-manager-input .image-wrapper:hover .add_image { + bottom: 0; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper:hover .delete_image { + top: 0; + right: 0; + transition: 0.2s; } + .profile_info_accordion .form-group .image-manager-input .image-wrapper img { + object-fit: cover; + width: 165px !important; + height: 165px !important; + margin: -5px; + text-align: center; } +.profile_info_accordion .panel-heading { + padding: 0; } +.profile_info_accordion .collapse_toggle_text { + margin: 0; + padding: 10px 0; } +.profile_info_accordion .panel:hover { + background: none; } +.profile_info_accordion .panel .panel-body { + text-align: left; } + .profile_info_accordion .panel .panel-body .personal_info_submit_button { + margin-left: 10px; } + .profile_info_accordion .panel .panel-body .profile_edit_image { + text-align: center; } + .profile_info_accordion .panel .panel-body .profile_edit_image img { + max-width: 100%; + border-radius: 50%; } + +.form-control-feedback { + margin: 0; + height: 32px; + margin-top: 1px; + padding-top: 4px; } + +.profile_edit_image { + display: none; } + +.form-control.has-feedback-left { + padding-right: 10px !important; } + +.table.borderless td, .table.borderless th { + border: none; } + +.right_border { + border-right: 2px lightgrey solid; } + +.nav-sm .navbar.nav_title a span.fa { + display: block; + min-height: 50px; + top: 25px; + left: 15px; + position: relative; } + +.has-feedback.has-error.bad { + padding-bottom: 8px; } + .has-feedback.has-error.bad .help-block.alert { + opacity: 1; + position: relative; + max-width: inherit; + top: 0; + left: 0; + margin: 0; + z-index: 2; + width: 100%; + overflow: hidden; + margin-bottom: 10px; + border-radius: 0 0 4px 3px; } + @media (min-width: 1200px) { + .has-feedback.has-error.bad .help-block.alert { + opacity: 1; + position: absolute; + max-width: inherit; + width: initial; + top: 4px; + left: 100%; + z-index: 4; + overflow: visible; + margin: 0; + border-radius: 3px 4px 4px 3px; } } + +@media (min-width: 1200px) { + .field-userdata-email.has-error.bad .help-block.alert { + left: initial; + right: 100%; } + .field-userdata-email.has-error.bad .help-block.alert:after { + border-color: transparent transparent transparent #ce5454; + left: initial; + right: -13px; } } + +.alias-search .form-group input, .alias-search .form-group select { + width: 100%; } +.alias-search .field-aliassearch-search { + width: 30%; +} + +.alias-search .field-aliassearch-entity { + width: 20%; +} +.alias-search .field-aliassearch-static { + width: 20%; } +.alias-search .field-aliassearch-language_id { + width: 20%; } +.alias-search .btn { + width: 10%; + border-radius: 0; + margin-bottom: 10px; + margin-right: 0; } + +.field-group .field-group-remove { + display: block; + height: 50px; + padding-top: 25px; + font-size: 23px; } + +.sitemap-buttons .btn { + height: 200px; + font-size: 25px; + padding: 10% 10%; + overflow: hidden; + width: 50%; } + .sitemap-buttons .btn .fa { + font-size: 70px; } + .sitemap-buttons .btn .indexed { + z-index: 100; + position: relative; } + .sitemap-buttons .btn.active .spinner { + display: block; } + .sitemap-buttons .btn .spinner { + display: none; + position: absolute; + border-radius: 100%; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: palegreen; + -webkit-animation: sk-scaleout 1.5s infinite ease-in-out; + animation: sk-scaleout 1.5s infinite ease-in-out; } + +@-webkit-keyframes sk-scaleout { + 0% { + -webkit-transform: scale(0); } + 100% { + -webkit-transform: scale(1.5); + opacity: 0.5; } } +@keyframes sk-scaleout { + 0% { + -webkit-transform: scale(0); + transform: scale(0); } + 100% { + -webkit-transform: scale(1.5); + transform: scale(1.5); + opacity: 0.5; } } +.language-form-frame { + border-bottom: 25px solid #f5f7fa; + border-right: 15px solid #f5f7fa; + border-left: 15px solid #f5f7fa; + border-top: 15px solid #f5f7fa; + margin-top: 30px; } + .language-form-frame .tab-content { + padding: 0 15px; } + +.bar_tabs > li.disabled a { + background-color: lightgrey; } + .bar_tabs > li.disabled a:hover, .bar_tabs > li.disabled a:focus { + background-color: lightgrey; } + +.gw-item { + overflow: hidden; + padding: 0 0 10px; + margin: 0 10px 20px; + text-align: center; + border-radius: 5px; + box-shadow: 0px 0px 0px 1px #e6e9ed; } + .gw-item .text-info { + min-height: 19px; } + .gw-item .image_gall { + background-color: #f5f7fa; + position: relative; + padding: 0 0 80%; + margin: 0 0 10px; + border-bottom: 1px solid #e6e9ed; } + .gw-item .image_gall img { + position: absolute; + width: calc(100% - 20px); + height: calc(100% - 20px); + left: 0; + margin: 10px; + background-color: white; + outline: none; } + +.icheckbox_flat-green, +.iradio_flat-green { + margin-right: 7px; + margin-bottom: 2px; } + +.loader-wrapper { + background: rgba(255, 255, 255, 0.7); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 2000; +} + +.loader { + display: block; + position: relative; + left: 50%; + top: 50%; + width: 150px; + height: 150px; + margin: -75px 0 0 -75px; + border-radius: 50%; + border: 3px solid transparent; + border-top-color: #1980b3; + z-index: 2001; + -webkit-animation: spin 2s linear infinite; + animation: spin 2s linear infinite; +} + +.loader:before { + content: ""; + position: absolute; + top: 5px; + left: 5px; + right: 5px; + bottom: 5px; + border-radius: 50%; + border: 3px solid transparent; + border-top-color: #3399cc; + -webkit-animation: spin 3s linear infinite; + animation: spin 3s linear infinite; +} + +.loader:after { + content: ""; + position: absolute; + top: 15px; + left: 15px; + right: 15px; + bottom: 15px; + border-radius: 50%; + border: 3px solid transparent; + border-top-color: #70b7da; + -webkit-animation: spin 1.5s linear infinite; + animation: spin 1.5s linear infinite; +} + +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + -ms-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + -ms-transform: rotate(360deg); + transform: rotate(360deg); + } +} +@keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + -ms-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + -ms-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +/*# sourceMappingURL=styles.css.map */ diff --git a/artweb/artbox-core/web/css/styles.css.map b/artweb/artbox-core/web/css/styles.css.map new file mode 100755 index 0000000..8a5fcb7 --- /dev/null +++ b/artweb/artbox-core/web/css/styles.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, + "mappings": "AAKE,gCAAG;EAID,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,MAAM;EAJlB,0BAAkC;IADpC,gCAAG;MAEC,KAAK,EAAE,IAAI;;AAQf,mCAAY;EACV,QAAQ,EAAE,QAAQ;EAClB,qDAAkB;IAChB,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,CAAC;IACN,aAAa,EAAE,IAAI;IACnB,IAAI,EAAE,KAAK;IACX,aAAa,EAAE,WAAW;IAC1B,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,OAAO;IAClB,aAAa,EAAE,QAAQ;EAGvB,2EAAmB;IACjB,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,MAAM;IAChB,aAAa,EAAE,GAAG;IAClB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,MAAM;IACd,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,cAAc;IACtB,UAAU,EAAE,gBAAgB;IAC5B,sFAAW;MACT,MAAM,EAAE,OAAO;MACf,QAAQ,EAAE,QAAQ;MAClB,gBAAgB,EAAE,kBAAkB;MACpC,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,IAAI;MACZ,MAAM,EAAE,KAAK;MACb,UAAU,EAAE,IAAI;MAChB,8GAAwB;QACtB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,QAAQ;QAClB,GAAG,EAAE,gBAAgB;QACrB,IAAI,EAAE,gBAAgB;IAG1B,4FAAmB;MACjB,MAAM,EAAE,CAAC;IAEX,iFAAQ;MACN,OAAO,EAAE,EAAE;MACX,OAAO,EAAE,KAAK;MACd,UAAU,EAAE,OAAO;MACnB,KAAK,EAAE,KAAK;MACZ,MAAM,EAAE,KAAK;EAGjB,qEAAa;IACX,OAAO,EAAE,IAAI;EAEf,uEAAe;IACb,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,MAAM;IAChB,aAAa,EAAE,GAAG;IAClB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,MAAM;IACd,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,cAAc;IACtB,UAAU,EAAE,gBAAgB;IAC5B,qFAAc;MACZ,QAAQ,EAAE,QAAQ;MAClB,gBAAgB,EAAE,kBAAkB;MACpC,KAAK,EAAE,GAAG;MACV,MAAM,EAAE,GAAG;MACX,OAAO,EAAE,KAAK;MACd,GAAG,EAAE,IAAI;MACT,KAAK,EAAE,IAAI;MACX,aAAa,EAAE,SAAS;MACxB,UAAU,EAAE,IAAI;MAChB,MAAM,EAAE,OAAO;MACf,wGAAmB;QACjB,KAAK,EAAE,KAAkB;QACzB,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,QAAQ;QAClB,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,4BAA4B;IAG7C,kFAAW;MACT,OAAO,EAAE,EAAE;MACX,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,GAAG;MACX,gBAAgB,EAAE,kBAAkB;MACpC,QAAQ,EAAE,QAAQ;MAClB,MAAM,EAAE,IAAI;MACZ,IAAI,EAAE,CAAC;MACP,UAAU,EAAE,IAAI;MAChB,MAAM,EAAE,OAAO;MACf,0GAAwB;QACtB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,QAAQ;QAClB,GAAG,EAAE,GAAG;QACR,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,4BAA4B;IAG7C,wFAAmB;MACjB,MAAM,EAAE,CAAC;IAEX,2FAAsB;MACpB,GAAG,EAAE,CAAC;MACN,KAAK,EAAE,CAAC;MACR,UAAU,EAAE,IAAI;IAElB,2EAAI;MACF,UAAU,EAAE,KAAK;MACjB,KAAK,EAAE,gBAAgB;MACvB,MAAM,EAAE,gBAAgB;MACxB,MAAM,EAAE,IAAI;MACZ,UAAU,EAAE,MAAM;AAK1B,sCAAe;EACb,OAAO,EAAE,CAAC;AAEZ,6CAAsB;EACpB,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,MAAM;AAGf,oCAAQ;EACN,UAAU,EAAE,IAAI;AAElB,0CAAY;EACV,UAAU,EAAE,IAAI;EAChB,uEAA6B;IAC3B,WAAW,EAAE,IAAI;EAEnB,8DAAoB;IAClB,UAAU,EAAE,MAAM;IAClB,kEAAI;MACF,SAAS,EAAE,IAAI;MACf,aAAa,EAAE,GAAG;;AAO5B,sBAAuB;EACrB,MAAM,EAAE,CAAC;EACT,MAAM,EAAE,IAAI;EACZ,UAAU,EAAE,GAAG;EACf,WAAW,EAAE,GAAG;;AAGlB,mBAAoB;EAClB,OAAO,EAAE,IAAI;;AAGf,+BAAgC;EAC9B,aAAa,EAAE,eAAe;;AAI9B,0CAAO;EACL,MAAM,EAAE,IAAI;;AAIhB,aAAc;EACZ,YAAY,EAAE,mBAAmB;;AAGnC,mCAAoC;EAClC,OAAO,EAAE,KAAK;EACd,UAAU,EAAE,IAAI;EAChB,GAAG,EAAE,IAAI;EACT,IAAI,EAAE,IAAI;EACV,QAAQ,EAAE,QAAQ;;AAGpB,2BAA4B;EAC1B,cAAc,EAAE,GAAG;EACnB,6CAAkB;IAChB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,OAAO;IAClB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,MAAM;IAChB,aAAa,EAAE,IAAI;IACnB,aAAa,EAAE,WAAW;IAC1B,0BAAiC;MAZnC,6CAAkB;QAad,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,OAAO;QAClB,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,GAAG;QACR,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,CAAC;QACT,aAAa,EAAE,eAAe;;AAMlC,0BAAiC;EAC/B,qDAAkB;IAChB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,IAAI;IACX,2DAAQ;MACN,YAAY,EAAE,2CAA2C;MACzD,IAAI,EAAE,OAAO;MACb,KAAK,EAAE,KAAK;;AAQhB,iEAAc;EACZ,KAAK,EAAE,IAAI;AAGf,uCAA0B;EACxB,KAAK,EAAE,GAAG;AAEZ,uCAA0B;EACxB,KAAK,EAAE,GAAG;AAEZ,uCAA0B;EACxB,KAAK,EAAE,GAAG;AAEZ,4CAA+B;EAC7B,KAAK,EAAE,GAAG;AAEZ,kBAAK;EACH,KAAK,EAAE,GAAG;EACV,aAAa,EAAE,CAAC;EAChB,aAAa,EAAE,IAAI;EACnB,YAAY,EAAE,CAAC;;AAKjB,gCAAoB;EAClB,OAAO,EAAE,KAAK;EACd,MAAM,EAAE,IAAI;EACZ,WAAW,EAAE,IAAI;EACjB,SAAS,EAAE,IAAI;;AAKjB,qBAAK;EACH,MAAM,EAAE,KAAK;EACb,SAAS,EAAE,IAAI;EACf,OAAO,EAAE,OAAO;EAChB,QAAQ,EAAE,MAAM;EAChB,KAAK,EAAE,GAAG;EACV,yBAAI;IACF,SAAS,EAAE,IAAI;EAEjB,8BAAS;IACP,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,QAAQ;EAGlB,qCAAS;IACP,OAAO,EAAE,KAAK;EAGlB,8BAAS;IACP,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,IAAI;IACnB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,gBAAgB,EAAE,SAAS;IAC3B,iBAAiB,EAAE,qCAAqC;IACxD,SAAS,EAAE,qCAAqC;;AAKtD,8BAQC;EAPC,EAAG;IACD,iBAAiB,EAAE,QACrB;EACA,IAAK;IACH,iBAAiB,EAAE,UAAU;IAC7B,OAAO,EAAE,GAAG;AAIhB,sBAUC;EATC,EAAG;IACD,iBAAiB,EAAE,QAAQ;IAC3B,SAAS,EAAE,QAAQ;EAErB,IAAK;IACH,iBAAiB,EAAE,UAAU;IAC7B,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,GAAG;AAIhB,oBAAqB;EACnB,aAAa,EAAE,kBAAkB;EACjC,YAAY,EAAE,kBAAkB;EAChC,WAAW,EAAE,kBAAkB;EAC/B,UAAU,EAAE,kBAAkB;EAC9B,UAAU,EAAE,IAAI;EAChB,iCAAa;IACX,OAAO,EAAE,MAAM;;AAOb,yBAAE;EACA,gBAAgB,EAAE,SAAS;EAC3B,gEAAiB;IACf,gBAAgB,EAAE,SAAS;;AAOrC,QAAS;EACP,QAAQ,EAAE,MAAM;EAChB,OAAO,EAAE,QAAQ;EACjB,MAAM,EAAE,WAAW;EACnB,UAAU,EAAE,MAAM;EAClB,aAAa,EAAE,GAAG;EAClB,UAAU,EAAE,uBAAuB;EACnC,mBAAW;IACT,UAAU,EAAE,IAAI;EAElB,oBAAY;IACV,gBAAgB,EAAE,OAAO;IACzB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,iBAAiB;IAChC,wBAAI;MACF,QAAQ,EAAE,QAAQ;MAClB,KAAK,EAAE,iBAAiB;MACxB,MAAM,EAAE,iBAAiB;MACzB,IAAI,EAAE,CAAC;MACP,MAAM,EAAE,IAAI;MACZ,gBAAgB,EAAE,KAAK;MACvB,OAAO,EAAE,IAAI;;AAKnB;kBACmB;EACjB,YAAY,EAAE,GAAG;EACjB,aAAa,EAAE,GAAG;;AAGpB,eAAgB;EACd,UAAU,EAAE,wBAAwB;EACpC,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;;AAGf,OAAQ;EACN,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,QAAQ;EAClB,IAAI,EAAE,GAAG;EACT,GAAG,EAAE,GAAG;EACR,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,KAAK;EACb,MAAM,EAAE,eAAe;EACvB,aAAa,EAAE,GAAG;EAClB,MAAM,EAAE,qBAAqB;EAC7B,gBAAgB,EAAE,OAAO;EACzB,OAAO,EAAE,IAAI;EAEb,iBAAiB,EAAE,uBAAuB;EAC1C,SAAS,EAAE,uBAAuB;;AAGpC,cAAe;EACb,OAAO,EAAE,EAAE;EACX,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,GAAG;EACR,IAAI,EAAE,GAAG;EACT,KAAK,EAAE,GAAG;EACV,MAAM,EAAE,GAAG;EACX,aAAa,EAAE,GAAG;EAClB,MAAM,EAAE,qBAAqB;EAC7B,gBAAgB,EAAE,OAAO;EAEzB,iBAAiB,EAAE,uBAAuB;EAC1C,SAAS,EAAE,uBAAuB;;AAGpC,aAAc;EACZ,OAAO,EAAE,EAAE;EACX,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,IAAI;EACT,IAAI,EAAE,IAAI;EACV,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,aAAa,EAAE,GAAG;EAClB,MAAM,EAAE,qBAAqB;EAC7B,gBAAgB,EAAE,OAAO;EAEzB,iBAAiB,EAAE,yBAAyB;EAC5C,SAAS,EAAE,yBAAyB;;AAGtC,uBAWC;EAVC,EAAG;IACD,iBAAiB,EAAE,YAAY;IAC/B,aAAa,EAAE,YAAY;IAC3B,SAAS,EAAE,YAAY;EAEzB,IAAK;IACH,iBAAiB,EAAE,cAAc;IACjC,aAAa,EAAE,cAAc;IAC7B,SAAS,EAAE,cAAc;AAI7B,eAWC;EAVC,EAAG;IACD,iBAAiB,EAAE,YAAY;IAC/B,aAAa,EAAE,YAAY;IAC3B,SAAS,EAAE,YAAY;EAEzB,IAAK;IACH,iBAAiB,EAAE,cAAc;IACjC,aAAa,EAAE,cAAc;IAC7B,SAAS,EAAE,cAAc", +"sources": ["styles.scss"], +"names": [], +"file": "styles.css" +} \ No newline at end of file diff --git a/artweb/artbox-core/web/css/styles.scss b/artweb/artbox-core/web/css/styles.scss new file mode 100755 index 0000000..2fc5d6b --- /dev/null +++ b/artweb/artbox-core/web/css/styles.scss @@ -0,0 +1,475 @@ +$small-screen: 768px; +$medium-screen: 970px; +$large-screen: 1200px; + +.profile_custom_title.x_title { + h2 { + @media (max-width: $large-screen) { + width: 100%; + } + float: none; + text-align: center; + } +} + +.profile_info_accordion { + .form-group { + position: relative; + .help-block.alert { + position: relative; + top: 0; + margin-bottom: 10px; + left: -20px; + border-radius: 0 0 4px 3px; + white-space: nowrap; + overflow: hidden; + width: 100%; + max-width: inherit; + text-overflow: ellipsis; + } + .image-manager-input { + .image-wrapper-new { + cursor: default; + position: relative; + overflow: hidden; + border-radius: 50%; + width: 170px; + height: 170px; + display: block; + margin: 0 auto; + margin-bottom: 20px; + border: 5px solid #fff; + box-shadow: 0 0 3px 1px #ddd; + .add_image { + cursor: pointer; + position: absolute; + background-color: rgba(0, 0, 0, 0.5); + width: 100%; + height: 100%; + bottom: -100%; + transition: 0.2s; + i.glyphicon-folder-open { + color: white; + font-size: 24px; + position: absolute; + top: calc(50% - 12px); + left: calc(50% - 12px); + } + } + &:hover .add_image { + bottom: 0; + } + &:after { + content: ''; + display: block; + background: #dadada; + width: 165px; + height: 165px; + } + } + .input-group { + display: none; + } + .image-wrapper { + cursor: default; + position: relative; + overflow: hidden; + border-radius: 50%; + width: 170px; + height: 170px; + display: block; + margin: 0 auto; + margin-bottom: 20px; + border: 5px solid #fff; + box-shadow: 0 0 3px 1px #ddd; + .delete_image { + position: absolute; + background-color: rgba(0, 0, 0, 0.5); + width: 30%; + height: 30%; + display: block; + top: -30%; + right: -30%; + border-radius: 0 0 0 5px; + transition: 0.2s; + cursor: pointer; + i.glyphicon-remove { + color: rgb(255, 255, 255); + font-size: 15px; + position: absolute; + top: 27px; + left: 7px; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); + } + } + .add_image { + content: ''; + width: 100%; + height: 30%; + background-color: rgba(0, 0, 0, 0.5); + position: absolute; + bottom: -30%; + left: 0; + transition: 0.3s; + cursor: pointer; + i.glyphicon-folder-open { + color: white; + font-size: 15px; + position: absolute; + top: 25%; + left: calc(50% - 7px); + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); + } + } + &:hover .add_image { + bottom: 0; + } + &:hover .delete_image { + top: 0; + right: 0; + transition: 0.2s; + } + img { + object-fit: cover; + width: 165px !important; + height: 165px !important; + margin: -5px; + text-align: center; + } + } + } + } + .panel-heading { + padding: 0; + } + .collapse_toggle_text { + margin: 0; + padding: 10px 0; + } + .panel { + &:hover { + background: none; + } + .panel-body { + text-align: left; + .personal_info_submit_button { + margin-left: 10px; + } + .profile_edit_image { + text-align: center; + img { + max-width: 100%; + border-radius: 50%; + } + } + } + } +} + +.form-control-feedback { + margin: 0; + height: 32px; + margin-top: 1px; + padding-top: 4px; +} + +.profile_edit_image { + display: none; +} + +.form-control.has-feedback-left { + padding-right: 10px !important; +} + +.table.borderless { + td, th { + border: none; + } +} + +.right_border { + border-right: 2px lightgrey solid; +} + +.nav-sm .navbar.nav_title a span.fa { + display: block; + min-height: 50px; + top: 25px; + left: 15px; + position: relative; +} + +.has-feedback.has-error.bad { + padding-bottom: 8px; + .help-block.alert { + opacity: 1; + position: relative; + max-width: inherit; + top: 0; + left: 0; + margin: 0; + z-index: 2; + width: 100%; + overflow: hidden; + margin-bottom: 10px; + border-radius: 0 0 4px 3px; + @media(min-width: $large-screen) { + opacity: 1; + position: absolute; + max-width: inherit; + width: initial; + top: 4px; + left: 100%; + z-index: 4; + overflow: visible; + margin: 0; + border-radius: 3px 4px 4px 3px; + } + } +} + +.field-userdata-email.has-error.bad { + @media(min-width: $large-screen) { + .help-block.alert { + left: initial; + right: 100%; + &:after { + border-color: transparent transparent transparent #ce5454; + left: initial; + right: -13px; + } + } + } +} + +.alias-search { + .form-group { + input, select { + width: 100%; + } + } + .field-aliassearch-search { + width: 30%; + } + .field-aliassearch-entity { + width: 20%; + } + .field-aliassearch-static { + width: 20%; + } + .field-aliassearch-language_id { + width: 20%; + } + .btn { + width: 10%; + border-radius: 0; + margin-bottom: 10px; + margin-right: 0; + } +} + +.field-group { + .field-group-remove { + display: block; + height: 50px; + padding-top: 25px; + font-size: 23px; + } +} + +.sitemap-buttons { + .btn { + height: 200px; + font-size: 25px; + padding: 10% 10%; + overflow: hidden; + width: 50%; + .fa { + font-size: 70px; + } + .indexed { + z-index: 100; + position: relative; + } + &.active { + .spinner { + display: block; + } + } + .spinner { + display: none; + position: absolute; + border-radius: 100%; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: palegreen; + -webkit-animation: sk-scaleout 1.5s infinite ease-in-out; + animation: sk-scaleout 1.5s infinite ease-in-out; + } + } +} + +@-webkit-keyframes sk-scaleout { + 0% { + -webkit-transform: scale(0) + } + 100% { + -webkit-transform: scale(1.5); + opacity: 0.5; + } +} + +@keyframes sk-scaleout { + 0% { + -webkit-transform: scale(0); + transform: scale(0); + } + 100% { + -webkit-transform: scale(1.5); + transform: scale(1.5); + opacity: 0.5; + } +} + +.language-form-frame { + border-bottom: 25px solid #f5f7fa; + border-right: 15px solid #f5f7fa; + border-left: 15px solid #f5f7fa; + border-top: 15px solid #f5f7fa; + margin-top: 30px; + .tab-content { + padding: 0 15px; + } +} + +.bar_tabs { + & > li { + &.disabled { + a { + background-color: lightgrey; + &:hover, &:focus { + background-color: lightgrey; + } + } + } + } +} + +.gw-item { + overflow: hidden; + padding: 0 0 10px; + margin: 0 10px 20px; + text-align: center; + border-radius: 5px; + box-shadow: 0px 0px 0px 1px #e6e9ed; + .text-info { + min-height: 19px; + } + .image_gall { + background-color: #f5f7fa; + position: relative; + padding: 0 0 80%; + margin: 0 0 10px; + border-bottom: 1px solid #e6e9ed; + img { + position: absolute; + width: calc(100% - 20px); + height: calc(100% - 20px); + left: 0; + margin: 10px; + background-color: white; + outline: none; + } + } +} + +.icheckbox_flat-green, +.iradio_flat-green { + margin-right: 7px; + margin-bottom: 2px; +} + +.loader-wrapper { + background: rgba(255, 255, 255, 0.7); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 2000; +} + +.loader { + display: block; + position: relative; + left: 50%; + top: 50%; + width: 150px; + height: 150px; + margin: -75px 0 0 -75px; + border-radius: 50%; + border: 3px solid transparent; + border-top-color: #1980b3; + z-index: 2001; + + -webkit-animation: spin 2s linear infinite; + animation: spin 2s linear infinite; +} + +.loader:before { + content: ""; + position: absolute; + top: 5px; + left: 5px; + right: 5px; + bottom: 5px; + border-radius: 50%; + border: 3px solid transparent; + border-top-color: #3399cc; + + -webkit-animation: spin 3s linear infinite; + animation: spin 3s linear infinite; +} + +.loader:after { + content: ""; + position: absolute; + top: 15px; + left: 15px; + right: 15px; + bottom: 15px; + border-radius: 50%; + border: 3px solid transparent; + border-top-color: #70b7da; + + -webkit-animation: spin 1.5s linear infinite; + animation: spin 1.5s linear infinite; +} + +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + -ms-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + -ms-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + -ms-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + -ms-transform: rotate(360deg); + transform: rotate(360deg); + } +} diff --git a/artweb/artbox-core/web/js/script.js b/artweb/artbox-core/web/js/script.js new file mode 100755 index 0000000..0c14550 --- /dev/null +++ b/artweb/artbox-core/web/js/script.js @@ -0,0 +1,157 @@ +$(function() { + + $('.profile_info_accordion .image-wrapper') + .append('
'); + if ($(".profile_info_accordion .image-wrapper.hide") + .hasClass("hide")) { + $('.profile_info_accordion .image-manager-input') + .append('
'); + } else { + $('.profile_info_accordion .image-manager-input') + .append('
'); + } + + $(document) + .on('click', '.add_image', function() { + $(this) + .parent() + .parent() + .find(".open-modal-imagemanager") + .click(); + $(".image-wrapper-new") + .addClass('hide'); + $(".image-wrapper") + .removeClass('hide'); + + }); + $(document) + .on('click', '.delete_image', function() { + $(this) + .parent() + .parent() + .find(".delete-selected-image") + .click(); + $(".image-wrapper-new") + .removeClass("hide"); + return false; + }); + $(document) + .on('click', '.slugify_button', function() { + var id = $(this) + .data('id'); + var attribute_id = $(this) + .data('attribute-id'); + var url = $(this) + .data('url'); + var language_id = $(this) + .data('language-id'); + var input = $('#' + id); + var attribute_input = $('#' + attribute_id); + var value = attribute_input.val(); + if (id !== undefined && url !== undefined && value !== undefined && attribute_id !== undefined && value.length > 0) { + $.get(url, { + text: value, + languageId: language_id + }, function(data) { + input.val(data); + }); + } + }); + $(document) + .on('click', '.slugify_cancel_button', function() { + var id = $(this) + .data('id'); + var value = $(this) + .data('value'); + var input = $('#' + id); + if (id !== undefined && value !== undefined) { + input.val(value); + } + }); + + $(document) + .on('click', 'a.viewed-toggle', function(e) { + e.preventDefault(); + var a = $(this); + $.ajax({ + type: "POST", + url: a.attr('href'), + success: function(data) { + console.log(data); + a.parent() + .parent() + .removeClass('success'); + a.replaceWith(data.text); + $('.feedback-widget') + .replaceWith(data.widget); + new PNotify({ + title: data.message.title, + text: data.message.text, + type: "success", + styling: "bootstrap3", + icon: "glyphicon glyphicon-exclamation-sign" + }); + } + }); + }); + $(document) + .on('click', '.main_menu .homepage_link a', function() { + $(this) + .parents('.homepage_link') + .removeClass('active'); + }); + $(document) + .on('click', '.sitemap-buttons .btn.ajax', function(e) { + e.preventDefault(); + var url = $(this) + .attr('href'); + $(this) + .addClass('active'); + $.get(url, function() { + $(this) + .removeClass('active'); + new PNotify({ + title: "Карта сайта", + text: "Карта сайта успещно сгенерирована", + type: "success", + styling: "bootstrap3", + icon: "glyphicon glyphicon-exclamation-sign" + }); + if ($(this) + .data('need-reload')) { + setTimeout(function() { + location.reload(); + }, 1000); + } + }.bind(this)) + .fail(function() { + $(this) + .removeClass('active'); + new PNotify({ + title: "Карта сайта", + text: "Ошибка при генерации карты сайта", + type: "error", + styling: "bootstrap3", + icon: "glyphicon glyphicon-exclamation-sign" + }); + }.bind(this)); + }); + $('.bar_tabs>li.disabled a') + .removeAttr('data-toggle'); + $(document) + .on('click', '.artbox-selection-delete', function(e) { + var selectedRows = $('.grid-view') + .yiiGridView('getSelectedRows'); + var msg = $(this) + .data('message'); + var url = $(this) + .data('url'); + if (selectedRows.length > 0 && confirm(msg)) { + $.post(url + '?ids=' + encodeURIComponent(selectedRows), function(data) { + if (data.success) { + location.reload(); + } + }) + } + }); +}); \ No newline at end of file diff --git a/artweb/artbox-core/widgets/BitMaskWidget.php b/artweb/artbox-core/widgets/BitMaskWidget.php new file mode 100755 index 0000000..de7bcc0 --- /dev/null +++ b/artweb/artbox-core/widgets/BitMaskWidget.php @@ -0,0 +1,73 @@ +model->fields as $id => $field) { + $value = boolval($this->model->getMaskInt() & 2 ** $field); + echo Html::beginTag('div', [ 'class' => 'form-group' ]); + echo Html::checkbox( + $this->model->getModelName() . '[masks][' . $id . ']', + $value, + [ 'class' => 'flat' ] + ); + echo Html::label( + $id, + null, + [ + 'class' => 'control-label', + ] + ); + echo Html::endTag('div'); + } + } + + /** + * Only for Active records + * + * @param \yii\db\ActiveRecord $model + */ + public function setModel(ActiveRecord $model) + { + $this->model = $model; + } + + /** + * Form must be active form + * + * @param \yii\widgets\ActiveForm $form + */ + public function setForm(ActiveForm $form) + { + $this->form = $form; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/widgets/FeedbackWidget.php b/artweb/artbox-core/widgets/FeedbackWidget.php new file mode 100755 index 0000000..3b48eb4 --- /dev/null +++ b/artweb/artbox-core/widgets/FeedbackWidget.php @@ -0,0 +1,31 @@ +where( + [ + 'status' => false, + ] + ) + ->count(); + + return $this->render( + '_feedback', + [ + 'count' => $count, + ] + ); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/widgets/FlashWidget.php b/artweb/artbox-core/widgets/FlashWidget.php new file mode 100755 index 0000000..273b44f --- /dev/null +++ b/artweb/artbox-core/widgets/FlashWidget.php @@ -0,0 +1,41 @@ +flashes as $flash) { + if (Yii::$app->session->hasFlash($flash)) { + $message = Yii::$app->session->getFlash($flash); + $js = ' + new PNotify({ + title: "' . Yii::t('core', 'Notification') . ':", + text: "' . $message . '", + type: "' . $flash . '", + styling: "bootstrap3", + icon: "glyphicon glyphicon-exclamation-sign" + }); + '; + return $this->render('_flash', [ 'js' => $js ]); + } + } + return ''; + } + + } \ No newline at end of file diff --git a/artweb/artbox-core/widgets/GalleryWidget.php b/artweb/artbox-core/widgets/GalleryWidget.php new file mode 100755 index 0000000..44252fc --- /dev/null +++ b/artweb/artbox-core/widgets/GalleryWidget.php @@ -0,0 +1,28 @@ +render( + '_gallery_view', + [ + 'images' => $this->model->getImages(), + ] + ); + } + } \ No newline at end of file diff --git a/artweb/artbox-core/widgets/LangLink.php b/artweb/artbox-core/widgets/LangLink.php new file mode 100755 index 0000000..7ece995 --- /dev/null +++ b/artweb/artbox-core/widgets/LangLink.php @@ -0,0 +1,97 @@ +languageIds)) { + $this->languageIds = Language::find() + ->select( + [ + 'url', + 'id', + ] + ) + ->where([ 'status' => true ]) + ->asArray() + ->indexBy('id') + ->column(); + } + if (count($this->languageIds) < 2) { + return; + } + foreach ($this->languageIds as $languageId => $url) { + if (Language::getCurrent()->id !== $languageId) { + $this->links[ $languageId ] = Html::a( + $url, + Url::to( + [ \Yii::$app->requestedRoute ] + \Yii::$app->request->get( + ) + [ 'language_id' => $languageId ], + true + ) + ); + } else { + $this->links[ $languageId ] = $url; + } + } + } + + public function run() + { + return $this->render('_langLink'); + } + + protected function mapAliases(array $aliases): array + { + $map = []; + $result = []; + $currentLanguageId = Language::getCurrent()->id; + foreach ($aliases as $alias) { + if ($alias[ 'language_id' ] === $currentLanguageId) { + $map[ $alias[ 'route' ] ][ 0 ] = $alias[ 'value' ]; + } else { + $map[ $alias[ 'route' ] ][ 1 ] = $alias[ 'value' ]; + } + } + foreach ($map as $route => $alias) { + if (!empty($alias[ 0 ]) && !empty($alias[ 1 ])) { + $result[ $alias[ 0 ] ] = $alias[ 1 ]; + } else { + \Yii::getLogger() + ->log("Missing alias for route $route.", Logger::LEVEL_ERROR); + } + } + return $result; + } + + protected function replaceParams(array $map): array + { + $params = \Yii::$app->request->get(); + if (isset($params[ 'filter' ])) { + $filter = explode('_', $params[ 'filter' ]); + } + if (array_key_exists($params[ 'category' ], $map)) { + $params[ 'category' ] = $map[ $params[ 'category' ] ]; + } + if (!empty($filter)) { + foreach ($filter as $index => $item) { + if (array_key_exists($item, $map)) { + $filter[ $index ] = $map[ $item ]; + } + } + $params[ 'filter' ] = implode('_', $filter); + } + return $params; + } + } \ No newline at end of file diff --git a/artweb/artbox-core/widgets/LanguageForm.php b/artweb/artbox-core/widgets/LanguageForm.php new file mode 100755 index 0000000..8dfdef7 --- /dev/null +++ b/artweb/artbox-core/widgets/LanguageForm.php @@ -0,0 +1,82 @@ +formView === null) { + throw new InvalidConfigException('Form view must be set'); + } + if (empty( $this->modelLangs ) || !is_array($this->modelLangs)) { + throw new InvalidConfigException('Language models must be passed'); + } + if (empty( $this->getForm() )) { + throw new InvalidConfigException('Form model must be set'); + } + $this->languages = Language::find() + ->where([ 'status' => true ]) + ->orderBy([ 'default' => SORT_DESC ]) + ->indexBy('id') + ->all(); + } + + public function run() + { + return $this->render( + 'language_form_frame', + [ + 'languages' => $this->languages, + 'form_view' => $this->formView, + 'modelLangs' => $this->modelLangs, + 'form' => $this->getForm(), + 'idPrefix' => $this->idPrefix, + ] + ); + } + + public function getForm(): ActiveForm + { + return $this->form; + } + + public function setForm(ActiveForm $value) + { + $this->form = $value; + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/widgets/LanguagePicker.php b/artweb/artbox-core/widgets/LanguagePicker.php new file mode 100755 index 0000000..08076b1 --- /dev/null +++ b/artweb/artbox-core/widgets/LanguagePicker.php @@ -0,0 +1,35 @@ +render( + 'view', + [ + 'current' => Language::getCurrent(), + 'languages' => Language::find() + ->where( + [ + '!=', + 'id', + Language::getCurrent()->id, + ] + ) + ->all(), + ] + ); + } + } + \ No newline at end of file diff --git a/artweb/artbox-core/widgets/views/_feedback.php b/artweb/artbox-core/widgets/views/_feedback.php new file mode 100755 index 0000000..e1cd914 --- /dev/null +++ b/artweb/artbox-core/widgets/views/_feedback.php @@ -0,0 +1,16 @@ + + + diff --git a/artweb/artbox-core/widgets/views/_flash.php b/artweb/artbox-core/widgets/views/_flash.php new file mode 100755 index 0000000..0291baf --- /dev/null +++ b/artweb/artbox-core/widgets/views/_flash.php @@ -0,0 +1,9 @@ +registerJs($js, View::POS_READY); diff --git a/artweb/artbox-core/widgets/views/_gallery_view.php b/artweb/artbox-core/widgets/views/_gallery_view.php new file mode 100755 index 0000000..2dff629 --- /dev/null +++ b/artweb/artbox-core/widgets/views/_gallery_view.php @@ -0,0 +1,203 @@ +registerJs("imageManagerInput.baseUrl = '" . $sBaseUrl . "';"); + $this->registerJs( + "imageManagerInput.message = " . Json::encode( + [ + 'detachWarningMessage' => Yii::t('core', 'Are you sure you want to detach the image?'), + ] + ) . ";" + ); + + GalleryAsset::register($this); + +?> + +
+
+ +
+ $hash, + 'class' => 'gw-image-input', + 'data' => [ + 'img' => $hash . '_img', + 'name' => $hash . '_name', + ], + ] + ); + ?> +
+ 'img-rounded', + 'id' => $hash . '_img', + ] + ); + ?> +
+ 'text-info', + 'id' => $hash . '_name', + ] + ); + + echo Html::button( + Html::tag( + 'i', + '', + [ + 'class' => 'fa fa-folder-open', + ] + ), + [ + 'class' => 'open-modal-imagemanager btn btn-primary', + 'data' => [ + 'aspect-ratio' => '', + 'crop-view-mode' => 1, + 'input-id' => $hash, + ], + ] + ); + + echo Html::button( + Html::tag( + 'i', + '', + [ + 'class' => 'fa fa-trash', + ] + ), + [ + 'class' => 'remove-img btn btn-danger', + ] + ); + ?> +
+ + +
+ id, + [ + 'id' => $hash, + 'class' => 'gw-image-input', + 'data' => [ + 'img' => $hash . '_img', + 'name' => $hash . '_name', + ], + ] + ); + ?> +
+ getPath()) + ->resize(400, 400) + ->renderImage( + [ + 'id' => $hash . '_img', + ] + ); + ?> +
+ fileName, + [ + 'class' => 'text-info', + 'id' => $hash . '_name', + ] + ); + + echo Html::button( + Html::tag( + 'i', + '', + [ + 'class' => 'fa fa-folder-open', + ] + ), + [ + 'class' => 'open-modal-imagemanager btn btn-primary', + 'data' => [ + 'aspect-ratio' => '', + 'crop-view-mode' => 1, + 'input-id' => $hash, + ], + ] + ); + + echo Html::button( + Html::tag( + 'i', + '', + [ + 'class' => 'fa fa-trash', + ] + ), + [ + 'class' => 'remove-img btn btn-danger', + ] + ); + ?> +
+ + +
+
+ + 'fa fa-plus', + ] + ) . ' Add', + [ + 'id' => 'add-image', + 'class' => 'btn btn-success', + ] +) ?> \ No newline at end of file diff --git a/artweb/artbox-core/widgets/views/_langLink.php b/artweb/artbox-core/widgets/views/_langLink.php new file mode 100755 index 0000000..d64d848 --- /dev/null +++ b/artweb/artbox-core/widgets/views/_langLink.php @@ -0,0 +1,7 @@ +context; + echo implode(' / ', $widget->links); diff --git a/artweb/artbox-core/widgets/views/language_form_frame.php b/artweb/artbox-core/widgets/views/language_form_frame.php new file mode 100755 index 0000000..5e097c7 --- /dev/null +++ b/artweb/artbox-core/widgets/views/language_form_frame.php @@ -0,0 +1,87 @@ + +
+ 1) { + ?> + +
+ $model_lang) { + if (!array_key_exists($lang, $languages)) { + continue; + } + echo Html::tag( + 'div', + $this->render( + $form_view, + [ + 'model_lang' => $model_lang, + 'language' => $languages[ $lang ], + 'form' => $form, + ] + ), + [ + 'class' => 'tab-pane' . ( $first ? ' active' : '' ), + 'id' => $idPrefix . '_' . $lang, + ] + ); + $first = false; + } + ?> +
+ id ] )) { + echo $this->render( + $form_view, + [ + 'model_lang' => $modelLangs[ $language->id ], + 'language' => $language, + 'form' => $form, + ] + ); + } + } + ?> +
diff --git a/artweb/artbox-core/widgets/views/view.php b/artweb/artbox-core/widgets/views/view.php new file mode 100755 index 0000000..46e84c4 --- /dev/null +++ b/artweb/artbox-core/widgets/views/view.php @@ -0,0 +1,35 @@ + +
+ + name; + ?> + + +
    + +
  • + getRequest(); + echo Html::a($language->name, '/' . $language->url . $request->getLanguageUrl()); + ?> +
  • + +
+
-- libgit2 0.21.4