From f14dfdc726c9a712d4dbbdfdcc306da878e5fb00 Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Mon, 25 Feb 2019 14:56:59 +0000 Subject: [PATCH] add plugins --- server/plugins/graker/photoalbums/LICENSE | 21 + server/plugins/graker/photoalbums/Plugin.php | 254 ++++ server/plugins/graker/photoalbums/README.md | 101 ++ .../photoalbums/assets/css/dropzone.css | 392 ++++++ .../assets/js/extend-markdown-editor.js | 54 + .../graker/photoalbums/assets/js/upload.js | 83 ++ .../classes/MarkdownPhotoInsert.php | 117 ++ .../photoalbums/classes/MenuItemsProvider.php | 349 +++++ .../graker/photoalbums/components/Album.php | 186 +++ .../photoalbums/components/AlbumList.php | 206 +++ .../graker/photoalbums/components/Photo.php | 112 ++ .../photoalbums/components/RandomPhotos.php | 171 +++ .../photoalbums/components/album/default.htm | 46 + .../components/albumlist/default.htm | 35 + .../photoalbums/components/photo/default.htm | 36 + .../components/randomphotos/default.htm | 12 + .../graker/photoalbums/controllers/Albums.php | 95 ++ .../graker/photoalbums/controllers/Photos.php | 25 + .../photoalbums/controllers/Reorder.php | 69 + .../graker/photoalbums/controllers/Upload.php | 147 ++ .../controllers/albums/_list_toolbar.htm | 7 + .../controllers/albums/_relation_toolbar.htm | 53 + .../controllers/albums/config_form.yaml | 31 + .../controllers/albums/config_list.yaml | 44 + .../controllers/albums/config_relation.yaml | 12 + .../photoalbums/controllers/albums/create.htm | 52 + .../photoalbums/controllers/albums/index.htm | 2 + .../controllers/albums/preview.htm | 19 + .../photoalbums/controllers/albums/update.htm | 60 + .../controllers/photos/_list_toolbar.htm | 7 + .../controllers/photos/config_form.yaml | 31 + .../controllers/photos/config_list.yaml | 36 + .../photoalbums/controllers/photos/create.htm | 48 + .../photoalbums/controllers/photos/index.htm | 2 + .../controllers/photos/preview.htm | 19 + .../photoalbums/controllers/photos/update.htm | 56 + .../controllers/reorder/_records.htm | 11 + .../controllers/reorder/_reorder.htm | 36 + .../photoalbums/controllers/upload/_form.htm | 51 + .../graker/photoalbums/lang/en/lang.php | 111 ++ .../graker/photoalbums/models/Album.php | 119 ++ .../graker/photoalbums/models/Photo.php | 122 ++ .../graker/photoalbums/models/Settings.php | 25 + .../photoalbums/models/album/columns.yaml | 16 + .../photoalbums/models/album/fields.yaml | 24 + .../photoalbums/models/photo/columns.yaml | 34 + .../photoalbums/models/photo/fields.yaml | 31 + .../photoalbums/models/settings/fields.yaml | 10 + server/plugins/graker/photoalbums/phpunit.xml | 23 + .../photoalbums/tests/RandomPhotosTest.php | 112 ++ .../photoalbums/updates/add_album_front.php | 25 + .../updates/add_sort_order_field.php | 25 + .../updates/create_albums_table.php | 28 + .../updates/create_photos_table.php | 28 + .../update_sort_order_on_existing_photos.php | 23 + .../graker/photoalbums/updates/version.yaml | 32 + .../photoalbums/widgets/PhotoSelector.php | 184 +++ .../assets/css/photoselector.css | 20 + .../photoselector/assets/js/photoselector.js | 180 +++ .../photoselector/partials/_albums.htm | 16 + .../widgets/photoselector/partials/_body.htm | 21 + .../photoselector/partials/_photos.htm | 26 + server/plugins/manogi/mediathumb/LICENCE.md | 19 + server/plugins/manogi/mediathumb/Plugin.php | 44 + server/plugins/manogi/mediathumb/README.md | 116 ++ .../manogi/mediathumb/config/config.php | 20 + .../manogi/mediathumb/lang/cs/lang.php | 8 + .../manogi/mediathumb/lang/de/lang.php | 8 + .../manogi/mediathumb/lang/en/lang.php | 8 + .../manogi/mediathumb/lang/hu/lang.php | 8 + .../manogi/mediathumb/updates/version.yaml | 19 + .../manogi/mediathumb/vendor/autoload.php | 7 + .../vendor/composer/ClassLoader.php | 413 ++++++ .../manogi/mediathumb/vendor/composer/LICENSE | 21 + .../vendor/composer/autoload_classmap.php | 9 + .../vendor/composer/autoload_files.php | 11 + .../vendor/composer/autoload_namespaces.php | 9 + .../vendor/composer/autoload_psr4.php | 13 + .../vendor/composer/autoload_real.php | 59 + .../vendor/composer/autoload_static.php | 60 + .../mediathumb/vendor/composer/installed.json | 245 ++++ .../vendor/guzzlehttp/psr7/CHANGELOG.md | 110 ++ .../mediathumb/vendor/guzzlehttp/psr7/LICENSE | 19 + .../vendor/guzzlehttp/psr7/README.md | 739 ++++++++++ .../vendor/guzzlehttp/psr7/composer.json | 39 + .../guzzlehttp/psr7/src/AppendStream.php | 233 ++++ .../guzzlehttp/psr7/src/BufferStream.php | 137 ++ .../guzzlehttp/psr7/src/CachingStream.php | 138 ++ .../guzzlehttp/psr7/src/DroppingStream.php | 42 + .../vendor/guzzlehttp/psr7/src/FnStream.php | 149 ++ .../guzzlehttp/psr7/src/InflateStream.php | 52 + .../guzzlehttp/psr7/src/LazyOpenStream.php | 39 + .../guzzlehttp/psr7/src/LimitStream.php | 155 +++ .../guzzlehttp/psr7/src/MessageTrait.php | 183 +++ .../guzzlehttp/psr7/src/MultipartStream.php | 153 +++ .../guzzlehttp/psr7/src/NoSeekStream.php | 22 + .../vendor/guzzlehttp/psr7/src/PumpStream.php | 165 +++ .../vendor/guzzlehttp/psr7/src/Request.php | 142 ++ .../vendor/guzzlehttp/psr7/src/Response.php | 132 ++ .../guzzlehttp/psr7/src/ServerRequest.php | 358 +++++ .../vendor/guzzlehttp/psr7/src/Stream.php | 257 ++++ .../psr7/src/StreamDecoratorTrait.php | 149 ++ .../guzzlehttp/psr7/src/StreamWrapper.php | 121 ++ .../guzzlehttp/psr7/src/UploadedFile.php | 316 +++++ .../vendor/guzzlehttp/psr7/src/Uri.php | 702 ++++++++++ .../guzzlehttp/psr7/src/UriNormalizer.php | 216 +++ .../guzzlehttp/psr7/src/UriResolver.php | 219 +++ .../vendor/guzzlehttp/psr7/src/functions.php | 828 +++++++++++ .../guzzlehttp/psr7/src/functions_include.php | 6 + .../vendor/intervention/image/LICENSE | 9 + .../vendor/intervention/image/composer.json | 47 + .../vendor/intervention/image/provides.json | 11 + .../src/Intervention/Image/AbstractColor.php | 226 +++ .../Intervention/Image/AbstractDecoder.php | 358 +++++ .../src/Intervention/Image/AbstractDriver.php | 132 ++ .../Intervention/Image/AbstractEncoder.php | 234 ++++ .../src/Intervention/Image/AbstractFont.php | 260 ++++ .../src/Intervention/Image/AbstractShape.php | 71 + .../Image/Commands/AbstractCommand.php | 79 ++ .../Intervention/Image/Commands/Argument.php | 225 +++ .../Image/Commands/ChecksumCommand.php | 29 + .../Image/Commands/CircleCommand.php | 35 + .../Image/Commands/EllipseCommand.php | 36 + .../Image/Commands/ExifCommand.php | 37 + .../Image/Commands/IptcCommand.php | 64 + .../Image/Commands/LineCommand.php | 36 + .../Image/Commands/OrientateCommand.php | 48 + .../Image/Commands/PolygonCommand.php | 48 + .../Image/Commands/PsrResponseCommand.php | 45 + .../Image/Commands/RectangleCommand.php | 36 + .../Image/Commands/ResponseCommand.php | 26 + .../Image/Commands/StreamCommand.php | 25 + .../Image/Commands/TextCommand.php | 34 + .../src/Intervention/Image/Constraint.php | 92 ++ .../Image/Exception/ImageException.php | 8 + .../Exception/InvalidArgumentException.php | 8 + .../Exception/MissingDependencyException.php | 8 + .../Image/Exception/NotFoundException.php | 8 + .../Image/Exception/NotReadableException.php | 8 + .../Image/Exception/NotSupportedException.php | 8 + .../Image/Exception/NotWritableException.php | 8 + .../Image/Exception/RuntimeException.php | 8 + .../src/Intervention/Image/Facades/Image.php | 13 + .../image/src/Intervention/Image/File.php | 92 ++ .../Intervention/Image/Filters/DemoFilter.php | 42 + .../Image/Filters/FilterInterface.php | 14 + .../image/src/Intervention/Image/Gd/Color.php | 226 +++ .../Image/Gd/Commands/BackupCommand.php | 23 + .../Image/Gd/Commands/BlurCommand.php | 23 + .../Image/Gd/Commands/BrightnessCommand.php | 19 + .../Image/Gd/Commands/ColorizeCommand.php | 27 + .../Image/Gd/Commands/ContrastCommand.php | 19 + .../Image/Gd/Commands/CropCommand.php | 40 + .../Image/Gd/Commands/DestroyCommand.php | 25 + .../Image/Gd/Commands/FillCommand.php | 68 + .../Image/Gd/Commands/FitCommand.php | 32 + .../Image/Gd/Commands/FlipCommand.php | 37 + .../Image/Gd/Commands/GammaCommand.php | 19 + .../Image/Gd/Commands/GetSizeCommand.php | 24 + .../Image/Gd/Commands/GreyscaleCommand.php | 17 + .../Image/Gd/Commands/HeightenCommand.php | 28 + .../Image/Gd/Commands/InsertCommand.php | 32 + .../Image/Gd/Commands/InterlaceCommand.php | 21 + .../Image/Gd/Commands/InvertCommand.php | 17 + .../Image/Gd/Commands/LimitColorsCommand.php | 51 + .../Image/Gd/Commands/MaskCommand.php | 81 ++ .../Image/Gd/Commands/OpacityCommand.php | 29 + .../Image/Gd/Commands/PickColorCommand.php | 36 + .../Image/Gd/Commands/PixelCommand.php | 24 + .../Image/Gd/Commands/PixelateCommand.php | 19 + .../Image/Gd/Commands/ResetCommand.php | 35 + .../Image/Gd/Commands/ResizeCanvasCommand.php | 81 ++ .../Image/Gd/Commands/ResizeCommand.php | 82 ++ .../Image/Gd/Commands/RotateCommand.php | 26 + .../Image/Gd/Commands/SharpenCommand.php | 32 + .../Image/Gd/Commands/TrimCommand.php | 176 +++ .../Image/Gd/Commands/WidenCommand.php | 28 + .../src/Intervention/Image/Gd/Decoder.php | 153 +++ .../src/Intervention/Image/Gd/Driver.php | 86 ++ .../src/Intervention/Image/Gd/Encoder.php | 122 ++ .../image/src/Intervention/Image/Gd/Font.php | 255 ++++ .../Image/Gd/Shapes/CircleShape.php | 40 + .../Image/Gd/Shapes/EllipseShape.php | 64 + .../Image/Gd/Shapes/LineShape.php | 89 ++ .../Image/Gd/Shapes/PolygonShape.php | 48 + .../Image/Gd/Shapes/RectangleShape.php | 75 + .../image/src/Intervention/Image/Image.php | 363 +++++ .../src/Intervention/Image/ImageManager.php | 138 ++ .../Intervention/Image/ImageManagerStatic.php | 87 ++ .../Image/ImageServiceProvider.php | 85 ++ .../Image/ImageServiceProviderLaravel4.php | 112 ++ .../Image/ImageServiceProviderLaravel5.php | 89 ++ .../Image/ImageServiceProviderLeague.php | 42 + .../Image/ImageServiceProviderLumen.php | 34 + .../src/Intervention/Image/Imagick/Color.php | 277 ++++ .../Image/Imagick/Commands/BackupCommand.php | 23 + .../Image/Imagick/Commands/BlurCommand.php | 19 + .../Imagick/Commands/BrightnessCommand.php | 19 + .../Imagick/Commands/ColorizeCommand.php | 42 + .../Imagick/Commands/ContrastCommand.php | 19 + .../Image/Imagick/Commands/CropCommand.php | 43 + .../Image/Imagick/Commands/DestroyCommand.php | 25 + .../Image/Imagick/Commands/ExifCommand.php | 62 + .../Image/Imagick/Commands/FillCommand.php | 103 ++ .../Image/Imagick/Commands/FitCommand.php | 41 + .../Image/Imagick/Commands/FlipCommand.php | 25 + .../Image/Imagick/Commands/GammaCommand.php | 19 + .../Image/Imagick/Commands/GetSizeCommand.php | 27 + .../Imagick/Commands/GreyscaleCommand.php | 17 + .../Imagick/Commands/HeightenCommand.php | 28 + .../Image/Imagick/Commands/InsertCommand.php | 31 + .../Imagick/Commands/InterlaceCommand.php | 27 + .../Image/Imagick/Commands/InvertCommand.php | 17 + .../Imagick/Commands/LimitColorsCommand.php | 57 + .../Image/Imagick/Commands/MaskCommand.php | 58 + .../Image/Imagick/Commands/OpacityCommand.php | 21 + .../Imagick/Commands/PickColorCommand.php | 29 + .../Image/Imagick/Commands/PixelCommand.php | 30 + .../Imagick/Commands/PixelateCommand.php | 25 + .../Image/Imagick/Commands/ResetCommand.php | 37 + .../Imagick/Commands/ResizeCanvasCommand.php | 89 ++ .../Image/Imagick/Commands/ResizeCommand.php | 27 + .../Image/Imagick/Commands/RotateCommand.php | 26 + .../Image/Imagick/Commands/SharpenCommand.php | 19 + .../Image/Imagick/Commands/TrimCommand.php | 120 ++ .../Image/Imagick/Commands/WidenCommand.php | 28 + .../Intervention/Image/Imagick/Decoder.php | 120 ++ .../src/Intervention/Image/Imagick/Driver.php | 70 + .../Intervention/Image/Imagick/Encoder.php | 168 +++ .../src/Intervention/Image/Imagick/Font.php | 78 ++ .../Image/Imagick/Shapes/CircleShape.php | 40 + .../Image/Imagick/Shapes/EllipseShape.php | 65 + .../Image/Imagick/Shapes/LineShape.php | 93 ++ .../Image/Imagick/Shapes/PolygonShape.php | 80 ++ .../Image/Imagick/Shapes/RectangleShape.php | 83 ++ .../image/src/Intervention/Image/Point.php | 64 + .../image/src/Intervention/Image/Response.php | 69 + .../image/src/Intervention/Image/Size.php | 373 +++++ .../intervention/image/src/config/config.php | 20 + .../manogi/mediathumb/resize_helper.php | 179 +++ .../vendor/psr/http-message/CHANGELOG.md | 36 + .../vendor/psr/http-message/LICENSE | 19 + .../vendor/psr/http-message/README.md | 13 + .../vendor/psr/http-message/composer.json | 26 + .../psr/http-message/src/MessageInterface.php | 187 +++ .../psr/http-message/src/RequestInterface.php | 129 ++ .../http-message/src/ResponseInterface.php | 68 + .../src/ServerRequestInterface.php | 261 ++++ .../psr/http-message/src/StreamInterface.php | 158 +++ .../src/UploadedFileInterface.php | 123 ++ .../psr/http-message/src/UriInterface.php | 323 +++++ .../vendor/urodoz/truncate-html/LICENSE | 21 + .../vendor/urodoz/truncate-html/README.md | 119 ++ .../urodoz/truncate-html/phpunit.xml.dist | 14 + .../Bridge/Symfony/UrodozTruncateBundle.php | 36 + .../Symfony/UrodozTruncateExtension.php | 45 + .../src/Bridge/Twig/TruncateExtension.php | 68 + .../truncate-html/src/TruncateInterface.php | 42 + .../truncate-html/src/TruncateService.php | 133 ++ .../tests/TruncateServiceTest.php | 57 + server/plugins/rainlab/builder/LICENCE.md | 19 + server/plugins/rainlab/builder/Plugin.php | 148 ++ .../rainlab/builder/assets/css/builder.css | 1209 +++++++++++++++++ .../builder/assets/images/builder-icon.svg | 17 + .../rainlab/builder/assets/images/tab.png | Bin 0 -> 3002 bytes .../rainlab/builder/assets/js/build-min.js | 809 +++++++++++ .../rainlab/builder/assets/js/build.js | 20 + .../builder/assets/js/builder.dataregistry.js | 170 +++ .../assets/js/builder.index.entity.base.js | 100 ++ .../js/builder.index.entity.controller.js | 109 ++ .../js/builder.index.entity.databasetable.js | 303 +++++ .../js/builder.index.entity.localization.js | 282 ++++ .../assets/js/builder.index.entity.menus.js | 86 ++ .../assets/js/builder.index.entity.model.js | 72 + .../js/builder.index.entity.modelform.js | 155 +++ .../js/builder.index.entity.modellist.js | 304 +++++ .../js/builder.index.entity.permission.js | 122 ++ .../assets/js/builder.index.entity.plugin.js | 116 ++ .../assets/js/builder.index.entity.version.js | 272 ++++ .../builder/assets/js/builder.index.js | 294 ++++ .../builder.inspector.editor.localization.js | 114 ++ .../assets/js/builder.localizationinput.js | 299 ++++ .../builder.table.processor.localization.js | 126 ++ .../builder/assets/less/behaviors.less | 167 +++ .../rainlab/builder/assets/less/builder.less | 198 +++ .../builder/assets/less/buildingarea.less | 251 ++++ .../builder/assets/less/controlblueprint.less | 260 ++++ .../builder/assets/less/localization.less | 86 ++ .../rainlab/builder/assets/less/menus.less | 177 +++ .../rainlab/builder/assets/less/tabs.less | 307 +++++ .../behaviors/IndexControllerOperations.php | 172 +++ .../builder/behaviors/IndexDataRegistry.php | 66 + .../IndexDatabaseTableOperations.php | 198 +++ .../behaviors/IndexLocalizationOperations.php | 218 +++ .../behaviors/IndexMenusOperations.php | 75 + .../behaviors/IndexModelFormOperations.php | 186 +++ .../behaviors/IndexModelListOperations.php | 176 +++ .../behaviors/IndexModelOperations.php | 69 + .../behaviors/IndexPermissionsOperations.php | 76 ++ .../behaviors/IndexPluginOperations.php | 91 ++ .../behaviors/IndexVersionsOperations.php | 178 +++ .../_create-controller-popup-form.htm | 26 + .../partials/_tab.htm | 11 + .../partials/_toolbar.htm | 10 + .../partials/_migration-popup-form.htm | 49 + .../partials/_tab.htm | 15 + .../partials/_toolbar.htm | 17 + .../partials/_copy-strings-popup-form.htm | 41 + .../partials/_new-string-popup.htm | 42 + .../partials/_tab.htm | 15 + .../partials/_toolbar.htm | 27 + .../indexmenusoperations/partials/_tab.htm | 11 + .../partials/_toolbar.htm | 10 + .../partials/_tab.htm | 13 + .../partials/_toolbar.htm | 17 + .../partials/_tab.htm | 16 + .../partials/_toolbar.htm | 17 + .../partials/_model-popup-form.htm | 32 + .../partials/_tab.htm | 11 + .../partials/_toolbar.htm | 10 + .../partials/_plugin-popup-form.htm | 33 + .../partials/_plugin-update-hint.htm | 1 + .../indexversionsoperations/partials/_tab.htm | 42 + .../partials/_toolbar.htm | 33 + .../partials/_version-hint-block.htm | 28 + .../rainlab/builder/classes/BaseModel.php | 131 ++ .../BehaviorDesignTimeProviderBase.php | 34 + .../builder/classes/ComponentHelper.php | 108 ++ .../classes/ControlDesignTimeProviderBase.php | 42 + .../builder/classes/ControlLibrary.php | 312 +++++ .../classes/ControllerBehaviorLibrary.php | 78 ++ .../builder/classes/ControllerFileParser.php | 125 ++ .../builder/classes/ControllerGenerator.php | 341 +++++ .../builder/classes/ControllerModel.php | 394 ++++++ .../builder/classes/DatabaseTableModel.php | 401 ++++++ .../classes/DatabaseTableSchemaCreator.php | 65 + .../rainlab/builder/classes/EnumDbType.php | 38 + .../builder/classes/FilesystemGenerator.php | 137 ++ .../rainlab/builder/classes/IconList.php | 607 +++++++++ .../classes/IndexOperationsBehaviorBase.php | 46 + .../rainlab/builder/classes/LanguageMixer.php | 201 +++ .../builder/classes/LocalizationModel.php | 436 ++++++ .../rainlab/builder/classes/MenusModel.php | 205 +++ .../builder/classes/MigrationColumnType.php | 224 +++ .../builder/classes/MigrationFileParser.php | 69 + .../builder/classes/MigrationModel.php | 500 +++++++ .../builder/classes/ModelFileParser.php | 186 +++ .../builder/classes/ModelFormModel.php | 93 ++ .../builder/classes/ModelListModel.php | 185 +++ .../rainlab/builder/classes/ModelModel.php | 294 ++++ .../builder/classes/ModelYamlModel.php | 202 +++ .../builder/classes/PermissionsModel.php | 195 +++ .../builder/classes/PhpSourceStream.php | 242 ++++ .../builder/classes/PluginBaseModel.php | 217 +++ .../rainlab/builder/classes/PluginCode.php | 107 ++ .../rainlab/builder/classes/PluginVector.php | 58 + .../rainlab/builder/classes/PluginVersion.php | 49 + .../builder/classes/PluginYamlModel.php | 66 + .../classes/StandardBehaviorsRegistry.php | 429 ++++++ .../classes/StandardControlsRegistry.php | 1073 +++++++++++++++ .../classes/TableMigrationCodeGenerator.php | 626 +++++++++ .../rainlab/builder/classes/YamlModel.php | 186 +++ .../templates/controller-config-vars.php.tpl | 3 + .../templates/controller-permissions.php.tpl | 7 + .../templates/controller.php.tpl | 23 + .../classes/controllermodel/fields.yaml | 23 + .../new-controller-fields.yaml | 37 + .../classes/databasetablemodel/fields.yaml | 79 ++ .../templates/full-migration-code.php.tpl | 9 + .../templates/migration-code.php.tpl | 9 + .../classes/localizationmodel/fields.yaml | 25 + .../localizationmodel/templates/lang.php | 6 + .../builder/classes/menusmodel/fields.yaml | 17 + .../classes/migrationmodel/fields.yaml | 11 + .../migrationmodel/management-fields.yaml | 31 + .../templates/migration.php.tpl | 19 + .../migrationmodel/templates/seeder.php.tpl | 11 + .../classes/modelformmodel/fields.yaml | 24 + .../classes/modellistmodel/fields.yaml | 88 ++ .../builder/classes/modelmodel/fields.yaml | 17 + .../modelmodel/templates/model.php.tpl | 23 + .../templates/no-timestamps.php.tpl | 6 + .../modelmodel/templates/soft-delete.php.tpl | 4 + .../classes/permissionsmodel/fields.yaml | 30 + .../classes/pluginbasemodel/fields.yaml | 57 + .../pluginbasemodel/templates/lang.php.tpl | 6 + .../pluginbasemodel/templates/plugin.php.tpl | 14 + .../templates/version.yaml.tpl | 2 + .../formcontroller/templates/create.htm.tpl | 46 + .../formcontroller/templates/preview.htm.tpl | 22 + .../formcontroller/templates/update.htm.tpl | 54 + .../templates/_list_toolbar.htm.tpl | 23 + .../listcontroller/templates/index.htm.tpl | 1 + .../templates/_reorder_toolbar.htm.tpl | 3 + .../templates/reorder.htm.tpl | 8 + .../builder/components/RecordDetails.php | 161 +++ .../rainlab/builder/components/RecordList.php | 342 +++++ .../components/recorddetails/default.htm | 9 + .../builder/components/recordlist/default.htm | 45 + .../rainlab/builder/controllers/Index.php | 100 ++ .../controllers/index/_plugin-selector.htm | 9 + .../builder/controllers/index/_sidepanel.htm | 55 + .../builder/controllers/index/index.htm | 38 + .../builder/formwidgets/ControllerBuilder.php | 117 ++ .../builder/formwidgets/FormBuilder.php | 411 ++++++ .../builder/formwidgets/MenuEditor.php | 222 +++ .../assets/js/controllerbuilder.js | 0 .../controllerbuilder/partials/_behavior.htm | 16 + .../controllerbuilder/partials/_body.htm | 10 + .../partials/_buildingarea.htm | 11 + .../assets/js/formbuilder.controlpalette.js | 263 ++++ .../js/formbuilder.domtopropertyjson.js | 330 +++++ .../formbuilder/assets/js/formbuilder.js | 801 +++++++++++ .../formbuilder/assets/js/formbuilder.tabs.js | 286 ++++ .../formbuilder/partials/_body.htm | 34 + .../formbuilder/partials/_buildingarea.htm | 9 + .../formbuilder/partials/_controlbody.htm | 26 + .../partials/_controlcontainer.htm | 26 + .../formbuilder/partials/_controllist.htm | 40 + .../formbuilder/partials/_controlpalette.htm | 33 + .../formbuilder/partials/_controlwrapper.htm | 14 + .../formwidgets/formbuilder/partials/_tab.htm | 22 + .../formbuilder/partials/_tabpanel.htm | 6 + .../formbuilder/partials/_tabs.htm | 66 + .../menueditor/assets/js/menubuilder.js | 230 ++++ .../formwidgets/menueditor/partials/_body.htm | 28 + .../menueditor/partials/_mainmenuitem.htm | 17 + .../menueditor/partials/_mainmenuitems.htm | 15 + .../menueditor/partials/_submenuitem.htm | 15 + .../menueditor/partials/_submenuitems.htm | 17 + .../plugins/rainlab/builder/lang/cs/lang.php | 637 +++++++++ .../plugins/rainlab/builder/lang/en/lang.php | 684 ++++++++++ .../plugins/rainlab/builder/lang/es/lang.php | 653 +++++++++ .../plugins/rainlab/builder/lang/fa/lang.php | 638 +++++++++ .../plugins/rainlab/builder/lang/nl/lang.php | 654 +++++++++ .../rainlab/builder/lang/pt-br/lang.php | 679 +++++++++ .../rainlab/builder/models/Settings.php | 29 + .../builder/models/settings/fields.yaml | 13 + server/plugins/rainlab/builder/phpunit.xml | 23 + .../rainlab/builder/tests/TestCase.php | 3 + .../rainlab/builder/tests/fixtures/MyMock.php | 6 + .../templates/plugin.php.tpl | 6 + .../unit/classes/FilesystemGeneratorTest.php | 145 ++ .../tests/unit/classes/ModelModelTest.php | 68 + .../rainlab/builder/tests/unit/phpunit.xml | 23 + .../rainlab/builder/updates/version.yaml | 23 + .../builder/validation/ReservedValidator.php | 129 ++ .../rainlab/builder/vendor/autoload.php | 7 + .../builder/vendor/composer/ClassLoader.php | 445 ++++++ .../rainlab/builder/vendor/composer/LICENSE | 21 + .../vendor/composer/autoload_classmap.php | 9 + .../vendor/composer/autoload_namespaces.php | 9 + .../builder/vendor/composer/autoload_psr4.php | 10 + .../builder/vendor/composer/autoload_real.php | 52 + .../vendor/composer/autoload_static.php | 31 + .../builder/vendor/composer/installed.json | 124 ++ .../vendor/composer/installers/LICENSE | 19 + .../vendor/composer/installers/composer.json | 105 ++ .../src/Composer/Installers/AglInstaller.php | 21 + .../Composer/Installers/AimeosInstaller.php | 9 + .../Installers/AnnotateCmsInstaller.php | 11 + .../Composer/Installers/AsgardInstaller.php | 49 + .../Composer/Installers/AttogramInstaller.php | 9 + .../src/Composer/Installers/BaseInstaller.php | 136 ++ .../Composer/Installers/BitrixInstaller.php | 126 ++ .../Composer/Installers/BonefishInstaller.php | 9 + .../Composer/Installers/CakePHPInstaller.php | 82 ++ .../src/Composer/Installers/ChefInstaller.php | 11 + .../Composer/Installers/CiviCrmInstaller.php | 9 + .../Installers/ClanCatsFrameworkInstaller.php | 10 + .../Composer/Installers/CockpitInstaller.php | 34 + .../Installers/CodeIgniterInstaller.php | 11 + .../Installers/Concrete5Installer.php | 13 + .../Composer/Installers/CraftInstaller.php | 35 + .../Composer/Installers/CroogoInstaller.php | 21 + .../Composer/Installers/DecibelInstaller.php | 10 + .../Composer/Installers/DokuWikiInstaller.php | 50 + .../Composer/Installers/DolibarrInstaller.php | 16 + .../Composer/Installers/DrupalInstaller.php | 16 + .../src/Composer/Installers/ElggInstaller.php | 9 + .../Composer/Installers/EliasisInstaller.php | 12 + .../Installers/ExpressionEngineInstaller.php | 29 + .../Installers/EzPlatformInstaller.php | 10 + .../src/Composer/Installers/FuelInstaller.php | 11 + .../Composer/Installers/FuelphpInstaller.php | 9 + .../src/Composer/Installers/GravInstaller.php | 30 + .../Composer/Installers/HuradInstaller.php | 25 + .../Composer/Installers/ImageCMSInstaller.php | 11 + .../src/Composer/Installers/Installer.php | 274 ++++ .../src/Composer/Installers/ItopInstaller.php | 9 + .../Composer/Installers/JoomlaInstaller.php | 15 + .../Composer/Installers/KanboardInstaller.php | 18 + .../Composer/Installers/KirbyInstaller.php | 11 + .../Composer/Installers/KodiCMSInstaller.php | 10 + .../Composer/Installers/KohanaInstaller.php | 9 + .../LanManagementSystemInstaller.php | 27 + .../Composer/Installers/LaravelInstaller.php | 9 + .../Composer/Installers/LavaLiteInstaller.php | 10 + .../Composer/Installers/LithiumInstaller.php | 10 + .../Installers/MODULEWorkInstaller.php | 9 + .../Composer/Installers/MODXEvoInstaller.php | 16 + .../Composer/Installers/MagentoInstaller.php | 11 + .../Composer/Installers/MajimaInstaller.php | 37 + .../src/Composer/Installers/MakoInstaller.php | 9 + .../Composer/Installers/MauticInstaller.php | 25 + .../src/Composer/Installers/MayaInstaller.php | 33 + .../Installers/MediaWikiInstaller.php | 51 + .../Installers/MicroweberInstaller.php | 111 ++ .../src/Composer/Installers/ModxInstaller.php | 12 + .../Composer/Installers/MoodleInstaller.php | 57 + .../Composer/Installers/OctoberInstaller.php | 47 + .../Composer/Installers/OntoWikiInstaller.php | 24 + .../Composer/Installers/OsclassInstaller.php | 14 + .../src/Composer/Installers/OxidInstaller.php | 59 + .../src/Composer/Installers/PPIInstaller.php | 9 + .../Composer/Installers/PhiftyInstaller.php | 11 + .../Composer/Installers/PhpBBInstaller.php | 11 + .../Composer/Installers/PimcoreInstaller.php | 21 + .../Composer/Installers/PiwikInstaller.php | 32 + .../Installers/PlentymarketsInstaller.php | 29 + .../src/Composer/Installers/Plugin.php | 17 + .../Composer/Installers/PortoInstaller.php | 9 + .../Installers/PrestashopInstaller.php | 10 + .../Composer/Installers/PuppetInstaller.php | 11 + .../Composer/Installers/PxcmsInstaller.php | 63 + .../Composer/Installers/RadPHPInstaller.php | 24 + .../Composer/Installers/ReIndexInstaller.php | 10 + .../Composer/Installers/RedaxoInstaller.php | 10 + .../Installers/RoundcubeInstaller.php | 22 + .../src/Composer/Installers/SMFInstaller.php | 10 + .../Composer/Installers/ShopwareInstaller.php | 60 + .../Installers/SilverStripeInstaller.php | 35 + .../Installers/SiteDirectInstaller.php | 25 + .../Composer/Installers/SyDESInstaller.php | 49 + .../Composer/Installers/Symfony1Installer.php | 26 + .../Composer/Installers/TYPO3CmsInstaller.php | 16 + .../Installers/TYPO3FlowInstaller.php | 38 + .../Composer/Installers/TheliaInstaller.php | 12 + .../src/Composer/Installers/TuskInstaller.php | 14 + .../Installers/UserFrostingInstaller.php | 9 + .../Composer/Installers/VanillaInstaller.php | 10 + .../Composer/Installers/VgmcpInstaller.php | 49 + .../Composer/Installers/WHMCSInstaller.php | 10 + .../Composer/Installers/WolfCMSInstaller.php | 9 + .../Installers/WordPressInstaller.php | 12 + .../Composer/Installers/YawikInstaller.php | 32 + .../src/Composer/Installers/ZendInstaller.php | 11 + .../Composer/Installers/ZikulaInstaller.php | 10 + .../composer/installers/src/bootstrap.php | 13 + .../builder/widgets/ControllerList.php | 104 ++ .../builder/widgets/DatabaseTableList.php | 118 ++ .../DefaultBehaviorDesignTimeProvider.php | 196 +++ .../DefaultControlDesignTimeProvider.php | 119 ++ .../rainlab/builder/widgets/LanguageList.php | 104 ++ .../rainlab/builder/widgets/ModelList.php | 129 ++ .../rainlab/builder/widgets/PluginList.php | 201 +++ .../rainlab/builder/widgets/VersionList.php | 123 ++ .../widgets/controllerlist/partials/_body.htm | 3 + .../partials/_controller-list.htm | 13 + .../controllerlist/partials/_items.htm | 20 + .../controllerlist/partials/_toolbar.htm | 25 + .../partials/_widget-contents.htm | 28 + .../databasetablelist/partials/_body.htm | 3 + .../databasetablelist/partials/_items.htm | 18 + .../partials/_table-list.htm | 13 + .../databasetablelist/partials/_toolbar.htm | 24 + .../partials/_widget-contents.htm | 28 + .../partials/_behavior-form-controller.htm | 23 + .../partials/_behavior-list-controller.htm | 41 + .../partials/_behavior-reorder-controller.htm | 19 + .../partials/_behavior-unknown.htm | 1 + .../partials/_control-balloon-selector.htm | 16 + .../partials/_control-checkbox.htm | 9 + .../partials/_control-checkboxlist.htm | 16 + .../partials/_control-codeeditor.htm | 3 + .../partials/_control-colorpicker.htm | 3 + .../partials/_control-datepicker.htm | 3 + .../partials/_control-dropdown.htm | 3 + .../partials/_control-fileupload.htm | 6 + .../partials/_control-hint.htm | 7 + .../partials/_control-markdown.htm | 3 + .../partials/_control-mediafinder.htm | 3 + .../partials/_control-number.htm | 3 + .../partials/_control-partial.htm | 7 + .../partials/_control-password.htm | 3 + .../partials/_control-radio.htm | 16 + .../partials/_control-recordfinder.htm | 3 + .../partials/_control-relation.htm | 3 + .../partials/_control-repeater.htm | 9 + .../partials/_control-richeditor.htm | 3 + .../partials/_control-section.htm | 9 + .../partials/_control-static-repeater.htm | 11 + .../partials/_control-switch.htm | 9 + .../partials/_control-text.htm | 3 + .../partials/_control-textarea.htm | 3 + .../partials/_control-unknowncontrol.htm | 4 + .../widgets/languagelist/partials/_body.htm | 3 + .../widgets/languagelist/partials/_items.htm | 20 + .../languagelist/partials/_language-list.htm | 13 + .../languagelist/partials/_toolbar.htm | 24 + .../partials/_widget-contents.htm | 28 + .../widgets/modellist/partials/_body.htm | 3 + .../widgets/modellist/partials/_items.htm | 94 ++ .../modellist/partials/_model-list.htm | 14 + .../widgets/modellist/partials/_toolbar.htm | 24 + .../modellist/partials/_widget-contents.htm | 28 + .../widgets/pluginlist/partials/_body.htm | 8 + .../widgets/pluginlist/partials/_items.htm | 35 + .../pluginlist/partials/_plugin-list.htm | 13 + .../pluginlist/partials/_toolbar-buttons.htm | 14 + .../widgets/pluginlist/partials/_toolbar.htm | 22 + .../widgets/versionlist/partials/_body.htm | 3 + .../widgets/versionlist/partials/_items.htm | 35 + .../widgets/versionlist/partials/_toolbar.htm | 34 + .../versionlist/partials/_version-list.htm | 13 + .../versionlist/partials/_widget-contents.htm | 28 + .../plugins/studiovx/marcleopold/Plugin.php | 44 + .../marcleopold/controllers/IndexImage.php | 19 + .../marcleopold/controllers/IndexTagline.php | 19 + .../marcleopold/controllers/Pages.php | 18 + .../marcleopold/controllers/Services.php | 19 + .../controllers/indeximage/_list_toolbar.htm | 19 + .../indeximage/_reorder_toolbar.htm | 3 + .../controllers/indeximage/config_form.yaml | 10 + .../controllers/indeximage/config_list.yaml | 12 + .../indeximage/config_reorder.yaml | 5 + .../controllers/indeximage/create.htm | 46 + .../controllers/indeximage/index.htm | 1 + .../controllers/indeximage/preview.htm | 22 + .../controllers/indeximage/reorder.htm | 8 + .../controllers/indeximage/update.htm | 54 + .../indextagline/_list_toolbar.htm | 19 + .../indextagline/_reorder_toolbar.htm | 3 + .../controllers/indextagline/config_form.yaml | 10 + .../controllers/indextagline/config_list.yaml | 12 + .../indextagline/config_reorder.yaml | 5 + .../controllers/indextagline/create.htm | 46 + .../controllers/indextagline/index.htm | 1 + .../controllers/indextagline/preview.htm | 22 + .../controllers/indextagline/reorder.htm | 8 + .../controllers/indextagline/update.htm | 54 + .../controllers/pages/_list_toolbar.htm | 18 + .../controllers/pages/config_form.yaml | 10 + .../controllers/pages/config_list.yaml | 12 + .../marcleopold/controllers/pages/create.htm | 46 + .../marcleopold/controllers/pages/index.htm | 1 + .../marcleopold/controllers/pages/preview.htm | 22 + .../marcleopold/controllers/pages/update.htm | 54 + .../controllers/services/_list_toolbar.htm | 19 + .../controllers/services/_reorder_toolbar.htm | 3 + .../controllers/services/config_form.yaml | 10 + .../controllers/services/config_list.yaml | 12 + .../controllers/services/config_reorder.yaml | 5 + .../controllers/services/create.htm | 46 + .../controllers/services/index.htm | 1 + .../controllers/services/preview.htm | 22 + .../controllers/services/reorder.htm | 8 + .../controllers/services/update.htm | 54 + .../studiovx/marcleopold/lang/en/lang.php | 6 + .../marcleopold/models/IndexImage.php | 30 + .../marcleopold/models/IndexTagline.php | 32 + .../studiovx/marcleopold/models/Pages.php | 29 + .../studiovx/marcleopold/models/Services.php | 30 + .../studiovx/marcleopold/models/Settings.php | 19 + .../models/indeximage/columns.yaml | 14 + .../marcleopold/models/indeximage/fields.yaml | 11 + .../models/indextagline/columns.yaml | 10 + .../models/indextagline/fields.yaml | 5 + .../marcleopold/models/pages/columns.yaml | 11 + .../marcleopold/models/pages/fields.yaml | 18 + .../marcleopold/models/services/columns.yaml | 13 + .../marcleopold/models/services/fields.yaml | 20 + .../marcleopold/models/settings/fields.yaml | 6 + .../plugins/studiovx/marcleopold/plugin.yaml | 28 + .../updates/add_fields_to_albums_table.php | 26 + ...eate_studiovx_marcleopold_index_images.php | 24 + ...te_studiovx_marcleopold_index_taglines.php | 23 + ...able_create_studiovx_marcleopold_pages.php | 24 + ...e_create_studiovx_marcleopold_services.php | 27 + .../studiovx/marcleopold/updates/version.yaml | 14 + server/plugins/xeor/contenttype/LICENSE.md | 21 + server/plugins/xeor/contenttype/Plugin.php | 117 ++ server/plugins/xeor/contenttype/README.md | 12 + .../plugins/xeor/contenttype/lang/en/lang.php | 16 + .../xeor/contenttype/updates/version.yaml | 7 + 685 files changed, 54803 insertions(+) create mode 100644 server/plugins/graker/photoalbums/LICENSE create mode 100644 server/plugins/graker/photoalbums/Plugin.php create mode 100644 server/plugins/graker/photoalbums/README.md create mode 100644 server/plugins/graker/photoalbums/assets/css/dropzone.css create mode 100644 server/plugins/graker/photoalbums/assets/js/extend-markdown-editor.js create mode 100644 server/plugins/graker/photoalbums/assets/js/upload.js create mode 100644 server/plugins/graker/photoalbums/classes/MarkdownPhotoInsert.php create mode 100644 server/plugins/graker/photoalbums/classes/MenuItemsProvider.php create mode 100644 server/plugins/graker/photoalbums/components/Album.php create mode 100644 server/plugins/graker/photoalbums/components/AlbumList.php create mode 100644 server/plugins/graker/photoalbums/components/Photo.php create mode 100644 server/plugins/graker/photoalbums/components/RandomPhotos.php create mode 100644 server/plugins/graker/photoalbums/components/album/default.htm create mode 100644 server/plugins/graker/photoalbums/components/albumlist/default.htm create mode 100644 server/plugins/graker/photoalbums/components/photo/default.htm create mode 100644 server/plugins/graker/photoalbums/components/randomphotos/default.htm create mode 100644 server/plugins/graker/photoalbums/controllers/Albums.php create mode 100644 server/plugins/graker/photoalbums/controllers/Photos.php create mode 100644 server/plugins/graker/photoalbums/controllers/Reorder.php create mode 100644 server/plugins/graker/photoalbums/controllers/Upload.php create mode 100644 server/plugins/graker/photoalbums/controllers/albums/_list_toolbar.htm create mode 100644 server/plugins/graker/photoalbums/controllers/albums/_relation_toolbar.htm create mode 100644 server/plugins/graker/photoalbums/controllers/albums/config_form.yaml create mode 100644 server/plugins/graker/photoalbums/controllers/albums/config_list.yaml create mode 100644 server/plugins/graker/photoalbums/controllers/albums/config_relation.yaml create mode 100644 server/plugins/graker/photoalbums/controllers/albums/create.htm create mode 100644 server/plugins/graker/photoalbums/controllers/albums/index.htm create mode 100644 server/plugins/graker/photoalbums/controllers/albums/preview.htm create mode 100644 server/plugins/graker/photoalbums/controllers/albums/update.htm create mode 100644 server/plugins/graker/photoalbums/controllers/photos/_list_toolbar.htm create mode 100644 server/plugins/graker/photoalbums/controllers/photos/config_form.yaml create mode 100644 server/plugins/graker/photoalbums/controllers/photos/config_list.yaml create mode 100644 server/plugins/graker/photoalbums/controllers/photos/create.htm create mode 100644 server/plugins/graker/photoalbums/controllers/photos/index.htm create mode 100644 server/plugins/graker/photoalbums/controllers/photos/preview.htm create mode 100644 server/plugins/graker/photoalbums/controllers/photos/update.htm create mode 100644 server/plugins/graker/photoalbums/controllers/reorder/_records.htm create mode 100644 server/plugins/graker/photoalbums/controllers/reorder/_reorder.htm create mode 100644 server/plugins/graker/photoalbums/controllers/upload/_form.htm create mode 100644 server/plugins/graker/photoalbums/lang/en/lang.php create mode 100644 server/plugins/graker/photoalbums/models/Album.php create mode 100644 server/plugins/graker/photoalbums/models/Photo.php create mode 100644 server/plugins/graker/photoalbums/models/Settings.php create mode 100644 server/plugins/graker/photoalbums/models/album/columns.yaml create mode 100644 server/plugins/graker/photoalbums/models/album/fields.yaml create mode 100644 server/plugins/graker/photoalbums/models/photo/columns.yaml create mode 100644 server/plugins/graker/photoalbums/models/photo/fields.yaml create mode 100644 server/plugins/graker/photoalbums/models/settings/fields.yaml create mode 100644 server/plugins/graker/photoalbums/phpunit.xml create mode 100644 server/plugins/graker/photoalbums/tests/RandomPhotosTest.php create mode 100644 server/plugins/graker/photoalbums/updates/add_album_front.php create mode 100644 server/plugins/graker/photoalbums/updates/add_sort_order_field.php create mode 100644 server/plugins/graker/photoalbums/updates/create_albums_table.php create mode 100644 server/plugins/graker/photoalbums/updates/create_photos_table.php create mode 100644 server/plugins/graker/photoalbums/updates/update_sort_order_on_existing_photos.php create mode 100644 server/plugins/graker/photoalbums/updates/version.yaml create mode 100644 server/plugins/graker/photoalbums/widgets/PhotoSelector.php create mode 100644 server/plugins/graker/photoalbums/widgets/photoselector/assets/css/photoselector.css create mode 100644 server/plugins/graker/photoalbums/widgets/photoselector/assets/js/photoselector.js create mode 100644 server/plugins/graker/photoalbums/widgets/photoselector/partials/_albums.htm create mode 100644 server/plugins/graker/photoalbums/widgets/photoselector/partials/_body.htm create mode 100644 server/plugins/graker/photoalbums/widgets/photoselector/partials/_photos.htm create mode 100644 server/plugins/manogi/mediathumb/LICENCE.md create mode 100644 server/plugins/manogi/mediathumb/Plugin.php create mode 100644 server/plugins/manogi/mediathumb/README.md create mode 100644 server/plugins/manogi/mediathumb/config/config.php create mode 100644 server/plugins/manogi/mediathumb/lang/cs/lang.php create mode 100644 server/plugins/manogi/mediathumb/lang/de/lang.php create mode 100644 server/plugins/manogi/mediathumb/lang/en/lang.php create mode 100644 server/plugins/manogi/mediathumb/lang/hu/lang.php create mode 100644 server/plugins/manogi/mediathumb/updates/version.yaml create mode 100644 server/plugins/manogi/mediathumb/vendor/autoload.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/ClassLoader.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/LICENSE create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/autoload_classmap.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/autoload_files.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/autoload_namespaces.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/autoload_psr4.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/autoload_real.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/autoload_static.php create mode 100644 server/plugins/manogi/mediathumb/vendor/composer/installed.json create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/CHANGELOG.md create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/LICENSE create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/README.md create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/composer.json create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/AppendStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/BufferStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/CachingStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/DroppingStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/FnStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/InflateStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LazyOpenStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LimitStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MessageTrait.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MultipartStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/NoSeekStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/PumpStream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Request.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Response.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/ServerRequest.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Stream.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamWrapper.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UploadedFile.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Uri.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriNormalizer.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriResolver.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions.php create mode 100644 server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions_include.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/LICENSE create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/composer.json create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/provides.json create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractColor.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractEncoder.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractFont.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/Argument.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/CircleCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/EllipseCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ExifCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/IptcCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/LineCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/OrientateCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/RectangleCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ResponseCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/StreamCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/TextCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Constraint.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/ImageException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/InvalidArgumentException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/MissingDependencyException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/NotFoundException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/NotReadableException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/NotSupportedException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/NotWritableException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/RuntimeException.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Facades/Image.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/File.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/DemoFilter.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/FilterInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Color.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BackupCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BlurCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BrightnessCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ColorizeCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ContrastCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/DestroyCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FitCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FlipCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GammaCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GetSizeCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/HeightenCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InsertCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InterlaceCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InvertCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/MaskCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/OpacityCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PickColorCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelateCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResetCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/RotateCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/SharpenCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/TrimCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/WidenCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Encoder.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Font.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/CircleShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/EllipseShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/LineShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/PolygonShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/RectangleShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Image.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManager.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManagerStatic.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProvider.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel5.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Color.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BackupCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BlurCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ContrastCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/CropCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/DestroyCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ExifCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FillCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FitCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FlipCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GammaCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/HeightenCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InsertCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InvertCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/MaskCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/OpacityCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PickColorCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelateCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResetCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/RotateCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/SharpenCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/TrimCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/WidenCommand.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Decoder.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Driver.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Encoder.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Font.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/CircleShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/EllipseShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/LineShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/PolygonShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/RectangleShape.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Point.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Response.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Size.php create mode 100644 server/plugins/manogi/mediathumb/vendor/intervention/image/src/config/config.php create mode 100644 server/plugins/manogi/mediathumb/vendor/manogi/mediathumb/resize_helper.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/CHANGELOG.md create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/LICENSE create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/README.md create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/composer.json create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/MessageInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/RequestInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/ResponseInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/ServerRequestInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/StreamInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/UploadedFileInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/psr/http-message/src/UriInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/LICENSE create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/README.md create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/phpunit.xml.dist create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateBundle.php create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateExtension.php create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Twig/TruncateExtension.php create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateInterface.php create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateService.php create mode 100644 server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/tests/TruncateServiceTest.php create mode 100644 server/plugins/rainlab/builder/LICENCE.md create mode 100644 server/plugins/rainlab/builder/Plugin.php create mode 100644 server/plugins/rainlab/builder/assets/css/builder.css create mode 100644 server/plugins/rainlab/builder/assets/images/builder-icon.svg create mode 100644 server/plugins/rainlab/builder/assets/images/tab.png create mode 100644 server/plugins/rainlab/builder/assets/js/build-min.js create mode 100644 server/plugins/rainlab/builder/assets/js/build.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.dataregistry.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.base.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.controller.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.databasetable.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.localization.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.menus.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.model.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.modelform.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.modellist.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.permission.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.plugin.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.entity.version.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.index.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.inspector.editor.localization.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.localizationinput.js create mode 100644 server/plugins/rainlab/builder/assets/js/builder.table.processor.localization.js create mode 100644 server/plugins/rainlab/builder/assets/less/behaviors.less create mode 100644 server/plugins/rainlab/builder/assets/less/builder.less create mode 100644 server/plugins/rainlab/builder/assets/less/buildingarea.less create mode 100644 server/plugins/rainlab/builder/assets/less/controlblueprint.less create mode 100644 server/plugins/rainlab/builder/assets/less/localization.less create mode 100644 server/plugins/rainlab/builder/assets/less/menus.less create mode 100644 server/plugins/rainlab/builder/assets/less/tabs.less create mode 100644 server/plugins/rainlab/builder/behaviors/IndexControllerOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexDataRegistry.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexDatabaseTableOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexLocalizationOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexMenusOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexModelFormOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexModelListOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexModelOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexPermissionsOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexPluginOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/IndexVersionsOperations.php create mode 100644 server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_create-controller-popup-form.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_migration-popup-form.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_copy-strings-popup-form.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_new-string-popup.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexmodeloperations/partials/_model-popup-form.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-popup-form.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-update-hint.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_version-hint-block.htm create mode 100644 server/plugins/rainlab/builder/classes/BaseModel.php create mode 100644 server/plugins/rainlab/builder/classes/BehaviorDesignTimeProviderBase.php create mode 100644 server/plugins/rainlab/builder/classes/ComponentHelper.php create mode 100644 server/plugins/rainlab/builder/classes/ControlDesignTimeProviderBase.php create mode 100644 server/plugins/rainlab/builder/classes/ControlLibrary.php create mode 100644 server/plugins/rainlab/builder/classes/ControllerBehaviorLibrary.php create mode 100644 server/plugins/rainlab/builder/classes/ControllerFileParser.php create mode 100644 server/plugins/rainlab/builder/classes/ControllerGenerator.php create mode 100644 server/plugins/rainlab/builder/classes/ControllerModel.php create mode 100644 server/plugins/rainlab/builder/classes/DatabaseTableModel.php create mode 100644 server/plugins/rainlab/builder/classes/DatabaseTableSchemaCreator.php create mode 100644 server/plugins/rainlab/builder/classes/EnumDbType.php create mode 100644 server/plugins/rainlab/builder/classes/FilesystemGenerator.php create mode 100644 server/plugins/rainlab/builder/classes/IconList.php create mode 100644 server/plugins/rainlab/builder/classes/IndexOperationsBehaviorBase.php create mode 100644 server/plugins/rainlab/builder/classes/LanguageMixer.php create mode 100644 server/plugins/rainlab/builder/classes/LocalizationModel.php create mode 100644 server/plugins/rainlab/builder/classes/MenusModel.php create mode 100644 server/plugins/rainlab/builder/classes/MigrationColumnType.php create mode 100644 server/plugins/rainlab/builder/classes/MigrationFileParser.php create mode 100644 server/plugins/rainlab/builder/classes/MigrationModel.php create mode 100644 server/plugins/rainlab/builder/classes/ModelFileParser.php create mode 100644 server/plugins/rainlab/builder/classes/ModelFormModel.php create mode 100644 server/plugins/rainlab/builder/classes/ModelListModel.php create mode 100644 server/plugins/rainlab/builder/classes/ModelModel.php create mode 100644 server/plugins/rainlab/builder/classes/ModelYamlModel.php create mode 100644 server/plugins/rainlab/builder/classes/PermissionsModel.php create mode 100644 server/plugins/rainlab/builder/classes/PhpSourceStream.php create mode 100644 server/plugins/rainlab/builder/classes/PluginBaseModel.php create mode 100644 server/plugins/rainlab/builder/classes/PluginCode.php create mode 100644 server/plugins/rainlab/builder/classes/PluginVector.php create mode 100644 server/plugins/rainlab/builder/classes/PluginVersion.php create mode 100644 server/plugins/rainlab/builder/classes/PluginYamlModel.php create mode 100644 server/plugins/rainlab/builder/classes/StandardBehaviorsRegistry.php create mode 100644 server/plugins/rainlab/builder/classes/StandardControlsRegistry.php create mode 100644 server/plugins/rainlab/builder/classes/TableMigrationCodeGenerator.php create mode 100644 server/plugins/rainlab/builder/classes/YamlModel.php create mode 100644 server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-config-vars.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-permissions.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/controllergenerator/templates/controller.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/controllermodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/controllermodel/new-controller-fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/databasetablemodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/databasetablemodel/templates/full-migration-code.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/databasetablemodel/templates/migration-code.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/localizationmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/localizationmodel/templates/lang.php create mode 100644 server/plugins/rainlab/builder/classes/menusmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/migrationmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/migrationmodel/management-fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/migrationmodel/templates/migration.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/migrationmodel/templates/seeder.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/modelformmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/modellistmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/modelmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/modelmodel/templates/model.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/modelmodel/templates/no-timestamps.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/modelmodel/templates/soft-delete.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/permissionsmodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/pluginbasemodel/fields.yaml create mode 100644 server/plugins/rainlab/builder/classes/pluginbasemodel/templates/lang.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/pluginbasemodel/templates/plugin.php.tpl create mode 100644 server/plugins/rainlab/builder/classes/pluginbasemodel/templates/version.yaml.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/create.htm.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/preview.htm.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/update.htm.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/_list_toolbar.htm.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/index.htm.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/_reorder_toolbar.htm.tpl create mode 100644 server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/reorder.htm.tpl create mode 100644 server/plugins/rainlab/builder/components/RecordDetails.php create mode 100644 server/plugins/rainlab/builder/components/RecordList.php create mode 100644 server/plugins/rainlab/builder/components/recorddetails/default.htm create mode 100644 server/plugins/rainlab/builder/components/recordlist/default.htm create mode 100644 server/plugins/rainlab/builder/controllers/Index.php create mode 100644 server/plugins/rainlab/builder/controllers/index/_plugin-selector.htm create mode 100644 server/plugins/rainlab/builder/controllers/index/_sidepanel.htm create mode 100644 server/plugins/rainlab/builder/controllers/index/index.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/ControllerBuilder.php create mode 100644 server/plugins/rainlab/builder/formwidgets/FormBuilder.php create mode 100644 server/plugins/rainlab/builder/formwidgets/MenuEditor.php create mode 100644 server/plugins/rainlab/builder/formwidgets/controllerbuilder/assets/js/controllerbuilder.js create mode 100644 server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_behavior.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_buildingarea.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.controlpalette.js create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.domtopropertyjson.js create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.js create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.tabs.js create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_buildingarea.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlbody.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlcontainer.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controllist.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlpalette.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlwrapper.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tab.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabpanel.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabs.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/menueditor/assets/js/menubuilder.js create mode 100644 server/plugins/rainlab/builder/formwidgets/menueditor/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitem.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitems.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitem.htm create mode 100644 server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitems.htm create mode 100644 server/plugins/rainlab/builder/lang/cs/lang.php create mode 100644 server/plugins/rainlab/builder/lang/en/lang.php create mode 100644 server/plugins/rainlab/builder/lang/es/lang.php create mode 100644 server/plugins/rainlab/builder/lang/fa/lang.php create mode 100644 server/plugins/rainlab/builder/lang/nl/lang.php create mode 100644 server/plugins/rainlab/builder/lang/pt-br/lang.php create mode 100644 server/plugins/rainlab/builder/models/Settings.php create mode 100644 server/plugins/rainlab/builder/models/settings/fields.yaml create mode 100644 server/plugins/rainlab/builder/phpunit.xml create mode 100644 server/plugins/rainlab/builder/tests/TestCase.php create mode 100644 server/plugins/rainlab/builder/tests/fixtures/MyMock.php create mode 100644 server/plugins/rainlab/builder/tests/fixtures/filesystemgenerator/templates/plugin.php.tpl create mode 100644 server/plugins/rainlab/builder/tests/unit/classes/FilesystemGeneratorTest.php create mode 100644 server/plugins/rainlab/builder/tests/unit/classes/ModelModelTest.php create mode 100644 server/plugins/rainlab/builder/tests/unit/phpunit.xml create mode 100644 server/plugins/rainlab/builder/updates/version.yaml create mode 100644 server/plugins/rainlab/builder/validation/ReservedValidator.php create mode 100644 server/plugins/rainlab/builder/vendor/autoload.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/ClassLoader.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/LICENSE create mode 100644 server/plugins/rainlab/builder/vendor/composer/autoload_classmap.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/autoload_namespaces.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/autoload_psr4.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/autoload_real.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/autoload_static.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installed.json create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/LICENSE create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/composer.json create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AglInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/GravInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Installer.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Plugin.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php create mode 100644 server/plugins/rainlab/builder/vendor/composer/installers/src/bootstrap.php create mode 100644 server/plugins/rainlab/builder/widgets/ControllerList.php create mode 100644 server/plugins/rainlab/builder/widgets/DatabaseTableList.php create mode 100644 server/plugins/rainlab/builder/widgets/DefaultBehaviorDesignTimeProvider.php create mode 100644 server/plugins/rainlab/builder/widgets/DefaultControlDesignTimeProvider.php create mode 100644 server/plugins/rainlab/builder/widgets/LanguageList.php create mode 100644 server/plugins/rainlab/builder/widgets/ModelList.php create mode 100644 server/plugins/rainlab/builder/widgets/PluginList.php create mode 100644 server/plugins/rainlab/builder/widgets/VersionList.php create mode 100644 server/plugins/rainlab/builder/widgets/controllerlist/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/widgets/controllerlist/partials/_controller-list.htm create mode 100644 server/plugins/rainlab/builder/widgets/controllerlist/partials/_items.htm create mode 100644 server/plugins/rainlab/builder/widgets/controllerlist/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/widgets/controllerlist/partials/_widget-contents.htm create mode 100644 server/plugins/rainlab/builder/widgets/databasetablelist/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/widgets/databasetablelist/partials/_items.htm create mode 100644 server/plugins/rainlab/builder/widgets/databasetablelist/partials/_table-list.htm create mode 100644 server/plugins/rainlab/builder/widgets/databasetablelist/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/widgets/databasetablelist/partials/_widget-contents.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-form-controller.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-list-controller.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-reorder-controller.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-unknown.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-balloon-selector.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkbox.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkboxlist.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-codeeditor.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-colorpicker.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-datepicker.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-dropdown.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-fileupload.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-hint.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-markdown.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-mediafinder.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-number.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-partial.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-password.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-radio.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-recordfinder.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-relation.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-repeater.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-richeditor.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-section.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-static-repeater.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-switch.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-text.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-textarea.htm create mode 100644 server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-unknowncontrol.htm create mode 100644 server/plugins/rainlab/builder/widgets/languagelist/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/widgets/languagelist/partials/_items.htm create mode 100644 server/plugins/rainlab/builder/widgets/languagelist/partials/_language-list.htm create mode 100644 server/plugins/rainlab/builder/widgets/languagelist/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/widgets/languagelist/partials/_widget-contents.htm create mode 100644 server/plugins/rainlab/builder/widgets/modellist/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/widgets/modellist/partials/_items.htm create mode 100644 server/plugins/rainlab/builder/widgets/modellist/partials/_model-list.htm create mode 100644 server/plugins/rainlab/builder/widgets/modellist/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/widgets/modellist/partials/_widget-contents.htm create mode 100644 server/plugins/rainlab/builder/widgets/pluginlist/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/widgets/pluginlist/partials/_items.htm create mode 100644 server/plugins/rainlab/builder/widgets/pluginlist/partials/_plugin-list.htm create mode 100644 server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar-buttons.htm create mode 100644 server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/widgets/versionlist/partials/_body.htm create mode 100644 server/plugins/rainlab/builder/widgets/versionlist/partials/_items.htm create mode 100644 server/plugins/rainlab/builder/widgets/versionlist/partials/_toolbar.htm create mode 100644 server/plugins/rainlab/builder/widgets/versionlist/partials/_version-list.htm create mode 100644 server/plugins/rainlab/builder/widgets/versionlist/partials/_widget-contents.htm create mode 100644 server/plugins/studiovx/marcleopold/Plugin.php create mode 100644 server/plugins/studiovx/marcleopold/controllers/IndexImage.php create mode 100644 server/plugins/studiovx/marcleopold/controllers/IndexTagline.php create mode 100644 server/plugins/studiovx/marcleopold/controllers/Pages.php create mode 100644 server/plugins/studiovx/marcleopold/controllers/Services.php create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/_list_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/_reorder_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/config_form.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/config_list.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/config_reorder.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/create.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/index.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/preview.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/reorder.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indeximage/update.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/_list_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/_reorder_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/config_form.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/config_list.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/config_reorder.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/create.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/index.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/preview.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/reorder.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/indextagline/update.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/_list_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/config_form.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/config_list.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/create.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/index.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/preview.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/pages/update.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/_list_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/_reorder_toolbar.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/config_form.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/config_list.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/config_reorder.yaml create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/create.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/index.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/preview.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/reorder.htm create mode 100644 server/plugins/studiovx/marcleopold/controllers/services/update.htm create mode 100644 server/plugins/studiovx/marcleopold/lang/en/lang.php create mode 100644 server/plugins/studiovx/marcleopold/models/IndexImage.php create mode 100644 server/plugins/studiovx/marcleopold/models/IndexTagline.php create mode 100644 server/plugins/studiovx/marcleopold/models/Pages.php create mode 100644 server/plugins/studiovx/marcleopold/models/Services.php create mode 100644 server/plugins/studiovx/marcleopold/models/Settings.php create mode 100644 server/plugins/studiovx/marcleopold/models/indeximage/columns.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/indeximage/fields.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/indextagline/columns.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/indextagline/fields.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/pages/columns.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/pages/fields.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/services/columns.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/services/fields.yaml create mode 100644 server/plugins/studiovx/marcleopold/models/settings/fields.yaml create mode 100644 server/plugins/studiovx/marcleopold/plugin.yaml create mode 100644 server/plugins/studiovx/marcleopold/updates/add_fields_to_albums_table.php create mode 100644 server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_images.php create mode 100644 server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_taglines.php create mode 100644 server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_pages.php create mode 100644 server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_services.php create mode 100644 server/plugins/studiovx/marcleopold/updates/version.yaml create mode 100644 server/plugins/xeor/contenttype/LICENSE.md create mode 100644 server/plugins/xeor/contenttype/Plugin.php create mode 100644 server/plugins/xeor/contenttype/README.md create mode 100644 server/plugins/xeor/contenttype/lang/en/lang.php create mode 100644 server/plugins/xeor/contenttype/updates/version.yaml diff --git a/server/plugins/graker/photoalbums/LICENSE b/server/plugins/graker/photoalbums/LICENSE new file mode 100644 index 0000000..18dc53c --- /dev/null +++ b/server/plugins/graker/photoalbums/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Graker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/server/plugins/graker/photoalbums/Plugin.php b/server/plugins/graker/photoalbums/Plugin.php new file mode 100644 index 0000000..8a9cc21 --- /dev/null +++ b/server/plugins/graker/photoalbums/Plugin.php @@ -0,0 +1,254 @@ + 'graker.photoalbums::lang.plugin.name', + 'description' => 'graker.photoalbums::lang.plugin.description', + 'author' => 'Graker', + 'icon' => 'icon-camera-retro', + 'homepage' => 'https://github.com/graker/oc-photoalbums-plugin', + ]; + } + + /** + * Registers any front-end components implemented in this plugin. + * + * @return array + */ + public function registerComponents() + { + return [ + 'Graker\PhotoAlbums\Components\Photo' => 'singlePhoto', + 'Graker\PhotoAlbums\Components\Album' => 'photoAlbum', + 'Graker\PhotoAlbums\Components\AlbumList' => 'albumList', + 'Graker\PhotoAlbums\Components\RandomPhotos' => 'randomPhotos', + ]; + } + + /** + * Registers any back-end permissions used by this plugin. + * At the moment there's one permission allowing overall management of albums and photos + * + * @return array + */ + public function registerPermissions() + { + return [ + 'graker.photoalbums.manage_albums' => [ + 'label' => 'graker.photoalbums::lang.plugin.manage_albums', + 'tab' => 'graker.photoalbums::lang.plugin.tab', + ], + 'graker.photoalbums.access_settings' => [ + 'label' => 'graker.photoalbums::lang.plugin.access_permission', + 'tab' => 'graker.photoalbums::lang.plugin.tab', + ], + ]; + } + + /** + * Registers back-end navigation items for this plugin. + * + * @return array + */ + public function registerNavigation() + { + return [ + 'photoalbums' => [ + 'label' => 'graker.photoalbums::lang.plugin.tab', + 'url' => Backend::url('graker/photoalbums/albums'), + 'icon' => 'icon-camera-retro', + 'permissions' => ['graker.photoalbums.manage_albums'], + 'order' => 500, + + 'sideMenu' => [ + 'upload_photos' => [ + 'label' => 'graker.photoalbums::lang.plugin.upload_photos', + 'icon' => 'icon-upload', + 'url' => Backend::url('graker/photoalbums/upload/form'), + 'permissions' => ['graker.photoalbums.manage_albums'], + ], + 'new_album' => [ + 'label' => 'graker.photoalbums::lang.plugin.new_album', + 'icon' => 'icon-plus', + 'url' => Backend::url('graker/photoalbums/albums/create'), + 'permissions' => ['graker.photoalbums.manage_albums'], + ], + 'albums' => [ + 'label' => 'graker.photoalbums::lang.plugin.albums', + 'icon' => 'icon-copy', + 'url' => Backend::url('graker/photoalbums/albums'), + 'permissions' => ['graker.photoalbums.manage_albums'], + ], + 'new_photo' => [ + 'label' => 'graker.photoalbums::lang.plugin.new_photo', + 'icon' => 'icon-plus-square-o', + 'url' => Backend::url('graker/photoalbums/photos/create'), + 'permissions' => ['graker.photoalbums.manage_albums'], + ], + 'photos' => [ + 'label' => 'graker.photoalbums::lang.plugin.photos', + 'icon' => 'icon-picture-o', + 'url' => Backend::url('graker/photoalbums/photos'), + 'permissions' => ['graker.photoalbums.manage_albums'], + ], + ], + ], + ]; + } + + + /** + * + * Registers plugin's settings + * + * @return array + */ + public function registerSettings() + { + return [ + 'settings' => [ + 'label' => 'graker.photoalbums::lang.plugin.name', + 'description' => 'graker.photoalbums::lang.plugin.settings_description', + 'icon' => 'icon-camera-retro', + 'class' => 'Graker\PhotoAlbums\Models\Settings', + 'order' => 100, + 'permissions' => ['graker.photoalbums.access_settings'], + ] + ]; + } + + + /** + * + * Custom column types definition + * + * @return array + */ + public function registerListColumnTypes() { + return [ + 'is_front' => [$this, 'evalIsFrontListColumn'], + 'image' => [$this, 'evalImageListColumn'], + ]; + } + + + /** + * + * Special column to show photo set to be album's front in album's relations list + * + * @param $value + * @param $column + * @param $record + * @return string + */ + public function evalIsFrontListColumn($value, $column, $record) { + return ($value == $record->id) ? Lang::get('graker.photoalbums::lang.plugin.bool_positive') : ''; + } + + + /** + * + * Column to render image thumb for Photo model + * + * @param $value + * @param $column + * @param $record + * @return string + */ + function evalImageListColumn($value, $column, $record) { + if ($record->has('image')) { + $thumb = $record->image->getThumb( + isset($column->config['width']) ? $column->config['width'] : 200, + isset($column->config['height']) ? $column->config['height'] : 200, + ['mode' => 'auto'] + ); + } else { + // in case the file attachment was manually deleted for some reason + $thumb = ''; + } + return ""; + } + + + /** + * boot() implementation + * - Register listener to markdown.parse + * - Add button to blog post form to insert photos from albums + */ + public function boot() { + Event::listen('markdown.parse', 'Graker\PhotoAlbums\Classes\MarkdownPhotoInsert@parse'); + $this->extendBlogPostForm(); + $this->registerMenuItems(); + } + + + /** + * Extends Blog post form by adding a new button: Insert photo from albums + */ + protected function extendBlogPostForm() { + Event::listen('backend.form.extendFields', function (Form $widget) { + // attach to post forms only + $controller = $widget->getController(); + if (!($controller instanceof \RainLab\Blog\Controllers\Posts)) { + return ; + } + if (!($widget->model instanceof \RainLab\Blog\Models\Post)) { + return ; + } + + // add PhotoSelector widget to Post controller + $photo_selector = new PhotoSelector($controller); + $photo_selector->alias = 'photoSelector'; + $photo_selector->bindToController(); + + // add javascript extending Markdown editor with new button + $widget->addJs('/plugins/graker/photoalbums/assets/js/extend-markdown-editor.js'); + }); + } + + + /** + * Listen to events from RainLab.Pages plugin to register and resolve new menu items + */ + protected function registerMenuItems() { + // register items + Event::listen('pages.menuitem.listTypes', function() { + return MenuItemsProvider::listTypes(); + }); + + // return item type info + Event::listen('pages.menuitem.getTypeInfo', function($type) { + if (in_array($type, array_keys(MenuItemsProvider::listTypes()))) { + return MenuItemsProvider::getMenuTypeInfo($type); + } + }); + + // resolve item + Event::listen('pages.menuitem.resolveItem', function($type, $item, $url, $theme) { + if (in_array($type, array_keys(MenuItemsProvider::listTypes()))) { + return MenuItemsProvider::resolveMenuItem($type, $item, $url, $theme); + } + }); + } + +} diff --git a/server/plugins/graker/photoalbums/README.md b/server/plugins/graker/photoalbums/README.md new file mode 100644 index 0000000..785eb4c --- /dev/null +++ b/server/plugins/graker/photoalbums/README.md @@ -0,0 +1,101 @@ +# Photo Albums plugin + +This is [OctoberCMS](http://octobercms.com) plugin allowing to create, edit and display photos arranged in albums. Each Photo is a model with image attached to it. +And Album is an another model, owning multiple of Photos. + +The aim of this approach is to treat each photo as a separate entity which can be displayed separately, have it's own title, description, could have comments of its own etc. +And at the same time, photos are grouped in albums and can be displayed on album's page with pagination. + +Also now you can insert photos from galleries right into the blog posts (see below). + +## Components + +There are 4 components in the plugin: Photo, Album, Albums List and Random Photos. + +### Photo + +Photo component should be used to output a single photo. Data available for this single photo: + +* photo's title and description +* photo's created date +* image path +* parent album's title and url +* mini-navigator to go to the previous or the next photo + +### Album + +This component is used to output album's photos. Data available: + +* album's title and description +* each photo's title, thumb and url +* pagination + +### Albums list + +Use this component to output all albums (pagination is supported). For each album you can output title, image thumb and photos count. +Image thumb is generated from selected front photo which you can set on album's edit page in the photos list (check the photo, click "Set as front" button). +If no photo is selected is front, the latest uploaded photo will be used for thumb. + +### Random Photos + +Displays given number of random photos. Note that for big database tables, selects with random sorting can slow down your site, so use the component with caution and make use of cache lifetime to avoid running the query on each component show. Also note that due to the use of RAND() function for sorting, the component would work with MySQL and Sqlite databases only. To use the component with other databases, you'd need to rewrite orderBy() call, otherwise it will just return non-random collection. After October updates to Laravel 5.5, DB-independent function will be used. + +## Uploading + +At the moment, there are 3 ways to upload photos: + +* Add single photo using the New photo form +* Add single photo using relations manager when in album update form +* Add multiple photos to an album from the Upload photos form + +Uploading multiple photos is supported with the [Dropzone.js](http://www.dropzonejs.com/) plugin. You don't need to install it as it is already a part of October. + +## Insert photos from galleries + +### Dialog to insert photos into Blog posts + +You can insert photos from galleries created by this plugin into [Blog](https://octobercms.com/plugin/rainlab-blog) posts. +Just click on a camera icon near media manager in the post markdown editor, then select album and photo. Markdown code for selected photo will appear in the editor. + +### Markdown syntax + +To change the code template, go to Settings -> Photo Albums tab. The syntax is explained below and you can use `%id%` and `%title%` placeholders for photo id and title. +You can use placeholders multiple times. For example, you can type in template like this: + +```[![%title%]([photo:%id%:640:480:crop]){.img-responsive}]([photo:%id%] "%title%"){.magnific}``` + +It will result in image 640x480 cropped thumb with title having `img-responsive` class, linked to full-size image with title and `magnific` class. +Note that you can't use quote symbol in the template, you have to replace quotes with `"`. + +The syntax for [photo] part is as follows: + +```[photo:id:width:height:mode]``` + +Here: +* `id` is a photo model id (you can get it from url). +* `width` and `height` are optional, if they are provided, photo will be inserted as a thumbnail with these width and height. +* `mode` is an optional mode for thumbnail generation, possible values are: `auto`, `exact`, `portrait`, `landscape`, `crop` (see October thumbs generation for more info). Defaults to `auto`. + +For example: + +* `[photo:123:640:480:crop]` for cropped thumbnail 640x480 of photo with id 123 +* `[photo:123:200:200]` for thumbnail 200x200 of photo with id 123 +* `[photo:123]` for image as is, no thumb + +The placeholder will be replaced with path to image (or thumb), for example: `/storage/app/uploads/public/57a/24e/bff/thumb_301_640x480_0_0_auto.jpg`. + +You can use this code to insert photos in any markdown-processed text. + +Note that to avoid possible conflicts, placeholders are only replaced inside `src=""` and `href=""` clauses. +So if you add placeholder in href for anchor tag or in src for img tag (or into Markdown link or image), it will be replaced. And if you add it into plain text, it will be ignored. + +## Roadmap + +### Attachments location + +Right now plugin uses System\Models\File to attach images so they are stored in system uploads, each one in separate directory with random names. +It could be nice to put them in one directory per album. + +### Categories support for albums + +It would be nice to be able to separate albums by categories, to group them by categories in the AlbumsList component etc. diff --git a/server/plugins/graker/photoalbums/assets/css/dropzone.css b/server/plugins/graker/photoalbums/assets/css/dropzone.css new file mode 100644 index 0000000..ba883d4 --- /dev/null +++ b/server/plugins/graker/photoalbums/assets/css/dropzone.css @@ -0,0 +1,392 @@ +/* + * The MIT License + * Copyright (c) 2012 Matias Meno + */ +@-webkit-keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@-moz-keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@-webkit-keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@-moz-keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@-webkit-keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +@-moz-keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +@keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +.dropzone, .dropzone * { + box-sizing: border-box; } + +.dropzone { + min-height: 150px; + border: 2px solid rgba(0, 0, 0, 0.3); + background: white; + padding: 20px 20px; } +.dropzone.dz-clickable { + cursor: pointer; } +.dropzone.dz-clickable * { + cursor: default; } +.dropzone.dz-clickable .dz-message, .dropzone.dz-clickable .dz-message * { + cursor: pointer; } +.dropzone.dz-started .dz-message { + display: none; } +.dropzone.dz-drag-hover { + border-style: solid; } +.dropzone.dz-drag-hover .dz-message { + opacity: 0.5; } +.dropzone .dz-message { + text-align: center; + margin: 2em 0; } +.dropzone .dz-preview { + position: relative; + display: inline-block; + vertical-align: top; + margin: 16px; + min-height: 100px; } +.dropzone .dz-preview:hover { + z-index: 1000; } +.dropzone .dz-preview:hover .dz-details { + opacity: 1; } +.dropzone .dz-preview.dz-file-preview .dz-image { + border-radius: 20px; + background: #999; + background: linear-gradient(to bottom, #eee, #ddd); } +.dropzone .dz-preview.dz-file-preview .dz-details { + opacity: 1; } +.dropzone .dz-preview.dz-image-preview { + background: white; } +.dropzone .dz-preview.dz-image-preview .dz-details { + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + -ms-transition: opacity 0.2s linear; + -o-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; } +.dropzone .dz-preview .dz-remove { + font-size: 14px; + text-align: center; + display: block; + cursor: pointer; + border: none; } +.dropzone .dz-preview .dz-remove:hover { + text-decoration: underline; } +.dropzone .dz-preview:hover .dz-details { + opacity: 1; } +.dropzone .dz-preview .dz-details { + z-index: 20; + position: absolute; + top: 0; + left: 0; + opacity: 0; + font-size: 13px; + min-width: 100%; + max-width: 100%; + padding: 2em 1em; + text-align: center; + color: rgba(0, 0, 0, 0.9); + line-height: 150%; } +.dropzone .dz-preview .dz-details .dz-size { + margin-bottom: 1em; + font-size: 16px; } +.dropzone .dz-preview .dz-details .dz-filename { + white-space: nowrap; } +.dropzone .dz-preview .dz-details .dz-filename:hover span { + border: 1px solid rgba(200, 200, 200, 0.8); + background-color: rgba(255, 255, 255, 0.8); } +.dropzone .dz-preview .dz-details .dz-filename:not(:hover) { + overflow: hidden; + text-overflow: ellipsis; } +.dropzone .dz-preview .dz-details .dz-filename:not(:hover) span { + border: 1px solid transparent; } +.dropzone .dz-preview .dz-details .dz-filename span, .dropzone .dz-preview .dz-details .dz-size span { + background-color: rgba(255, 255, 255, 0.4); + padding: 0 0.4em; + border-radius: 3px; } +.dropzone .dz-preview:hover .dz-image img { + -webkit-transform: scale(1.05, 1.05); + -moz-transform: scale(1.05, 1.05); + -ms-transform: scale(1.05, 1.05); + -o-transform: scale(1.05, 1.05); + transform: scale(1.05, 1.05); + -webkit-filter: blur(8px); + filter: blur(8px); } +.dropzone .dz-preview .dz-image { + border-radius: 20px; + overflow: hidden; + width: 120px; + height: 120px; + position: relative; + display: block; + z-index: 10; } +.dropzone .dz-preview .dz-image img { + display: block; } +.dropzone .dz-preview.dz-success .dz-success-mark { + -webkit-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -moz-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -ms-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -o-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); } +.dropzone .dz-preview.dz-error .dz-error-mark { + opacity: 1; + -webkit-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -moz-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -ms-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -o-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); } +.dropzone .dz-preview .dz-success-mark, .dropzone .dz-preview .dz-error-mark { + pointer-events: none; + opacity: 0; + z-index: 500; + position: absolute; + display: block; + top: 50%; + left: 50%; + margin-left: -27px; + margin-top: -27px; } +.dropzone .dz-preview .dz-success-mark svg, .dropzone .dz-preview .dz-error-mark svg { + display: block; + width: 54px; + height: 54px; } +.dropzone .dz-preview.dz-processing .dz-progress { + opacity: 1; + -webkit-transition: all 0.2s linear; + -moz-transition: all 0.2s linear; + -ms-transition: all 0.2s linear; + -o-transition: all 0.2s linear; + transition: all 0.2s linear; } +.dropzone .dz-preview.dz-complete .dz-progress { + opacity: 0; + -webkit-transition: opacity 0.4s ease-in; + -moz-transition: opacity 0.4s ease-in; + -ms-transition: opacity 0.4s ease-in; + -o-transition: opacity 0.4s ease-in; + transition: opacity 0.4s ease-in; } +.dropzone .dz-preview:not(.dz-processing) .dz-progress { + -webkit-animation: pulse 6s ease infinite; + -moz-animation: pulse 6s ease infinite; + -ms-animation: pulse 6s ease infinite; + -o-animation: pulse 6s ease infinite; + animation: pulse 6s ease infinite; } +.dropzone .dz-preview .dz-progress { + opacity: 1; + z-index: 1000; + pointer-events: none; + position: absolute; + height: 16px; + left: 50%; + top: 50%; + margin-top: -8px; + width: 80px; + margin-left: -40px; + background: rgba(255, 255, 255, 0.9); + -webkit-transform: scale(1); + border-radius: 8px; + overflow: hidden; } +.dropzone .dz-preview .dz-progress .dz-upload { + background: #333; + background: linear-gradient(to bottom, #666, #444); + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 0; + -webkit-transition: width 300ms ease-in-out; + -moz-transition: width 300ms ease-in-out; + -ms-transition: width 300ms ease-in-out; + -o-transition: width 300ms ease-in-out; + transition: width 300ms ease-in-out; } +.dropzone .dz-preview.dz-error .dz-error-message { + display: block; } +.dropzone .dz-preview.dz-error:hover .dz-error-message { + opacity: 1; + pointer-events: auto; } +.dropzone .dz-preview .dz-error-message { + pointer-events: none; + z-index: 1000; + position: absolute; + display: block; + display: none; + opacity: 0; + -webkit-transition: opacity 0.3s ease; + -moz-transition: opacity 0.3s ease; + -ms-transition: opacity 0.3s ease; + -o-transition: opacity 0.3s ease; + transition: opacity 0.3s ease; + border-radius: 8px; + font-size: 13px; + top: 130px; + left: -10px; + width: 140px; + background: #be2626; + background: linear-gradient(to bottom, #be2626, #a92222); + padding: 0.5em 1.2em; + color: white; } +.dropzone .dz-preview .dz-error-message:after { + content: ''; + position: absolute; + top: -6px; + left: 64px; + width: 0; + height: 0; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid #be2626; +} +.dropzone input.form-control { + width: 120px; +} diff --git a/server/plugins/graker/photoalbums/assets/js/extend-markdown-editor.js b/server/plugins/graker/photoalbums/assets/js/extend-markdown-editor.js new file mode 100644 index 0000000..7772aed --- /dev/null +++ b/server/plugins/graker/photoalbums/assets/js/extend-markdown-editor.js @@ -0,0 +1,54 @@ +/** + * Script to extend Markdown editor for Blog post form + * - add button to insert photos from albums + * - add visual dialog for this button + */ + ++function ($) { + + $(document).one('ready', function () { + var editor = $('[data-control="markdowneditor"]').data('oc.markdownEditor'); + + // to preserve last selected album so user won't open it again and again + var currentAlbum = 0; + + // FIXME Localize label when it is supported + var button = { + label: 'Insert photo from Photoalbums', + cssClass: 'oc-autumn-button oc-icon-camera-retro', + insertAfter: 'mediaimage', + action: 'showAlbumsDialog', + template: '$1' + }; + + /** + * + * Markdown editor method to show photo selection dialog + * + * @param template + */ + editor.showAlbumsDialog = function (template) { + var editor = this.editor, + pos = this.editor.getCursorPosition(); + + new $.oc.photoselector.popup({ + alias: 'photoSelector', + album: currentAlbum, + onInsert: function (code, album) { + editor.insert(template.replace('$1', code)); + editor.moveCursorToPosition(pos); + editor.focus(); + this.hide(); + // save current album + currentAlbum = album; + console.log(currentAlbum); + console.log(album); + } + }); + }; + + //add button to editor + editor.addToolbarButton('photoalbums', button); + }); + +}(window.jQuery); diff --git a/server/plugins/graker/photoalbums/assets/js/upload.js b/server/plugins/graker/photoalbums/assets/js/upload.js new file mode 100644 index 0000000..49f0abc --- /dev/null +++ b/server/plugins/graker/photoalbums/assets/js/upload.js @@ -0,0 +1,83 @@ +/** + * Dropzone multiupload support to upload photos to album + */ + ++function ($) { + + /** + * + * File is being removed from the list + * We need to remove it on the server + * + * @param file + */ + var removeFile = function (file) { + var $preview = $(file.previewElement); + var fileData = { + file_id: $preview.data('id'), + _token: $('input[name="_token"]').attr('value') + }; + $(this).request('onFileRemove', {data: fileData}); + }; + + + /** + * + * File is being sent to the server + * Used to add CSRF token to the form + * + * @param file + * @param xhr + * @param formData + */ + var sendingData = function (file, xhr, formData) { + var token = $('input[name="_token"]').attr('value'); + formData.append('_token', token); + }; + + + /** + * + * File upload success callback + * + * @param data + * @param response + */ + var uploadSuccess = function (file, response) { + var $preview = $(file.previewElement); + if (response.id) { + $preview.data('id', response.id); + // hidden value to pass file id when saving form + $preview.append(''); + $preview.append('
'); + } + }; + + + /** + * Initializes Dropzone + */ + var initDropzone = function () { + // register removed file callback + this.on('removedfile', removeFile); + // register before-send callback + this.on('sending', sendingData); + }; + + + /** + * Initialize file upload + */ + $(document).ready(function () { + $("div.field-fileupload").each(function () { + var uploadUrl = $(this).attr('data-url'); + $(this).dropzone({ + url: uploadUrl, + init: initDropzone, + addRemoveLinks: true, + previewsContainer: '#filesContainer', + success: uploadSuccess + }); + }); + }); +} (window.jQuery); diff --git a/server/plugins/graker/photoalbums/classes/MarkdownPhotoInsert.php b/server/plugins/graker/photoalbums/classes/MarkdownPhotoInsert.php new file mode 100644 index 0000000..f54bd00 --- /dev/null +++ b/server/plugins/graker/photoalbums/classes/MarkdownPhotoInsert.php @@ -0,0 +1,117 @@ +text, $links, PREG_SET_ORDER); + preg_match_all(self::PHOTO_IMG_REGEXP, $data->text, $images, PREG_SET_ORDER); + + if (!empty($images)) { + $data->text = $this->replaceMatches($images, $data->text); + } + + if (!empty($links)) { + $data->text = $this->replaceMatches($links, $data->text); + } + } + + + /** + * + * Goes over all matches and replaces them in text + * Returns processed text + * + * @param $matches + * @param $text + * @return mixed + */ + protected function replaceMatches($matches, $text) { + foreach ($matches as $match) { + list($entry, $placeholder) = $match; + $replacement = $this->getReplacement($entry, $placeholder); + $text = str_replace($entry, $replacement, $text); + } + return $text; + } + + + /** + * + * Returns replacement for text + * (replaces [photo:id:width:height:mode] with resulting photo's image path) + * + * @param $entry + * @param $placeholder + * @return string + */ + protected function getReplacement($entry, $placeholder) { + list($id, $width, $height, $mode) = $this->getPhotoParams($placeholder); + $photo = Photo::where('id', $id) + ->with('image') + ->first(); + if (!$photo) { + return $placeholder; + } else { + if ($width && $height) { + $path = $photo->image->getThumb($width, $height, ['mode' => $mode]); + } else { + $path = $photo->image->path; + } + return str_replace($placeholder, $path, $entry); + } + } + + + /** + * + * Parses parameters of image from the tag and returns them in array + * [$id, $width, $height, $mode] + * Width, height and mode are optional and will return 0 and empty string + * if omitted in the tag + * + * @param string $placeholder + * @return array + */ + protected function getPhotoParams($placeholder) { + // remove brackets + $values = str_replace('[', '', $placeholder); + $values = str_replace(']', '', $values); + // get parameters + $values = explode(':', $values); + $id = $values[1]; + $width = isset($values[2]) ? $values[2] : 0; + $height = isset($values[3]) ? $values[3] : 0; + $mode = isset($values[4]) ? $values[4] : 'auto'; + return array($id, $width, $height, $mode); + } + +} diff --git a/server/plugins/graker/photoalbums/classes/MenuItemsProvider.php b/server/plugins/graker/photoalbums/classes/MenuItemsProvider.php new file mode 100644 index 0000000..7d09b8f --- /dev/null +++ b/server/plugins/graker/photoalbums/classes/MenuItemsProvider.php @@ -0,0 +1,349 @@ + 'graker.photoalbums::lang.plugin.all_photo_albums', + 'all-photos' => 'graker.photoalbums::lang.plugin.all_photos', + 'photo-album' => 'graker.photoalbums::lang.plugin.album', + ]; + } + + + /** + * + * Returns an array of info about menu item type + * + * @param string $type item name + * @return array + */ + public static function getMenuTypeInfo($type) { + switch ($type) { + case 'all-photo-albums' : + $result = self::getAllAlbumsInfo(); + break; + case 'all-photos' : + $result = self::getAllPhotosInfo(); + break; + case 'photo-album' : + $result = self::getSingleAlbumInfo(); + break; + default: + $result = []; + } + + return $result; + } + + + /** + * + * Returns information about a menu item + * + * @param string $type + * @param MenuItem $item + * @param string $url + * @param Theme $theme + * @return array + */ + public static function resolveMenuItem($type, $item, $url, $theme) { + $result = []; + + switch ($type) { + case 'all-photo-albums' : + $result = self::resolveAllAlbumsItem($item, $url, $theme); + break; + case 'all-photos' : + $result = self::resolveAllPhotosItem($item, $url, $theme); + break; + case 'photo-album' : + $result = self::resolveSingleAlbumItem($item, $url, $theme); + break; + default: + $result = []; + } + + return $result; + } + + + /** + * + * Generates url for the item to be resolved + * + * @param int $year - year number + * @param string $pageCode - page code to be used + * @param $theme + * @return string + */ + protected static function getUrl($year, $pageCode, $theme) { + $page = CmsPage::loadCached($theme, $pageCode); + if (!$page) return ''; + + $properties = $page->getComponentProperties('blogArchive'); + if (!isset($properties['yearParam'])) { + return ''; + } + + // get year url param and strip it of {{ : }} to get pure name + $paramName = str_replace(array('{', '}', ' ', ':'), '', $properties['yearParam']); + $url = CmsPage::url($page->getBaseFileName(), [$paramName => $year]); + + return $url; + } + + + /** + * + * Returns menu type info for all-photo-albums menu item + * + * @return array + */ + protected static function getAllAlbumsInfo() { + $result = ['dynamicItems' => TRUE,]; + $result['cmsPages'] = self::getCmsPages('photoAlbum'); + return $result; + } + + + /** + * + * Returns menu type info for all-photo-albums menu item + * + * @return array + */ + protected static function getSingleAlbumInfo() { + $result = [ + 'dynamicItems' => FALSE, + 'nesting' => FALSE, + ]; + $result['cmsPages'] = self::getCmsPages('photoAlbum'); + + $references = []; + $albums = Album::all(); + foreach ($albums as $album) { + $references[$album->id] = $album->title; + } + $result['references'] = $references; + + return $result; + } + + + /** + * + * Returns menu type info for all-photos menu item + * + * @return array + */ + protected static function getAllPhotosInfo() { + $result = ['dynamicItems' => true,]; + $result['cmsPages'] = self::getCmsPages('singlePhoto'); + return $result; + } + + + /** + * + * Return array of Cms pages having $component attached + * + * @param string $component + * @return array + */ + protected static function getCmsPages($component) { + $theme = Theme::getActiveTheme(); + + $pages = CmsPage::listInTheme($theme, true); + $cmsPages = []; + + foreach ($pages as $page) { + if (!$page->hasComponent($component)) { + continue; + } + + $cmsPages[] = $page; + } + + return $cmsPages; + } + + + /** + * + * Resolves All Albums menu item + * + * @param MenuItem $item + * @param string $url + * @param Theme $theme + * @return array + */ + protected static function resolveAllAlbumsItem($item, $url, $theme) { + $result = [ + 'items' => [], + ]; + + $albums = Album::all(); + foreach ($albums as $album) { + $albumItem = [ + 'title' => $album->title, + 'url' => self::getAlbumUrl($album, $item->cmsPage, $theme), + 'mtime' => $album->updated_at, + ]; + $albumItem['isActive'] = ($albumItem['url'] == $url); + $result['items'][] = $albumItem; + } + + return $result; + } + + + /** + * + * Resolves single Album menu item + * + * @param MenuItem $item + * @param string $url + * @param Theme $theme + * @return array + */ + protected static function resolveSingleAlbumItem($item, $url, $theme) { + $result = []; + + if (!$item->reference || !$item->cmsPage) { + return []; + } + + $album = Album::find($item->reference); + if (!$album) { + return []; + } + + $pageUrl = self::getAlbumUrl($album, $item->cmsPage, $theme); + if (!$pageUrl) { + return []; + } + $pageUrl = Url::to($pageUrl); + + $result['url'] = $pageUrl; + $result['isActive'] = ($pageUrl == $url); + $result['mtime'] = $album->updated_at; + + return $result; + } + + + /** + * + * Resolves All Photos menu item + * + * @param MenuItem $item + * @param string $url + * @param Theme $theme + * @return array + */ + protected static function resolveAllPhotosItem($item, $url, $theme) { + $result = [ + 'items' => [], + ]; + + $photos = Photo::all(); + foreach ($photos as $photo) { + $photoItem = [ + 'title' => $photo->title, + 'url' => self::getPhotoUrl($photo, $item->cmsPage, $theme), + 'mtime' => $photo->updated_at, + ]; + $photoItem['isActive'] = ($photoItem['url'] == $url); + $result['items'][] = $photoItem; + } + + return $result; + } + + + /** + * + * Generates url for album + * + * @param Album $album + * @param string $pageCode + * @param Theme $theme + * @return string + */ + protected static function getAlbumUrl($album, $pageCode, $theme) { + $page = CmsPage::loadCached($theme, $pageCode); + if (!$page) return ''; + + $properties = $page->getComponentProperties('photoAlbum'); + if (!isset($properties['slug'])) { + return ''; + } + + if (!preg_match('/^\{\{([^\}]+)\}\}$/', $properties['slug'], $matches)) { + return ''; + } + + $paramName = substr(trim($matches[1]), 1); + $params = [ + $paramName => $album->slug, + 'id' => $album->id, + ]; + $url = CmsPage::url($page->getBaseFileName(), $params); + + return $url; + } + + + /** + * + * Generates url for photo + * + * @param Photo $photo + * @param string $pageCode + * @param Theme $theme + * @return string + */ + protected static function getPhotoUrl($photo, $pageCode, $theme) { + $page = CmsPage::loadCached($theme, $pageCode); + if (!$page) return ''; + + $properties = $page->getComponentProperties('singlePhoto'); + if (!isset($properties['id'])) { + return ''; + } + + if (!preg_match('/^\{\{([^\}]+)\}\}$/', $properties['id'], $matches)) { + return ''; + } + + $paramName = substr(trim($matches[1]), 1); + $params = [ + $paramName => $photo->id, + 'album_slug' => $photo->album->slug, + ]; + $url = CmsPage::url($page->getBaseFileName(), $params); + + return $url; + } + +} diff --git a/server/plugins/graker/photoalbums/components/Album.php b/server/plugins/graker/photoalbums/components/Album.php new file mode 100644 index 0000000..6b0b98b --- /dev/null +++ b/server/plugins/graker/photoalbums/components/Album.php @@ -0,0 +1,186 @@ + 'graker.photoalbums::lang.plugin.album', + 'description' => 'graker.photoalbums::lang.components.album_description' + ]; + } + + /** + * @return array of component properties + */ + public function defineProperties() + { + return [ + 'slug' => [ + 'title' => 'graker.photoalbums::lang.plugin.slug_label', + 'description' => 'graker.photoalbums::lang.plugin.slug_description', + 'default' => '{{ :slug }}', + 'type' => 'string' + ], + 'photoPage' => [ + 'title' => 'graker.photoalbums::lang.components.photo_page_label', + 'description' => 'graker.photoalbums::lang.components.photo_page_description', + 'type' => 'dropdown', + 'default' => 'photoalbums/album/photo', + ], + 'thumbMode' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_mode_label', + 'description' => 'graker.photoalbums::lang.components.thumb_mode_description', + 'type' => 'dropdown', + 'default' => 'auto', + ], + 'thumbWidth' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_width_label', + 'description' => 'graker.photoalbums::lang.components.thumb_width_description', + 'default' => 640, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.thumb_width_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'thumbHeight' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_height_label', + 'description' => 'graker.photoalbums::lang.components.thumb_height_description', + 'default' => 480, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.thumbs_height_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'photosOnPage' => [ + 'title' => 'graker.photoalbums::lang.components.photos_on_page_label', + 'description' => 'graker.photoalbums::lang.components.photos_on_page_description', + 'default' => 12, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.photos_on_page_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + ]; + } + + /** + * + * Returns pages list for album page select box setting + * + * @return mixed + */ + public function getPhotoPageOptions() { + return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + + + /** + * + * Returns thumb resize mode options for thumb mode select box setting + * + * @return array + */ + public function getThumbModeOptions() { + return [ + 'auto' => 'Auto', + 'exact' => 'Exact', + 'portrait' => 'Portrait', + 'landscape' => 'Landscape', + 'crop' => 'Crop', + ]; + } + + + /** + * Get photo page number from query + */ + protected function setCurrentPage() { + if (isset($_GET['page'])) { + if (ctype_digit($_GET['page']) && ($_GET['page'] > 0)) { + $this->currentPage = $_GET['page']; + } else { + return FALSE; + } + } else { + $this->currentPage = 1; + } + return TRUE; + } + + + /** + * Loads album on onRun event + */ + public function onRun() { + if (!$this->setCurrentPage()) { + // if page parameter is invalid, redirect to the first page + return Redirect::to($this->currentPageUrl() . '?page=1'); + } + $this->album = $this->page->album = $this->loadAlbum(); + // if current page is greater than number of pages, redirect to the last page + // check for > 1 to avoid infinite redirect when there are no photos + if (($this->currentPage > 1) && ($this->currentPage > $this->lastPage)) { + return Redirect::to($this->currentPageUrl() . '?page=' . $this->lastPage); + } + } + + + /** + * + * Loads album model with it's photos + * + * @return AlbumModel + */ + protected function loadAlbum() { + $slug = $this->property('slug'); + $album = AlbumModel::where('slug', $slug) + ->with(['photos' => function ($query) { + $query->orderBy('created_at', 'desc'); + $query->with('image'); + $query->paginate($this->property('photosOnPage'), $this->currentPage); + }]) + ->first(); + + if ($album) { + //prepare photo urls and thumbs + foreach ($album->photos as $photo) { + $photo->url = $photo->setUrl($this->property('photoPage'), $this->controller); + $photo->thumb = $photo->image->getThumb( + $this->property('thumbWidth'), + $this->property('thumbHeight'), + ['mode' => $this->property('thumbMode')] + ); + } + //setup page numbers + $this->lastPage = ceil($album->photosCount / $this->property('photosOnPage')); + } + + return $album; + } + +} diff --git a/server/plugins/graker/photoalbums/components/AlbumList.php b/server/plugins/graker/photoalbums/components/AlbumList.php new file mode 100644 index 0000000..5d2efa5 --- /dev/null +++ b/server/plugins/graker/photoalbums/components/AlbumList.php @@ -0,0 +1,206 @@ + 'graker.photoalbums::lang.components.albums_list', + 'description' => 'graker.photoalbums::lang.components.albums_list_description' + ]; + } + + /** + * + * Define properties + * + * @return array of component properties + */ + public function defineProperties() + { + return [ + 'albumPage' => [ + 'title' => 'graker.photoalbums::lang.components.album_page_label', + 'description' => 'graker.photoalbums::lang.components.album_page_description', + 'type' => 'dropdown', + 'default' => 'photoalbums/album', + ], + 'thumbMode' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_mode_label', + 'description' => 'graker.photoalbums::lang.components.thumb_mode_description', + 'type' => 'dropdown', + 'default' => 'auto', + ], + 'thumbWidth' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_width_label', + 'description' => 'graker.photoalbums::lang.components.thumb_width_description', + 'default' => 640, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.thumb_width_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'thumbHeight' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_height_label', + 'description' => 'graker.photoalbums::lang.components.thumb_height_description', + 'default' => 480, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.thumb_height_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'albumsOnPage' => [ + 'title' => 'graker.photoalbums::lang.components.albums_on_page_label', + 'description' => 'graker.photoalbums::lang.components.albums_on_page_description', + 'default' => 12, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.albums_on_page_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + ]; + } + + + /** + * + * Returns pages list for album page select box setting + * + * @return mixed + */ + public function getAlbumPageOptions() { + return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + + + /** + * + * Returns thumb resize mode options for thumb mode select box setting + * + * @return array + */ + public function getThumbModeOptions() { + return [ + 'auto' => 'Auto', + 'exact' => 'Exact', + 'portrait' => 'Portrait', + 'landscape' => 'Landscape', + 'crop' => 'Crop', + ]; + } + + + /** + * Get photo page number from query + */ + protected function setCurrentPage() { + if (isset($_GET['page'])) { + if (ctype_digit($_GET['page']) && ($_GET['page'] > 0)) { + $this->currentPage = $_GET['page']; + } else { + return FALSE; + } + } else { + $this->currentPage = 1; + } + return TRUE; + } + + + /** + * OnRun implementation + * Setup pager + * Load albums + */ + public function onRun() { + if (!$this->setCurrentPage()) { + return Redirect::to($this->currentPageUrl() . '?page=1'); + } + $this->albums = $this->loadAlbums(); + $this->prepareAlbums(); + + $this->lastPage = $this->albums->lastPage(); + // if current page is greater than number of pages, redirect to the last page + // only if lastPage > 0 to avoid redirect loop when there are no elements + if ($this->lastPage && ($this->currentPage > $this->lastPage)) { + return Redirect::to($this->currentPageUrl() . '?page=' . $this->lastPage); + } + } + + + /** + * + * Returns array of site's albums to be used in component + * Albums are sorted by created date desc, each one loaded with one latest photo (or photo set to be front) + * Empty albums won't be displayed + * + * @return array + */ + protected function loadAlbums() { + $albums = AlbumModel::orderBy('created_at', 'desc') + ->has('photos') + ->with(['latestPhoto' => function ($query) { + $query->with('image'); + }]) + ->with(['front' => function ($query) { + $query->with('image'); + }]) + ->with('photosCount') + ->paginate($this->property('albumsOnPage'), $this->currentPage); + + return $albums; + } + + + /** + * + * Prepares array of album models to be displayed: + * - set up album urls + * - set up photo counts + * - set up album thumb + */ + protected function prepareAlbums() { + //set up photo count and url + foreach ($this->albums as $album) { + $album->photo_count = $album->photosCount; + $album->url = $album->setUrl($this->property('albumPage'), $this->controller); + + // prepare thumb from $album->front if it is set or from latestPhoto otherwise + $image = ($album->front) ? $album->front->image : $album->latestPhoto->image; + $album->latestPhoto->thumb = $image->getThumb( + $this->property('thumbWidth'), + $this->property('thumbHeight'), + ['mode' => $this->property('thumbMode')] + ); + } + } + +} diff --git a/server/plugins/graker/photoalbums/components/Photo.php b/server/plugins/graker/photoalbums/components/Photo.php new file mode 100644 index 0000000..5ee7c2d --- /dev/null +++ b/server/plugins/graker/photoalbums/components/Photo.php @@ -0,0 +1,112 @@ + 'graker.photoalbums::lang.plugin.photo', + 'description' => 'graker.photoalbums::lang.components.photo_description' + ]; + } + + /** + * + * Properties of component + * + * @return array + */ + public function defineProperties() + { + return [ + 'id' => [ + 'title' => 'graker.photoalbums::lang.components.id_label', + 'description' => 'graker.photoalbums::lang.components.id_description', + 'default' => '{{ :id }}', + 'type' => 'string' + ], + 'albumPage' => [ + 'title' => 'graker.photoalbums::lang.components.album_page_label', + 'description' => 'graker.photoalbums::lang.components.album_page_description', + 'type' => 'dropdown', + 'default' => 'photoalbums/album', + ], + 'photoPage' => [ + 'title' => 'graker.photoalbums::lang.components.photo_page_label', + 'description' => 'graker.photoalbums::lang.components.photo_page_description', + 'type' => 'dropdown', + 'default' => 'photoalbums/album/photo', + ], + ]; + } + + + /** + * + * Returns pages list for album page select box setting + * + * @return mixed + */ + public function getAlbumPageOptions() { + return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + + + /** + * + * Returns pages list for photo page select box setting + * + * @return mixed + */ + public function getPhotoPageOptions() { + return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + + + /** + * Loads photo on onRun event + */ + public function onRun() { + $this->photo = $this->page->photo = $this->loadPhoto(); + } + + + /** + * + * Loads photo to be displayed in this component + * + * @return PhotoModel + */ + protected function loadPhoto() { + $id = $this->property('id'); + $photo = PhotoModel::where('id', $id) + ->with('image') + ->with('album') + ->first(); + + if ($photo) { + // set url so we can have back link to the parent album + $photo->album->url = $photo->album->setUrl($this->property('albumPage'), $this->controller); + + //set next and previous photos + $photo->next = $photo->nextPhoto(); + if ($photo->next) { + $photo->next->url = $photo->next->setUrl($this->property('photoPage'), $this->controller); + } + $photo->previous = $photo->previousPhoto(); + if ($photo->previous) { + $photo->previous->url = $photo->previous->setUrl($this->property('photoPage'), $this->controller); + } + } + + return $photo; + } + +} diff --git a/server/plugins/graker/photoalbums/components/RandomPhotos.php b/server/plugins/graker/photoalbums/components/RandomPhotos.php new file mode 100644 index 0000000..7336df8 --- /dev/null +++ b/server/plugins/graker/photoalbums/components/RandomPhotos.php @@ -0,0 +1,171 @@ + 'graker.photoalbums::lang.components.random_photos', + 'description' => 'graker.photoalbums::lang.components.random_photos_description', + ]; + } + + public function defineProperties() + { + return [ + 'photosCount' => [ + 'title' => 'graker.photoalbums::lang.components.photos_count_label', + 'description' => 'graker.photoalbums::lang.components.photos_count_description', + 'default' => 5, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.photos_count_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'cacheLifetime' => [ + 'title' => 'graker.photoalbums::lang.components.cache_lifetime_label', + 'description' => 'graker.photoalbums::lang.components.cache_lifetime_description', + 'default' => 0, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.cache_lifetime_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'thumbMode' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_mode_label', + 'description' => 'graker.photoalbums::lang.components.thumb_mode_description', + 'type' => 'dropdown', + 'default' => 'auto', + ], + 'thumbWidth' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_width_label', + 'description' => 'graker.photoalbums::lang.components.thumb_width_description', + 'default' => 640, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.thumb_width_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'thumbHeight' => [ + 'title' => 'graker.photoalbums::lang.components.thumb_height_label', + 'description' => 'graker.photoalbums::lang.components.thumb_height_description', + 'default' => 480, + 'type' => 'string', + 'validationMessage' => 'graker.photoalbums::lang.errors.thumb_height_error', + 'validationPattern' => '^[0-9]+$', + 'required' => FALSE, + ], + 'photoPage' => [ + 'title' => 'graker.photoalbums::lang.components.photo_page_label', + 'description' => 'graker.photoalbums::lang.components.photo_page_description', + 'type' => 'dropdown', + 'default' => 'blog/post', + ], + ]; + } + + + /** + * + * Returns pages list for album page select box setting + * + * @return mixed + */ + public function getPhotoPageOptions() { + return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + } + + + /** + * + * Returns thumb resize mode options for thumb mode select box setting + * + * @return array + */ + public function getThumbModeOptions() { + return [ + 'auto' => 'Auto', + 'exact' => 'Exact', + 'portrait' => 'Portrait', + 'landscape' => 'Landscape', + 'crop' => 'Crop', + ]; + } + + + /** + * + * Returns an array of photosCount random photos + * Array is returned if from Cache, Collection otherwise + * + * @return array|Collection + */ + public function photos() { + $photos = []; + if ($this->property('cacheLifetime')) { + $photos = Cache::get('photoalbums_random_photos'); + } + + if (empty($photos)) { + $photos = $this->getPhotos(); + } + + return $photos; + } + + + /** + * + * Returns a collection of random photos + * Works for MySQL and Sqlite, for other drivers returns non-random selection + * + * @return Collection + */ + protected function getPhotos() { + $count = $this->property('photosCount'); + if (DB::connection()->getDriverName() == 'mysql') { + $photos = PhotoModel::orderBy(DB::raw('RAND()')); + } else if (DB::connection()->getDriverName() == 'sqlite') { + $photos = PhotoModel::orderBy(DB::raw('RANDOM()')); + } else { + $photos = PhotoModel::orderBy('id'); + } + $photos = $photos->with('image')->take($count)->get(); + + foreach ($photos as $photo) { + $photo->url = $photo->setUrl($this->property('photoPage'), $this->controller); + $photo->thumb = $photo->image->getThumb( + $this->property('thumbWidth'), + $this->property('thumbHeight'), + ['mode' => $this->property('thumbMode')] + ); + } + + $this->cachePhotos($photos); + + return $photos; + } + + + /** + * + * Cache photos if caching is enabled + * + * @param Collection $photos + */ + protected function cachePhotos($photos) { + $cache = $this->property('cacheLifetime'); + if ($cache) { + Cache::put('photoalbums_random_photos', $photos->toArray(), $cache); + } + } + +} diff --git a/server/plugins/graker/photoalbums/components/album/default.htm b/server/plugins/graker/photoalbums/components/album/default.htm new file mode 100644 index 0000000..6c50fb7 --- /dev/null +++ b/server/plugins/graker/photoalbums/components/album/default.htm @@ -0,0 +1,46 @@ +{% set album = __SELF__.album %} + +

{{ album.title }}

+ +{% if album.description %} +
+
+ {{ album.description|raw }} +
+
+{% endif %} + +
+ {% for photo in album.photos %} + + {% else %} +
Album doesn't have any photos yet
+ {% endfor %} +
+ +{% if __SELF__.lastPage > 1 %} +
    + {% if __SELF__.currentPage > 1 %} +
  • ← Prev
  • + {% endif %} + + {% for page in 1..__SELF__.lastPage %} +
  • + {{ page }} +
  • + {% endfor %} + + {% if __SELF__.lastPage > __SELF__.currentPage %} +
  • Next →
  • + {% endif %} +
+{% endif %} diff --git a/server/plugins/graker/photoalbums/components/albumlist/default.htm b/server/plugins/graker/photoalbums/components/albumlist/default.htm new file mode 100644 index 0000000..96bdadf --- /dev/null +++ b/server/plugins/graker/photoalbums/components/albumlist/default.htm @@ -0,0 +1,35 @@ +
+ {% for album in __SELF__.albums %} +
+

{{ album.title }}

+ + + + Created on {{ album.created_at|date('M d, Y') }} + {{ album.photo_count }} images +
+ {% else %} +
You have not created any albums yet
+ {% endfor %} +
+ +{% if __SELF__.lastPage > 1 %} +
    + {% if __SELF__.currentPage > 1 %} +
  • ← Prev
  • + {% endif %} + + {% for page in 1..__SELF__.lastPage %} +
  • + {{ page }} +
  • + {% endfor %} + + {% if __SELF__.lastPage > __SELF__.currentPage %} +
  • Next →
  • + {% endif %} +
+{% endif %} diff --git a/server/plugins/graker/photoalbums/components/photo/default.htm b/server/plugins/graker/photoalbums/components/photo/default.htm new file mode 100644 index 0000000..c50d973 --- /dev/null +++ b/server/plugins/graker/photoalbums/components/photo/default.htm @@ -0,0 +1,36 @@ +{% set photo = __SELF__.photo %} + +{% if photo.title %} +

{{ photo.title }}

+{% endif %} +
+
+ {{ photo.title }} +
+
+
+
+ {{ photo.created_at|date('Y/m/d') }} + {{ photo.album.title }} + {% if photo.description %} + {{ photo.description | raw }} + {% endif %} +
+
+ {% if photo.previous %} + Previous photo + {% else %} + Previous photo + {% endif %} + {% if photo.next %} + Next photo + {% else %} + Next photo + {% endif %} +
+
diff --git a/server/plugins/graker/photoalbums/components/randomphotos/default.htm b/server/plugins/graker/photoalbums/components/randomphotos/default.htm new file mode 100644 index 0000000..80ea007 --- /dev/null +++ b/server/plugins/graker/photoalbums/components/randomphotos/default.htm @@ -0,0 +1,12 @@ +
+ {% for photo in __SELF__.photos() %} +
+ + {% if photo.title %} + {{ photo.title }} + {% endif %} +
+ {% else %} + You have not created any photos + {% endfor %} +
diff --git a/server/plugins/graker/photoalbums/controllers/Albums.php b/server/plugins/graker/photoalbums/controllers/Albums.php new file mode 100644 index 0000000..aa598e4 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/Albums.php @@ -0,0 +1,95 @@ +album_id != $album->id) { + // attempt to use other album's photo + throw new ApplicationException(Lang::get('graker.photoalbums::lang.errors.not_this_album')); + } + } catch (Exception $e) { + return Response::json($e->getMessage(), 400); + } + + // set front id + $album->front_id = $photo->id; + $album->save(); + + $this->initRelation($album, 'photos'); + return $this->relationRefresh('photos'); + } + + + /** + * + * Returns path to reorder current album + * + * @return string + */ + protected function getReorderPath() { + if (!isset($this->vars['formModel']->id)) { + return ''; + } + + $uri = \Backend::url('graker/photoalbums/reorder/album/' . $this->vars['formModel']->id); + return $uri; + } + +} diff --git a/server/plugins/graker/photoalbums/controllers/Photos.php b/server/plugins/graker/photoalbums/controllers/Photos.php new file mode 100644 index 0000000..eadb3d1 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/Photos.php @@ -0,0 +1,25 @@ +model = $album; + $this->addJs('/modules/backend/behaviors/reordercontroller/assets/js/october.reorder.js', 'core'); + + $this->pageTitle = Lang::get('graker.photoalbums::lang.plugin.reorder_title', ['name' => $album->title]); + + return $this->makePartial('reorder', ['reorderRecords' => $this->model->photos,]); + } + + + /** + * Callback to save reorder information + * Calls function from Sortable trait on the model + */ + public function onReorder() { + if (!$ids = post('record_ids')) return; + if (!$orders = post('sort_orders')) return; + + $model = new Photo(); + $model->setSortableOrder($ids, $orders); + } + + + /** + * Reorder constructor + */ + public function __construct() + { + parent::__construct(); + + BackendMenu::setContext('Graker.PhotoAlbums', 'photoalbums', 'albums'); + } + +} diff --git a/server/plugins/graker/photoalbums/controllers/Upload.php b/server/plugins/graker/photoalbums/controllers/Upload.php new file mode 100644 index 0000000..c5e2de7 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/Upload.php @@ -0,0 +1,147 @@ +pageTitle = Lang::get('graker.photoalbums::lang.plugin.upload_photos'); + $this->addJs('/modules/backend/assets/vendor/dropzone/dropzone.js'); + $this->addJs('/plugins/graker/photoalbums/assets/js/upload.js'); + $this->addCss('/plugins/graker/photoalbums/assets/css/dropzone.css'); + return $this->makePartial('form'); + } + + + /** + * File upload controller + */ + public function post_files() { + try { + if (!Input::hasFile('file')) { + throw new ApplicationException(Lang::get('graker.photoalbums::lang.errors.no_file')); + } + + $upload = Input::file('file'); + + $validationRules = ['max:' . File::getMaxFilesize()]; + + $validation = Validator::make( + ['file' => $upload], + ['file' => $validationRules] + ); + if ($validation->fails()) { + throw new ValidationException($validation); + } + if (!$upload->isValid()) { + throw new ApplicationException(Lang::get('graker.photoalbums::lang.errors.invalid_file', ['name' => $upload->getClientOriginalName()])); + } + + $file = new File; + $file->data = $upload; + $file->is_public = true; + $file->save(); + return Response::json(['id' => $file->id], 200); + } catch (Exception $e) { + return Response::json($e->getMessage(), 400); + } + } + + + /** + * Form save callback + */ + public function onSave() { + $input = Input::all(); + + $album = AlbumModel::find($input['album']); + if ($album && !empty($input['file-id'])) { + $this->savePhotos($album, $input['file-id'], $input['file-title']); + Flash::success(Lang::get('graker.photoalbums::lang.messages.photos_saved')); + return Redirect::to(Backend::url('graker/photoalbums/albums/update/' . $album->id)); + } + + Flash::error(Lang::get('graker.photoalbums::lang.errors.album_not_found')); + return Redirect::to(Backend::url('graker/photoalbums/albums')); + } + + + /** + * File remove callback + */ + public function onFileRemove() { + if (Input::has('file_id')) { + $file_id = Input::get('file_id'); + $file = File::find($file_id); + if ($file) { + $file->delete(); + } + } + } + + + /** + * + * Saves photos with files attached from $file_ids and attaches them to album + * + * @param AlbumModel $album + * @param array $file_ids + * @param string[] $file_titles arrray of titles + */ + protected function savePhotos($album, $file_ids, $file_titles) { + $files = File::whereIn('id', $file_ids)->get(); + $photos = array(); + foreach ($files as $file) { + $photo = new PhotoModel(); + $photo->title = isset($file_titles[$file->id]) ? $file_titles[$file->id] : ''; + $photo->save(); + $photo->image()->save($file); + $photos[] = $photo; + } + $album->photos()->saveMany($photos); + } + + + /** + * @return array of [album id => album title] to use in select list + */ + protected function getAlbumsList() { + $albums = AlbumModel::orderBy('created_at', 'desc')->get(); + $options = []; + + foreach ($albums as $album) { + $options[$album->id] = $album->title; + } + + return $options; + } + + + public function __construct() + { + parent::__construct(); + + BackendMenu::setContext('Graker.PhotoAlbums', 'photoalbums', 'upload'); + } +} diff --git a/server/plugins/graker/photoalbums/controllers/albums/_list_toolbar.htm b/server/plugins/graker/photoalbums/controllers/albums/_list_toolbar.htm new file mode 100644 index 0000000..b6c0259 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/_list_toolbar.htm @@ -0,0 +1,7 @@ +
+ + + +
\ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/albums/_relation_toolbar.htm b/server/plugins/graker/photoalbums/controllers/albums/_relation_toolbar.htm new file mode 100644 index 0000000..9a0dfc2 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/_relation_toolbar.htm @@ -0,0 +1,53 @@ +
+ + trans($relationLabel)])) ?> + + + + + + + + + + +
diff --git a/server/plugins/graker/photoalbums/controllers/albums/config_form.yaml b/server/plugins/graker/photoalbums/controllers/albums/config_form.yaml new file mode 100644 index 0000000..103bd0f --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/config_form.yaml @@ -0,0 +1,31 @@ +# =================================== +# Form Behavior Config +# =================================== + +# Record name +name: graker.photoalbums::lang.plugin.album + +# Model Form Field configuration +form: $/graker/photoalbums/models/album/fields.yaml + +# Model Class name +modelClass: Graker\Photoalbums\Models\Album + +# Default redirect location +defaultRedirect: graker/photoalbums/albums + +# Create page +create: + title: graker.photoalbums::lang.plugin.create_album + redirect: graker/photoalbums/albums/update/:id + redirectClose: graker/photoalbums/albums + +# Update page +update: + title: graker.photoalbums::lang.plugin.edit_album + redirect: graker/photoalbums/albums + redirectClose: graker/photoalbums/albums + +# Preview page +preview: + title: graker.photoalbums::lang.plugin.preview_album \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/albums/config_list.yaml b/server/plugins/graker/photoalbums/controllers/albums/config_list.yaml new file mode 100644 index 0000000..efee31b --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/config_list.yaml @@ -0,0 +1,44 @@ +# =================================== +# List Behavior Config +# =================================== + +# Model List Column configuration +list: $/graker/photoalbums/models/album/columns.yaml + +# Model Class name +modelClass: Graker\Photoalbums\Models\Album + +# List Title +title: graker.photoalbums::lang.plugin.list_title + +# Link URL for each record +recordUrl: graker/photoalbums/albums/update/:id + +# Message to display if the list is empty +noRecordsMessage: backend::lang.list.no_records + +# Records to display per page +recordsPerPage: 20 + +# Displays the list column set up button +showSetup: true + +# Displays the sorting link on each column +showSorting: true + +# Default sorting column +# defaultSort: +# column: created_at +# direction: desc + +# Display checkboxes next to each record +# showCheckboxes: true + +# Toolbar widget configuration +toolbar: + # Partial for toolbar buttons + buttons: list_toolbar + + # Search widget configuration + search: + prompt: backend::lang.list.search_prompt diff --git a/server/plugins/graker/photoalbums/controllers/albums/config_relation.yaml b/server/plugins/graker/photoalbums/controllers/albums/config_relation.yaml new file mode 100644 index 0000000..fc2220e --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/config_relation.yaml @@ -0,0 +1,12 @@ +# =================================== +# Relation Behavior Config +# =================================== + +photos: + label: graker.photoalbums::lang.plugin.photo + manage: + form: $/graker/photoalbums/models/photo/fields.yaml + list: $/graker/photoalbums/models/photo/columns.yaml + view: + list: $/graker/photoalbums/models/photo/columns.yaml + toolbarPartial: relation_toolbar diff --git a/server/plugins/graker/photoalbums/controllers/albums/create.htm b/server/plugins/graker/photoalbums/controllers/albums/create.htm new file mode 100644 index 0000000..b551341 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/create.htm @@ -0,0 +1,52 @@ + +
    +
  • +
  • pageTitle) ?>
  • +
+ + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+ relationRender('photos') ?> +
+ +
+
+ + + + + +
+
+ + + + + +

fatalError) ?>

+

+ + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/albums/index.htm b/server/plugins/graker/photoalbums/controllers/albums/index.htm new file mode 100644 index 0000000..766877d --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/index.htm @@ -0,0 +1,2 @@ + +listRender() ?> diff --git a/server/plugins/graker/photoalbums/controllers/albums/preview.htm b/server/plugins/graker/photoalbums/controllers/albums/preview.htm new file mode 100644 index 0000000..3e8a61f --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/preview.htm @@ -0,0 +1,19 @@ + +
    +
  • +
  • pageTitle) ?>
  • +
+ + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + + +

fatalError) ?>

+

+ + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/albums/update.htm b/server/plugins/graker/photoalbums/controllers/albums/update.htm new file mode 100644 index 0000000..48bb5e5 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/albums/update.htm @@ -0,0 +1,60 @@ + +
    +
  • +
  • pageTitle) ?>
  • +
+ + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+ relationRender('photos') ?> +
+ +
+
+ + + + + + +
+
+ + + + + +

fatalError) ?>

+

+ + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/photos/_list_toolbar.htm b/server/plugins/graker/photoalbums/controllers/photos/_list_toolbar.htm new file mode 100644 index 0000000..5c3952a --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/_list_toolbar.htm @@ -0,0 +1,7 @@ +
+ + + +
\ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/photos/config_form.yaml b/server/plugins/graker/photoalbums/controllers/photos/config_form.yaml new file mode 100644 index 0000000..c0d4c5f --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/config_form.yaml @@ -0,0 +1,31 @@ +# =================================== +# Form Behavior Config +# =================================== + +# Record name +name: graker.photoalbums::lang.plugin.photo + +# Model Form Field configuration +form: $/graker/photoalbums/models/photo/fields.yaml + +# Model Class name +modelClass: Graker\PhotoAlbums\Models\Photo + +# Default redirect location +defaultRedirect: graker/photoalbums/photos + +# Create page +create: + title: graker.photoalbums::lang.plugin.create_photo + redirect: graker/photoalbums/photos/update/:id + redirectClose: graker/photoalbums/photos + +# Update page +update: + title: graker.photoalbums::lang.plugin.edit_photo + redirect: graker/photoalbums/photos + redirectClose: graker/photoalbums/photos + +# Preview page +preview: + title: graker.photoalbums::lang.plugin.preview_photo \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/photos/config_list.yaml b/server/plugins/graker/photoalbums/controllers/photos/config_list.yaml new file mode 100644 index 0000000..10dc71d --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/config_list.yaml @@ -0,0 +1,36 @@ +# =================================== +# List Behavior Config +# =================================== + +# Model List Column configuration +list: $/graker/photoalbums/models/photo/columns.yaml + +# Model Class name +modelClass: Graker\PhotoAlbums\Models\Photo + +# List Title +title: graker.photoalbums::lang.plugin.manage_photos + +# Link URL for each record +recordUrl: graker/photoalbums/photos/update/:id + +# Message to display if the list is empty +noRecordsMessage: backend::lang.list.no_records + +# Records to display per page +recordsPerPage: 20 + +# Displays the list column set up button +showSetup: true + +# Displays the sorting link on each column +showSorting: true + +# Toolbar widget configuration +toolbar: + # Partial for toolbar buttons + buttons: list_toolbar + + # Search widget configuration + search: + prompt: backend::lang.list.search_prompt diff --git a/server/plugins/graker/photoalbums/controllers/photos/create.htm b/server/plugins/graker/photoalbums/controllers/photos/create.htm new file mode 100644 index 0000000..2552f54 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/create.htm @@ -0,0 +1,48 @@ + +
    +
  • +
  • pageTitle) ?>
  • +
+ + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + + +

fatalError) ?>

+

+ + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/photos/index.htm b/server/plugins/graker/photoalbums/controllers/photos/index.htm new file mode 100644 index 0000000..766877d --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/index.htm @@ -0,0 +1,2 @@ + +listRender() ?> diff --git a/server/plugins/graker/photoalbums/controllers/photos/preview.htm b/server/plugins/graker/photoalbums/controllers/photos/preview.htm new file mode 100644 index 0000000..ef07d97 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/preview.htm @@ -0,0 +1,19 @@ + +
    +
  • +
  • pageTitle) ?>
  • +
+ + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + + +

fatalError) ?>

+

+ + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/photos/update.htm b/server/plugins/graker/photoalbums/controllers/photos/update.htm new file mode 100644 index 0000000..2a77e41 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/photos/update.htm @@ -0,0 +1,56 @@ + +
    +
  • +
  • pageTitle) ?>
  • +
+ + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + +
+
+ + + + + +

fatalError) ?>

+

+ + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/reorder/_records.htm b/server/plugins/graker/photoalbums/controllers/reorder/_records.htm new file mode 100644 index 0000000..02e57ed --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/reorder/_records.htm @@ -0,0 +1,11 @@ + + +
  • +
    + + title ?> + +
    +
  • + + diff --git a/server/plugins/graker/photoalbums/controllers/reorder/_reorder.htm b/server/plugins/graker/photoalbums/controllers/reorder/_reorder.htm new file mode 100644 index 0000000..10d19b5 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/reorder/_reorder.htm @@ -0,0 +1,36 @@ + + + + +fatalError): ?> + + +
    + +
      + makePartial('records', ['records' => $reorderRecords]) ?> +
    + +

    + +
    + + + + + +

    fatalError) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/controllers/upload/_form.htm b/server/plugins/graker/photoalbums/controllers/upload/_form.htm new file mode 100644 index 0000000..22d53b0 --- /dev/null +++ b/server/plugins/graker/photoalbums/controllers/upload/_form.htm @@ -0,0 +1,51 @@ + +
      +
    • +
    • +
    + + +fatalError): ?> + TRUE, 'class' => 'layout',]) ?> +
    +
    + + getAlbumsList()) ?> +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + + + +
    +
    + + + + + +

    fatalError) ?>

    +

    + + diff --git a/server/plugins/graker/photoalbums/lang/en/lang.php b/server/plugins/graker/photoalbums/lang/en/lang.php new file mode 100644 index 0000000..a19d0ed --- /dev/null +++ b/server/plugins/graker/photoalbums/lang/en/lang.php @@ -0,0 +1,111 @@ + [ + 'name' => 'Photo Albums', + 'description' => 'Create, display and manage galleries of photos arranged in albums.', + 'settings_description' => 'Photo Albums plugin settings', + 'tab' => 'Photo Albums', + 'manage_albums' => 'Manage photo albums', + 'access_permission' => 'Access Settings', + 'upload_photos' => 'Upload photos', + 'new_album' => 'New album', + 'create_album' => 'Create album', + 'edit_album' => 'Edit album', + 'preview_album' => 'Preview album', + 'creating_album' => 'Creating album...', + 'saving_album' => 'Saving album...', + 'deleting_album' => 'Deleting album...', + 'list_title' => 'Manage albums', + 'album' => 'Album', + 'albums' => 'Albums', + 'manage_photos' => 'Manage photos', + 'new_photo' => 'New photo', + 'create_photo' => 'Create photo', + 'edit_photo' => 'Edit photo', + 'preview_photo' => 'Preview photo', + 'creating_photo' => 'Creating photo...', + 'saving_photo' => 'Saving photo...', + 'deleting_photo' => 'Deleting photo...', + 'photo' => 'Photo', + 'photos' => 'Photos', + 'photo_description' => 'Description', + 'set_front_button' => 'Set as front', + 'reorder_button' => 'Reorder photos', + 'bool_positive' => 'Yes', + 'reorder_title' => 'Reorder album :name', + 'reorder' => 'Reorder', + 'saving_upload' => 'Saving upload...', + 'upload_photos_title' => 'Upload multiple photos', + 'album_to_upload' => 'Album to upload to', + 'save_upload' => 'Save upload', + 'title_label' => 'Title', + 'title_placeholder_album' => 'Album title', + 'title_placeholder_photo' => 'Photo title', + 'created_label' => 'Created', + 'updated_label' => 'Updated', + 'slug_label' => 'Slug', + 'slug_description' => 'URL slug parameter', + 'slug_placeholder_album' => 'album-title', + 'description_label' => 'Description', + 'front_label' => 'Front', + 'code_label' => 'Code', + 'code_description' => 'Type in default markdown to use for photo insert. There are two placeholders: %id% and %title%, they will be replaced with photo id and photo title automatically.', + 'selecting_photo' => 'Selecting photo', + 'insert' => 'Insert', + 'not_selected' => 'Not selected', + 'back_to_albums' => 'Back to albums', + 'all_photo_albums' => 'All Photo Albums', + 'all_photos' => 'All Photos', + ], + 'errors' => [ + 'album_not_found' => 'Album not found!', + 'cant_find_selected' => 'Can\'t find selected photo!', + 'not_this_album' => 'Selected photo doesn\'t belong to this album!', + 'return_to_albums' => 'Return to albums list', + 'return_to_photos' => 'Return to photos list', + 'no_file' => 'No file in request', + 'invalid_file' => 'File :name is not valid.', + 'thumb_width_error' => 'Thumb width must be a number', + 'thumb_height_error' => 'Thumb height must be a number', + 'photos_on_page_error' => 'Photos on page value must be a number', + 'albums_on_page_error' => 'Albums on page value must be a number', + 'photos_count_error' => 'Photos count must be a number', + 'cache_lifetime_error' => 'Cache lifetime must be a number', + 'no_albums' => 'You don\'t have any albums yet.', + ], + 'messages' => [ + 'set_front' => 'Are you sure to set this photo as front for the album?', + 'delete' => 'Do you really want to delete this album?', + 'delete_photo' => 'Do you really want to delete this photo?', + 'photos_saved' => 'Photos are saved!', + ], + 'components' => [ + 'photo_description' => 'Single photo component', + 'album_description' => 'Component to output one photo album with all its photos.', + 'photo_page_label' => 'Photo page', + 'photo_page_description' => 'Page used to display a single photo', + 'thumb_mode_label' => 'Thumb mode', + 'thumb_mode_description' => 'Mode of thumb generation', + 'thumb_width_label' => 'Thumb width', + 'thumb_width_description' => 'Width of the thumb to be generated', + 'thumb_height_label' => 'Thumb height', + 'thumb_height_description' => 'Height of the thumb to be generated', + 'photos_on_page_label' => 'Photos on page', + 'photos_on_page_description' => 'Amount of photos on one page (to use in pagination)', + 'albums_on_page_label' => 'Albums on page', + 'albums_on_page_description' => 'Amount of albums on one page (to use in pagination)', + 'albums_list' => 'Albums list', + 'albums_list_description' => 'Lists all photo albums on site', + 'album_page_label' => 'Album page', + 'album_page_description' => 'Page used to display photo albums', + 'id_label' => 'ID', + 'id_description' => 'Photo id parameter', + 'random_photos' => 'Random Photos', + 'random_photos_description' => 'Output predefined number of random photos', + 'photos_count_label' => 'Photos to output', + 'photos_count_description' => 'Amount of random photos to output', + 'cache_lifetime_label' => 'Cache lifetime', + 'cache_lifetime_description' => 'Number of minutes selected photos are stored in cache. 0 for no caching.', + ], +]; diff --git a/server/plugins/graker/photoalbums/models/Album.php b/server/plugins/graker/photoalbums/models/Album.php new file mode 100644 index 0000000..00ef6ab --- /dev/null +++ b/server/plugins/graker/photoalbums/models/Album.php @@ -0,0 +1,119 @@ + 'required', + 'slug' => ['required', 'regex:/^[a-z0-9\/\:_\-\*\[\]\+\?\|]*$/i', 'unique:graker_photoalbums_albums'], + ]; + + /** + * @var array Relations + */ + public $hasMany = [ + 'photos' => [ + 'Graker\PhotoAlbums\Models\Photo', + 'order' => 'sort_order desc', + ] + ]; + public $belongsTo = [ + 'user' => ['Backend\Models\User'], + 'front' => ['Graker\PhotoAlbums\Models\Photo'], + ]; + + + /** + * + * This relation allows us to eager-load 1 latest photo per album + * + * @return mixed + */ + public function latestPhoto() { + return $this->hasOne('Graker\PhotoAlbums\Models\Photo')->latest(); + } + + + /** + * + * This relation allows us to count photos + * + * @return mixed + */ + public function photosCount() { + return $this->hasOne('Graker\PhotoAlbums\Models\Photo') + ->selectRaw('album_id, count(*) as aggregate') + ->orderBy('album_id') + ->groupBy('album_id'); + } + + + /** + * + * Getter for photos count + * + * @return int + */ + public function getPhotosCountAttribute() { + // if relation is not loaded already, let's do it first + if (!array_key_exists('photosCount', $this->relations)) { + $this->load('photosCount'); + } + $related = $this->getRelation('photosCount'); + + return ($related) ? (int) $related->aggregate : 0; + } + + + /** + * + * Returns image file of photo set as album front or image in the latest photo of the album + * + * @return File + */ + public function getImage() { + if ($this->front) { + return $this->front->image; + } + + if ($this->latestPhoto) { + return $this->latestPhoto->image; + } + + return NULL; + } + + + /** + * + * Sets and returns url for this model using provided page name and controller + * For now we expose just id and slug for URL parameters + * + * @param string $pageName + * @param CMS\Classes\Controller $controller + * @return string + */ + public function setUrl($pageName, $controller) { + $params = [ + 'id' => $this->id, + 'slug' => $this->slug, + ]; + + return $this->url = $controller->pageUrl($pageName, $params); + } + +} diff --git a/server/plugins/graker/photoalbums/models/Photo.php b/server/plugins/graker/photoalbums/models/Photo.php new file mode 100644 index 0000000..95e4ff8 --- /dev/null +++ b/server/plugins/graker/photoalbums/models/Photo.php @@ -0,0 +1,122 @@ + 'required', + ]; + + /** + * @var array of fillable fields to use in mass assignment + */ + protected $fillable = [ + 'title', 'description', + ]; + + /** + * @var array Relations + */ + public $belongsTo = [ + 'user' => ['Backend\Models\User'], + 'album' => ['Graker\PhotoAlbums\Models\Album'], + ]; + public $attachOne = [ + 'image' => ['System\Models\File'], + ]; + + + /** + * + * Returns next photo or NULL if this is the last in the album + * + * @return Photo + */ + public function nextPhoto() { + $next = NULL; + $current_found = FALSE; + + foreach ($this->album->photos as $photo) { + if ($current_found) { + // previous iteration was current photo, so we found the next one + $next = $photo; + break; + } + if ($photo->id == $this->id) { + $current_found = TRUE; + } + } + + return $next; + } + + + /** + * + * Returns previous photo or NULL if this is the first in the album + * + * @return Photo + */ + public function previousPhoto() { + $previous = NULL; + + foreach ($this->album->photos as $photo) { + if ($photo->id == $this->id) { + // found current photo + break; + } else { + $previous = $photo; + } + } + + return $previous; + } + + + /** + * + * Sets and returns url for this model using provided page name and controller + * For now we expose photo id and album's slug + * + * @param string $pageName + * @param CMS\Classes\Controller $controller + * @return string + */ + public function setUrl($pageName, $controller) { + $params = [ + 'id' => $this->id, + 'album_slug' => $this->album->slug, + ]; + + return $this->url = $controller->pageUrl($pageName, $params); + } + + + /** + * beforeDelete() event + * Using it to delete attached + */ + public function beforeDelete() { + if ($this->image) { + $this->image->delete(); + } + } + +} diff --git a/server/plugins/graker/photoalbums/models/Settings.php b/server/plugins/graker/photoalbums/models/Settings.php new file mode 100644 index 0000000..74e319a --- /dev/null +++ b/server/plugins/graker/photoalbums/models/Settings.php @@ -0,0 +1,25 @@ + + + + + ./tests + + + + + + + + \ No newline at end of file diff --git a/server/plugins/graker/photoalbums/tests/RandomPhotosTest.php b/server/plugins/graker/photoalbums/tests/RandomPhotosTest.php new file mode 100644 index 0000000..cae2ee1 --- /dev/null +++ b/server/plugins/graker/photoalbums/tests/RandomPhotosTest.php @@ -0,0 +1,112 @@ +createAlbum(); + $photos[] = $this->createPhoto($album); + $photos[] = $this->createPhoto($album); + $photos[] = $this->createPhoto($album); + $photos[] = $this->createPhoto($album); + $photos[] = $this->createPhoto($album); + $photos[] = $this->createPhoto($album); + $photos[] = $this->createPhoto($album); + + // get random photos + $component = $this->createRandomPhotosComponent(); + $random_photos = $component->photos(); + + // assert all photos are from generated array + self::assertEquals(5, count($random_photos), 'There are 5 random photos'); + $found_all = TRUE; + foreach ($random_photos as $random_photo) { + $found = FALSE; + foreach ($photos as $photo) { + if ($photo->id == $random_photo->id) { + $found = TRUE; + break; + } + } + if (!$found) { + $found_all = FALSE; + break; + } + } + self::assertTrue($found_all, 'All photos exist in original array'); + } + + + /** + * + * Creates album model + * + * @return \Graker\PhotoAlbums\Models\Album + */ + protected function createAlbum() { + $faker = Faker\Factory::create(); + $album = new Album(); + $album->title = $faker->sentence(3); + $album->slug = str_slug($album->title); + $album->description = $faker->text(); + $album->save(); + return $album; + } + + + /** + * + * Creates photo model and put it into album + * + * @param \Graker\PhotoAlbums\Models\Album $album + * @return \Graker\PhotoAlbums\Models\Photo + */ + protected function createPhoto(Album $album) { + $faker = Faker\Factory::create(); + $photo = new Photo(); + $photo->title = $faker->sentence(3); + $photo->description = $faker->text(); + $photo->image = $faker->image(); + $photo->album = $album; + $photo->save(); + return $photo; + } + + + /** + * + * Creates randomPhotos component to test + * + * @return \Graker\PhotoAlbums\Components\RandomPhotos + */ + protected function createRandomPhotosComponent() { + // Spoof all the objects we need to make a page object + $theme = Theme::load('test'); + $page = Page::load($theme, 'index.htm'); + $layout = Layout::load($theme, 'content.htm'); + $controller = new Controller($theme); + $parser = new CodeParser($page); + $pageObj = $parser->source($page, $layout, $controller); + $manager = ComponentManager::instance(); + $object = $manager->makeComponent('randomPhotos', $pageObj); + return $object; + } +} diff --git a/server/plugins/graker/photoalbums/updates/add_album_front.php b/server/plugins/graker/photoalbums/updates/add_album_front.php new file mode 100644 index 0000000..4baa8cb --- /dev/null +++ b/server/plugins/graker/photoalbums/updates/add_album_front.php @@ -0,0 +1,25 @@ +integer('front_id')->unsigned()->nullable(); + }); + } + + public function down() + { + Schema::table('graker_photoalbums_albums', function($table) + { + $table->dropColumn('front_id'); + }); + } + +} diff --git a/server/plugins/graker/photoalbums/updates/add_sort_order_field.php b/server/plugins/graker/photoalbums/updates/add_sort_order_field.php new file mode 100644 index 0000000..6c86c0f --- /dev/null +++ b/server/plugins/graker/photoalbums/updates/add_sort_order_field.php @@ -0,0 +1,25 @@ +integer('sort_order')->unsigned()->nullable(); + }); + } + + public function down() + { + Schema::table('graker_photoalbums_photos', function($table) + { + $table->dropColumn('sort_order'); + }); + } + +} diff --git a/server/plugins/graker/photoalbums/updates/create_albums_table.php b/server/plugins/graker/photoalbums/updates/create_albums_table.php new file mode 100644 index 0000000..b45c4a0 --- /dev/null +++ b/server/plugins/graker/photoalbums/updates/create_albums_table.php @@ -0,0 +1,28 @@ +engine = 'InnoDB'; + $table->increments('id'); + $table->integer('user_id')->unsigned()->nullable()->index(); + $table->string('title')->nullable(); + $table->string('slug')->index(); + $table->text('description')->nullable(); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('graker_photoalbums_albums'); + } + +} diff --git a/server/plugins/graker/photoalbums/updates/create_photos_table.php b/server/plugins/graker/photoalbums/updates/create_photos_table.php new file mode 100644 index 0000000..3a74c5f --- /dev/null +++ b/server/plugins/graker/photoalbums/updates/create_photos_table.php @@ -0,0 +1,28 @@ +engine = 'InnoDB'; + $table->increments('id'); + $table->integer('user_id')->unsigned()->nullable()->index(); + $table->integer('album_id')->unsigned()->nullable()->index(); + $table->string('title')->nullable(); + $table->text('description')->nullable(); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('graker_photoalbums_photos'); + } + +} diff --git a/server/plugins/graker/photoalbums/updates/update_sort_order_on_existing_photos.php b/server/plugins/graker/photoalbums/updates/update_sort_order_on_existing_photos.php new file mode 100644 index 0000000..d8e63cb --- /dev/null +++ b/server/plugins/graker/photoalbums/updates/update_sort_order_on_existing_photos.php @@ -0,0 +1,23 @@ +sort_order = $photo->id; + $photo->save(); + } + } + + public function down() + { + } + +} diff --git a/server/plugins/graker/photoalbums/updates/version.yaml b/server/plugins/graker/photoalbums/updates/version.yaml new file mode 100644 index 0000000..d2f2b55 --- /dev/null +++ b/server/plugins/graker/photoalbums/updates/version.yaml @@ -0,0 +1,32 @@ +1.0.1: First version of PhotoAlbums +1.0.2: + - Update with migrations to create albums and photos table + - create_albums_table.php + - create_photos_table.php +1.1.0: + - Add ability to select front photo for album from the interface + - add_album_front.php +1.2.0: + - Added ability to reorder photos in the album + - add_sort_order_field.php +1.2.1: + - Fill default sort_order values for existing photos + - update_sort_order_on_existing_photos.php +1.2.2: + - Sqlite support for RandomPhotos component +1.2.3: + - Added helper method to get album's cover photo +1.2.4: + - Fix for album front photo eager loading +1.2.5: + - Fix for photos count in only_full_group_by sql mode +1.3.0: + - New dialog to insert photos into blog posts +1.4.0: + - Integration with RainLab.Pages to use Albums and Photos in Menu Items (and Sitemap) +1.4.1: + - Improved layout of Photo form (thanks to gergo85) + - Improved lang.php strings (thanks to gergo85) + - Localized Menu Item types +1.4.2: + - Fixed second insert photo icon from occuring in blog post form diff --git a/server/plugins/graker/photoalbums/widgets/PhotoSelector.php b/server/plugins/graker/photoalbums/widgets/PhotoSelector.php new file mode 100644 index 0000000..7e1bbdf --- /dev/null +++ b/server/plugins/graker/photoalbums/widgets/PhotoSelector.php @@ -0,0 +1,184 @@ +vars['albums'] = NULL; + $this->vars['album'] = $this->album($album_id); + } else { + $this->vars['albums'] = $this->albums(); + $this->vars['album'] = NULL; + } + + + return $this->makePartial('body'); + } + + + /** + * Loads widget assets + */ + protected function loadAssets() { + $this->addJs('js/photoselector.js'); + $this->addCss('css/photoselector.css'); + } + + + /** + * + * Callback for when the dialog is initially open + * + * @return string + */ + public function onDialogOpen() { + return $this->render(); + } + + + /** + * + * Callback to generate albums list + * + * @return array + */ + public function onAlbumListLoad() { + $this->vars['albums'] = $this->albums(); + + return [ + '#listContainer' => $this->makePartial('albums'), + ]; + } + + + /** + * + * Callback to generate photos list + * Photos list is to replace albums list in dialog markup + * + * @return array + */ + public function onAlbumLoad() { + $album_id = input('id'); + $album = $this->album($album_id); + $this->vars['album'] = $album; + + return [ + '#listContainer' => $this->makePartial('photos'), + ]; + } + + + /** + * + * Returns a collection of all user's albums + * + * @return Collection + */ + protected function albums() { + $albums = Album::orderBy('created_at', 'desc') + ->has('photos') + ->with(['latestPhoto' => function ($query) { + $query->with('image'); + }]) + ->with(['front' => function ($query) { + $query->with('image'); + }]) + ->get(); + + foreach ($albums as $album) { + // prepare thumb from $album->front if it is set or from latestPhoto otherwise + $image = ($album->front) ? $album->front->image : $album->latestPhoto->image; + $album->thumb = $image->getThumb( + 160, + 120, + ['mode' => 'crop'] + ); + } + + return $albums; + } + + + /** + * + * Returns album with its photos loaded and prepared for display in dialog + * + * @param int $album_id + * @return Album + */ + protected function album($album_id) { + $album = Album::where('id', $album_id) + ->with(['photos' => function ($query) { + $query->orderBy('sort_order', 'desc'); + $query->with('image'); + // TODO implement pagination + }]) + ->first(); + + if ($album) { + //prepare photo urls and thumbs + foreach ($album->photos as $photo) { + // set thumb + $photo->thumb = $photo->image->getThumb( + 160, + 120, + ['mode' => 'crop'] + ); + // set code + $photo->code = $this->createPhotoCode($photo); + } + } + + return $album; + } + + + /** + * + * Create an insert markdown code for photo from plugin settings + * + * @param Photo $photo + * @return string + */ + protected function createPhotoCode($photo) { + $code_template = Settings::get('code', '![%title%]([photo:%id%])'); + $code = str_replace( + array('%id%', '%title%'), + array($photo->id, $photo->title), + $code_template + ); + return $code; + } + +} diff --git a/server/plugins/graker/photoalbums/widgets/photoselector/assets/css/photoselector.css b/server/plugins/graker/photoalbums/widgets/photoselector/assets/css/photoselector.css new file mode 100644 index 0000000..37d0bbc --- /dev/null +++ b/server/plugins/graker/photoalbums/widgets/photoselector/assets/css/photoselector.css @@ -0,0 +1,20 @@ +#photosList .photo-link.image-link { + display: inline-block; + padding: 7px; +} + +#photosList .photo-link.image-link.selected { + border: 1px solid; + padding: 6px; + border-radius: 6px; +} + +#photosList .photo-link.title-link.selected { + font-weight: bold; +} + +#photosList .back-to-albums { + margin-top: 16px; + margin-bottom: 16px; + display: block; +} diff --git a/server/plugins/graker/photoalbums/widgets/photoselector/assets/js/photoselector.js b/server/plugins/graker/photoalbums/widgets/photoselector/assets/js/photoselector.js new file mode 100644 index 0000000..f72e454 --- /dev/null +++ b/server/plugins/graker/photoalbums/widgets/photoselector/assets/js/photoselector.js @@ -0,0 +1,180 @@ + +/** + * PhotoSelector dialog + */ + ++function () { + + if ($.oc.photoselector === undefined) { + $.oc.photoselector = {}; + } + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype; + + var PhotoSelector = function (options) { + this.$dialog = $('
    '); + this.options = $.extend({}, PhotoSelector.DEFAULTS, options); + + Base.call(this); + + this.show(); + }; + + + PhotoSelector.prototype = Object.create(BaseProto); + PhotoSelector.prototype.constructor = PhotoSelector; + + + /** + * Load and show the dialog + */ + PhotoSelector.prototype.show = function () { + this.$dialog.one('complete.oc.popup', this.proxy(this.onPopupShown)); + this.$dialog.popup({ + size: 'large', + extraData: {album: this.options.album }, + handler: this.options.alias + '::onDialogOpen' + }); + }; + + + /** + * Callback when the popup is loaded and shown + * + * @param event + * @param element + * @param popup + */ + PhotoSelector.prototype.onPopupShown = function (event, element, popup) { + this.$dialog = popup; + // bind clicks for album thumb and title links + if (this.options.album) { + this.bindPhotosListHandlers(); + } else { + $('#albumsList .album-link', popup).one('click', this.proxy(this.onAlbumClicked)); + } + $('div.photo-selection-dialog').find('button.btn-insert').click(this.proxy(this.onInsertClicked)); + }; + + + /** + * Album clicked callback + * @param event + */ + PhotoSelector.prototype.onAlbumClicked = function (event) { + var link_id = $(event.currentTarget).data('request-data'); + var selector = this; + $.request('onAlbumLoad', { + data: {id: link_id}, + update: {photos: '#listContainer'}, + loading: $.oc.stripeLoadIndicator, + success: function (data) { + this.success(data); + selector.bindPhotosListHandlers(); + } + }); + }; + + + /** + * Bind event handlers for photos list + */ + PhotoSelector.prototype.bindPhotosListHandlers = function () { + // bind photo link click and double click events + $('#photosList').find('a.photo-link').click(this.proxy(this.onPhotoSelected)); + $('#photosList').find('a.photo-link').dblclick(this.proxy(this.onPhotoDoubleClicked)); + // bind back to albums click event + $('#photosList').find('a.back-to-albums').one('click', this.proxy(this.onBackToAlbums)); + }; + + + /** + * + * Photo clicked callback + * + * @param event + */ + PhotoSelector.prototype.onPhotoSelected = function (event) { + // remove old selected classes + $('#photosList').find('a.selected').removeClass('selected'); + + // add new selected classes + var wrapper = $(event.currentTarget).parents('.photo-links-wrapper'); + wrapper.find('a.photo-link').addClass('selected'); + }; + + + /** + * + * Back to albums clicked callback + * + * @param event + */ + PhotoSelector.prototype.onBackToAlbums = function (event) { + var selector = this; + $.request('onAlbumListLoad', { + 'update': { albums: '#listContainer'}, + loading: $.oc.stripeLoadIndicator, + success: function (data) { + this.success(data); + $('#albumsList').find('.album-link').one('click', selector.proxy(selector.onAlbumClicked)); + } + }); + }; + + + /** + * Photo insert button callback + * + * @param event + */ + PhotoSelector.prototype.onInsertClicked = function (event) { + var selected = $('#photosList').find('a.selected').first(); + if (!selected.length) { + // FIXME Localize when it is supported + alert('You have to select a photo first. Click on the photo, then click "Insert". Or just double-click the photo.'); + } else { + var code = selected.data('request-data'); + var album = $('#photosList').data('request-data'); + this.options.onInsert.call(this, code, album); + } + }; + + + /** + * + * Double click callback + * + * @param event + */ + PhotoSelector.prototype.onPhotoDoubleClicked = function (event) { + // select the photo and insert it + var link = $(event.currentTarget); + link.trigger('click'); + $('div.photo-selection-dialog').find('button.btn-insert').trigger('click'); + }; + + + /** + * Hide popup + */ + PhotoSelector.prototype.hide = function () { + if (this.$dialog) { + this.$dialog.trigger('close.oc.popup'); + } + }; + + + /** + * Default options + */ + PhotoSelector.DEFAULTS = { + alias: undefined, + album: 0, + onInsert: undefined + }; + + $.oc.photoselector.popup = PhotoSelector; + +} (window.jQuery); diff --git a/server/plugins/graker/photoalbums/widgets/photoselector/partials/_albums.htm b/server/plugins/graker/photoalbums/widgets/photoselector/partials/_albums.htm new file mode 100644 index 0000000..3cd3a4b --- /dev/null +++ b/server/plugins/graker/photoalbums/widgets/photoselector/partials/_albums.htm @@ -0,0 +1,16 @@ +
    + + + +
    diff --git a/server/plugins/graker/photoalbums/widgets/photoselector/partials/_body.htm b/server/plugins/graker/photoalbums/widgets/photoselector/partials/_body.htm new file mode 100644 index 0000000..8d74b13 --- /dev/null +++ b/server/plugins/graker/photoalbums/widgets/photoselector/partials/_body.htm @@ -0,0 +1,21 @@ + diff --git a/server/plugins/graker/photoalbums/widgets/photoselector/partials/_photos.htm b/server/plugins/graker/photoalbums/widgets/photoselector/partials/_photos.htm new file mode 100644 index 0000000..2bac0fa --- /dev/null +++ b/server/plugins/graker/photoalbums/widgets/photoselector/partials/_photos.htm @@ -0,0 +1,26 @@ +
    +

    title; ?>

    + photos as $photo) : ?> + + +
    + +
    +
    diff --git a/server/plugins/manogi/mediathumb/LICENCE.md b/server/plugins/manogi/mediathumb/LICENCE.md new file mode 100644 index 0000000..38cee79 --- /dev/null +++ b/server/plugins/manogi/mediathumb/LICENCE.md @@ -0,0 +1,19 @@ +# MIT license + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/server/plugins/manogi/mediathumb/Plugin.php b/server/plugins/manogi/mediathumb/Plugin.php new file mode 100644 index 0000000..245b813 --- /dev/null +++ b/server/plugins/manogi/mediathumb/Plugin.php @@ -0,0 +1,44 @@ + 'manogi.mediathumb::lang.plugin.name', + 'description' => 'manogi.mediathumb::lang.plugin.description', + 'author' => 'manogi', + 'icon' => 'icon-compress', + 'homepage' => 'https://github.com/manogi/october-mediathumb' + ]; + } + + public function registerMarkupTags() + { + return [ + 'filters' => [ + 'mediathumb_resize' => [$this, 'mediathumb_resize'] + ] + ]; + } + + public function mediathumb_resize($img, $mode = null, $size = null, $quality = null) + { + return mediathumbResize($img, $mode, $size, $quality, 'media'); + } + + +} diff --git a/server/plugins/manogi/mediathumb/README.md b/server/plugins/manogi/mediathumb/README.md new file mode 100644 index 0000000..c4b3142 --- /dev/null +++ b/server/plugins/manogi/mediathumb/README.md @@ -0,0 +1,116 @@ +# Thumbnail images for Media + ++ Twig filter for automatic thumbnail images for your media images. ++ Static PHP helper function for automatic thumbnail images for your media images in your backend files. + +You can find this plugin in the OctoberCMS Plugins page [here](http://octobercms.com/plugin/manogi-mediathumb). + +After installing the plugin you can use it... + +...as a Twig filter in other plugins or in your theme files: + + + +... as a static PHP helper function in your backend PHP and .htm files: + + + +The filter supports three arguments: + ++ _mode_: can bei either 'auto', 'width' or 'height'. 'auto' is the default. ++ _size_: an integer describing the length in pixels (defaults to 200) of + - the longer edge of the image in 'auto' mode + - the width in 'width' mode + - the height in 'height' mode ++ _quality_: an integer from 1 – 100 to set the quality of the image. Only applies to JPGs. Defaults to 90. + +The static PHP helper function needs the image path as a string as the first argument. + +## Examples: + +### Twig (frontend code) + + + +Creates and displays a 200px wide thumbnail image of an landscape image or a 200px high thumbnail image of a portrait image. + + + + +Creates and displays a 400px high thumbnail image, no matter if the original is a landscape or a portrait image. + + + + +Creates and displays a 800px wide thumbnail image with a quality of 96, no matter if the original is a landscape or a portrait image. + + +### Static PHP helper function (backend code) + +The static PHP helper function needs the image path as a string as the first argument. You can use it for example when you display a list of items in the backend, using the default `$record` variable you get when using the default OctoberCMS `$this->listRender()` function: + + + +Creates and displays a 180px high thumbnail image, no matter if the original is a landscape or a portrait image. + +While of course `$record->image` might be something else in your case. "image" is here the name of the field you store your image in. + +You can of course also use the defaults like so: + + + +Creates and displays a 200px wide thumbnail image of an landscape image or a 200px high thumbnail image of a portrait image. + +_until now this function was called `getMediathumb` instead of `mediathumbResize`. This name will still work, I left an alias for it that will stay in there forever ;-)_ + + +###Uploads images functionality (for example "featured images" in Blog and Pro Blog): + +We made the functionality also available for so called "uploads" - these are for example those images that are uploaded directly when editing a Model instance, like the "featured images" of a blog post in the Blog and Pro Blog plugins. You can use the following with all mediathumb features: + + + +and + + + + + + +##Configuration + +### Custom folder name: + +The default folder name "_mediathumbs" can be changed (also to a subfolder like "some/sub/folder") in the config/config.php file of the plugin. + + +### Defaults: + +The defaults for `mode`, `size` and `quality` can be changed in the config/config.php file of the plugin. + + +## How does it work: + +The plugin checks if a thumbnail for the original image was already created - if not, it creates the thumbnail. +Then the thumbnail path is returned. + +## What if I overwrite the original with an altered version? + +The plugin uses the filetime and filesize in naming the thumbnail to make sure that altered images with the same name don't produce old thumbnails. + +## Where are the thumbnails stored? + +In a mediathumb folder in your storage media folder (which is created automatically, also see "Custom folder name" above). + +## Does it work with Amazon S3? + +Yep. + +## What happens to the thumbnail files once I delete the original? + +So far they just stay in the mediathumb folder. I am working on a solution to have them deleted together with the originals, but remember you can easily empty or delete the mediathumbs folder altogether - the thumbnails will just start being re-created when people hit your website. + +## Roadmap + ++ Adding a `mediathumb_square` filter for creating automatic square thumbs. ++ ... (let me know if you have feature requests. No promises, though...) diff --git a/server/plugins/manogi/mediathumb/config/config.php b/server/plugins/manogi/mediathumb/config/config.php new file mode 100644 index 0000000..079aeef --- /dev/null +++ b/server/plugins/manogi/mediathumb/config/config.php @@ -0,0 +1,20 @@ + '_mediathumbs', + + // Set the default for creating mediathumbs + + 'default' => [ + 'mode' => 'auto', + 'size' => 200, + 'quality' => 90, + ] +]; diff --git a/server/plugins/manogi/mediathumb/lang/cs/lang.php b/server/plugins/manogi/mediathumb/lang/cs/lang.php new file mode 100644 index 0000000..1543594 --- /dev/null +++ b/server/plugins/manogi/mediathumb/lang/cs/lang.php @@ -0,0 +1,8 @@ + [ + 'name' => 'Mediathumb', + 'description' => 'Přidává nový Twig filtr mediathumb.' + ] +]; diff --git a/server/plugins/manogi/mediathumb/lang/de/lang.php b/server/plugins/manogi/mediathumb/lang/de/lang.php new file mode 100644 index 0000000..6ce86cc --- /dev/null +++ b/server/plugins/manogi/mediathumb/lang/de/lang.php @@ -0,0 +1,8 @@ + [ + 'name' => 'Mediathumb', + 'description' => 'Fügt den mediathumb Twig-Filter hinzu.' + ] +]; diff --git a/server/plugins/manogi/mediathumb/lang/en/lang.php b/server/plugins/manogi/mediathumb/lang/en/lang.php new file mode 100644 index 0000000..6fb407a --- /dev/null +++ b/server/plugins/manogi/mediathumb/lang/en/lang.php @@ -0,0 +1,8 @@ + [ + 'name' => 'Mediathumb', + 'description' => 'Twig filter for automatic thumbnail images for your media images.' + ] +]; diff --git a/server/plugins/manogi/mediathumb/lang/hu/lang.php b/server/plugins/manogi/mediathumb/lang/hu/lang.php new file mode 100644 index 0000000..334182b --- /dev/null +++ b/server/plugins/manogi/mediathumb/lang/hu/lang.php @@ -0,0 +1,8 @@ + [ + 'name' => 'Képméretezés', + 'description' => 'A Média képeinek dinamikus átméretezése.' + ] +]; diff --git a/server/plugins/manogi/mediathumb/updates/version.yaml b/server/plugins/manogi/mediathumb/updates/version.yaml new file mode 100644 index 0000000..9947079 --- /dev/null +++ b/server/plugins/manogi/mediathumb/updates/version.yaml @@ -0,0 +1,19 @@ +0.0.0: First version of Mediathumb +0.0.1: Added Amazon S3 support +0.1.0: Added config/config.php file for setting defaults and added backend support (major change, please see documentation) +0.2.0: Renamed the helper function getMediathumb(). Left an alias for mediathumbGetThumb() to prevent breaking change. +0.2.1: Fixed an error when an empty string was passed as image path. +0.2.2: cs_CZ language added - thanks to Vojta Svoboda +0.2.3: Hungarian language added and minor typos corrected - thanks to Szabó Gergő +0.2.4: Added MIT lincence - thanks to Szabó Gergő +0.2.5: Corrected a bug to make it work in installations of OctoberCMS in a subfolder. +0.3.0: Added option to change mediathumb folder name (including subfolders) in the config file. +0.3.1: Fixed a bug which made the plugin return an exception when failing to create a thumbnail for unsupported file types. +0.3.2: Making sure the static helper function does not overwrite an existing function (Thanks to Tobias Kündig). +0.3.3: Fixed syntax error in helper function +0.4.0: Added functionality for uploads files like featured images in blogposts +0.4.1: Fixed bug in autoload file +0.4.2: Fixed bug that made Amazon S3 not working correctly for uploads +0.4.3: Fixed bug that made Mediathumb not work in OctoberCMS installed in a sub directory using local disk +0.4.4: Fix for octobercms breaking change +0.4.5: Slugify the thumb filename, copy Gifs without resizing (because animated gifs) diff --git a/server/plugins/manogi/mediathumb/vendor/autoload.php b/server/plugins/manogi/mediathumb/vendor/autoload.php new file mode 100644 index 0000000..3879821 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/server/plugins/manogi/mediathumb/vendor/composer/LICENSE b/server/plugins/manogi/mediathumb/vendor/composer/LICENSE new file mode 100644 index 0000000..1a28124 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) 2016 Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/server/plugins/manogi/mediathumb/vendor/composer/autoload_classmap.php b/server/plugins/manogi/mediathumb/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', + 'c573a7e5893a138545b4829bb4a11fcc' => $vendorDir . '/manogi/mediathumb/resize_helper.php', +); diff --git a/server/plugins/manogi/mediathumb/vendor/composer/autoload_namespaces.php b/server/plugins/manogi/mediathumb/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($vendorDir . '/urodoz/truncate-html/src'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), + 'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'), + 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), +); diff --git a/server/plugins/manogi/mediathumb/vendor/composer/autoload_real.php b/server/plugins/manogi/mediathumb/vendor/composer/autoload_real.php new file mode 100644 index 0000000..51724be --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/composer/autoload_real.php @@ -0,0 +1,59 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + $includeFiles = require __DIR__ . '/autoload_files.php'; + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequire6c3de2f9e71443bc1a465e7aa469c6e4($fileIdentifier, $file); + } + + return $loader; + } +} + +function composerRequire6c3de2f9e71443bc1a465e7aa469c6e4($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/composer/autoload_static.php b/server/plugins/manogi/mediathumb/vendor/composer/autoload_static.php new file mode 100644 index 0000000..2c012e0 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/composer/autoload_static.php @@ -0,0 +1,60 @@ + __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', + 'c573a7e5893a138545b4829bb4a11fcc' => __DIR__ . '/..' . '/manogi/mediathumb/resize_helper.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'U' => + array ( + 'Urodoz\\Truncate\\' => 16, + ), + 'P' => + array ( + 'Psr\\Http\\Message\\' => 17, + ), + 'I' => + array ( + 'Intervention\\Image\\' => 19, + ), + 'G' => + array ( + 'GuzzleHttp\\Psr7\\' => 16, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Urodoz\\Truncate\\' => + array ( + 0 => __DIR__ . '/..' . '/urodoz/truncate-html/src', + ), + 'Psr\\Http\\Message\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-message/src', + ), + 'Intervention\\Image\\' => + array ( + 0 => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image', + ), + 'GuzzleHttp\\Psr7\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit6c3de2f9e71443bc1a465e7aa469c6e4::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit6c3de2f9e71443bc1a465e7aa469c6e4::$prefixDirsPsr4; + + }, null, ClassLoader::class); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/composer/installed.json b/server/plugins/manogi/mediathumb/vendor/composer/installed.json new file mode 100644 index 0000000..9e5cd60 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/composer/installed.json @@ -0,0 +1,245 @@ +[ + { + "name": "urodoz/truncate-html", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/urodoz/truncateHTML.git", + "reference": "88fb29fd3a30c95b879f1642e08fd8746dd05bd7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/urodoz/truncateHTML/zipball/88fb29fd3a30c95b879f1642e08fd8746dd05bd7", + "reference": "88fb29fd3a30c95b879f1642e08fd8746dd05bd7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4", + "symfony/dependency-injection": "~2.4", + "symfony/http-kernel": "~2.4", + "twig/twig": "~1" + }, + "time": "2014-05-25 22:50:06", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Urodoz\\Truncate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Albert Lacarta", + "email": "urodoz@gmail.com", + "homepage": "http://www.rqlogic.com" + } + ], + "description": "Handle truncate action on HTML strings", + "keywords": [ + "content", + "html", + "shorten", + "truncate", + "truncating" + ] + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2016-08-06 14:39:51", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ] + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "version_normalized": "1.4.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "time": "2017-03-20 17:10:46", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ] + }, + { + "name": "intervention/image", + "version": "2.4.1", + "version_normalized": "2.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "3603dbcc9a17d307533473246a6c58c31cf17919" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/3603dbcc9a17d307533473246a6c58c31cf17919", + "reference": "3603dbcc9a17d307533473246a6c58c31cf17919", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "^4.8 || ^5.7" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "time": "2017-09-21 16:29:17", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@olivervogel.com", + "homepage": "http://olivervogel.com/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ] + } +] diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/CHANGELOG.md b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/CHANGELOG.md new file mode 100644 index 0000000..5c252b3 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -0,0 +1,110 @@ +# CHANGELOG + +## 1.4.2 - 2017-03-20 + +* Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing + calls to `trigger_error` when deprecated methods are invoked. + +## 1.4.1 - 2017-02-27 + +* Reverted BC break by reintroducing behavior to automagically fix a URI with a + relative path and an authority by adding a leading slash to the path. It's only + deprecated now. +* Added triggering of silenced deprecation warnings. + +## 1.4.0 - 2017-02-21 + +* Fix `Stream::read` when length parameter <= 0. +* `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory. +* Fix `ServerRequest::getUriFromGlobals` when `Host` header contains port. +* Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form. +* Allow `parse_response` to parse a response without delimiting space and reason. +* Ensure each URI modification results in a valid URI according to PSR-7 discussions. + Invalid modifications will throw an exception instead of returning a wrong URI or + doing some magic. + - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception + because the path of a URI with an authority must start with a slash "/" or be empty + - `(new Uri())->withScheme('http')` will return `'http://localhost'` +* Fix compatibility of URIs with `file` scheme and empty host. +* Added common URI utility methods based on RFC 3986 (see documentation in the readme): + - `Uri::isDefaultPort` + - `Uri::isAbsolute` + - `Uri::isNetworkPathReference` + - `Uri::isAbsolutePathReference` + - `Uri::isRelativePathReference` + - `Uri::isSameDocumentReference` + - `Uri::composeComponents` + - `UriNormalizer::normalize` + - `UriNormalizer::isEquivalent` + - `UriResolver::relativize` +* Deprecated `Uri::resolve` in favor of `UriResolver::resolve` +* Deprecated `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments` + +## 1.3.1 - 2016-06-25 + +* Fix `Uri::__toString` for network path references, e.g. `//example.org`. +* Fix missing lowercase normalization for host. +* Fix handling of URI components in case they are `'0'` in a lot of places, + e.g. as a user info password. +* Fix `Uri::withAddedHeader` to correctly merge headers with different case. +* Fix trimming of header values in `Uri::withAddedHeader`. Header values may + be surrounded by whitespace which should be ignored according to RFC 7230 + Section 3.2.4. This does not apply to header names. +* Fix `Uri::withAddedHeader` with an array of header values. +* Fix `Uri::resolve` when base path has no slash and handling of fragment. +* Fix handling of encoding in `Uri::with(out)QueryValue` so one can pass the + key/value both in encoded as well as decoded form to those methods. This is + consistent with withPath, withQuery etc. +* Fix `ServerRequest::withoutAttribute` when attribute value is null. + +## 1.3.0 - 2016-04-13 + +* Added remaining interfaces needed for full PSR7 compatibility + (ServerRequestInterface, UploadedFileInterface, etc.). +* Added support for stream_for from scalars. +* Can now extend Uri. +* Fixed a bug in validating request methods by making it more permissive. + +## 1.2.3 - 2016-02-18 + +* Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote + streams, which can sometimes return fewer bytes than requested with `fread`. +* Fixed handling of gzipped responses with FNAME headers. + +## 1.2.2 - 2016-01-22 + +* Added support for URIs without any authority. +* Added support for HTTP 451 'Unavailable For Legal Reasons.' +* Added support for using '0' as a filename. +* Added support for including non-standard ports in Host headers. + +## 1.2.1 - 2015-11-02 + +* Now supporting negative offsets when seeking to SEEK_END. + +## 1.2.0 - 2015-08-15 + +* Body as `"0"` is now properly added to a response. +* Now allowing forward seeking in CachingStream. +* Now properly parsing HTTP requests that contain proxy targets in + `parse_request`. +* functions.php is now conditionally required. +* user-info is no longer dropped when resolving URIs. + +## 1.1.0 - 2015-06-24 + +* URIs can now be relative. +* `multipart/form-data` headers are now overridden case-insensitively. +* URI paths no longer encode the following characters because they are allowed + in URIs: "(", ")", "*", "!", "'" +* A port is no longer added to a URI when the scheme is missing and no port is + present. + +## 1.0.0 - 2015-05-19 + +Initial release. + +Currently unsupported: + +- `Psr\Http\Message\ServerRequestInterface` +- `Psr\Http\Message\UploadedFileInterface` diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/LICENSE b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/LICENSE new file mode 100644 index 0000000..581d95f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/README.md b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/README.md new file mode 100644 index 0000000..1649935 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/README.md @@ -0,0 +1,739 @@ +# PSR-7 Message Implementation + +This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/) +message implementation, several stream decorators, and some helpful +functionality like query string parsing. + + +[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7) + + +# Stream implementation + +This package comes with a number of stream implementations and stream +decorators. + + +## AppendStream + +`GuzzleHttp\Psr7\AppendStream` + +Reads from multiple streams, one after the other. + +```php +use GuzzleHttp\Psr7; + +$a = Psr7\stream_for('abc, '); +$b = Psr7\stream_for('123.'); +$composed = new Psr7\AppendStream([$a, $b]); + +$composed->addStream(Psr7\stream_for(' Above all listen to me')); + +echo $composed; // abc, 123. Above all listen to me. +``` + + +## BufferStream + +`GuzzleHttp\Psr7\BufferStream` + +Provides a buffer stream that can be written to fill a buffer, and read +from to remove bytes from the buffer. + +This stream returns a "hwm" metadata value that tells upstream consumers +what the configured high water mark of the stream is, or the maximum +preferred size of the buffer. + +```php +use GuzzleHttp\Psr7; + +// When more than 1024 bytes are in the buffer, it will begin returning +// false to writes. This is an indication that writers should slow down. +$buffer = new Psr7\BufferStream(1024); +``` + + +## CachingStream + +The CachingStream is used to allow seeking over previously read bytes on +non-seekable streams. This can be useful when transferring a non-seekable +entity body fails due to needing to rewind the stream (for example, resulting +from a redirect). Data that is read from the remote stream will be buffered in +a PHP temp stream so that previously read bytes are cached first in memory, +then on disk. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for(fopen('http://www.google.com', 'r')); +$stream = new Psr7\CachingStream($original); + +$stream->read(1024); +echo $stream->tell(); +// 1024 + +$stream->seek(0); +echo $stream->tell(); +// 0 +``` + + +## DroppingStream + +`GuzzleHttp\Psr7\DroppingStream` + +Stream decorator that begins dropping data once the size of the underlying +stream becomes too full. + +```php +use GuzzleHttp\Psr7; + +// Create an empty stream +$stream = Psr7\stream_for(); + +// Start dropping data when the stream has more than 10 bytes +$dropping = new Psr7\DroppingStream($stream, 10); + +$dropping->write('01234567890123456789'); +echo $stream; // 0123456789 +``` + + +## FnStream + +`GuzzleHttp\Psr7\FnStream` + +Compose stream implementations based on a hash of functions. + +Allows for easy testing and extension of a provided stream without needing +to create a concrete class for a simple extension point. + +```php + +use GuzzleHttp\Psr7; + +$stream = Psr7\stream_for('hi'); +$fnStream = Psr7\FnStream::decorate($stream, [ + 'rewind' => function () use ($stream) { + echo 'About to rewind - '; + $stream->rewind(); + echo 'rewound!'; + } +]); + +$fnStream->rewind(); +// Outputs: About to rewind - rewound! +``` + + +## InflateStream + +`GuzzleHttp\Psr7\InflateStream` + +Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. + +This stream decorator skips the first 10 bytes of the given stream to remove +the gzip header, converts the provided stream to a PHP stream resource, +then appends the zlib.inflate filter. The stream is then converted back +to a Guzzle stream resource to be used as a Guzzle stream. + + +## LazyOpenStream + +`GuzzleHttp\Psr7\LazyOpenStream` + +Lazily reads or writes to a file that is opened only after an IO operation +take place on the stream. + +```php +use GuzzleHttp\Psr7; + +$stream = new Psr7\LazyOpenStream('/path/to/file', 'r'); +// The file has not yet been opened... + +echo $stream->read(10); +// The file is opened and read from only when needed. +``` + + +## LimitStream + +`GuzzleHttp\Psr7\LimitStream` + +LimitStream can be used to read a subset or slice of an existing stream object. +This can be useful for breaking a large file into smaller pieces to be sent in +chunks (e.g. Amazon S3's multipart upload API). + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+')); +echo $original->getSize(); +// >>> 1048576 + +// Limit the size of the body to 1024 bytes and start reading from byte 2048 +$stream = new Psr7\LimitStream($original, 1024, 2048); +echo $stream->getSize(); +// >>> 1024 +echo $stream->tell(); +// >>> 0 +``` + + +## MultipartStream + +`GuzzleHttp\Psr7\MultipartStream` + +Stream that when read returns bytes for a streaming multipart or +multipart/form-data stream. + + +## NoSeekStream + +`GuzzleHttp\Psr7\NoSeekStream` + +NoSeekStream wraps a stream and does not allow seeking. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for('foo'); +$noSeek = new Psr7\NoSeekStream($original); + +echo $noSeek->read(3); +// foo +var_export($noSeek->isSeekable()); +// false +$noSeek->seek(0); +var_export($noSeek->read(3)); +// NULL +``` + + +## PumpStream + +`GuzzleHttp\Psr7\PumpStream` + +Provides a read only stream that pumps data from a PHP callable. + +When invoking the provided callable, the PumpStream will pass the amount of +data requested to read to the callable. The callable can choose to ignore +this value and return fewer or more bytes than requested. Any extra data +returned by the provided callable is buffered internally until drained using +the read() function of the PumpStream. The provided callable MUST return +false when there is no more data to read. + + +## Implementing stream decorators + +Creating a stream decorator is very easy thanks to the +`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that +implement `Psr\Http\Message\StreamInterface` by proxying to an underlying +stream. Just `use` the `StreamDecoratorTrait` and implement your custom +methods. + +For example, let's say we wanted to call a specific function each time the last +byte is read from a stream. This could be implemented by overriding the +`read()` method. + +```php +use Psr\Http\Message\StreamInterface; +use GuzzleHttp\Psr7\StreamDecoratorTrait; + +class EofCallbackStream implements StreamInterface +{ + use StreamDecoratorTrait; + + private $callback; + + public function __construct(StreamInterface $stream, callable $cb) + { + $this->stream = $stream; + $this->callback = $cb; + } + + public function read($length) + { + $result = $this->stream->read($length); + + // Invoke the callback when EOF is hit. + if ($this->eof()) { + call_user_func($this->callback); + } + + return $result; + } +} +``` + +This decorator could be added to any existing stream and used like so: + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for('foo'); + +$eofStream = new EofCallbackStream($original, function () { + echo 'EOF!'; +}); + +$eofStream->read(2); +$eofStream->read(1); +// echoes "EOF!" +$eofStream->seek(0); +$eofStream->read(3); +// echoes "EOF!" +``` + + +## PHP StreamWrapper + +You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a +PSR-7 stream as a PHP stream resource. + +Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP +stream from a PSR-7 stream. + +```php +use GuzzleHttp\Psr7\StreamWrapper; + +$stream = GuzzleHttp\Psr7\stream_for('hello!'); +$resource = StreamWrapper::getResource($stream); +echo fread($resource, 6); // outputs hello! +``` + + +# Function API + +There are various functions available under the `GuzzleHttp\Psr7` namespace. + + +## `function str` + +`function str(MessageInterface $message)` + +Returns the string representation of an HTTP message. + +```php +$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); +echo GuzzleHttp\Psr7\str($request); +``` + + +## `function uri_for` + +`function uri_for($uri)` + +This function accepts a string or `Psr\Http\Message\UriInterface` and returns a +UriInterface for the given value. If the value is already a `UriInterface`, it +is returned as-is. + +```php +$uri = GuzzleHttp\Psr7\uri_for('http://example.com'); +assert($uri === GuzzleHttp\Psr7\uri_for($uri)); +``` + + +## `function stream_for` + +`function stream_for($resource = '', array $options = [])` + +Create a new stream based on the input type. + +Options is an associative array that can contain the following keys: + +* - metadata: Array of custom metadata. +* - size: Size of the stream. + +This method accepts the following `$resource` types: + +- `Psr\Http\Message\StreamInterface`: Returns the value as-is. +- `string`: Creates a stream object that uses the given string as the contents. +- `resource`: Creates a stream object that wraps the given PHP stream resource. +- `Iterator`: If the provided value implements `Iterator`, then a read-only + stream object will be created that wraps the given iterable. Each time the + stream is read from, data from the iterator will fill a buffer and will be + continuously called until the buffer is equal to the requested read size. + Subsequent read calls will first read from the buffer and then call `next` + on the underlying iterator until it is exhausted. +- `object` with `__toString()`: If the object has the `__toString()` method, + the object will be cast to a string and then a stream will be returned that + uses the string value. +- `NULL`: When `null` is passed, an empty stream object is returned. +- `callable` When a callable is passed, a read-only stream object will be + created that invokes the given callable. The callable is invoked with the + number of suggested bytes to read. The callable can return any number of + bytes, but MUST return `false` when there is no more data to return. The + stream object that wraps the callable will invoke the callable until the + number of requested bytes are available. Any additional bytes will be + buffered and used in subsequent reads. + +```php +$stream = GuzzleHttp\Psr7\stream_for('foo'); +$stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r')); + +$generator function ($bytes) { + for ($i = 0; $i < $bytes; $i++) { + yield ' '; + } +} + +$stream = GuzzleHttp\Psr7\stream_for($generator(100)); +``` + + +## `function parse_header` + +`function parse_header($header)` + +Parse an array of header values containing ";" separated data into an array of +associative arrays representing the header key value pair data of the header. +When a parameter does not contain a value, but just contains a key, this +function will inject a key with a '' string value. + + +## `function normalize_header` + +`function normalize_header($header)` + +Converts an array of header values that may contain comma separated headers +into an array of headers with no comma separated values. + + +## `function modify_request` + +`function modify_request(RequestInterface $request, array $changes)` + +Clone and modify a request with the given changes. This method is useful for +reducing the number of clones needed to mutate a message. + +The changes can be one of: + +- method: (string) Changes the HTTP method. +- set_headers: (array) Sets the given headers. +- remove_headers: (array) Remove the given headers. +- body: (mixed) Sets the given body. +- uri: (UriInterface) Set the URI. +- query: (string) Set the query string value of the URI. +- version: (string) Set the protocol version. + + +## `function rewind_body` + +`function rewind_body(MessageInterface $message)` + +Attempts to rewind a message body and throws an exception on failure. The body +of the message will only be rewound if a call to `tell()` returns a value other +than `0`. + + +## `function try_fopen` + +`function try_fopen($filename, $mode)` + +Safely opens a PHP stream resource using a filename. + +When fopen fails, PHP normally raises a warning. This function adds an error +handler that checks for errors and throws an exception instead. + + +## `function copy_to_string` + +`function copy_to_string(StreamInterface $stream, $maxLen = -1)` + +Copy the contents of a stream into a string until the given number of bytes +have been read. + + +## `function copy_to_stream` + +`function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)` + +Copy the contents of a stream into another stream until the given number of +bytes have been read. + + +## `function hash` + +`function hash(StreamInterface $stream, $algo, $rawOutput = false)` + +Calculate a hash of a Stream. This method reads the entire stream to calculate +a rolling hash (based on PHP's hash_init functions). + + +## `function readline` + +`function readline(StreamInterface $stream, $maxLength = null)` + +Read a line from the stream up to the maximum allowed buffer length. + + +## `function parse_request` + +`function parse_request($message)` + +Parses a request message string into a request object. + + +## `function parse_response` + +`function parse_response($message)` + +Parses a response message string into a response object. + + +## `function parse_query` + +`function parse_query($str, $urlEncoding = true)` + +Parse a query string into an associative array. + +If multiple values are found for the same key, the value of that key value pair +will become an array. This function does not parse nested PHP style arrays into +an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into +`['foo[a]' => '1', 'foo[b]' => '2']`). + + +## `function build_query` + +`function build_query(array $params, $encoding = PHP_QUERY_RFC3986)` + +Build a query string from an array of key value pairs. + +This function can use the return value of parse_query() to build a query string. +This function does not modify the provided keys when an array is encountered +(like http_build_query would). + + +## `function mimetype_from_filename` + +`function mimetype_from_filename($filename)` + +Determines the mimetype of a file by looking at its extension. + + +## `function mimetype_from_extension` + +`function mimetype_from_extension($extension)` + +Maps a file extensions to a mimetype. + + +# Additional URI Methods + +Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class, +this library also provides additional functionality when working with URIs as static methods. + +## URI Types + +An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference. +An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, +the base URI. Relative references can be divided into several forms according to +[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2): + +- network-path references, e.g. `//example.com/path` +- absolute-path references, e.g. `/path` +- relative-path references, e.g. `subpath` + +The following methods can be used to identify the type of the URI. + +### `GuzzleHttp\Psr7\Uri::isAbsolute` + +`public static function isAbsolute(UriInterface $uri): bool` + +Whether the URI is absolute, i.e. it has a scheme. + +### `GuzzleHttp\Psr7\Uri::isNetworkPathReference` + +`public static function isNetworkPathReference(UriInterface $uri): bool` + +Whether the URI is a network-path reference. A relative reference that begins with two slash characters is +termed an network-path reference. + +### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference` + +`public static function isAbsolutePathReference(UriInterface $uri): bool` + +Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is +termed an absolute-path reference. + +### `GuzzleHttp\Psr7\Uri::isRelativePathReference` + +`public static function isRelativePathReference(UriInterface $uri): bool` + +Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is +termed a relative-path reference. + +### `GuzzleHttp\Psr7\Uri::isSameDocumentReference` + +`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool` + +Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its +fragment component, identical to the base URI. When no base URI is given, only an empty URI reference +(apart from its fragment) is considered a same-document reference. + +## URI Components + +Additional methods to work with URI components. + +### `GuzzleHttp\Psr7\Uri::isDefaultPort` + +`public static function isDefaultPort(UriInterface $uri): bool` + +Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null +or the standard port. This method can be used independently of the implementation. + +### `GuzzleHttp\Psr7\Uri::composeComponents` + +`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string` + +Composes a URI reference string from its various components according to +[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called +manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`. + +### `GuzzleHttp\Psr7\Uri::fromParts` + +`public static function fromParts(array $parts): UriInterface` + +Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components. + + +### `GuzzleHttp\Psr7\Uri::withQueryValue` + +`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface` + +Creates a new URI with a specific query string value. Any existing query string values that exactly match the +provided key are removed and replaced with the given key value pair. A value of null will set the query string +key without a value, e.g. "key" instead of "key=value". + + +### `GuzzleHttp\Psr7\Uri::withoutQueryValue` + +`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface` + +Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the +provided key are removed. + +## Reference Resolution + +`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according +to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers +do when resolving a link in a website based on the current request URI. + +### `GuzzleHttp\Psr7\UriResolver::resolve` + +`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface` + +Converts the relative URI into a new URI that is resolved against the base URI. + +### `GuzzleHttp\Psr7\UriResolver::removeDotSegments` + +`public static function removeDotSegments(string $path): string` + +Removes dot segments from a path and returns the new path according to +[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4). + +### `GuzzleHttp\Psr7\UriResolver::relativize` + +`public static function relativize(UriInterface $base, UriInterface $target): UriInterface` + +Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve(): + +```php +(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) +``` + +One use-case is to use the current request URI as base URI and then generate relative links in your documents +to reduce the document size or offer self-contained downloadable document archives. + +```php +$base = new Uri('http://example.com/a/b/'); +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. +echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. +``` + +## Normalization and Comparison + +`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to +[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6). + +### `GuzzleHttp\Psr7\UriNormalizer::normalize` + +`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface` + +Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. +This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask +of normalizations to apply. The following normalizations are available: + +- `UriNormalizer::PRESERVING_NORMALIZATIONS` + + Default normalizations which only include the ones that preserve semantics. + +- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING` + + All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. + + Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b` + +- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS` + + Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of + ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should + not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved + characters by URI normalizers. + + Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/` + +- `UriNormalizer::CONVERT_EMPTY_PATH` + + Converts the empty path to "/" for http and https URIs. + + Example: `http://example.org` → `http://example.org/` + +- `UriNormalizer::REMOVE_DEFAULT_HOST` + + Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host + "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to + RFC 3986. + + Example: `file://localhost/myfile` → `file:///myfile` + +- `UriNormalizer::REMOVE_DEFAULT_PORT` + + Removes the default port of the given URI scheme from the URI. + + Example: `http://example.org:80/` → `http://example.org/` + +- `UriNormalizer::REMOVE_DOT_SEGMENTS` + + Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would + change the semantics of the URI reference. + + Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html` + +- `UriNormalizer::REMOVE_DUPLICATE_SLASHES` + + Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes + and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization + may change the semantics. Encoded slashes (%2F) are not removed. + + Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html` + +- `UriNormalizer::SORT_QUERY_PARAMETERS` + + Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be + significant (this is not defined by the standard). So this normalization is not safe and may change the semantics + of the URI. + + Example: `?lang=en&article=fred` → `?article=fred&lang=en` + +### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent` + +`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool` + +Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given +`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent. +This of course assumes they will be resolved against the same base URI. If this is not the case, determination of +equivalence or difference of relative references does not mean anything. diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/composer.json b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/composer.json new file mode 100644 index 0000000..b1c5a90 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/composer.json @@ -0,0 +1,39 @@ +{ + "name": "guzzlehttp/psr7", + "type": "library", + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": ["request", "response", "message", "stream", "http", "uri", "url"], + "license": "MIT", + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": ["src/functions_include.php"] + }, + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/AppendStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/AppendStream.php new file mode 100644 index 0000000..23039fd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/AppendStream.php @@ -0,0 +1,233 @@ +addStream($stream); + } + } + + public function __toString() + { + try { + $this->rewind(); + return $this->getContents(); + } catch (\Exception $e) { + return ''; + } + } + + /** + * Add a stream to the AppendStream + * + * @param StreamInterface $stream Stream to append. Must be readable. + * + * @throws \InvalidArgumentException if the stream is not readable + */ + public function addStream(StreamInterface $stream) + { + if (!$stream->isReadable()) { + throw new \InvalidArgumentException('Each stream must be readable'); + } + + // The stream is only seekable if all streams are seekable + if (!$stream->isSeekable()) { + $this->seekable = false; + } + + $this->streams[] = $stream; + } + + public function getContents() + { + return copy_to_string($this); + } + + /** + * Closes each attached stream. + * + * {@inheritdoc} + */ + public function close() + { + $this->pos = $this->current = 0; + + foreach ($this->streams as $stream) { + $stream->close(); + } + + $this->streams = []; + } + + /** + * Detaches each attached stream + * + * {@inheritdoc} + */ + public function detach() + { + $this->close(); + $this->detached = true; + } + + public function tell() + { + return $this->pos; + } + + /** + * Tries to calculate the size by adding the size of each stream. + * + * If any of the streams do not return a valid number, then the size of the + * append stream cannot be determined and null is returned. + * + * {@inheritdoc} + */ + public function getSize() + { + $size = 0; + + foreach ($this->streams as $stream) { + $s = $stream->getSize(); + if ($s === null) { + return null; + } + $size += $s; + } + + return $size; + } + + public function eof() + { + return !$this->streams || + ($this->current >= count($this->streams) - 1 && + $this->streams[$this->current]->eof()); + } + + public function rewind() + { + $this->seek(0); + } + + /** + * Attempts to seek to the given position. Only supports SEEK_SET. + * + * {@inheritdoc} + */ + public function seek($offset, $whence = SEEK_SET) + { + if (!$this->seekable) { + throw new \RuntimeException('This AppendStream is not seekable'); + } elseif ($whence !== SEEK_SET) { + throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); + } + + $this->pos = $this->current = 0; + + // Rewind each stream + foreach ($this->streams as $i => $stream) { + try { + $stream->rewind(); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to seek stream ' + . $i . ' of the AppendStream', 0, $e); + } + } + + // Seek to the actual position by reading from each stream + while ($this->pos < $offset && !$this->eof()) { + $result = $this->read(min(8096, $offset - $this->pos)); + if ($result === '') { + break; + } + } + } + + /** + * Reads from all of the appended streams until the length is met or EOF. + * + * {@inheritdoc} + */ + public function read($length) + { + $buffer = ''; + $total = count($this->streams) - 1; + $remaining = $length; + $progressToNext = false; + + while ($remaining > 0) { + + // Progress to the next stream if needed. + if ($progressToNext || $this->streams[$this->current]->eof()) { + $progressToNext = false; + if ($this->current === $total) { + break; + } + $this->current++; + } + + $result = $this->streams[$this->current]->read($remaining); + + // Using a loose comparison here to match on '', false, and null + if ($result == null) { + $progressToNext = true; + continue; + } + + $buffer .= $result; + $remaining = $length - strlen($buffer); + } + + $this->pos += strlen($buffer); + + return $buffer; + } + + public function isReadable() + { + return true; + } + + public function isWritable() + { + return false; + } + + public function isSeekable() + { + return $this->seekable; + } + + public function write($string) + { + throw new \RuntimeException('Cannot write to an AppendStream'); + } + + public function getMetadata($key = null) + { + return $key ? null : []; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/BufferStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/BufferStream.php new file mode 100644 index 0000000..af4d4c2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/BufferStream.php @@ -0,0 +1,137 @@ +hwm = $hwm; + } + + public function __toString() + { + return $this->getContents(); + } + + public function getContents() + { + $buffer = $this->buffer; + $this->buffer = ''; + + return $buffer; + } + + public function close() + { + $this->buffer = ''; + } + + public function detach() + { + $this->close(); + } + + public function getSize() + { + return strlen($this->buffer); + } + + public function isReadable() + { + return true; + } + + public function isWritable() + { + return true; + } + + public function isSeekable() + { + return false; + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + throw new \RuntimeException('Cannot seek a BufferStream'); + } + + public function eof() + { + return strlen($this->buffer) === 0; + } + + public function tell() + { + throw new \RuntimeException('Cannot determine the position of a BufferStream'); + } + + /** + * Reads data from the buffer. + */ + public function read($length) + { + $currentLength = strlen($this->buffer); + + if ($length >= $currentLength) { + // No need to slice the buffer because we don't have enough data. + $result = $this->buffer; + $this->buffer = ''; + } else { + // Slice up the result to provide a subset of the buffer. + $result = substr($this->buffer, 0, $length); + $this->buffer = substr($this->buffer, $length); + } + + return $result; + } + + /** + * Writes data to the buffer. + */ + public function write($string) + { + $this->buffer .= $string; + + // TODO: What should happen here? + if (strlen($this->buffer) >= $this->hwm) { + return false; + } + + return strlen($string); + } + + public function getMetadata($key = null) + { + if ($key == 'hwm') { + return $this->hwm; + } + + return $key ? null : []; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/CachingStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/CachingStream.php new file mode 100644 index 0000000..ed68f08 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -0,0 +1,138 @@ +remoteStream = $stream; + $this->stream = $target ?: new Stream(fopen('php://temp', 'r+')); + } + + public function getSize() + { + return max($this->stream->getSize(), $this->remoteStream->getSize()); + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + if ($whence == SEEK_SET) { + $byte = $offset; + } elseif ($whence == SEEK_CUR) { + $byte = $offset + $this->tell(); + } elseif ($whence == SEEK_END) { + $size = $this->remoteStream->getSize(); + if ($size === null) { + $size = $this->cacheEntireStream(); + } + $byte = $size + $offset; + } else { + throw new \InvalidArgumentException('Invalid whence'); + } + + $diff = $byte - $this->stream->getSize(); + + if ($diff > 0) { + // Read the remoteStream until we have read in at least the amount + // of bytes requested, or we reach the end of the file. + while ($diff > 0 && !$this->remoteStream->eof()) { + $this->read($diff); + $diff = $byte - $this->stream->getSize(); + } + } else { + // We can just do a normal seek since we've already seen this byte. + $this->stream->seek($byte); + } + } + + public function read($length) + { + // Perform a regular read on any previously read data from the buffer + $data = $this->stream->read($length); + $remaining = $length - strlen($data); + + // More data was requested so read from the remote stream + if ($remaining) { + // If data was written to the buffer in a position that would have + // been filled from the remote stream, then we must skip bytes on + // the remote stream to emulate overwriting bytes from that + // position. This mimics the behavior of other PHP stream wrappers. + $remoteData = $this->remoteStream->read( + $remaining + $this->skipReadBytes + ); + + if ($this->skipReadBytes) { + $len = strlen($remoteData); + $remoteData = substr($remoteData, $this->skipReadBytes); + $this->skipReadBytes = max(0, $this->skipReadBytes - $len); + } + + $data .= $remoteData; + $this->stream->write($remoteData); + } + + return $data; + } + + public function write($string) + { + // When appending to the end of the currently read stream, you'll want + // to skip bytes from being read from the remote stream to emulate + // other stream wrappers. Basically replacing bytes of data of a fixed + // length. + $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); + if ($overflow > 0) { + $this->skipReadBytes += $overflow; + } + + return $this->stream->write($string); + } + + public function eof() + { + return $this->stream->eof() && $this->remoteStream->eof(); + } + + /** + * Close both the remote stream and buffer stream + */ + public function close() + { + $this->remoteStream->close() && $this->stream->close(); + } + + private function cacheEntireStream() + { + $target = new FnStream(['write' => 'strlen']); + copy_to_stream($this, $target); + + return $this->tell(); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/DroppingStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/DroppingStream.php new file mode 100644 index 0000000..8935c80 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/DroppingStream.php @@ -0,0 +1,42 @@ +stream = $stream; + $this->maxLength = $maxLength; + } + + public function write($string) + { + $diff = $this->maxLength - $this->stream->getSize(); + + // Begin returning 0 when the underlying stream is too large. + if ($diff <= 0) { + return 0; + } + + // Write the stream or a subset of the stream if needed. + if (strlen($string) < $diff) { + return $this->stream->write($string); + } + + return $this->stream->write(substr($string, 0, $diff)); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/FnStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/FnStream.php new file mode 100644 index 0000000..cc9b445 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/FnStream.php @@ -0,0 +1,149 @@ +methods = $methods; + + // Create the functions on the class + foreach ($methods as $name => $fn) { + $this->{'_fn_' . $name} = $fn; + } + } + + /** + * Lazily determine which methods are not implemented. + * @throws \BadMethodCallException + */ + public function __get($name) + { + throw new \BadMethodCallException(str_replace('_fn_', '', $name) + . '() is not implemented in the FnStream'); + } + + /** + * The close method is called on the underlying stream only if possible. + */ + public function __destruct() + { + if (isset($this->_fn_close)) { + call_user_func($this->_fn_close); + } + } + + /** + * Adds custom functionality to an underlying stream by intercepting + * specific method calls. + * + * @param StreamInterface $stream Stream to decorate + * @param array $methods Hash of method name to a closure + * + * @return FnStream + */ + public static function decorate(StreamInterface $stream, array $methods) + { + // If any of the required methods were not provided, then simply + // proxy to the decorated stream. + foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { + $methods[$diff] = [$stream, $diff]; + } + + return new self($methods); + } + + public function __toString() + { + return call_user_func($this->_fn___toString); + } + + public function close() + { + return call_user_func($this->_fn_close); + } + + public function detach() + { + return call_user_func($this->_fn_detach); + } + + public function getSize() + { + return call_user_func($this->_fn_getSize); + } + + public function tell() + { + return call_user_func($this->_fn_tell); + } + + public function eof() + { + return call_user_func($this->_fn_eof); + } + + public function isSeekable() + { + return call_user_func($this->_fn_isSeekable); + } + + public function rewind() + { + call_user_func($this->_fn_rewind); + } + + public function seek($offset, $whence = SEEK_SET) + { + call_user_func($this->_fn_seek, $offset, $whence); + } + + public function isWritable() + { + return call_user_func($this->_fn_isWritable); + } + + public function write($string) + { + return call_user_func($this->_fn_write, $string); + } + + public function isReadable() + { + return call_user_func($this->_fn_isReadable); + } + + public function read($length) + { + return call_user_func($this->_fn_read, $length); + } + + public function getContents() + { + return call_user_func($this->_fn_getContents); + } + + public function getMetadata($key = null) + { + return call_user_func($this->_fn_getMetadata, $key); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/InflateStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/InflateStream.php new file mode 100644 index 0000000..0051d3f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/InflateStream.php @@ -0,0 +1,52 @@ +read(10); + $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header); + // Skip the header, that is 10 + length of filename + 1 (nil) bytes + $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength); + $resource = StreamWrapper::getResource($stream); + stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); + $this->stream = new Stream($resource); + } + + /** + * @param StreamInterface $stream + * @param $header + * @return int + */ + private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) + { + $filename_header_length = 0; + + if (substr(bin2hex($header), 6, 2) === '08') { + // we have a filename, read until nil + $filename_header_length = 1; + while ($stream->read(1) !== chr(0)) { + $filename_header_length++; + } + } + + return $filename_header_length; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LazyOpenStream.php new file mode 100644 index 0000000..02cec3a --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LazyOpenStream.php @@ -0,0 +1,39 @@ +filename = $filename; + $this->mode = $mode; + } + + /** + * Creates the underlying stream lazily when required. + * + * @return StreamInterface + */ + protected function createStream() + { + return stream_for(try_fopen($this->filename, $this->mode)); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LimitStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LimitStream.php new file mode 100644 index 0000000..3c13d4f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -0,0 +1,155 @@ +stream = $stream; + $this->setLimit($limit); + $this->setOffset($offset); + } + + public function eof() + { + // Always return true if the underlying stream is EOF + if ($this->stream->eof()) { + return true; + } + + // No limit and the underlying stream is not at EOF + if ($this->limit == -1) { + return false; + } + + return $this->stream->tell() >= $this->offset + $this->limit; + } + + /** + * Returns the size of the limited subset of data + * {@inheritdoc} + */ + public function getSize() + { + if (null === ($length = $this->stream->getSize())) { + return null; + } elseif ($this->limit == -1) { + return $length - $this->offset; + } else { + return min($this->limit, $length - $this->offset); + } + } + + /** + * Allow for a bounded seek on the read limited stream + * {@inheritdoc} + */ + public function seek($offset, $whence = SEEK_SET) + { + if ($whence !== SEEK_SET || $offset < 0) { + throw new \RuntimeException(sprintf( + 'Cannot seek to offset % with whence %s', + $offset, + $whence + )); + } + + $offset += $this->offset; + + if ($this->limit !== -1) { + if ($offset > $this->offset + $this->limit) { + $offset = $this->offset + $this->limit; + } + } + + $this->stream->seek($offset); + } + + /** + * Give a relative tell() + * {@inheritdoc} + */ + public function tell() + { + return $this->stream->tell() - $this->offset; + } + + /** + * Set the offset to start limiting from + * + * @param int $offset Offset to seek to and begin byte limiting from + * + * @throws \RuntimeException if the stream cannot be seeked. + */ + public function setOffset($offset) + { + $current = $this->stream->tell(); + + if ($current !== $offset) { + // If the stream cannot seek to the offset position, then read to it + if ($this->stream->isSeekable()) { + $this->stream->seek($offset); + } elseif ($current > $offset) { + throw new \RuntimeException("Could not seek to stream offset $offset"); + } else { + $this->stream->read($offset - $current); + } + } + + $this->offset = $offset; + } + + /** + * Set the limit of bytes that the decorator allows to be read from the + * stream. + * + * @param int $limit Number of bytes to allow to be read from the stream. + * Use -1 for no limit. + */ + public function setLimit($limit) + { + $this->limit = $limit; + } + + public function read($length) + { + if ($this->limit == -1) { + return $this->stream->read($length); + } + + // Check if the current position is less than the total allowed + // bytes + original offset + $remaining = ($this->offset + $this->limit) - $this->stream->tell(); + if ($remaining > 0) { + // Only return the amount of requested data, ensuring that the byte + // limit is not exceeded + return $this->stream->read(min($remaining, $length)); + } + + return ''; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MessageTrait.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MessageTrait.php new file mode 100644 index 0000000..1e4da64 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -0,0 +1,183 @@ + array of values */ + private $headers = []; + + /** @var array Map of lowercase header name => original name at registration */ + private $headerNames = []; + + /** @var string */ + private $protocol = '1.1'; + + /** @var StreamInterface */ + private $stream; + + public function getProtocolVersion() + { + return $this->protocol; + } + + public function withProtocolVersion($version) + { + if ($this->protocol === $version) { + return $this; + } + + $new = clone $this; + $new->protocol = $version; + return $new; + } + + public function getHeaders() + { + return $this->headers; + } + + public function hasHeader($header) + { + return isset($this->headerNames[strtolower($header)]); + } + + public function getHeader($header) + { + $header = strtolower($header); + + if (!isset($this->headerNames[$header])) { + return []; + } + + $header = $this->headerNames[$header]; + + return $this->headers[$header]; + } + + public function getHeaderLine($header) + { + return implode(', ', $this->getHeader($header)); + } + + public function withHeader($header, $value) + { + if (!is_array($value)) { + $value = [$value]; + } + + $value = $this->trimHeaderValues($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + unset($new->headers[$new->headerNames[$normalized]]); + } + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + + return $new; + } + + public function withAddedHeader($header, $value) + { + if (!is_array($value)) { + $value = [$value]; + } + + $value = $this->trimHeaderValues($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $new->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + } + + return $new; + } + + public function withoutHeader($header) + { + $normalized = strtolower($header); + + if (!isset($this->headerNames[$normalized])) { + return $this; + } + + $header = $this->headerNames[$normalized]; + + $new = clone $this; + unset($new->headers[$header], $new->headerNames[$normalized]); + + return $new; + } + + public function getBody() + { + if (!$this->stream) { + $this->stream = stream_for(''); + } + + return $this->stream; + } + + public function withBody(StreamInterface $body) + { + if ($body === $this->stream) { + return $this; + } + + $new = clone $this; + $new->stream = $body; + return $new; + } + + private function setHeaders(array $headers) + { + $this->headerNames = $this->headers = []; + foreach ($headers as $header => $value) { + if (!is_array($value)) { + $value = [$value]; + } + + $value = $this->trimHeaderValues($value); + $normalized = strtolower($header); + if (isset($this->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $this->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $this->headerNames[$normalized] = $header; + $this->headers[$header] = $value; + } + } + } + + /** + * Trims whitespace from the header values. + * + * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. + * + * header-field = field-name ":" OWS field-value OWS + * OWS = *( SP / HTAB ) + * + * @param string[] $values Header values + * + * @return string[] Trimmed header values + * + * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 + */ + private function trimHeaderValues(array $values) + { + return array_map(function ($value) { + return trim($value, " \t"); + }, $values); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MultipartStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MultipartStream.php new file mode 100644 index 0000000..c0fd584 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/MultipartStream.php @@ -0,0 +1,153 @@ +boundary = $boundary ?: sha1(uniqid('', true)); + $this->stream = $this->createStream($elements); + } + + /** + * Get the boundary + * + * @return string + */ + public function getBoundary() + { + return $this->boundary; + } + + public function isWritable() + { + return false; + } + + /** + * Get the headers needed before transferring the content of a POST file + */ + private function getHeaders(array $headers) + { + $str = ''; + foreach ($headers as $key => $value) { + $str .= "{$key}: {$value}\r\n"; + } + + return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n"; + } + + /** + * Create the aggregate stream that will be used to upload the POST data + */ + protected function createStream(array $elements) + { + $stream = new AppendStream(); + + foreach ($elements as $element) { + $this->addElement($stream, $element); + } + + // Add the trailing boundary with CRLF + $stream->addStream(stream_for("--{$this->boundary}--\r\n")); + + return $stream; + } + + private function addElement(AppendStream $stream, array $element) + { + foreach (['contents', 'name'] as $key) { + if (!array_key_exists($key, $element)) { + throw new \InvalidArgumentException("A '{$key}' key is required"); + } + } + + $element['contents'] = stream_for($element['contents']); + + if (empty($element['filename'])) { + $uri = $element['contents']->getMetadata('uri'); + if (substr($uri, 0, 6) !== 'php://') { + $element['filename'] = $uri; + } + } + + list($body, $headers) = $this->createElement( + $element['name'], + $element['contents'], + isset($element['filename']) ? $element['filename'] : null, + isset($element['headers']) ? $element['headers'] : [] + ); + + $stream->addStream(stream_for($this->getHeaders($headers))); + $stream->addStream($body); + $stream->addStream(stream_for("\r\n")); + } + + /** + * @return array + */ + private function createElement($name, StreamInterface $stream, $filename, array $headers) + { + // Set a default content-disposition header if one was no provided + $disposition = $this->getHeader($headers, 'content-disposition'); + if (!$disposition) { + $headers['Content-Disposition'] = ($filename === '0' || $filename) + ? sprintf('form-data; name="%s"; filename="%s"', + $name, + basename($filename)) + : "form-data; name=\"{$name}\""; + } + + // Set a default content-length header if one was no provided + $length = $this->getHeader($headers, 'content-length'); + if (!$length) { + if ($length = $stream->getSize()) { + $headers['Content-Length'] = (string) $length; + } + } + + // Set a default Content-Type if one was not supplied + $type = $this->getHeader($headers, 'content-type'); + if (!$type && ($filename === '0' || $filename)) { + if ($type = mimetype_from_filename($filename)) { + $headers['Content-Type'] = $type; + } + } + + return [$stream, $headers]; + } + + private function getHeader(array $headers, $key) + { + $lowercaseHeader = strtolower($key); + foreach ($headers as $k => $v) { + if (strtolower($k) === $lowercaseHeader) { + return $v; + } + } + + return null; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/NoSeekStream.php new file mode 100644 index 0000000..2332218 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/NoSeekStream.php @@ -0,0 +1,22 @@ +source = $source; + $this->size = isset($options['size']) ? $options['size'] : null; + $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; + $this->buffer = new BufferStream(); + } + + public function __toString() + { + try { + return copy_to_string($this); + } catch (\Exception $e) { + return ''; + } + } + + public function close() + { + $this->detach(); + } + + public function detach() + { + $this->tellPos = false; + $this->source = null; + } + + public function getSize() + { + return $this->size; + } + + public function tell() + { + return $this->tellPos; + } + + public function eof() + { + return !$this->source; + } + + public function isSeekable() + { + return false; + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + throw new \RuntimeException('Cannot seek a PumpStream'); + } + + public function isWritable() + { + return false; + } + + public function write($string) + { + throw new \RuntimeException('Cannot write to a PumpStream'); + } + + public function isReadable() + { + return true; + } + + public function read($length) + { + $data = $this->buffer->read($length); + $readLen = strlen($data); + $this->tellPos += $readLen; + $remaining = $length - $readLen; + + if ($remaining) { + $this->pump($remaining); + $data .= $this->buffer->read($remaining); + $this->tellPos += strlen($data) - $readLen; + } + + return $data; + } + + public function getContents() + { + $result = ''; + while (!$this->eof()) { + $result .= $this->read(1000000); + } + + return $result; + } + + public function getMetadata($key = null) + { + if (!$key) { + return $this->metadata; + } + + return isset($this->metadata[$key]) ? $this->metadata[$key] : null; + } + + private function pump($length) + { + if ($this->source) { + do { + $data = call_user_func($this->source, $length); + if ($data === false || $data === null) { + $this->source = null; + return; + } + $this->buffer->write($data); + $length -= strlen($data); + } while ($length > 0); + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Request.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Request.php new file mode 100644 index 0000000..0828548 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Request.php @@ -0,0 +1,142 @@ +method = strtoupper($method); + $this->uri = $uri; + $this->setHeaders($headers); + $this->protocol = $version; + + if (!$this->hasHeader('Host')) { + $this->updateHostFromUri(); + } + + if ($body !== '' && $body !== null) { + $this->stream = stream_for($body); + } + } + + public function getRequestTarget() + { + if ($this->requestTarget !== null) { + return $this->requestTarget; + } + + $target = $this->uri->getPath(); + if ($target == '') { + $target = '/'; + } + if ($this->uri->getQuery() != '') { + $target .= '?' . $this->uri->getQuery(); + } + + return $target; + } + + public function withRequestTarget($requestTarget) + { + if (preg_match('#\s#', $requestTarget)) { + throw new InvalidArgumentException( + 'Invalid request target provided; cannot contain whitespace' + ); + } + + $new = clone $this; + $new->requestTarget = $requestTarget; + return $new; + } + + public function getMethod() + { + return $this->method; + } + + public function withMethod($method) + { + $new = clone $this; + $new->method = strtoupper($method); + return $new; + } + + public function getUri() + { + return $this->uri; + } + + public function withUri(UriInterface $uri, $preserveHost = false) + { + if ($uri === $this->uri) { + return $this; + } + + $new = clone $this; + $new->uri = $uri; + + if (!$preserveHost) { + $new->updateHostFromUri(); + } + + return $new; + } + + private function updateHostFromUri() + { + $host = $this->uri->getHost(); + + if ($host == '') { + return; + } + + if (($port = $this->uri->getPort()) !== null) { + $host .= ':' . $port; + } + + if (isset($this->headerNames['host'])) { + $header = $this->headerNames['host']; + } else { + $header = 'Host'; + $this->headerNames['host'] = 'Host'; + } + // Ensure Host is the first header. + // See: http://tools.ietf.org/html/rfc7230#section-5.4 + $this->headers = [$header => [$host]] + $this->headers; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Response.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Response.php new file mode 100644 index 0000000..2830c6c --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Response.php @@ -0,0 +1,132 @@ + 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-status', + 208 => 'Already Reported', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 306 => 'Switch Proxy', + 307 => 'Temporary Redirect', + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Time-out', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Large', + 415 => 'Unsupported Media Type', + 416 => 'Requested range not satisfiable', + 417 => 'Expectation Failed', + 418 => 'I\'m a teapot', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 425 => 'Unordered Collection', + 426 => 'Upgrade Required', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + 431 => 'Request Header Fields Too Large', + 451 => 'Unavailable For Legal Reasons', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Time-out', + 505 => 'HTTP Version not supported', + 506 => 'Variant Also Negotiates', + 507 => 'Insufficient Storage', + 508 => 'Loop Detected', + 511 => 'Network Authentication Required', + ]; + + /** @var string */ + private $reasonPhrase = ''; + + /** @var int */ + private $statusCode = 200; + + /** + * @param int $status Status code + * @param array $headers Response headers + * @param string|null|resource|StreamInterface $body Response body + * @param string $version Protocol version + * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) + */ + public function __construct( + $status = 200, + array $headers = [], + $body = null, + $version = '1.1', + $reason = null + ) { + $this->statusCode = (int) $status; + + if ($body !== '' && $body !== null) { + $this->stream = stream_for($body); + } + + $this->setHeaders($headers); + if ($reason == '' && isset(self::$phrases[$this->statusCode])) { + $this->reasonPhrase = self::$phrases[$this->statusCode]; + } else { + $this->reasonPhrase = (string) $reason; + } + + $this->protocol = $version; + } + + public function getStatusCode() + { + return $this->statusCode; + } + + public function getReasonPhrase() + { + return $this->reasonPhrase; + } + + public function withStatus($code, $reasonPhrase = '') + { + $new = clone $this; + $new->statusCode = (int) $code; + if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { + $reasonPhrase = self::$phrases[$new->statusCode]; + } + $new->reasonPhrase = $reasonPhrase; + return $new; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/ServerRequest.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/ServerRequest.php new file mode 100644 index 0000000..575aab8 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -0,0 +1,358 @@ +serverParams = $serverParams; + + parent::__construct($method, $uri, $headers, $body, $version); + } + + /** + * Return an UploadedFile instance array. + * + * @param array $files A array which respect $_FILES structure + * @throws InvalidArgumentException for unrecognized values + * @return array + */ + public static function normalizeFiles(array $files) + { + $normalized = []; + + foreach ($files as $key => $value) { + if ($value instanceof UploadedFileInterface) { + $normalized[$key] = $value; + } elseif (is_array($value) && isset($value['tmp_name'])) { + $normalized[$key] = self::createUploadedFileFromSpec($value); + } elseif (is_array($value)) { + $normalized[$key] = self::normalizeFiles($value); + continue; + } else { + throw new InvalidArgumentException('Invalid value in files specification'); + } + } + + return $normalized; + } + + /** + * Create and return an UploadedFile instance from a $_FILES specification. + * + * If the specification represents an array of values, this method will + * delegate to normalizeNestedFileSpec() and return that return value. + * + * @param array $value $_FILES struct + * @return array|UploadedFileInterface + */ + private static function createUploadedFileFromSpec(array $value) + { + if (is_array($value['tmp_name'])) { + return self::normalizeNestedFileSpec($value); + } + + return new UploadedFile( + $value['tmp_name'], + (int) $value['size'], + (int) $value['error'], + $value['name'], + $value['type'] + ); + } + + /** + * Normalize an array of file specifications. + * + * Loops through all nested files and returns a normalized array of + * UploadedFileInterface instances. + * + * @param array $files + * @return UploadedFileInterface[] + */ + private static function normalizeNestedFileSpec(array $files = []) + { + $normalizedFiles = []; + + foreach (array_keys($files['tmp_name']) as $key) { + $spec = [ + 'tmp_name' => $files['tmp_name'][$key], + 'size' => $files['size'][$key], + 'error' => $files['error'][$key], + 'name' => $files['name'][$key], + 'type' => $files['type'][$key], + ]; + $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); + } + + return $normalizedFiles; + } + + /** + * Return a ServerRequest populated with superglobals: + * $_GET + * $_POST + * $_COOKIE + * $_FILES + * $_SERVER + * + * @return ServerRequestInterface + */ + public static function fromGlobals() + { + $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; + $headers = function_exists('getallheaders') ? getallheaders() : []; + $uri = self::getUriFromGlobals(); + $body = new LazyOpenStream('php://input', 'r+'); + $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; + + $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); + + return $serverRequest + ->withCookieParams($_COOKIE) + ->withQueryParams($_GET) + ->withParsedBody($_POST) + ->withUploadedFiles(self::normalizeFiles($_FILES)); + } + + /** + * Get a Uri populated with values from $_SERVER. + * + * @return UriInterface + */ + public static function getUriFromGlobals() { + $uri = new Uri(''); + + $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http'); + + $hasPort = false; + if (isset($_SERVER['HTTP_HOST'])) { + $hostHeaderParts = explode(':', $_SERVER['HTTP_HOST']); + $uri = $uri->withHost($hostHeaderParts[0]); + if (isset($hostHeaderParts[1])) { + $hasPort = true; + $uri = $uri->withPort($hostHeaderParts[1]); + } + } elseif (isset($_SERVER['SERVER_NAME'])) { + $uri = $uri->withHost($_SERVER['SERVER_NAME']); + } elseif (isset($_SERVER['SERVER_ADDR'])) { + $uri = $uri->withHost($_SERVER['SERVER_ADDR']); + } + + if (!$hasPort && isset($_SERVER['SERVER_PORT'])) { + $uri = $uri->withPort($_SERVER['SERVER_PORT']); + } + + $hasQuery = false; + if (isset($_SERVER['REQUEST_URI'])) { + $requestUriParts = explode('?', $_SERVER['REQUEST_URI']); + $uri = $uri->withPath($requestUriParts[0]); + if (isset($requestUriParts[1])) { + $hasQuery = true; + $uri = $uri->withQuery($requestUriParts[1]); + } + } + + if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) { + $uri = $uri->withQuery($_SERVER['QUERY_STRING']); + } + + return $uri; + } + + + /** + * {@inheritdoc} + */ + public function getServerParams() + { + return $this->serverParams; + } + + /** + * {@inheritdoc} + */ + public function getUploadedFiles() + { + return $this->uploadedFiles; + } + + /** + * {@inheritdoc} + */ + public function withUploadedFiles(array $uploadedFiles) + { + $new = clone $this; + $new->uploadedFiles = $uploadedFiles; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getCookieParams() + { + return $this->cookieParams; + } + + /** + * {@inheritdoc} + */ + public function withCookieParams(array $cookies) + { + $new = clone $this; + $new->cookieParams = $cookies; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getQueryParams() + { + return $this->queryParams; + } + + /** + * {@inheritdoc} + */ + public function withQueryParams(array $query) + { + $new = clone $this; + $new->queryParams = $query; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getParsedBody() + { + return $this->parsedBody; + } + + /** + * {@inheritdoc} + */ + public function withParsedBody($data) + { + $new = clone $this; + $new->parsedBody = $data; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * {@inheritdoc} + */ + public function getAttribute($attribute, $default = null) + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $default; + } + + return $this->attributes[$attribute]; + } + + /** + * {@inheritdoc} + */ + public function withAttribute($attribute, $value) + { + $new = clone $this; + $new->attributes[$attribute] = $value; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function withoutAttribute($attribute) + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $this; + } + + $new = clone $this; + unset($new->attributes[$attribute]); + + return $new; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Stream.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Stream.php new file mode 100644 index 0000000..e336628 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Stream.php @@ -0,0 +1,257 @@ + [ + 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, + 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, + 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, + 'x+t' => true, 'c+t' => true, 'a+' => true + ], + 'write' => [ + 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, + 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, + 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, + 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true + ] + ]; + + /** + * This constructor accepts an associative array of options. + * + * - size: (int) If a read stream would otherwise have an indeterminate + * size, but the size is known due to foreknowledge, then you can + * provide that size, in bytes. + * - metadata: (array) Any additional metadata to return when the metadata + * of the stream is accessed. + * + * @param resource $stream Stream resource to wrap. + * @param array $options Associative array of options. + * + * @throws \InvalidArgumentException if the stream is not a stream resource + */ + public function __construct($stream, $options = []) + { + if (!is_resource($stream)) { + throw new \InvalidArgumentException('Stream must be a resource'); + } + + if (isset($options['size'])) { + $this->size = $options['size']; + } + + $this->customMetadata = isset($options['metadata']) + ? $options['metadata'] + : []; + + $this->stream = $stream; + $meta = stream_get_meta_data($this->stream); + $this->seekable = $meta['seekable']; + $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]); + $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]); + $this->uri = $this->getMetadata('uri'); + } + + public function __get($name) + { + if ($name == 'stream') { + throw new \RuntimeException('The stream is detached'); + } + + throw new \BadMethodCallException('No value for ' . $name); + } + + /** + * Closes the stream when the destructed + */ + public function __destruct() + { + $this->close(); + } + + public function __toString() + { + try { + $this->seek(0); + return (string) stream_get_contents($this->stream); + } catch (\Exception $e) { + return ''; + } + } + + public function getContents() + { + $contents = stream_get_contents($this->stream); + + if ($contents === false) { + throw new \RuntimeException('Unable to read stream contents'); + } + + return $contents; + } + + public function close() + { + if (isset($this->stream)) { + if (is_resource($this->stream)) { + fclose($this->stream); + } + $this->detach(); + } + } + + public function detach() + { + if (!isset($this->stream)) { + return null; + } + + $result = $this->stream; + unset($this->stream); + $this->size = $this->uri = null; + $this->readable = $this->writable = $this->seekable = false; + + return $result; + } + + public function getSize() + { + if ($this->size !== null) { + return $this->size; + } + + if (!isset($this->stream)) { + return null; + } + + // Clear the stat cache if the stream has a URI + if ($this->uri) { + clearstatcache(true, $this->uri); + } + + $stats = fstat($this->stream); + if (isset($stats['size'])) { + $this->size = $stats['size']; + return $this->size; + } + + return null; + } + + public function isReadable() + { + return $this->readable; + } + + public function isWritable() + { + return $this->writable; + } + + public function isSeekable() + { + return $this->seekable; + } + + public function eof() + { + return !$this->stream || feof($this->stream); + } + + public function tell() + { + $result = ftell($this->stream); + + if ($result === false) { + throw new \RuntimeException('Unable to determine stream position'); + } + + return $result; + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + if (!$this->seekable) { + throw new \RuntimeException('Stream is not seekable'); + } elseif (fseek($this->stream, $offset, $whence) === -1) { + throw new \RuntimeException('Unable to seek to stream position ' + . $offset . ' with whence ' . var_export($whence, true)); + } + } + + public function read($length) + { + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); + } + if ($length < 0) { + throw new \RuntimeException('Length parameter cannot be negative'); + } + + if (0 === $length) { + return ''; + } + + $string = fread($this->stream, $length); + if (false === $string) { + throw new \RuntimeException('Unable to read from stream'); + } + + return $string; + } + + public function write($string) + { + if (!$this->writable) { + throw new \RuntimeException('Cannot write to a non-writable stream'); + } + + // We can't know the size after writing anything + $this->size = null; + $result = fwrite($this->stream, $string); + + if ($result === false) { + throw new \RuntimeException('Unable to write to stream'); + } + + return $result; + } + + public function getMetadata($key = null) + { + if (!isset($this->stream)) { + return $key ? null : []; + } elseif (!$key) { + return $this->customMetadata + stream_get_meta_data($this->stream); + } elseif (isset($this->customMetadata[$key])) { + return $this->customMetadata[$key]; + } + + $meta = stream_get_meta_data($this->stream); + + return isset($meta[$key]) ? $meta[$key] : null; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php new file mode 100644 index 0000000..daec6f5 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php @@ -0,0 +1,149 @@ +stream = $stream; + } + + /** + * Magic method used to create a new stream if streams are not added in + * the constructor of a decorator (e.g., LazyOpenStream). + * + * @param string $name Name of the property (allows "stream" only). + * + * @return StreamInterface + */ + public function __get($name) + { + if ($name == 'stream') { + $this->stream = $this->createStream(); + return $this->stream; + } + + throw new \UnexpectedValueException("$name not found on class"); + } + + public function __toString() + { + try { + if ($this->isSeekable()) { + $this->seek(0); + } + return $this->getContents(); + } catch (\Exception $e) { + // Really, PHP? https://bugs.php.net/bug.php?id=53648 + trigger_error('StreamDecorator::__toString exception: ' + . (string) $e, E_USER_ERROR); + return ''; + } + } + + public function getContents() + { + return copy_to_string($this); + } + + /** + * Allow decorators to implement custom methods + * + * @param string $method Missing method name + * @param array $args Method arguments + * + * @return mixed + */ + public function __call($method, array $args) + { + $result = call_user_func_array([$this->stream, $method], $args); + + // Always return the wrapped object if the result is a return $this + return $result === $this->stream ? $this : $result; + } + + public function close() + { + $this->stream->close(); + } + + public function getMetadata($key = null) + { + return $this->stream->getMetadata($key); + } + + public function detach() + { + return $this->stream->detach(); + } + + public function getSize() + { + return $this->stream->getSize(); + } + + public function eof() + { + return $this->stream->eof(); + } + + public function tell() + { + return $this->stream->tell(); + } + + public function isReadable() + { + return $this->stream->isReadable(); + } + + public function isWritable() + { + return $this->stream->isWritable(); + } + + public function isSeekable() + { + return $this->stream->isSeekable(); + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + $this->stream->seek($offset, $whence); + } + + public function read($length) + { + return $this->stream->read($length); + } + + public function write($string) + { + return $this->stream->write($string); + } + + /** + * Implement in subclasses to dynamically create streams when requested. + * + * @return StreamInterface + * @throws \BadMethodCallException + */ + protected function createStream() + { + throw new \BadMethodCallException('Not implemented'); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamWrapper.php new file mode 100644 index 0000000..cf7b223 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/StreamWrapper.php @@ -0,0 +1,121 @@ +isReadable()) { + $mode = $stream->isWritable() ? 'r+' : 'r'; + } elseif ($stream->isWritable()) { + $mode = 'w'; + } else { + throw new \InvalidArgumentException('The stream must be readable, ' + . 'writable, or both.'); + } + + return fopen('guzzle://stream', $mode, null, stream_context_create([ + 'guzzle' => ['stream' => $stream] + ])); + } + + /** + * Registers the stream wrapper if needed + */ + public static function register() + { + if (!in_array('guzzle', stream_get_wrappers())) { + stream_wrapper_register('guzzle', __CLASS__); + } + } + + public function stream_open($path, $mode, $options, &$opened_path) + { + $options = stream_context_get_options($this->context); + + if (!isset($options['guzzle']['stream'])) { + return false; + } + + $this->mode = $mode; + $this->stream = $options['guzzle']['stream']; + + return true; + } + + public function stream_read($count) + { + return $this->stream->read($count); + } + + public function stream_write($data) + { + return (int) $this->stream->write($data); + } + + public function stream_tell() + { + return $this->stream->tell(); + } + + public function stream_eof() + { + return $this->stream->eof(); + } + + public function stream_seek($offset, $whence) + { + $this->stream->seek($offset, $whence); + + return true; + } + + public function stream_stat() + { + static $modeMap = [ + 'r' => 33060, + 'r+' => 33206, + 'w' => 33188 + ]; + + return [ + 'dev' => 0, + 'ino' => 0, + 'mode' => $modeMap[$this->mode], + 'nlink' => 0, + 'uid' => 0, + 'gid' => 0, + 'rdev' => 0, + 'size' => $this->stream->getSize() ?: 0, + 'atime' => 0, + 'mtime' => 0, + 'ctime' => 0, + 'blksize' => 0, + 'blocks' => 0 + ]; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UploadedFile.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UploadedFile.php new file mode 100644 index 0000000..e62bd5c --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -0,0 +1,316 @@ +setError($errorStatus); + $this->setSize($size); + $this->setClientFilename($clientFilename); + $this->setClientMediaType($clientMediaType); + + if ($this->isOk()) { + $this->setStreamOrFile($streamOrFile); + } + } + + /** + * Depending on the value set file or stream variable + * + * @param mixed $streamOrFile + * @throws InvalidArgumentException + */ + private function setStreamOrFile($streamOrFile) + { + if (is_string($streamOrFile)) { + $this->file = $streamOrFile; + } elseif (is_resource($streamOrFile)) { + $this->stream = new Stream($streamOrFile); + } elseif ($streamOrFile instanceof StreamInterface) { + $this->stream = $streamOrFile; + } else { + throw new InvalidArgumentException( + 'Invalid stream or file provided for UploadedFile' + ); + } + } + + /** + * @param int $error + * @throws InvalidArgumentException + */ + private function setError($error) + { + if (false === is_int($error)) { + throw new InvalidArgumentException( + 'Upload file error status must be an integer' + ); + } + + if (false === in_array($error, UploadedFile::$errors)) { + throw new InvalidArgumentException( + 'Invalid error status for UploadedFile' + ); + } + + $this->error = $error; + } + + /** + * @param int $size + * @throws InvalidArgumentException + */ + private function setSize($size) + { + if (false === is_int($size)) { + throw new InvalidArgumentException( + 'Upload file size must be an integer' + ); + } + + $this->size = $size; + } + + /** + * @param mixed $param + * @return boolean + */ + private function isStringOrNull($param) + { + return in_array(gettype($param), ['string', 'NULL']); + } + + /** + * @param mixed $param + * @return boolean + */ + private function isStringNotEmpty($param) + { + return is_string($param) && false === empty($param); + } + + /** + * @param string|null $clientFilename + * @throws InvalidArgumentException + */ + private function setClientFilename($clientFilename) + { + if (false === $this->isStringOrNull($clientFilename)) { + throw new InvalidArgumentException( + 'Upload file client filename must be a string or null' + ); + } + + $this->clientFilename = $clientFilename; + } + + /** + * @param string|null $clientMediaType + * @throws InvalidArgumentException + */ + private function setClientMediaType($clientMediaType) + { + if (false === $this->isStringOrNull($clientMediaType)) { + throw new InvalidArgumentException( + 'Upload file client media type must be a string or null' + ); + } + + $this->clientMediaType = $clientMediaType; + } + + /** + * Return true if there is no upload error + * + * @return boolean + */ + private function isOk() + { + return $this->error === UPLOAD_ERR_OK; + } + + /** + * @return boolean + */ + public function isMoved() + { + return $this->moved; + } + + /** + * @throws RuntimeException if is moved or not ok + */ + private function validateActive() + { + if (false === $this->isOk()) { + throw new RuntimeException('Cannot retrieve stream due to upload error'); + } + + if ($this->isMoved()) { + throw new RuntimeException('Cannot retrieve stream after it has already been moved'); + } + } + + /** + * {@inheritdoc} + * @throws RuntimeException if the upload was not successful. + */ + public function getStream() + { + $this->validateActive(); + + if ($this->stream instanceof StreamInterface) { + return $this->stream; + } + + return new LazyOpenStream($this->file, 'r+'); + } + + /** + * {@inheritdoc} + * + * @see http://php.net/is_uploaded_file + * @see http://php.net/move_uploaded_file + * @param string $targetPath Path to which to move the uploaded file. + * @throws RuntimeException if the upload was not successful. + * @throws InvalidArgumentException if the $path specified is invalid. + * @throws RuntimeException on any error during the move operation, or on + * the second or subsequent call to the method. + */ + public function moveTo($targetPath) + { + $this->validateActive(); + + if (false === $this->isStringNotEmpty($targetPath)) { + throw new InvalidArgumentException( + 'Invalid path provided for move operation; must be a non-empty string' + ); + } + + if ($this->file) { + $this->moved = php_sapi_name() == 'cli' + ? rename($this->file, $targetPath) + : move_uploaded_file($this->file, $targetPath); + } else { + copy_to_stream( + $this->getStream(), + new LazyOpenStream($targetPath, 'w') + ); + + $this->moved = true; + } + + if (false === $this->moved) { + throw new RuntimeException( + sprintf('Uploaded file could not be moved to %s', $targetPath) + ); + } + } + + /** + * {@inheritdoc} + * + * @return int|null The file size in bytes or null if unknown. + */ + public function getSize() + { + return $this->size; + } + + /** + * {@inheritdoc} + * + * @see http://php.net/manual/en/features.file-upload.errors.php + * @return int One of PHP's UPLOAD_ERR_XXX constants. + */ + public function getError() + { + return $this->error; + } + + /** + * {@inheritdoc} + * + * @return string|null The filename sent by the client or null if none + * was provided. + */ + public function getClientFilename() + { + return $this->clientFilename; + } + + /** + * {@inheritdoc} + */ + public function getClientMediaType() + { + return $this->clientMediaType; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Uri.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Uri.php new file mode 100644 index 0000000..f46c1db --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/Uri.php @@ -0,0 +1,702 @@ + 80, + 'https' => 443, + 'ftp' => 21, + 'gopher' => 70, + 'nntp' => 119, + 'news' => 119, + 'telnet' => 23, + 'tn3270' => 23, + 'imap' => 143, + 'pop' => 110, + 'ldap' => 389, + ]; + + private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; + private static $charSubDelims = '!\$&\'\(\)\*\+,;='; + private static $replaceQuery = ['=' => '%3D', '&' => '%26']; + + /** @var string Uri scheme. */ + private $scheme = ''; + + /** @var string Uri user info. */ + private $userInfo = ''; + + /** @var string Uri host. */ + private $host = ''; + + /** @var int|null Uri port. */ + private $port; + + /** @var string Uri path. */ + private $path = ''; + + /** @var string Uri query string. */ + private $query = ''; + + /** @var string Uri fragment. */ + private $fragment = ''; + + /** + * @param string $uri URI to parse + */ + public function __construct($uri = '') + { + // weak type check to also accept null until we can add scalar type hints + if ($uri != '') { + $parts = parse_url($uri); + if ($parts === false) { + throw new \InvalidArgumentException("Unable to parse URI: $uri"); + } + $this->applyParts($parts); + } + } + + public function __toString() + { + return self::composeComponents( + $this->scheme, + $this->getAuthority(), + $this->path, + $this->query, + $this->fragment + ); + } + + /** + * Composes a URI reference string from its various components. + * + * Usually this method does not need to be called manually but instead is used indirectly via + * `Psr\Http\Message\UriInterface::__toString`. + * + * PSR-7 UriInterface treats an empty component the same as a missing component as + * getQuery(), getFragment() etc. always return a string. This explains the slight + * difference to RFC 3986 Section 5.3. + * + * Another adjustment is that the authority separator is added even when the authority is missing/empty + * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with + * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But + * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to + * that format). + * + * @param string $scheme + * @param string $authority + * @param string $path + * @param string $query + * @param string $fragment + * + * @return string + * + * @link https://tools.ietf.org/html/rfc3986#section-5.3 + */ + public static function composeComponents($scheme, $authority, $path, $query, $fragment) + { + $uri = ''; + + // weak type checks to also accept null until we can add scalar type hints + if ($scheme != '') { + $uri .= $scheme . ':'; + } + + if ($authority != ''|| $scheme === 'file') { + $uri .= '//' . $authority; + } + + $uri .= $path; + + if ($query != '') { + $uri .= '?' . $query; + } + + if ($fragment != '') { + $uri .= '#' . $fragment; + } + + return $uri; + } + + /** + * Whether the URI has the default port of the current scheme. + * + * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used + * independently of the implementation. + * + * @param UriInterface $uri + * + * @return bool + */ + public static function isDefaultPort(UriInterface $uri) + { + return $uri->getPort() === null + || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]); + } + + /** + * Whether the URI is absolute, i.e. it has a scheme. + * + * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true + * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative + * to another URI, the base URI. Relative references can be divided into several forms: + * - network-path references, e.g. '//example.com/path' + * - absolute-path references, e.g. '/path' + * - relative-path references, e.g. 'subpath' + * + * @param UriInterface $uri + * + * @return bool + * @see Uri::isNetworkPathReference + * @see Uri::isAbsolutePathReference + * @see Uri::isRelativePathReference + * @link https://tools.ietf.org/html/rfc3986#section-4 + */ + public static function isAbsolute(UriInterface $uri) + { + return $uri->getScheme() !== ''; + } + + /** + * Whether the URI is a network-path reference. + * + * A relative reference that begins with two slash characters is termed an network-path reference. + * + * @param UriInterface $uri + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.2 + */ + public static function isNetworkPathReference(UriInterface $uri) + { + return $uri->getScheme() === '' && $uri->getAuthority() !== ''; + } + + /** + * Whether the URI is a absolute-path reference. + * + * A relative reference that begins with a single slash character is termed an absolute-path reference. + * + * @param UriInterface $uri + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.2 + */ + public static function isAbsolutePathReference(UriInterface $uri) + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && isset($uri->getPath()[0]) + && $uri->getPath()[0] === '/'; + } + + /** + * Whether the URI is a relative-path reference. + * + * A relative reference that does not begin with a slash character is termed a relative-path reference. + * + * @param UriInterface $uri + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.2 + */ + public static function isRelativePathReference(UriInterface $uri) + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); + } + + /** + * Whether the URI is a same-document reference. + * + * A same-document reference refers to a URI that is, aside from its fragment + * component, identical to the base URI. When no base URI is given, only an empty + * URI reference (apart from its fragment) is considered a same-document reference. + * + * @param UriInterface $uri The URI to check + * @param UriInterface|null $base An optional base URI to compare against + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.4 + */ + public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null) + { + if ($base !== null) { + $uri = UriResolver::resolve($base, $uri); + + return ($uri->getScheme() === $base->getScheme()) + && ($uri->getAuthority() === $base->getAuthority()) + && ($uri->getPath() === $base->getPath()) + && ($uri->getQuery() === $base->getQuery()); + } + + return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; + } + + /** + * Removes dot segments from a path and returns the new path. + * + * @param string $path + * + * @return string + * + * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead. + * @see UriResolver::removeDotSegments + */ + public static function removeDotSegments($path) + { + return UriResolver::removeDotSegments($path); + } + + /** + * Converts the relative URI into a new URI that is resolved against the base URI. + * + * @param UriInterface $base Base URI + * @param string|UriInterface $rel Relative URI + * + * @return UriInterface + * + * @deprecated since version 1.4. Use UriResolver::resolve instead. + * @see UriResolver::resolve + */ + public static function resolve(UriInterface $base, $rel) + { + if (!($rel instanceof UriInterface)) { + $rel = new self($rel); + } + + return UriResolver::resolve($base, $rel); + } + + /** + * Creates a new URI with a specific query string value removed. + * + * Any existing query string values that exactly match the provided key are + * removed. + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Query string key to remove. + * + * @return UriInterface + */ + public static function withoutQueryValue(UriInterface $uri, $key) + { + $current = $uri->getQuery(); + if ($current === '') { + return $uri; + } + + $decodedKey = rawurldecode($key); + $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { + return rawurldecode(explode('=', $part)[0]) !== $decodedKey; + }); + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a new URI with a specific query string value. + * + * Any existing query string values that exactly match the provided key are + * removed and replaced with the given key value pair. + * + * A value of null will set the query string key without a value, e.g. "key" + * instead of "key=value". + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Key to set. + * @param string|null $value Value to set + * + * @return UriInterface + */ + public static function withQueryValue(UriInterface $uri, $key, $value) + { + $current = $uri->getQuery(); + + if ($current === '') { + $result = []; + } else { + $decodedKey = rawurldecode($key); + $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { + return rawurldecode(explode('=', $part)[0]) !== $decodedKey; + }); + } + + // Query string separators ("=", "&") within the key or value need to be encoded + // (while preventing double-encoding) before setting the query string. All other + // chars that need percent-encoding will be encoded by withQuery(). + $key = strtr($key, self::$replaceQuery); + + if ($value !== null) { + $result[] = $key . '=' . strtr($value, self::$replaceQuery); + } else { + $result[] = $key; + } + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a URI from a hash of `parse_url` components. + * + * @param array $parts + * + * @return UriInterface + * @link http://php.net/manual/en/function.parse-url.php + * + * @throws \InvalidArgumentException If the components do not form a valid URI. + */ + public static function fromParts(array $parts) + { + $uri = new self(); + $uri->applyParts($parts); + $uri->validateState(); + + return $uri; + } + + public function getScheme() + { + return $this->scheme; + } + + public function getAuthority() + { + $authority = $this->host; + if ($this->userInfo !== '') { + $authority = $this->userInfo . '@' . $authority; + } + + if ($this->port !== null) { + $authority .= ':' . $this->port; + } + + return $authority; + } + + public function getUserInfo() + { + return $this->userInfo; + } + + public function getHost() + { + return $this->host; + } + + public function getPort() + { + return $this->port; + } + + public function getPath() + { + return $this->path; + } + + public function getQuery() + { + return $this->query; + } + + public function getFragment() + { + return $this->fragment; + } + + public function withScheme($scheme) + { + $scheme = $this->filterScheme($scheme); + + if ($this->scheme === $scheme) { + return $this; + } + + $new = clone $this; + $new->scheme = $scheme; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withUserInfo($user, $password = null) + { + $info = $user; + if ($password != '') { + $info .= ':' . $password; + } + + if ($this->userInfo === $info) { + return $this; + } + + $new = clone $this; + $new->userInfo = $info; + $new->validateState(); + + return $new; + } + + public function withHost($host) + { + $host = $this->filterHost($host); + + if ($this->host === $host) { + return $this; + } + + $new = clone $this; + $new->host = $host; + $new->validateState(); + + return $new; + } + + public function withPort($port) + { + $port = $this->filterPort($port); + + if ($this->port === $port) { + return $this; + } + + $new = clone $this; + $new->port = $port; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withPath($path) + { + $path = $this->filterPath($path); + + if ($this->path === $path) { + return $this; + } + + $new = clone $this; + $new->path = $path; + $new->validateState(); + + return $new; + } + + public function withQuery($query) + { + $query = $this->filterQueryAndFragment($query); + + if ($this->query === $query) { + return $this; + } + + $new = clone $this; + $new->query = $query; + + return $new; + } + + public function withFragment($fragment) + { + $fragment = $this->filterQueryAndFragment($fragment); + + if ($this->fragment === $fragment) { + return $this; + } + + $new = clone $this; + $new->fragment = $fragment; + + return $new; + } + + /** + * Apply parse_url parts to a URI. + * + * @param array $parts Array of parse_url parts to apply. + */ + private function applyParts(array $parts) + { + $this->scheme = isset($parts['scheme']) + ? $this->filterScheme($parts['scheme']) + : ''; + $this->userInfo = isset($parts['user']) ? $parts['user'] : ''; + $this->host = isset($parts['host']) + ? $this->filterHost($parts['host']) + : ''; + $this->port = isset($parts['port']) + ? $this->filterPort($parts['port']) + : null; + $this->path = isset($parts['path']) + ? $this->filterPath($parts['path']) + : ''; + $this->query = isset($parts['query']) + ? $this->filterQueryAndFragment($parts['query']) + : ''; + $this->fragment = isset($parts['fragment']) + ? $this->filterQueryAndFragment($parts['fragment']) + : ''; + if (isset($parts['pass'])) { + $this->userInfo .= ':' . $parts['pass']; + } + + $this->removeDefaultPort(); + } + + /** + * @param string $scheme + * + * @return string + * + * @throws \InvalidArgumentException If the scheme is invalid. + */ + private function filterScheme($scheme) + { + if (!is_string($scheme)) { + throw new \InvalidArgumentException('Scheme must be a string'); + } + + return strtolower($scheme); + } + + /** + * @param string $host + * + * @return string + * + * @throws \InvalidArgumentException If the host is invalid. + */ + private function filterHost($host) + { + if (!is_string($host)) { + throw new \InvalidArgumentException('Host must be a string'); + } + + return strtolower($host); + } + + /** + * @param int|null $port + * + * @return int|null + * + * @throws \InvalidArgumentException If the port is invalid. + */ + private function filterPort($port) + { + if ($port === null) { + return null; + } + + $port = (int) $port; + if (1 > $port || 0xffff < $port) { + throw new \InvalidArgumentException( + sprintf('Invalid port: %d. Must be between 1 and 65535', $port) + ); + } + + return $port; + } + + private function removeDefaultPort() + { + if ($this->port !== null && self::isDefaultPort($this)) { + $this->port = null; + } + } + + /** + * Filters the path of a URI + * + * @param string $path + * + * @return string + * + * @throws \InvalidArgumentException If the path is invalid. + */ + private function filterPath($path) + { + if (!is_string($path)) { + throw new \InvalidArgumentException('Path must be a string'); + } + + return preg_replace_callback( + '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $path + ); + } + + /** + * Filters the query string or fragment of a URI. + * + * @param string $str + * + * @return string + * + * @throws \InvalidArgumentException If the query or fragment is invalid. + */ + private function filterQueryAndFragment($str) + { + if (!is_string($str)) { + throw new \InvalidArgumentException('Query and fragment must be a string'); + } + + return preg_replace_callback( + '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $str + ); + } + + private function rawurlencodeMatchZero(array $match) + { + return rawurlencode($match[0]); + } + + private function validateState() + { + if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { + $this->host = self::HTTP_DEFAULT_HOST; + } + + if ($this->getAuthority() === '') { + if (0 === strpos($this->path, '//')) { + throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"'); + } + if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { + throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon'); + } + } elseif (isset($this->path[0]) && $this->path[0] !== '/') { + @trigger_error( + 'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' . + 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.', + E_USER_DEPRECATED + ); + $this->path = '/'. $this->path; + //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty'); + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriNormalizer.php new file mode 100644 index 0000000..384c29e --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriNormalizer.php @@ -0,0 +1,216 @@ +getPath() === '' && + ($uri->getScheme() === 'http' || $uri->getScheme() === 'https') + ) { + $uri = $uri->withPath('/'); + } + + if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') { + $uri = $uri->withHost(''); + } + + if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) { + $uri = $uri->withPort(null); + } + + if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) { + $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath())); + } + + if ($flags & self::REMOVE_DUPLICATE_SLASHES) { + $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath())); + } + + if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') { + $queryKeyValues = explode('&', $uri->getQuery()); + sort($queryKeyValues); + $uri = $uri->withQuery(implode('&', $queryKeyValues)); + } + + return $uri; + } + + /** + * Whether two URIs can be considered equivalent. + * + * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also + * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be + * resolved against the same base URI. If this is not the case, determination of equivalence or difference of + * relative references does not mean anything. + * + * @param UriInterface $uri1 An URI to compare + * @param UriInterface $uri2 An URI to compare + * @param int $normalizations A bitmask of normalizations to apply, see constants + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-6.1 + */ + public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS) + { + return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations); + } + + private static function capitalizePercentEncoding(UriInterface $uri) + { + $regex = '/(?:%[A-Fa-f0-9]{2})++/'; + + $callback = function (array $match) { + return strtoupper($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private static function decodeUnreservedCharacters(UriInterface $uri) + { + $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; + + $callback = function (array $match) { + return rawurldecode($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriResolver.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriResolver.php new file mode 100644 index 0000000..c1cb8a2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/UriResolver.php @@ -0,0 +1,219 @@ +getScheme() != '') { + return $rel->withPath(self::removeDotSegments($rel->getPath())); + } + + if ($rel->getAuthority() != '') { + $targetAuthority = $rel->getAuthority(); + $targetPath = self::removeDotSegments($rel->getPath()); + $targetQuery = $rel->getQuery(); + } else { + $targetAuthority = $base->getAuthority(); + if ($rel->getPath() === '') { + $targetPath = $base->getPath(); + $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); + } else { + if ($rel->getPath()[0] === '/') { + $targetPath = $rel->getPath(); + } else { + if ($targetAuthority != '' && $base->getPath() === '') { + $targetPath = '/' . $rel->getPath(); + } else { + $lastSlashPos = strrpos($base->getPath(), '/'); + if ($lastSlashPos === false) { + $targetPath = $rel->getPath(); + } else { + $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); + } + } + } + $targetPath = self::removeDotSegments($targetPath); + $targetQuery = $rel->getQuery(); + } + } + + return new Uri(Uri::composeComponents( + $base->getScheme(), + $targetAuthority, + $targetPath, + $targetQuery, + $rel->getFragment() + )); + } + + /** + * Returns the target URI as a relative reference from the base URI. + * + * This method is the counterpart to resolve(): + * + * (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) + * + * One use-case is to use the current request URI as base URI and then generate relative links in your documents + * to reduce the document size or offer self-contained downloadable document archives. + * + * $base = new Uri('http://example.com/a/b/'); + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. + * echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. + * + * This method also accepts a target that is already relative and will try to relativize it further. Only a + * relative-path reference will be returned as-is. + * + * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well + * + * @param UriInterface $base Base URI + * @param UriInterface $target Target URI + * + * @return UriInterface The relative URI reference + */ + public static function relativize(UriInterface $base, UriInterface $target) + { + if ($target->getScheme() !== '' && + ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') + ) { + return $target; + } + + if (Uri::isRelativePathReference($target)) { + // As the target is already highly relative we return it as-is. It would be possible to resolve + // the target with `$target = self::resolve($base, $target);` and then try make it more relative + // by removing a duplicate query. But let's not do that automatically. + return $target; + } + + if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) { + return $target->withScheme(''); + } + + // We must remove the path before removing the authority because if the path starts with two slashes, the URI + // would turn invalid. And we also cannot set a relative path before removing the authority, as that is also + // invalid. + $emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost(''); + + if ($base->getPath() !== $target->getPath()) { + return $emptyPathUri->withPath(self::getRelativePath($base, $target)); + } + + if ($base->getQuery() === $target->getQuery()) { + // Only the target fragment is left. And it must be returned even if base and target fragment are the same. + return $emptyPathUri->withQuery(''); + } + + // If the base URI has a query but the target has none, we cannot return an empty path reference as it would + // inherit the base query component when resolving. + if ($target->getQuery() === '') { + $segments = explode('/', $target->getPath()); + $lastSegment = end($segments); + + return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); + } + + return $emptyPathUri; + } + + private static function getRelativePath(UriInterface $base, UriInterface $target) + { + $sourceSegments = explode('/', $base->getPath()); + $targetSegments = explode('/', $target->getPath()); + array_pop($sourceSegments); + $targetLastSegment = array_pop($targetSegments); + foreach ($sourceSegments as $i => $segment) { + if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) { + unset($sourceSegments[$i], $targetSegments[$i]); + } else { + break; + } + } + $targetSegments[] = $targetLastSegment; + $relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments); + + // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./". + // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used + // as the first segment of a relative-path reference, as it would be mistaken for a scheme name. + if ('' === $relativePath || false !== strpos(explode('/', $relativePath, 2)[0], ':')) { + $relativePath = "./$relativePath"; + } elseif ('/' === $relativePath[0]) { + if ($base->getAuthority() != '' && $base->getPath() === '') { + // In this case an extra slash is added by resolve() automatically. So we must not add one here. + $relativePath = ".$relativePath"; + } else { + $relativePath = "./$relativePath"; + } + } + + return $relativePath; + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions.php new file mode 100644 index 0000000..e40348d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions.php @@ -0,0 +1,828 @@ +getMethod() . ' ' + . $message->getRequestTarget()) + . ' HTTP/' . $message->getProtocolVersion(); + if (!$message->hasHeader('host')) { + $msg .= "\r\nHost: " . $message->getUri()->getHost(); + } + } elseif ($message instanceof ResponseInterface) { + $msg = 'HTTP/' . $message->getProtocolVersion() . ' ' + . $message->getStatusCode() . ' ' + . $message->getReasonPhrase(); + } else { + throw new \InvalidArgumentException('Unknown message type'); + } + + foreach ($message->getHeaders() as $name => $values) { + $msg .= "\r\n{$name}: " . implode(', ', $values); + } + + return "{$msg}\r\n\r\n" . $message->getBody(); +} + +/** + * Returns a UriInterface for the given value. + * + * This function accepts a string or {@see Psr\Http\Message\UriInterface} and + * returns a UriInterface for the given value. If the value is already a + * `UriInterface`, it is returned as-is. + * + * @param string|UriInterface $uri + * + * @return UriInterface + * @throws \InvalidArgumentException + */ +function uri_for($uri) +{ + if ($uri instanceof UriInterface) { + return $uri; + } elseif (is_string($uri)) { + return new Uri($uri); + } + + throw new \InvalidArgumentException('URI must be a string or UriInterface'); +} + +/** + * Create a new stream based on the input type. + * + * Options is an associative array that can contain the following keys: + * - metadata: Array of custom metadata. + * - size: Size of the stream. + * + * @param resource|string|null|int|float|bool|StreamInterface|callable $resource Entity body data + * @param array $options Additional options + * + * @return Stream + * @throws \InvalidArgumentException if the $resource arg is not valid. + */ +function stream_for($resource = '', array $options = []) +{ + if (is_scalar($resource)) { + $stream = fopen('php://temp', 'r+'); + if ($resource !== '') { + fwrite($stream, $resource); + fseek($stream, 0); + } + return new Stream($stream, $options); + } + + switch (gettype($resource)) { + case 'resource': + return new Stream($resource, $options); + case 'object': + if ($resource instanceof StreamInterface) { + return $resource; + } elseif ($resource instanceof \Iterator) { + return new PumpStream(function () use ($resource) { + if (!$resource->valid()) { + return false; + } + $result = $resource->current(); + $resource->next(); + return $result; + }, $options); + } elseif (method_exists($resource, '__toString')) { + return stream_for((string) $resource, $options); + } + break; + case 'NULL': + return new Stream(fopen('php://temp', 'r+'), $options); + } + + if (is_callable($resource)) { + return new PumpStream($resource, $options); + } + + throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource)); +} + +/** + * Parse an array of header values containing ";" separated data into an + * array of associative arrays representing the header key value pair + * data of the header. When a parameter does not contain a value, but just + * contains a key, this function will inject a key with a '' string value. + * + * @param string|array $header Header to parse into components. + * + * @return array Returns the parsed header values. + */ +function parse_header($header) +{ + static $trimmed = "\"' \n\t\r"; + $params = $matches = []; + + foreach (normalize_header($header) as $val) { + $part = []; + foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) { + if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { + $m = $matches[0]; + if (isset($m[1])) { + $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); + } else { + $part[] = trim($m[0], $trimmed); + } + } + } + if ($part) { + $params[] = $part; + } + } + + return $params; +} + +/** + * Converts an array of header values that may contain comma separated + * headers into an array of headers with no comma separated values. + * + * @param string|array $header Header to normalize. + * + * @return array Returns the normalized header field values. + */ +function normalize_header($header) +{ + if (!is_array($header)) { + return array_map('trim', explode(',', $header)); + } + + $result = []; + foreach ($header as $value) { + foreach ((array) $value as $v) { + if (strpos($v, ',') === false) { + $result[] = $v; + continue; + } + foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) { + $result[] = trim($vv); + } + } + } + + return $result; +} + +/** + * Clone and modify a request with the given changes. + * + * The changes can be one of: + * - method: (string) Changes the HTTP method. + * - set_headers: (array) Sets the given headers. + * - remove_headers: (array) Remove the given headers. + * - body: (mixed) Sets the given body. + * - uri: (UriInterface) Set the URI. + * - query: (string) Set the query string value of the URI. + * - version: (string) Set the protocol version. + * + * @param RequestInterface $request Request to clone and modify. + * @param array $changes Changes to apply. + * + * @return RequestInterface + */ +function modify_request(RequestInterface $request, array $changes) +{ + if (!$changes) { + return $request; + } + + $headers = $request->getHeaders(); + + if (!isset($changes['uri'])) { + $uri = $request->getUri(); + } else { + // Remove the host header if one is on the URI + if ($host = $changes['uri']->getHost()) { + $changes['set_headers']['Host'] = $host; + + if ($port = $changes['uri']->getPort()) { + $standardPorts = ['http' => 80, 'https' => 443]; + $scheme = $changes['uri']->getScheme(); + if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) { + $changes['set_headers']['Host'] .= ':'.$port; + } + } + } + $uri = $changes['uri']; + } + + if (!empty($changes['remove_headers'])) { + $headers = _caseless_remove($changes['remove_headers'], $headers); + } + + if (!empty($changes['set_headers'])) { + $headers = _caseless_remove(array_keys($changes['set_headers']), $headers); + $headers = $changes['set_headers'] + $headers; + } + + if (isset($changes['query'])) { + $uri = $uri->withQuery($changes['query']); + } + + if ($request instanceof ServerRequestInterface) { + return new ServerRequest( + isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $uri, + $headers, + isset($changes['body']) ? $changes['body'] : $request->getBody(), + isset($changes['version']) + ? $changes['version'] + : $request->getProtocolVersion(), + $request->getServerParams() + ); + } + + return new Request( + isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $uri, + $headers, + isset($changes['body']) ? $changes['body'] : $request->getBody(), + isset($changes['version']) + ? $changes['version'] + : $request->getProtocolVersion() + ); +} + +/** + * Attempts to rewind a message body and throws an exception on failure. + * + * The body of the message will only be rewound if a call to `tell()` returns a + * value other than `0`. + * + * @param MessageInterface $message Message to rewind + * + * @throws \RuntimeException + */ +function rewind_body(MessageInterface $message) +{ + $body = $message->getBody(); + + if ($body->tell()) { + $body->rewind(); + } +} + +/** + * Safely opens a PHP stream resource using a filename. + * + * When fopen fails, PHP normally raises a warning. This function adds an + * error handler that checks for errors and throws an exception instead. + * + * @param string $filename File to open + * @param string $mode Mode used to open the file + * + * @return resource + * @throws \RuntimeException if the file cannot be opened + */ +function try_fopen($filename, $mode) +{ + $ex = null; + set_error_handler(function () use ($filename, $mode, &$ex) { + $ex = new \RuntimeException(sprintf( + 'Unable to open %s using mode %s: %s', + $filename, + $mode, + func_get_args()[1] + )); + }); + + $handle = fopen($filename, $mode); + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $handle; +} + +/** + * Copy the contents of a stream into a string until the given number of + * bytes have been read. + * + * @param StreamInterface $stream Stream to read + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * @return string + * @throws \RuntimeException on error. + */ +function copy_to_string(StreamInterface $stream, $maxLen = -1) +{ + $buffer = ''; + + if ($maxLen === -1) { + while (!$stream->eof()) { + $buf = $stream->read(1048576); + // Using a loose equality here to match on '' and false. + if ($buf == null) { + break; + } + $buffer .= $buf; + } + return $buffer; + } + + $len = 0; + while (!$stream->eof() && $len < $maxLen) { + $buf = $stream->read($maxLen - $len); + // Using a loose equality here to match on '' and false. + if ($buf == null) { + break; + } + $buffer .= $buf; + $len = strlen($buffer); + } + + return $buffer; +} + +/** + * Copy the contents of a stream into another stream until the given number + * of bytes have been read. + * + * @param StreamInterface $source Stream to read from + * @param StreamInterface $dest Stream to write to + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * + * @throws \RuntimeException on error. + */ +function copy_to_stream( + StreamInterface $source, + StreamInterface $dest, + $maxLen = -1 +) { + $bufferSize = 8192; + + if ($maxLen === -1) { + while (!$source->eof()) { + if (!$dest->write($source->read($bufferSize))) { + break; + } + } + } else { + $remaining = $maxLen; + while ($remaining > 0 && !$source->eof()) { + $buf = $source->read(min($bufferSize, $remaining)); + $len = strlen($buf); + if (!$len) { + break; + } + $remaining -= $len; + $dest->write($buf); + } + } +} + +/** + * Calculate a hash of a Stream + * + * @param StreamInterface $stream Stream to calculate the hash for + * @param string $algo Hash algorithm (e.g. md5, crc32, etc) + * @param bool $rawOutput Whether or not to use raw output + * + * @return string Returns the hash of the stream + * @throws \RuntimeException on error. + */ +function hash( + StreamInterface $stream, + $algo, + $rawOutput = false +) { + $pos = $stream->tell(); + + if ($pos > 0) { + $stream->rewind(); + } + + $ctx = hash_init($algo); + while (!$stream->eof()) { + hash_update($ctx, $stream->read(1048576)); + } + + $out = hash_final($ctx, (bool) $rawOutput); + $stream->seek($pos); + + return $out; +} + +/** + * Read a line from the stream up to the maximum allowed buffer length + * + * @param StreamInterface $stream Stream to read from + * @param int $maxLength Maximum buffer length + * + * @return string|bool + */ +function readline(StreamInterface $stream, $maxLength = null) +{ + $buffer = ''; + $size = 0; + + while (!$stream->eof()) { + // Using a loose equality here to match on '' and false. + if (null == ($byte = $stream->read(1))) { + return $buffer; + } + $buffer .= $byte; + // Break when a new line is found or the max length - 1 is reached + if ($byte === "\n" || ++$size === $maxLength - 1) { + break; + } + } + + return $buffer; +} + +/** + * Parses a request message string into a request object. + * + * @param string $message Request message string. + * + * @return Request + */ +function parse_request($message) +{ + $data = _parse_message($message); + $matches = []; + if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { + throw new \InvalidArgumentException('Invalid request string'); + } + $parts = explode(' ', $data['start-line'], 3); + $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; + + $request = new Request( + $parts[0], + $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1], + $data['headers'], + $data['body'], + $version + ); + + return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); +} + +/** + * Parses a response message string into a response object. + * + * @param string $message Response message string. + * + * @return Response + */ +function parse_response($message) +{ + $data = _parse_message($message); + // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space + // between status-code and reason-phrase is required. But browsers accept + // responses without space and reason as well. + if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) { + throw new \InvalidArgumentException('Invalid response string'); + } + $parts = explode(' ', $data['start-line'], 3); + + return new Response( + $parts[1], + $data['headers'], + $data['body'], + explode('/', $parts[0])[1], + isset($parts[2]) ? $parts[2] : null + ); +} + +/** + * Parse a query string into an associative array. + * + * If multiple values are found for the same key, the value of that key + * value pair will become an array. This function does not parse nested + * PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will + * be parsed into ['foo[a]' => '1', 'foo[b]' => '2']). + * + * @param string $str Query string to parse + * @param bool|string $urlEncoding How the query string is encoded + * + * @return array + */ +function parse_query($str, $urlEncoding = true) +{ + $result = []; + + if ($str === '') { + return $result; + } + + if ($urlEncoding === true) { + $decoder = function ($value) { + return rawurldecode(str_replace('+', ' ', $value)); + }; + } elseif ($urlEncoding == PHP_QUERY_RFC3986) { + $decoder = 'rawurldecode'; + } elseif ($urlEncoding == PHP_QUERY_RFC1738) { + $decoder = 'urldecode'; + } else { + $decoder = function ($str) { return $str; }; + } + + foreach (explode('&', $str) as $kvp) { + $parts = explode('=', $kvp, 2); + $key = $decoder($parts[0]); + $value = isset($parts[1]) ? $decoder($parts[1]) : null; + if (!isset($result[$key])) { + $result[$key] = $value; + } else { + if (!is_array($result[$key])) { + $result[$key] = [$result[$key]]; + } + $result[$key][] = $value; + } + } + + return $result; +} + +/** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of parse_query() to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like http_build_query would). + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 + * to encode using RFC3986, or PHP_QUERY_RFC1738 + * to encode using RFC1738. + * @return string + */ +function build_query(array $params, $encoding = PHP_QUERY_RFC3986) +{ + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function ($str) { return $str; }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder($k); + if (!is_array($v)) { + $qs .= $k; + if ($v !== null) { + $qs .= '=' . $encoder($v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + if ($vv !== null) { + $qs .= '=' . $encoder($vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; +} + +/** + * Determines the mimetype of a file by looking at its extension. + * + * @param $filename + * + * @return null|string + */ +function mimetype_from_filename($filename) +{ + return mimetype_from_extension(pathinfo($filename, PATHINFO_EXTENSION)); +} + +/** + * Maps a file extensions to a mimetype. + * + * @param $extension string The file extension. + * + * @return string|null + * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types + */ +function mimetype_from_extension($extension) +{ + static $mimetypes = [ + '7z' => 'application/x-7z-compressed', + 'aac' => 'audio/x-aac', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'asc' => 'text/plain', + 'asf' => 'video/x-ms-asf', + 'atom' => 'application/atom+xml', + 'avi' => 'video/x-msvideo', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bzip2', + 'cer' => 'application/pkix-cert', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'css' => 'text/css', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'deb' => 'application/x-debian-package', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dvi' => 'application/x-dvi', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'etx' => 'text/x-setext', + 'flac' => 'audio/flac', + 'flv' => 'video/x-flv', + 'gif' => 'image/gif', + 'gz' => 'application/gzip', + 'htm' => 'text/html', + 'html' => 'text/html', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ini' => 'text/plain', + 'iso' => 'application/x-iso9660-image', + 'jar' => 'application/java-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'js' => 'text/javascript', + 'json' => 'application/json', + 'latex' => 'application/x-latex', + 'log' => 'text/plain', + 'm4a' => 'audio/mp4', + 'm4v' => 'video/mp4', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4v' => 'video/mp4', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'pbm' => 'image/x-portable-bitmap', + 'pdf' => 'application/pdf', + 'pgm' => 'image/x-portable-graymap', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'ppm' => 'image/x-portable-pixmap', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'qt' => 'video/quicktime', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'svg' => 'image/svg+xml', + 'swf' => 'application/x-shockwave-flash', + 'tar' => 'application/x-tar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'torrent' => 'application/x-bittorrent', + 'ttf' => 'application/x-font-ttf', + 'txt' => 'text/plain', + 'wav' => 'audio/x-wav', + 'webm' => 'video/webm', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'video/x-ms-wmv', + 'woff' => 'application/x-font-woff', + 'wsdl' => 'application/wsdl+xml', + 'xbm' => 'image/x-xbitmap', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + 'xpm' => 'image/x-xpixmap', + 'xwd' => 'image/x-xwindowdump', + 'yaml' => 'text/yaml', + 'yml' => 'text/yaml', + 'zip' => 'application/zip', + ]; + + $extension = strtolower($extension); + + return isset($mimetypes[$extension]) + ? $mimetypes[$extension] + : null; +} + +/** + * Parses an HTTP message into an associative array. + * + * The array contains the "start-line" key containing the start line of + * the message, "headers" key containing an associative array of header + * array values, and a "body" key containing the body of the message. + * + * @param string $message HTTP request or response to parse. + * + * @return array + * @internal + */ +function _parse_message($message) +{ + if (!$message) { + throw new \InvalidArgumentException('Invalid message'); + } + + // Iterate over each line in the message, accounting for line endings + $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE); + $result = ['start-line' => array_shift($lines), 'headers' => [], 'body' => '']; + array_shift($lines); + + for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) { + $line = $lines[$i]; + // If two line breaks were encountered, then this is the end of body + if (empty($line)) { + if ($i < $totalLines - 1) { + $result['body'] = implode('', array_slice($lines, $i + 2)); + } + break; + } + if (strpos($line, ':')) { + $parts = explode(':', $line, 2); + $key = trim($parts[0]); + $value = isset($parts[1]) ? trim($parts[1]) : ''; + $result['headers'][$key][] = $value; + } + } + + return $result; +} + +/** + * Constructs a URI for an HTTP request message. + * + * @param string $path Path from the start-line + * @param array $headers Array of headers (each value an array). + * + * @return string + * @internal + */ +function _parse_request_uri($path, array $headers) +{ + $hostKey = array_filter(array_keys($headers), function ($k) { + return strtolower($k) === 'host'; + }); + + // If no host is found, then a full URI cannot be constructed. + if (!$hostKey) { + return $path; + } + + $host = $headers[reset($hostKey)][0]; + $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; + + return $scheme . '://' . $host . '/' . ltrim($path, '/'); +} + +/** @internal */ +function _caseless_remove($keys, array $data) +{ + $result = []; + + foreach ($keys as &$key) { + $key = strtolower($key); + } + + foreach ($data as $k => $v) { + if (!in_array(strtolower($k), $keys)) { + $result[$k] = $v; + } + } + + return $result; +} diff --git a/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions_include.php b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions_include.php new file mode 100644 index 0000000..96a4a83 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/guzzlehttp/psr7/src/functions_include.php @@ -0,0 +1,6 @@ +=5.4.0", + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1" + }, + "require-dev": { + "phpunit/phpunit": "^4.8 || ^5.7", + "mockery/mockery": "~0.9.2" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "minimum-stability": "stable" +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/provides.json b/server/plugins/manogi/mediathumb/vendor/intervention/image/provides.json new file mode 100644 index 0000000..a8cd1b6 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/provides.json @@ -0,0 +1,11 @@ +{ + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": [ + { + "alias": "Image", + "facade": "Intervention\\Image\\Facades\\Image" + } + ] +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractColor.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractColor.php new file mode 100644 index 0000000..0992d80 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractColor.php @@ -0,0 +1,226 @@ +parse($value); + } + + /** + * Parses given value as color + * + * @param mixed $value + * @return \Intervention\Image\AbstractColor + */ + public function parse($value) + { + switch (true) { + + case is_string($value): + $this->initFromString($value); + break; + + case is_int($value): + $this->initFromInteger($value); + break; + + case is_array($value): + $this->initFromArray($value); + break; + + case is_object($value): + $this->initFromObject($value); + break; + + case is_null($value): + $this->initFromArray([255, 255, 255, 0]); + break; + + default: + throw new \Intervention\Image\Exception\NotReadableException( + "Color format ({$value}) cannot be read." + ); + } + + return $this; + } + + /** + * Formats current color instance into given format + * + * @param string $type + * @return mixed + */ + public function format($type) + { + switch (strtolower($type)) { + + case 'rgba': + return $this->getRgba(); + + case 'hex': + return $this->getHex('#'); + + case 'int': + case 'integer': + return $this->getInt(); + + case 'array': + return $this->getArray(); + + case 'obj': + case 'object': + return $this; + + default: + throw new \Intervention\Image\Exception\NotSupportedException( + "Color format ({$type}) is not supported." + ); + } + } + + /** + * Reads RGBA values from string into array + * + * @param string $value + * @return array + */ + protected function rgbaFromString($value) + { + $result = false; + + // parse color string in hexidecimal format like #cccccc or cccccc or ccc + $hexPattern = '/^#?([a-f0-9]{1,2})([a-f0-9]{1,2})([a-f0-9]{1,2})$/i'; + + // parse color string in format rgb(140, 140, 140) + $rgbPattern = '/^rgb ?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3})\)$/i'; + + // parse color string in format rgba(255, 0, 0, 0.5) + $rgbaPattern = '/^rgba ?\(([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9]{1,3}), ?([0-9.]{1,4})\)$/i'; + + if (preg_match($hexPattern, $value, $matches)) { + $result = []; + $result[0] = strlen($matches[1]) == '1' ? hexdec($matches[1].$matches[1]) : hexdec($matches[1]); + $result[1] = strlen($matches[2]) == '1' ? hexdec($matches[2].$matches[2]) : hexdec($matches[2]); + $result[2] = strlen($matches[3]) == '1' ? hexdec($matches[3].$matches[3]) : hexdec($matches[3]); + $result[3] = 1; + } elseif (preg_match($rgbPattern, $value, $matches)) { + $result = []; + $result[0] = ($matches[1] >= 0 && $matches[1] <= 255) ? intval($matches[1]) : 0; + $result[1] = ($matches[2] >= 0 && $matches[2] <= 255) ? intval($matches[2]) : 0; + $result[2] = ($matches[3] >= 0 && $matches[3] <= 255) ? intval($matches[3]) : 0; + $result[3] = 1; + } elseif (preg_match($rgbaPattern, $value, $matches)) { + $result = []; + $result[0] = ($matches[1] >= 0 && $matches[1] <= 255) ? intval($matches[1]) : 0; + $result[1] = ($matches[2] >= 0 && $matches[2] <= 255) ? intval($matches[2]) : 0; + $result[2] = ($matches[3] >= 0 && $matches[3] <= 255) ? intval($matches[3]) : 0; + $result[3] = ($matches[4] >= 0 && $matches[4] <= 1) ? $matches[4] : 0; + } else { + throw new \Intervention\Image\Exception\NotReadableException( + "Unable to read color ({$value})." + ); + } + + return $result; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php new file mode 100644 index 0000000..a717db9 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php @@ -0,0 +1,358 @@ +data = $data; + } + + /** + * Init from fiven URL + * + * @param string $url + * @return \Intervention\Image\Image + */ + public function initFromUrl($url) + { + + $options = [ + 'http' => [ + 'method'=>"GET", + 'header'=>"Accept-language: en\r\n". + "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n" + ] + ]; + + $context = stream_context_create($options); + + + if ($data = @file_get_contents($url, false, $context)) { + return $this->initFromBinary($data); + } + + throw new \Intervention\Image\Exception\NotReadableException( + "Unable to init from given url (".$url.")." + ); + } + + /** + * Init from given stream + * + * @param StreamInterface|resource $stream + * @return \Intervention\Image\Image + */ + public function initFromStream($stream) + { + if (!$stream instanceof StreamInterface) { + $stream = new Stream($stream); + } + + try { + $offset = $stream->tell(); + } catch (\RuntimeException $e) { + $offset = 0; + } + + $shouldAndCanSeek = $offset !== 0 && $stream->isSeekable(); + + if ($shouldAndCanSeek) { + $stream->rewind(); + } + + try { + $data = $stream->getContents(); + } catch (\RuntimeException $e) { + $data = null; + } + + if ($shouldAndCanSeek) { + $stream->seek($offset); + } + + if ($data) { + return $this->initFromBinary($data); + } + + throw new \Intervention\Image\Exception\NotReadableException( + "Unable to init from given stream" + ); + } + + /** + * Determines if current source data is GD resource + * + * @return boolean + */ + public function isGdResource() + { + if (is_resource($this->data)) { + return (get_resource_type($this->data) == 'gd'); + } + + return false; + } + + /** + * Determines if current source data is Imagick object + * + * @return boolean + */ + public function isImagick() + { + return is_a($this->data, 'Imagick'); + } + + /** + * Determines if current source data is Intervention\Image\Image object + * + * @return boolean + */ + public function isInterventionImage() + { + return is_a($this->data, '\Intervention\Image\Image'); + } + + /** + * Determines if current data is SplFileInfo object + * + * @return boolean + */ + public function isSplFileInfo() + { + return is_a($this->data, 'SplFileInfo'); + } + + /** + * Determines if current data is Symfony UploadedFile component + * + * @return boolean + */ + public function isSymfonyUpload() + { + return is_a($this->data, 'Symfony\Component\HttpFoundation\File\UploadedFile'); + } + + /** + * Determines if current source data is file path + * + * @return boolean + */ + public function isFilePath() + { + if (is_string($this->data)) { + try { + return is_file($this->data); + } catch (\Exception $e) { + return false; + } + } + + return false; + } + + /** + * Determines if current source data is url + * + * @return boolean + */ + public function isUrl() + { + return (bool) filter_var($this->data, FILTER_VALIDATE_URL); + } + + /** + * Determines if current source data is a stream resource + * + * @return boolean + */ + public function isStream() + { + if ($this->data instanceof StreamInterface) return true; + if (!is_resource($this->data)) return false; + if (get_resource_type($this->data) !== 'stream') return false; + + return true; + } + + /** + * Determines if current source data is binary data + * + * @return boolean + */ + public function isBinary() + { + if (is_string($this->data)) { + $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $this->data); + return (substr($mime, 0, 4) != 'text' && $mime != 'application/x-empty'); + } + + return false; + } + + /** + * Determines if current source data is data-url + * + * @return boolean + */ + public function isDataUrl() + { + $data = $this->decodeDataUrl($this->data); + + return is_null($data) ? false : true; + } + + /** + * Determines if current source data is base64 encoded + * + * @return boolean + */ + public function isBase64() + { + if (!is_string($this->data)) { + return false; + } + + return base64_encode(base64_decode($this->data)) === $this->data; + } + + /** + * Initiates new Image from Intervention\Image\Image + * + * @param Image $object + * @return \Intervention\Image\Image + */ + public function initFromInterventionImage($object) + { + return $object; + } + + /** + * Parses and decodes binary image data from data-url + * + * @param string $data_url + * @return string + */ + private function decodeDataUrl($data_url) + { + if (!is_string($data_url)) { + return null; + } + + $pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P.+)$/"; + preg_match($pattern, $data_url, $matches); + + if (is_array($matches) && array_key_exists('data', $matches)) { + return base64_decode($matches['data']); + } + + return null; + } + + /** + * Initiates new image from mixed data + * + * @param mixed $data + * @return \Intervention\Image\Image + */ + public function init($data) + { + $this->data = $data; + + switch (true) { + + case $this->isGdResource(): + return $this->initFromGdResource($this->data); + + case $this->isImagick(): + return $this->initFromImagick($this->data); + + case $this->isInterventionImage(): + return $this->initFromInterventionImage($this->data); + + case $this->isSplFileInfo(): + return $this->initFromPath($this->data->getRealPath()); + + case $this->isBinary(): + return $this->initFromBinary($this->data); + + case $this->isUrl(): + return $this->initFromUrl($this->data); + + case $this->isStream(): + return $this->initFromStream($this->data); + + case $this->isDataUrl(): + return $this->initFromBinary($this->decodeDataUrl($this->data)); + + case $this->isFilePath(): + return $this->initFromPath($this->data); + + // isBase64 has to be after isFilePath to prevent false positives + case $this->isBase64(): + return $this->initFromBinary(base64_decode($this->data)); + + default: + throw new Exception\NotReadableException("Image source not readable"); + } + } + + /** + * Decoder object transforms to string source data + * + * @return string + */ + public function __toString() + { + return (string) $this->data; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php new file mode 100644 index 0000000..dfa1649 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php @@ -0,0 +1,132 @@ +decoder->init($data); + } + + /** + * Encodes given image + * + * @param Image $image + * @param string $format + * @param integer $quality + * @return \Intervention\Image\Image + */ + public function encode($image, $format, $quality) + { + return $this->encoder->process($image, $format, $quality); + } + + /** + * Executes named command on given image + * + * @param Image $image + * @param string $name + * @param array $arguments + * @return \Intervention\Image\Commands\AbstractCommand + */ + public function executeCommand($image, $name, $arguments) + { + $commandName = $this->getCommandClassName($name); + $command = new $commandName($arguments); + $command->execute($image); + + return $command; + } + + /** + * Returns classname of given command name + * + * @param string $name + * @return string + */ + private function getCommandClassName($name) + { + $drivername = $this->getDriverName(); + $classnameLocal = sprintf('\Intervention\Image\%s\Commands\%sCommand', $drivername, ucfirst($name)); + $classnameGlobal = sprintf('\Intervention\Image\Commands\%sCommand', ucfirst($name)); + + if (class_exists($classnameLocal)) { + return $classnameLocal; + } elseif (class_exists($classnameGlobal)) { + return $classnameGlobal; + } + + throw new \Intervention\Image\Exception\NotSupportedException( + "Command ({$name}) is not available for driver ({$drivername})." + ); + } + + /** + * Returns name of current driver instance + * + * @return string + */ + public function getDriverName() + { + $reflect = new \ReflectionClass($this); + $namespace = $reflect->getNamespaceName(); + + return substr(strrchr($namespace, "\\"), 1); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractEncoder.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractEncoder.php new file mode 100644 index 0000000..0b56db5 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractEncoder.php @@ -0,0 +1,234 @@ +setImage($image); + $this->setFormat($format); + $this->setQuality($quality); + + switch (strtolower($this->format)) { + + case 'data-url': + $this->result = $this->processDataUrl(); + break; + + case 'gif': + case 'image/gif': + $this->result = $this->processGif(); + break; + + case 'png': + case 'image/png': + case 'image/x-png': + $this->result = $this->processPng(); + break; + + case 'jpg': + case 'jpeg': + case 'image/jpg': + case 'image/jpeg': + case 'image/pjpeg': + $this->result = $this->processJpeg(); + break; + + case 'tif': + case 'tiff': + case 'image/tiff': + case 'image/tif': + case 'image/x-tif': + case 'image/x-tiff': + $this->result = $this->processTiff(); + break; + + case 'bmp': + case 'image/bmp': + case 'image/ms-bmp': + case 'image/x-bitmap': + case 'image/x-bmp': + case 'image/x-ms-bmp': + case 'image/x-win-bitmap': + case 'image/x-windows-bmp': + case 'image/x-xbitmap': + $this->result = $this->processBmp(); + break; + + case 'ico': + case 'image/x-ico': + case 'image/x-icon': + case 'image/vnd.microsoft.icon': + $this->result = $this->processIco(); + break; + + case 'psd': + case 'image/vnd.adobe.photoshop': + $this->result = $this->processPsd(); + break; + + case 'webp': + case 'image/webp': + case 'image/x-webp': + $this->result = $this->processWebp(); + break; + + default: + throw new \Intervention\Image\Exception\NotSupportedException( + "Encoding format ({$format}) is not supported." + ); + } + + $this->setImage(null); + + return $image->setEncoded($this->result); + } + + /** + * Processes and returns encoded image as data-url string + * + * @return string + */ + protected function processDataUrl() + { + $mime = $this->image->mime ? $this->image->mime : 'image/png'; + + return sprintf('data:%s;base64,%s', + $mime, + base64_encode($this->process($this->image, $mime, $this->quality)) + ); + } + + /** + * Sets image to process + * + * @param Image $image + */ + protected function setImage($image) + { + $this->image = $image; + } + + /** + * Determines output format + * + * @param string $format + */ + protected function setFormat($format = null) + { + if ($format == '' && $this->image instanceof Image) { + $format = $this->image->mime; + } + + $this->format = $format ? $format : 'jpg'; + + return $this; + } + + /** + * Determines output quality + * + * @param integer $quality + */ + protected function setQuality($quality) + { + $quality = is_null($quality) ? 90 : $quality; + $quality = $quality === 0 ? 1 : $quality; + + if ($quality < 0 || $quality > 100) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + 'Quality must range from 0 to 100.' + ); + } + + $this->quality = intval($quality); + + return $this; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractFont.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractFont.php new file mode 100644 index 0000000..8bcf3b2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractFont.php @@ -0,0 +1,260 @@ +text = $text; + } + + /** + * Set text to be written + * + * @param String $text + * @return void + */ + public function text($text) + { + $this->text = $text; + + return $this; + } + + /** + * Get text to be written + * + * @return String + */ + public function getText() + { + return $this->text; + } + + /** + * Set font size in pixels + * + * @param integer $size + * @return void + */ + public function size($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get font size in pixels + * + * @return integer + */ + public function getSize() + { + return $this->size; + } + + /** + * Set color of text to be written + * + * @param mixed $color + * @return void + */ + public function color($color) + { + $this->color = $color; + + return $this; + } + + /** + * Get color of text + * + * @return mixed + */ + public function getColor() + { + return $this->color; + } + + /** + * Set rotation angle of text + * + * @param integer $angle + * @return void + */ + public function angle($angle) + { + $this->angle = $angle; + + return $this; + } + + /** + * Get rotation angle of text + * + * @return integer + */ + public function getAngle() + { + return $this->angle; + } + + /** + * Set horizontal text alignment + * + * @param string $align + * @return void + */ + public function align($align) + { + $this->align = $align; + + return $this; + } + + /** + * Get horizontal text alignment + * + * @return string + */ + public function getAlign() + { + return $this->align; + } + + /** + * Set vertical text alignment + * + * @param string $valign + * @return void + */ + public function valign($valign) + { + $this->valign = $valign; + + return $this; + } + + /** + * Get vertical text alignment + * + * @return string + */ + public function getValign() + { + return $this->valign; + } + + /** + * Set path to font file + * + * @param string $file + * @return void + */ + public function file($file) + { + $this->file = $file; + + return $this; + } + + /** + * Get path to font file + * + * @return string + */ + public function getFile() + { + return $this->file; + } + + /** + * Checks if current font has access to an applicable font file + * + * @return boolean + */ + protected function hasApplicableFontFile() + { + if (is_string($this->file)) { + return file_exists($this->file); + } + + return false; + } + + /** + * Counts lines of text to be written + * + * @return integer + */ + public function countLines() + { + return count(explode(PHP_EOL, $this->text)); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractShape.php new file mode 100644 index 0000000..0ffc59e --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/AbstractShape.php @@ -0,0 +1,71 @@ +background = $color; + } + + /** + * Set border width and color of current shape + * + * @param integer $width + * @param string $color + * @return void + */ + public function border($width, $color = null) + { + $this->border_width = is_numeric($width) ? intval($width) : 0; + $this->border_color = is_null($color) ? '#000000' : $color; + } + + /** + * Determines if current shape has border + * + * @return boolean + */ + public function hasBorder() + { + return ($this->border_width >= 1); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php new file mode 100644 index 0000000..daa79bc --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php @@ -0,0 +1,79 @@ +arguments = $arguments; + } + + /** + * Creates new argument instance from given argument key + * + * @param integer $key + * @return \Intervention\Image\Commands\Argument + */ + public function argument($key) + { + return new \Intervention\Image\Commands\Argument($this, $key); + } + + /** + * Returns output data of current command + * + * @return mixed + */ + public function getOutput() + { + return $this->output ? $this->output : null; + } + + /** + * Determines if current instance has output data + * + * @return boolean + */ + public function hasOutput() + { + return ! is_null($this->output); + } + + /** + * Sets output data of current command + * + * @param mixed $value + */ + public function setOutput($value) + { + $this->output = $value; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/Argument.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/Argument.php new file mode 100644 index 0000000..ee33dce --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/Argument.php @@ -0,0 +1,225 @@ +command = $command; + $this->key = $key; + } + + /** + * Returns name of current arguments command + * + * @return string + */ + public function getCommandName() + { + preg_match("/\\\\([\w]+)Command$/", get_class($this->command), $matches); + return isset($matches[1]) ? lcfirst($matches[1]).'()' : 'Method'; + } + + /** + * Returns value of current argument + * + * @param mixed $default + * @return mixed + */ + public function value($default = null) + { + $arguments = $this->command->arguments; + + if (is_array($arguments)) { + return isset($arguments[$this->key]) ? $arguments[$this->key] : $default; + } + + return $default; + } + + /** + * Defines current argument as required + * + * @return \Intervention\Image\Commands\Argument + */ + public function required() + { + if ( ! array_key_exists($this->key, $this->command->arguments)) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + sprintf("Missing argument %d for %s", $this->key + 1, $this->getCommandName()) + ); + } + + return $this; + } + + /** + * Determines that current argument must be of given type + * + * @return \Intervention\Image\Commands\Argument + */ + public function type($type) + { + $fail = false; + + $value = $this->value(); + + if (is_null($value)) { + return $this; + } + + switch (strtolower($type)) { + + case 'bool': + case 'boolean': + $fail = ! is_bool($value); + $message = sprintf('%s accepts only boolean values as argument %d.', $this->getCommandName(), $this->key + 1); + break; + + case 'int': + case 'integer': + $fail = ! is_integer($value); + $message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(), $this->key + 1); + break; + + case 'num': + case 'numeric': + $fail = ! is_numeric($value); + $message = sprintf('%s accepts only numeric values as argument %d.', $this->getCommandName(), $this->key + 1); + break; + + case 'str': + case 'string': + $fail = ! is_string($value); + $message = sprintf('%s accepts only string values as argument %d.', $this->getCommandName(), $this->key + 1); + break; + + case 'array': + $fail = ! is_array($value); + $message = sprintf('%s accepts only array as argument %d.', $this->getCommandName(), $this->key + 1); + break; + + case 'closure': + $fail = ! is_a($value, '\Closure'); + $message = sprintf('%s accepts only Closure as argument %d.', $this->getCommandName(), $this->key + 1); + break; + + case 'digit': + $fail = ! $this->isDigit($value); + $message = sprintf('%s accepts only integer values as argument %d.', $this->getCommandName(), $this->key + 1); + break; + } + + if ($fail) { + + $message = isset($message) ? $message : sprintf("Missing argument for %d.", $this->key); + + throw new \Intervention\Image\Exception\InvalidArgumentException( + $message + ); + } + + return $this; + } + + /** + * Determines that current argument value must be numeric between given values + * + * @return \Intervention\Image\Commands\Argument + */ + public function between($x, $y) + { + $value = $this->type('numeric')->value(); + + if (is_null($value)) { + return $this; + } + + $alpha = min($x, $y); + $omega = max($x, $y); + + if ($value < $alpha || $value > $omega) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + sprintf('Argument %d must be between %s and %s.', $this->key, $x, $y) + ); + } + + return $this; + } + + /** + * Determines that current argument must be over a minimum value + * + * @return \Intervention\Image\Commands\Argument + */ + public function min($value) + { + $v = $this->type('numeric')->value(); + + if (is_null($v)) { + return $this; + } + + if ($v < $value) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + sprintf('Argument %d must be at least %s.', $this->key, $value) + ); + } + + return $this; + } + + /** + * Determines that current argument must be under a maxiumum value + * + * @return \Intervention\Image\Commands\Argument + */ + public function max($value) + { + $v = $this->type('numeric')->value(); + + if (is_null($v)) { + return $this; + } + + if ($v > $value) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + sprintf('Argument %d may not be greater than %s.', $this->key, $value) + ); + } + + return $this; + } + + /** + * Checks if value is "PHP" integer (120 but also 120.0) + * + * @param mixed $value + * @return boolean + */ + private function isDigit($value) + { + return is_numeric($value) ? intval($value) == $value : false; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php new file mode 100644 index 0000000..9acc403 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ChecksumCommand.php @@ -0,0 +1,29 @@ +getSize(); + + for ($x=0; $x <= ($size->width-1); $x++) { + for ($y=0; $y <= ($size->height-1); $y++) { + $colors[] = $image->pickColor($x, $y, 'array'); + } + } + + $this->setOutput(md5(serialize($colors))); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/CircleCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/CircleCommand.php new file mode 100644 index 0000000..2fc38dd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/CircleCommand.php @@ -0,0 +1,35 @@ +argument(0)->type('numeric')->required()->value(); + $x = $this->argument(1)->type('numeric')->required()->value(); + $y = $this->argument(2)->type('numeric')->required()->value(); + $callback = $this->argument(3)->type('closure')->value(); + + $circle_classname = sprintf('\Intervention\Image\%s\Shapes\CircleShape', + $image->getDriver()->getDriverName()); + + $circle = new $circle_classname($diameter); + + if ($callback instanceof Closure) { + $callback($circle); + } + + $circle->applyToImage($image, $x, $y); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/EllipseCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/EllipseCommand.php new file mode 100644 index 0000000..4f364ec --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/EllipseCommand.php @@ -0,0 +1,36 @@ +argument(0)->type('numeric')->required()->value(); + $height = $this->argument(1)->type('numeric')->required()->value(); + $x = $this->argument(2)->type('numeric')->required()->value(); + $y = $this->argument(3)->type('numeric')->required()->value(); + $callback = $this->argument(4)->type('closure')->value(); + + $ellipse_classname = sprintf('\Intervention\Image\%s\Shapes\EllipseShape', + $image->getDriver()->getDriverName()); + + $ellipse = new $ellipse_classname($width, $height); + + if ($callback instanceof Closure) { + $callback($ellipse); + } + + $ellipse->applyToImage($image, $x, $y); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ExifCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ExifCommand.php new file mode 100644 index 0000000..2986cae --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ExifCommand.php @@ -0,0 +1,37 @@ +argument(0)->value(); + + // try to read exif data from image file + $data = @exif_read_data($image->dirname .'/'. $image->basename); + + if (! is_null($key) && is_array($data)) { + $data = array_key_exists($key, $data) ? $data[$key] : false; + } + + $this->setOutput($data); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/IptcCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/IptcCommand.php new file mode 100644 index 0000000..88e8fd3 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/IptcCommand.php @@ -0,0 +1,64 @@ +argument(0)->value(); + + $info = []; + @getimagesize($image->dirname .'/'. $image->basename, $info); + + $data = []; + + if (array_key_exists('APP13', $info)) { + $iptc = iptcparse($info['APP13']); + + if (is_array($iptc)) { + $data['DocumentTitle'] = isset($iptc["2#005"][0]) ? $iptc["2#005"][0] : null; + $data['Urgency'] = isset($iptc["2#010"][0]) ? $iptc["2#010"][0] : null; + $data['Category'] = isset($iptc["2#015"][0]) ? $iptc["2#015"][0] : null; + $data['Subcategories'] = isset($iptc["2#020"][0]) ? $iptc["2#020"][0] : null; + $data['Keywords'] = isset($iptc["2#025"][0]) ? $iptc["2#025"] : null; + $data['SpecialInstructions'] = isset($iptc["2#040"][0]) ? $iptc["2#040"][0] : null; + $data['CreationDate'] = isset($iptc["2#055"][0]) ? $iptc["2#055"][0] : null; + $data['CreationTime'] = isset($iptc["2#060"][0]) ? $iptc["2#060"][0] : null; + $data['AuthorByline'] = isset($iptc["2#080"][0]) ? $iptc["2#080"][0] : null; + $data['AuthorTitle'] = isset($iptc["2#085"][0]) ? $iptc["2#085"][0] : null; + $data['City'] = isset($iptc["2#090"][0]) ? $iptc["2#090"][0] : null; + $data['SubLocation'] = isset($iptc["2#092"][0]) ? $iptc["2#092"][0] : null; + $data['State'] = isset($iptc["2#095"][0]) ? $iptc["2#095"][0] : null; + $data['Country'] = isset($iptc["2#101"][0]) ? $iptc["2#101"][0] : null; + $data['OTR'] = isset($iptc["2#103"][0]) ? $iptc["2#103"][0] : null; + $data['Headline'] = isset($iptc["2#105"][0]) ? $iptc["2#105"][0] : null; + $data['Source'] = isset($iptc["2#110"][0]) ? $iptc["2#110"][0] : null; + $data['PhotoSource'] = isset($iptc["2#115"][0]) ? $iptc["2#115"][0] : null; + $data['Copyright'] = isset($iptc["2#116"][0]) ? $iptc["2#116"][0] : null; + $data['Caption'] = isset($iptc["2#120"][0]) ? $iptc["2#120"][0] : null; + $data['CaptionWriter'] = isset($iptc["2#122"][0]) ? $iptc["2#122"][0] : null; + } + } + + if (! is_null($key) && is_array($data)) { + $data = array_key_exists($key, $data) ? $data[$key] : false; + } + + $this->setOutput($data); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/LineCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/LineCommand.php new file mode 100644 index 0000000..0089c64 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/LineCommand.php @@ -0,0 +1,36 @@ +argument(0)->type('numeric')->required()->value(); + $y1 = $this->argument(1)->type('numeric')->required()->value(); + $x2 = $this->argument(2)->type('numeric')->required()->value(); + $y2 = $this->argument(3)->type('numeric')->required()->value(); + $callback = $this->argument(4)->type('closure')->value(); + + $line_classname = sprintf('\Intervention\Image\%s\Shapes\LineShape', + $image->getDriver()->getDriverName()); + + $line = new $line_classname($x2, $y2); + + if ($callback instanceof Closure) { + $callback($line); + } + + $line->applyToImage($image, $x1, $y1); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/OrientateCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/OrientateCommand.php new file mode 100644 index 0000000..552482c --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/OrientateCommand.php @@ -0,0 +1,48 @@ +exif('Orientation')) { + + case 2: + $image->flip(); + break; + + case 3: + $image->rotate(180); + break; + + case 4: + $image->rotate(180)->flip(); + break; + + case 5: + $image->rotate(270)->flip(); + break; + + case 6: + $image->rotate(270); + break; + + case 7: + $image->rotate(90)->flip(); + break; + + case 8: + $image->rotate(90); + break; + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php new file mode 100644 index 0000000..e46e3ff --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php @@ -0,0 +1,48 @@ +argument(0)->type('array')->required()->value(); + $callback = $this->argument(1)->type('closure')->value(); + + $vertices_count = count($points); + + // check if number if coordinates is even + if ($vertices_count % 2 !== 0) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + "The number of given polygon vertices must be even." + ); + } + + if ($vertices_count < 6) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + "You must have at least 3 points in your array." + ); + } + + $polygon_classname = sprintf('\Intervention\Image\%s\Shapes\PolygonShape', + $image->getDriver()->getDriverName()); + + $polygon = new $polygon_classname($points); + + if ($callback instanceof Closure) { + $callback($polygon); + } + + $polygon->applyToImage($image); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php new file mode 100644 index 0000000..d75cd90 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php @@ -0,0 +1,45 @@ +argument(0)->value(); + $quality = $this->argument(1)->between(0, 100)->value(); + + //Encoded property will be populated at this moment + $stream = $image->stream($format, $quality); + + $mimetype = finfo_buffer( + finfo_open(FILEINFO_MIME_TYPE), + $image->getEncoded() + ); + + $this->setOutput(new Response( + 200, + [ + 'Content-Type' => $mimetype, + 'Content-Length' => strlen($image->getEncoded()) + ], + $stream + )); + + return true; + } +} \ No newline at end of file diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/RectangleCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/RectangleCommand.php new file mode 100644 index 0000000..3a2074c --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/RectangleCommand.php @@ -0,0 +1,36 @@ +argument(0)->type('numeric')->required()->value(); + $y1 = $this->argument(1)->type('numeric')->required()->value(); + $x2 = $this->argument(2)->type('numeric')->required()->value(); + $y2 = $this->argument(3)->type('numeric')->required()->value(); + $callback = $this->argument(4)->type('closure')->value(); + + $rectangle_classname = sprintf('\Intervention\Image\%s\Shapes\RectangleShape', + $image->getDriver()->getDriverName()); + + $rectangle = new $rectangle_classname($x1, $y1, $x2, $y2); + + if ($callback instanceof Closure) { + $callback($rectangle); + } + + $rectangle->applyToImage($image, $x1, $y1); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ResponseCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ResponseCommand.php new file mode 100644 index 0000000..7903b5a --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/ResponseCommand.php @@ -0,0 +1,26 @@ +argument(0)->value(); + $quality = $this->argument(1)->between(0, 100)->value(); + + $response = new Response($image, $format, $quality); + + $this->setOutput($response->make()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/StreamCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/StreamCommand.php new file mode 100644 index 0000000..111c475 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/StreamCommand.php @@ -0,0 +1,25 @@ +argument(0)->value(); + $quality = $this->argument(1)->between(0, 100)->value(); + + $this->setOutput(\GuzzleHttp\Psr7\stream_for( + $image->encode($format, $quality)->getEncoded() + )); + + return true; + } +} \ No newline at end of file diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/TextCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/TextCommand.php new file mode 100644 index 0000000..4aebd8e --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Commands/TextCommand.php @@ -0,0 +1,34 @@ +argument(0)->required()->value(); + $x = $this->argument(1)->type('numeric')->value(0); + $y = $this->argument(2)->type('numeric')->value(0); + $callback = $this->argument(3)->type('closure')->value(); + + $fontclassname = sprintf('\Intervention\Image\%s\Font', + $image->getDriver()->getDriverName()); + + $font = new $fontclassname($text); + + if ($callback instanceof Closure) { + $callback($font); + } + + $font->applyToImage($image, $x, $y); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Constraint.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Constraint.php new file mode 100644 index 0000000..7352354 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Constraint.php @@ -0,0 +1,92 @@ +size = $size; + } + + /** + * Returns current size of constraint + * + * @return \Intervention\Image\Size + */ + public function getSize() + { + return $this->size; + } + + /** + * Fix the given argument in current constraint + * + * @param integer $type + * @return void + */ + public function fix($type) + { + $this->fixed = ($this->fixed & ~(1 << $type)) | (1 << $type); + } + + /** + * Checks if given argument is fixed in current constraint + * + * @param integer $type + * @return boolean + */ + public function isFixed($type) + { + return (bool) ($this->fixed & (1 << $type)); + } + + /** + * Fixes aspect ratio in current constraint + * + * @return void + */ + public function aspectRatio() + { + $this->fix(self::ASPECTRATIO); + } + + /** + * Fixes possibility to size up in current constraint + * + * @return void + */ + public function upsize() + { + $this->fix(self::UPSIZE); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/ImageException.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/ImageException.php new file mode 100644 index 0000000..83e6b91 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Exception/ImageException.php @@ -0,0 +1,8 @@ +dirname = array_key_exists('dirname', $info) ? $info['dirname'] : null; + $this->basename = array_key_exists('basename', $info) ? $info['basename'] : null; + $this->extension = array_key_exists('extension', $info) ? $info['extension'] : null; + $this->filename = array_key_exists('filename', $info) ? $info['filename'] : null; + + if (file_exists($path) && is_file($path)) { + $this->mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); + } + + return $this; + } + + /** + * Get file size + * + * @return mixed + */ + public function filesize() + { + $path = $this->basePath(); + + if (file_exists($path) && is_file($path)) { + return filesize($path); + } + + return false; + } + + /** + * Get fully qualified path + * + * @return string + */ + public function basePath() + { + if ($this->dirname && $this->basename) { + return ($this->dirname .'/'. $this->basename); + } + + return null; + } + +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/DemoFilter.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/DemoFilter.php new file mode 100644 index 0000000..17e926e --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/DemoFilter.php @@ -0,0 +1,42 @@ +size = is_numeric($size) ? intval($size) : self::DEFAULT_SIZE; + } + + /** + * Applies filter effects to given image + * + * @param \Intervention\Image\Image $image + * @return \Intervention\Image\Image + */ + public function applyFilter(\Intervention\Image\Image $image) + { + $image->pixelate($this->size); + $image->greyscale(); + + return $image; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/FilterInterface.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/FilterInterface.php new file mode 100644 index 0000000..27c0bee --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Filters/FilterInterface.php @@ -0,0 +1,14 @@ +a = ($value >> 24) & 0xFF; + $this->r = ($value >> 16) & 0xFF; + $this->g = ($value >> 8) & 0xFF; + $this->b = $value & 0xFF; + } + + /** + * Initiates color object from given array + * + * @param array $value + * @return \Intervention\Image\AbstractColor + */ + public function initFromArray($array) + { + $array = array_values($array); + + if (count($array) == 4) { + + // color array with alpha value + list($r, $g, $b, $a) = $array; + $this->a = $this->alpha2gd($a); + + } elseif (count($array) == 3) { + + // color array without alpha value + list($r, $g, $b) = $array; + $this->a = 0; + + } + + $this->r = $r; + $this->g = $g; + $this->b = $b; + } + + /** + * Initiates color object from given string + * + * @param string $value + * @return \Intervention\Image\AbstractColor + */ + public function initFromString($value) + { + if ($color = $this->rgbaFromString($value)) { + $this->r = $color[0]; + $this->g = $color[1]; + $this->b = $color[2]; + $this->a = $this->alpha2gd($color[3]); + } + } + + /** + * Initiates color object from given R, G and B values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @return \Intervention\Image\AbstractColor + */ + public function initFromRgb($r, $g, $b) + { + $this->r = intval($r); + $this->g = intval($g); + $this->b = intval($b); + $this->a = 0; + } + + /** + * Initiates color object from given R, G, B and A values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @param float $a + * @return \Intervention\Image\AbstractColor + */ + public function initFromRgba($r, $g, $b, $a = 1) + { + $this->r = intval($r); + $this->g = intval($g); + $this->b = intval($b); + $this->a = $this->alpha2gd($a); + } + + /** + * Initiates color object from given ImagickPixel object + * + * @param ImagickPixel $value + * @return \Intervention\Image\AbstractColor + */ + public function initFromObject($value) + { + throw new \Intervention\Image\Exception\NotSupportedException( + "GD colors cannot init from ImagickPixel objects." + ); + } + + /** + * Calculates integer value of current color instance + * + * @return integer + */ + public function getInt() + { + return ($this->a << 24) + ($this->r << 16) + ($this->g << 8) + $this->b; + } + + /** + * Calculates hexadecimal value of current color instance + * + * @param string $prefix + * @return string + */ + public function getHex($prefix = '') + { + return sprintf('%s%02x%02x%02x', $prefix, $this->r, $this->g, $this->b); + } + + /** + * Calculates RGB(A) in array format of current color instance + * + * @return array + */ + public function getArray() + { + return [$this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)]; + } + + /** + * Calculates RGBA in string format of current color instance + * + * @return string + */ + public function getRgba() + { + return sprintf('rgba(%d, %d, %d, %.2F)', $this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)); + } + + /** + * Determines if current color is different from given color + * + * @param AbstractColor $color + * @param integer $tolerance + * @return boolean + */ + public function differs(AbstractColor $color, $tolerance = 0) + { + $color_tolerance = round($tolerance * 2.55); + $alpha_tolerance = round($tolerance * 1.27); + + $delta = [ + 'r' => abs($color->r - $this->r), + 'g' => abs($color->g - $this->g), + 'b' => abs($color->b - $this->b), + 'a' => abs($color->a - $this->a) + ]; + + return ( + $delta['r'] > $color_tolerance or + $delta['g'] > $color_tolerance or + $delta['b'] > $color_tolerance or + $delta['a'] > $alpha_tolerance + ); + } + + /** + * Convert rgba alpha (0-1) value to gd value (0-127) + * + * @param float $input + * @return int + */ + private function alpha2gd($input) + { + $oldMin = 0; + $oldMax = 1; + + $newMin = 127; + $newMax = 0; + + return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BackupCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BackupCommand.php new file mode 100644 index 0000000..98b3c72 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BackupCommand.php @@ -0,0 +1,23 @@ +argument(0)->value(); + + // clone current image resource + $clone = clone $image; + $image->setBackup($clone->getCore(), $backupName); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BlurCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BlurCommand.php new file mode 100644 index 0000000..d53f59d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BlurCommand.php @@ -0,0 +1,23 @@ +argument(0)->between(0, 100)->value(1); + + for ($i=0; $i < intval($amount); $i++) { + imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BrightnessCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BrightnessCommand.php new file mode 100644 index 0000000..de4263f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/BrightnessCommand.php @@ -0,0 +1,19 @@ +argument(0)->between(-100, 100)->required()->value(); + + return imagefilter($image->getCore(), IMG_FILTER_BRIGHTNESS, ($level * 2.55)); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ColorizeCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ColorizeCommand.php new file mode 100644 index 0000000..8f53963 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ColorizeCommand.php @@ -0,0 +1,27 @@ +argument(0)->between(-100, 100)->required()->value(); + $green = $this->argument(1)->between(-100, 100)->required()->value(); + $blue = $this->argument(2)->between(-100, 100)->required()->value(); + + // normalize colorize levels + $red = round($red * 2.55); + $green = round($green * 2.55); + $blue = round($blue * 2.55); + + // apply filter + return imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $red, $green, $blue); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ContrastCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ContrastCommand.php new file mode 100644 index 0000000..e43b761 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ContrastCommand.php @@ -0,0 +1,19 @@ +argument(0)->between(-100, 100)->required()->value(); + + return imagefilter($image->getCore(), IMG_FILTER_CONTRAST, ($level * -1)); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php new file mode 100644 index 0000000..b7f5954 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php @@ -0,0 +1,40 @@ +argument(0)->type('digit')->required()->value(); + $height = $this->argument(1)->type('digit')->required()->value(); + $x = $this->argument(2)->type('digit')->value(); + $y = $this->argument(3)->type('digit')->value(); + + if (is_null($width) || is_null($height)) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + "Width and height of cutout needs to be defined." + ); + } + + $cropped = new Size($width, $height); + $position = new Point($x, $y); + + // align boxes + if (is_null($x) && is_null($y)) { + $position = $image->getSize()->align('center')->relativePosition($cropped->align('center')); + } + + // crop image core + return $this->modify($image, 0, 0, $position->x, $position->y, $cropped->width, $cropped->height, $cropped->width, $cropped->height); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/DestroyCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/DestroyCommand.php new file mode 100644 index 0000000..1838330 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/DestroyCommand.php @@ -0,0 +1,25 @@ +getCore()); + + // destroy backups + foreach ($image->getBackups() as $backup) { + imagedestroy($backup); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php new file mode 100644 index 0000000..aaecb7f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php @@ -0,0 +1,68 @@ +argument(0)->value(); + $x = $this->argument(1)->type('digit')->value(); + $y = $this->argument(2)->type('digit')->value(); + + $width = $image->getWidth(); + $height = $image->getHeight(); + $resource = $image->getCore(); + + try { + + // set image tile filling + $source = new Decoder; + $tile = $source->init($filling); + imagesettile($image->getCore(), $tile->getCore()); + $filling = IMG_COLOR_TILED; + + } catch (\Intervention\Image\Exception\NotReadableException $e) { + + // set solid color filling + $color = new Color($filling); + $filling = $color->getInt(); + } + + imagealphablending($resource, true); + + if (is_int($x) && is_int($y)) { + + // resource should be visible through transparency + $base = $image->getDriver()->newImage($width, $height)->getCore(); + imagecopy($base, $resource, 0, 0, 0, 0, $width, $height); + + // floodfill if exact position is defined + imagefill($resource, $x, $y, $filling); + + // copy filled original over base + imagecopy($base, $resource, 0, 0, 0, 0, $width, $height); + + // set base as new resource-core + $image->setCore($base); + imagedestroy($resource); + + } else { + // fill whole image otherwise + imagefilledrectangle($resource, 0, 0, $width - 1, $height - 1, $filling); + } + + isset($tile) ? imagedestroy($tile->getCore()) : null; + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FitCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FitCommand.php new file mode 100644 index 0000000..d861ad9 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FitCommand.php @@ -0,0 +1,32 @@ +argument(0)->type('digit')->required()->value(); + $height = $this->argument(1)->type('digit')->value($width); + $constraints = $this->argument(2)->type('closure')->value(); + $position = $this->argument(3)->type('string')->value('center'); + + // calculate size + $cropped = $image->getSize()->fit(new Size($width, $height), $position); + $resized = clone $cropped; + $resized = $resized->resize($width, $height, $constraints); + + // modify image + $this->modify($image, 0, 0, $cropped->pivot->x, $cropped->pivot->y, $resized->getWidth(), $resized->getHeight(), $cropped->getWidth(), $cropped->getHeight()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FlipCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FlipCommand.php new file mode 100644 index 0000000..aa8f230 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/FlipCommand.php @@ -0,0 +1,37 @@ +argument(0)->value('h'); + + $size = $image->getSize(); + $dst = clone $size; + + switch (strtolower($mode)) { + case 2: + case 'v': + case 'vert': + case 'vertical': + $size->pivot->y = $size->height - 1; + $size->height = $size->height * (-1); + break; + + default: + $size->pivot->x = $size->width - 1; + $size->width = $size->width * (-1); + break; + } + + return $this->modify($image, 0, 0, $size->pivot->x, $size->pivot->y, $dst->width, $dst->height, $size->width, $size->height); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GammaCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GammaCommand.php new file mode 100644 index 0000000..366f118 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GammaCommand.php @@ -0,0 +1,19 @@ +argument(0)->type('numeric')->required()->value(); + + return imagegammacorrect($image->getCore(), 1, $gamma); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GetSizeCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GetSizeCommand.php new file mode 100644 index 0000000..89ee284 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GetSizeCommand.php @@ -0,0 +1,24 @@ +setOutput(new Size( + imagesx($image->getCore()), + imagesy($image->getCore()) + )); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php new file mode 100644 index 0000000..ded8e0d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/GreyscaleCommand.php @@ -0,0 +1,17 @@ +getCore(), IMG_FILTER_GRAYSCALE); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/HeightenCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/HeightenCommand.php new file mode 100644 index 0000000..d31e9cd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/HeightenCommand.php @@ -0,0 +1,28 @@ +argument(0)->type('digit')->required()->value(); + $additionalConstraints = $this->argument(1)->type('closure')->value(); + + $this->arguments[0] = null; + $this->arguments[1] = $height; + $this->arguments[2] = function ($constraint) use ($additionalConstraints) { + $constraint->aspectRatio(); + if(is_callable($additionalConstraints)) + $additionalConstraints($constraint); + }; + + return parent::execute($image); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InsertCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InsertCommand.php new file mode 100644 index 0000000..eba75f0 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InsertCommand.php @@ -0,0 +1,32 @@ +argument(0)->required()->value(); + $position = $this->argument(1)->type('string')->value(); + $x = $this->argument(2)->type('digit')->value(0); + $y = $this->argument(3)->type('digit')->value(0); + + // build watermark + $watermark = $image->getDriver()->init($source); + + // define insertion point + $image_size = $image->getSize()->align($position, $x, $y); + $watermark_size = $watermark->getSize()->align($position); + $target = $image_size->relativePosition($watermark_size); + + // insert image at position + imagealphablending($image->getCore(), true); + return imagecopy($image->getCore(), $watermark->getCore(), $target->x, $target->y, 0, 0, $watermark_size->width, $watermark_size->height); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InterlaceCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InterlaceCommand.php new file mode 100644 index 0000000..e8f4b18 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InterlaceCommand.php @@ -0,0 +1,21 @@ +argument(0)->type('bool')->value(true); + + imageinterlace($image->getCore(), $mode); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InvertCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InvertCommand.php new file mode 100644 index 0000000..f72e7e3 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/InvertCommand.php @@ -0,0 +1,17 @@ +getCore(), IMG_FILTER_NEGATE); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php new file mode 100644 index 0000000..27955e7 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/LimitColorsCommand.php @@ -0,0 +1,51 @@ +argument(0)->value(); + $matte = $this->argument(1)->value(); + + // get current image size + $size = $image->getSize(); + + // create empty canvas + $resource = imagecreatetruecolor($size->width, $size->height); + + // define matte + if (is_null($matte)) { + $matte = imagecolorallocatealpha($resource, 255, 255, 255, 127); + } else { + $matte = $image->getDriver()->parseColor($matte)->getInt(); + } + + // fill with matte and copy original image + imagefill($resource, 0, 0, $matte); + + // set transparency + imagecolortransparent($resource, $matte); + + // copy original image + imagecopy($resource, $image->getCore(), 0, 0, 0, 0, $size->width, $size->height); + + if (is_numeric($count) && $count <= 256) { + // decrease colors + imagetruecolortopalette($resource, true, $count); + } + + // set new resource + $image->setCore($resource); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/MaskCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/MaskCommand.php new file mode 100644 index 0000000..ef88d4d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/MaskCommand.php @@ -0,0 +1,81 @@ +argument(0)->value(); + $mask_w_alpha = $this->argument(1)->type('bool')->value(false); + + $image_size = $image->getSize(); + + // create empty canvas + $canvas = $image->getDriver()->newImage($image_size->width, $image_size->height, [0,0,0,0]); + + // build mask image from source + $mask = $image->getDriver()->init($mask_source); + $mask_size = $mask->getSize(); + + // resize mask to size of current image (if necessary) + if ($mask_size != $image_size) { + $mask->resize($image_size->width, $image_size->height); + } + + imagealphablending($canvas->getCore(), false); + + if ( ! $mask_w_alpha) { + // mask from greyscale image + imagefilter($mask->getCore(), IMG_FILTER_GRAYSCALE); + } + + // redraw old image pixel by pixel considering alpha map + for ($x=0; $x < $image_size->width; $x++) { + for ($y=0; $y < $image_size->height; $y++) { + + $color = $image->pickColor($x, $y, 'array'); + $alpha = $mask->pickColor($x, $y, 'array'); + + if ($mask_w_alpha) { + $alpha = $alpha[3]; // use alpha channel as mask + } else { + + if ($alpha[3] == 0) { // transparent as black + $alpha = 0; + } else { + + // $alpha = floatval(round((($alpha[0] + $alpha[1] + $alpha[3]) / 3) / 255, 2)); + + // image is greyscale, so channel doesn't matter (use red channel) + $alpha = floatval(round($alpha[0] / 255, 2)); + } + + } + + // preserve alpha of original image... + if ($color[3] < $alpha) { + $alpha = $color[3]; + } + + // replace alpha value + $color[3] = $alpha; + + // redraw pixel + $canvas->pixel($color, $x, $y); + } + } + + + // replace current image with masked instance + $image->setCore($canvas->getCore()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/OpacityCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/OpacityCommand.php new file mode 100644 index 0000000..081e68a --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/OpacityCommand.php @@ -0,0 +1,29 @@ +argument(0)->between(0, 100)->required()->value(); + + // get size of image + $size = $image->getSize(); + + // build temp alpha mask + $mask_color = sprintf('rgba(0, 0, 0, %.1F)', $transparency / 100); + $mask = $image->getDriver()->newImage($size->width, $size->height, $mask_color); + + // mask image + $image->mask($mask->getCore(), true); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PickColorCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PickColorCommand.php new file mode 100644 index 0000000..9fb4bb4 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PickColorCommand.php @@ -0,0 +1,36 @@ +argument(0)->type('digit')->required()->value(); + $y = $this->argument(1)->type('digit')->required()->value(); + $format = $this->argument(2)->type('string')->value('array'); + + // pick color + $color = imagecolorat($image->getCore(), $x, $y); + + if ( ! imageistruecolor($image->getCore())) { + $color = imagecolorsforindex($image->getCore(), $color); + $color['alpha'] = round(1 - $color['alpha'] / 127, 2); + } + + $color = new Color($color); + + // format to output + $this->setOutput($color->format($format)); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelCommand.php new file mode 100644 index 0000000..67f3e3b --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelCommand.php @@ -0,0 +1,24 @@ +argument(0)->required()->value(); + $color = new Color($color); + $x = $this->argument(1)->type('digit')->required()->value(); + $y = $this->argument(2)->type('digit')->required()->value(); + + return imagesetpixel($image->getCore(), $x, $y, $color->getInt()); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelateCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelateCommand.php new file mode 100644 index 0000000..2e2093d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/PixelateCommand.php @@ -0,0 +1,19 @@ +argument(0)->type('digit')->value(10); + + return imagefilter($image->getCore(), IMG_FILTER_PIXELATE, $size, true); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResetCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResetCommand.php new file mode 100644 index 0000000..c8d2e4a --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResetCommand.php @@ -0,0 +1,35 @@ +argument(0)->value(); + + if (is_resource($backup = $image->getBackup($backupName))) { + + // destroy current resource + imagedestroy($image->getCore()); + + // clone backup + $backup = $image->getDriver()->cloneCore($backup); + + // reset to new resource + $image->setCore($backup); + + return true; + } + + throw new \Intervention\Image\Exception\RuntimeException( + "Backup not available. Call backup() before reset()." + ); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php new file mode 100644 index 0000000..70739ff --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCanvasCommand.php @@ -0,0 +1,81 @@ +argument(0)->type('digit')->required()->value(); + $height = $this->argument(1)->type('digit')->required()->value(); + $anchor = $this->argument(2)->value('center'); + $relative = $this->argument(3)->type('boolean')->value(false); + $bgcolor = $this->argument(4)->value(); + + $original_width = $image->getWidth(); + $original_height = $image->getHeight(); + + // check of only width or height is set + $width = is_null($width) ? $original_width : intval($width); + $height = is_null($height) ? $original_height : intval($height); + + // check on relative width/height + if ($relative) { + $width = $original_width + $width; + $height = $original_height + $height; + } + + // check for negative width/height + $width = ($width <= 0) ? $width + $original_width : $width; + $height = ($height <= 0) ? $height + $original_height : $height; + + // create new canvas + $canvas = $image->getDriver()->newImage($width, $height, $bgcolor); + + // set copy position + $canvas_size = $canvas->getSize()->align($anchor); + $image_size = $image->getSize()->align($anchor); + $canvas_pos = $image_size->relativePosition($canvas_size); + $image_pos = $canvas_size->relativePosition($image_size); + + if ($width <= $original_width) { + $dst_x = 0; + $src_x = $canvas_pos->x; + $src_w = $canvas_size->width; + } else { + $dst_x = $image_pos->x; + $src_x = 0; + $src_w = $original_width; + } + + if ($height <= $original_height) { + $dst_y = 0; + $src_y = $canvas_pos->y; + $src_h = $canvas_size->height; + } else { + $dst_y = $image_pos->y; + $src_y = 0; + $src_h = $original_height; + } + + // make image area transparent to keep transparency + // even if background-color is set + $transparent = imagecolorallocatealpha($canvas->getCore(), 255, 255, 255, 127); + imagealphablending($canvas->getCore(), false); // do not blend / just overwrite + imagefilledrectangle($canvas->getCore(), $dst_x, $dst_y, $dst_x + $src_w - 1, $dst_y + $src_h - 1, $transparent); + + // copy image into new canvas + imagecopy($canvas->getCore(), $image->getCore(), $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h); + + // set new core to canvas + $image->setCore($canvas->getCore()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCommand.php new file mode 100644 index 0000000..2b5700f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/ResizeCommand.php @@ -0,0 +1,82 @@ +argument(0)->value(); + $height = $this->argument(1)->value(); + $constraints = $this->argument(2)->type('closure')->value(); + + // resize box + $resized = $image->getSize()->resize($width, $height, $constraints); + + // modify image + $this->modify($image, 0, 0, 0, 0, $resized->getWidth(), $resized->getHeight(), $image->getWidth(), $image->getHeight()); + + return true; + } + + /** + * Wrapper function for 'imagecopyresampled' + * + * @param Image $image + * @param integer $dst_x + * @param integer $dst_y + * @param integer $src_x + * @param integer $src_y + * @param integer $dst_w + * @param integer $dst_h + * @param integer $src_w + * @param integer $src_h + * @return boolean + */ + protected function modify($image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) + { + // create new image + $modified = imagecreatetruecolor($dst_w, $dst_h); + + // get current image + $resource = $image->getCore(); + + // preserve transparency + $transIndex = imagecolortransparent($resource); + + if ($transIndex != -1) { + $rgba = imagecolorsforindex($modified, $transIndex); + $transColor = imagecolorallocatealpha($modified, $rgba['red'], $rgba['green'], $rgba['blue'], 127); + imagefill($modified, 0, 0, $transColor); + imagecolortransparent($modified, $transColor); + } else { + imagealphablending($modified, false); + imagesavealpha($modified, true); + } + + // copy content from resource + $result = imagecopyresampled( + $modified, + $resource, + $dst_x, + $dst_y, + $src_x, + $src_y, + $dst_w, + $dst_h, + $src_w, + $src_h + ); + + // set new content as recource + $image->setCore($modified); + + return $result; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/RotateCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/RotateCommand.php new file mode 100644 index 0000000..26a460d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/RotateCommand.php @@ -0,0 +1,26 @@ +argument(0)->type('numeric')->required()->value(); + $color = $this->argument(1)->value(); + $color = new Color($color); + + // rotate image + $image->setCore(imagerotate($image->getCore(), $angle, $color->getInt())); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/SharpenCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/SharpenCommand.php new file mode 100644 index 0000000..4c0cc50 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/SharpenCommand.php @@ -0,0 +1,32 @@ +argument(0)->between(0, 100)->value(10); + + // build matrix + $min = $amount >= 10 ? $amount * -0.01 : 0; + $max = $amount * -0.025; + $abs = ((4 * $min + 4 * $max) * -1) + 1; + $div = 1; + + $matrix = [ + [$min, $max, $min], + [$max, $abs, $max], + [$min, $max, $min] + ]; + + // apply the matrix + return imageconvolution($image->getCore(), $matrix, $div, 0); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/TrimCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/TrimCommand.php new file mode 100644 index 0000000..2e36975 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/TrimCommand.php @@ -0,0 +1,176 @@ +argument(0)->type('string')->value(); + $away = $this->argument(1)->value(); + $tolerance = $this->argument(2)->type('numeric')->value(0); + $feather = $this->argument(3)->type('numeric')->value(0); + + $width = $image->getWidth(); + $height = $image->getHeight(); + + // default values + $checkTransparency = false; + + // define borders to trim away + if (is_null($away)) { + $away = ['top', 'right', 'bottom', 'left']; + } elseif (is_string($away)) { + $away = [$away]; + } + + // lower border names + foreach ($away as $key => $value) { + $away[$key] = strtolower($value); + } + + // define base color position + switch (strtolower($base)) { + case 'transparent': + case 'trans': + $checkTransparency = true; + $base_x = 0; + $base_y = 0; + break; + + case 'bottom-right': + case 'right-bottom': + $base_x = $width - 1; + $base_y = $height - 1; + break; + + default: + case 'top-left': + case 'left-top': + $base_x = 0; + $base_y = 0; + break; + } + + // pick base color + if ($checkTransparency) { + $color = new Color; // color will only be used to compare alpha channel + } else { + $color = $image->pickColor($base_x, $base_y, 'object'); + } + + $top_x = 0; + $top_y = 0; + $bottom_x = $width; + $bottom_y = $height; + + // search upper part of image for colors to trim away + if (in_array('top', $away)) { + + for ($y=0; $y < ceil($height/2); $y++) { + for ($x=0; $x < $width; $x++) { + + $checkColor = $image->pickColor($x, $y, 'object'); + + if ($checkTransparency) { + $checkColor->r = $color->r; + $checkColor->g = $color->g; + $checkColor->b = $color->b; + } + + if ($color->differs($checkColor, $tolerance)) { + $top_y = max(0, $y - $feather); + break 2; + } + + } + } + + } + + // search left part of image for colors to trim away + if (in_array('left', $away)) { + + for ($x=0; $x < ceil($width/2); $x++) { + for ($y=$top_y; $y < $height; $y++) { + + $checkColor = $image->pickColor($x, $y, 'object'); + + if ($checkTransparency) { + $checkColor->r = $color->r; + $checkColor->g = $color->g; + $checkColor->b = $color->b; + } + + if ($color->differs($checkColor, $tolerance)) { + $top_x = max(0, $x - $feather); + break 2; + } + + } + } + + } + + // search lower part of image for colors to trim away + if (in_array('bottom', $away)) { + + for ($y=($height-1); $y >= floor($height/2)-1; $y--) { + for ($x=$top_x; $x < $width; $x++) { + + $checkColor = $image->pickColor($x, $y, 'object'); + + if ($checkTransparency) { + $checkColor->r = $color->r; + $checkColor->g = $color->g; + $checkColor->b = $color->b; + } + + if ($color->differs($checkColor, $tolerance)) { + $bottom_y = min($height, $y+1 + $feather); + break 2; + } + + } + } + + } + + // search right part of image for colors to trim away + if (in_array('right', $away)) { + + for ($x=($width-1); $x >= floor($width/2)-1; $x--) { + for ($y=$top_y; $y < $bottom_y; $y++) { + + $checkColor = $image->pickColor($x, $y, 'object'); + + if ($checkTransparency) { + $checkColor->r = $color->r; + $checkColor->g = $color->g; + $checkColor->b = $color->b; + } + + if ($color->differs($checkColor, $tolerance)) { + $bottom_x = min($width, $x+1 + $feather); + break 2; + } + + } + } + + } + + + // trim parts of image + return $this->modify($image, 0, 0, $top_x, $top_y, ($bottom_x-$top_x), ($bottom_y-$top_y), ($bottom_x-$top_x), ($bottom_y-$top_y)); + + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/WidenCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/WidenCommand.php new file mode 100644 index 0000000..43000d5 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Commands/WidenCommand.php @@ -0,0 +1,28 @@ +argument(0)->type('digit')->required()->value(); + $additionalConstraints = $this->argument(1)->type('closure')->value(); + + $this->arguments[0] = $width; + $this->arguments[1] = null; + $this->arguments[2] = function ($constraint) use ($additionalConstraints) { + $constraint->aspectRatio(); + if(is_callable($additionalConstraints)) + $additionalConstraints($constraint); + }; + + return parent::execute($image); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php new file mode 100644 index 0000000..4fe821e --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php @@ -0,0 +1,153 @@ +gdResourceToTruecolor($core); + + // build image + $image = $this->initFromGdResource($core); + $image->mime = $mime; + $image->setFileInfoFromPath($path); + + return $image; + } + + /** + * Initiates new image from GD resource + * + * @param Resource $resource + * @return \Intervention\Image\Image + */ + public function initFromGdResource($resource) + { + return new Image(new Driver, $resource); + } + + /** + * Initiates new image from Imagick object + * + * @param Imagick $object + * @return \Intervention\Image\Image + */ + public function initFromImagick(\Imagick $object) + { + throw new \Intervention\Image\Exception\NotSupportedException( + "Gd driver is unable to init from Imagick object." + ); + } + + /** + * Initiates new image from binary data + * + * @param string $data + * @return \Intervention\Image\Image + */ + public function initFromBinary($binary) + { + $resource = @imagecreatefromstring($binary); + + if ($resource === false) { + throw new \Intervention\Image\Exception\NotReadableException( + "Unable to init from given binary data." + ); + } + + $image = $this->initFromGdResource($resource); + $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary); + + return $image; + } + + /** + * Transform GD resource into Truecolor version + * + * @param resource $resource + * @return bool + */ + public function gdResourceToTruecolor(&$resource) + { + $width = imagesx($resource); + $height = imagesy($resource); + + // new canvas + $canvas = imagecreatetruecolor($width, $height); + + // fill with transparent color + imagealphablending($canvas, false); + $transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127); + imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent); + imagecolortransparent($canvas, $transparent); + imagealphablending($canvas, true); + + // copy original + imagecopy($canvas, $resource, 0, 0, 0, 0, $width, $height); + imagedestroy($resource); + + $resource = $canvas; + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php new file mode 100644 index 0000000..8bbc4a3 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php @@ -0,0 +1,86 @@ +coreAvailable()) { + throw new \Intervention\Image\Exception\NotSupportedException( + "GD Library extension not available with this PHP installation." + ); + } + + $this->decoder = $decoder ? $decoder : new Decoder; + $this->encoder = $encoder ? $encoder : new Encoder; + } + + /** + * Creates new image instance + * + * @param integer $width + * @param integer $height + * @param mixed $background + * @return \Intervention\Image\Image + */ + public function newImage($width, $height, $background = null) + { + // create empty resource + $core = imagecreatetruecolor($width, $height); + $image = new \Intervention\Image\Image(new static, $core); + + // set background color + $background = new Color($background); + imagefill($image->getCore(), 0, 0, $background->getInt()); + + return $image; + } + + /** + * Reads given string into color object + * + * @param string $value + * @return AbstractColor + */ + public function parseColor($value) + { + return new Color($value); + } + + /** + * Checks if core module installation is available + * + * @return boolean + */ + protected function coreAvailable() + { + return (extension_loaded('gd') && function_exists('gd_info')); + } + + /** + * Returns clone of given core + * + * @return mixed + */ + public function cloneCore($core) + { + $width = imagesx($core); + $height = imagesy($core); + $clone = imagecreatetruecolor($width, $height); + imagealphablending($clone, false); + imagesavealpha($clone, true); + $transparency = imagecolorallocatealpha($clone, 0, 0, 0, 127); + imagefill($clone, 0, 0, $transparency); + + imagecopy($clone, $core, 0, 0, 0, 0, $width, $height); + + return $clone; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Encoder.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Encoder.php new file mode 100644 index 0000000..a3fd2f1 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Encoder.php @@ -0,0 +1,122 @@ +image->getCore(), null, $this->quality); + $this->image->mime = image_type_to_mime_type(IMAGETYPE_JPEG); + $buffer = ob_get_contents(); + ob_end_clean(); + + return $buffer; + } + + /** + * Processes and returns encoded image as PNG string + * + * @return string + */ + protected function processPng() + { + ob_start(); + $resource = $this->image->getCore(); + imagealphablending($resource, false); + imagesavealpha($resource, true); + imagepng($resource, null, -1); + $this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG); + $buffer = ob_get_contents(); + ob_end_clean(); + + return $buffer; + } + + /** + * Processes and returns encoded image as GIF string + * + * @return string + */ + protected function processGif() + { + ob_start(); + imagegif($this->image->getCore()); + $this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF); + $buffer = ob_get_contents(); + ob_end_clean(); + + return $buffer; + } + + protected function processWebp() + { + if ( ! function_exists('imagewebp')) { + throw new \Intervention\Image\Exception\NotSupportedException( + "Webp format is not supported by PHP installation." + ); + } + + ob_start(); + imagewebp($this->image->getCore(), null, $this->quality); + $this->image->mime = defined('IMAGETYPE_WEBP') ? image_type_to_mime_type(IMAGETYPE_WEBP) : 'image/webp'; + $buffer = ob_get_contents(); + ob_end_clean(); + + return $buffer; + } + + /** + * Processes and returns encoded image as TIFF string + * + * @return string + */ + protected function processTiff() + { + throw new \Intervention\Image\Exception\NotSupportedException( + "TIFF format is not supported by Gd Driver." + ); + } + + /** + * Processes and returns encoded image as BMP string + * + * @return string + */ + protected function processBmp() + { + throw new \Intervention\Image\Exception\NotSupportedException( + "BMP format is not supported by Gd Driver." + ); + } + + /** + * Processes and returns encoded image as ICO string + * + * @return string + */ + protected function processIco() + { + throw new \Intervention\Image\Exception\NotSupportedException( + "ICO format is not supported by Gd Driver." + ); + } + + /** + * Processes and returns encoded image as PSD string + * + * @return string + */ + protected function processPsd() + { + throw new \Intervention\Image\Exception\NotSupportedException( + "PSD format is not supported by Gd Driver." + ); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Font.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Font.php new file mode 100644 index 0000000..6e3a545 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Font.php @@ -0,0 +1,255 @@ +size * 0.75)); + } + + /** + * Filter function to access internal integer font values + * + * @return integer + */ + private function getInternalFont() + { + $internalfont = is_null($this->file) ? 1 : $this->file; + $internalfont = is_numeric($internalfont) ? $internalfont : false; + + if ( ! in_array($internalfont, [1, 2, 3, 4, 5])) { + throw new \Intervention\Image\Exception\NotSupportedException( + sprintf('Internal GD font (%s) not available. Use only 1-5.', $internalfont) + ); + } + + return intval($internalfont); + } + + /** + * Get width of an internal font character + * + * @return integer + */ + private function getInternalFontWidth() + { + return $this->getInternalFont() + 4; + } + + /** + * Get height of an internal font character + * + * @return integer + */ + private function getInternalFontHeight() + { + switch ($this->getInternalFont()) { + case 1: + return 8; + + case 2: + return 14; + + case 3: + return 14; + + case 4: + return 16; + + case 5: + return 16; + } + } + + /** + * Calculates bounding box of current font setting + * + * @return Array + */ + public function getBoxSize() + { + $box = []; + + if ($this->hasApplicableFontFile()) { + + // get bounding box with angle 0 + $box = imagettfbbox($this->getPointSize(), 0, $this->file, $this->text); + + // rotate points manually + if ($this->angle != 0) { + + $angle = pi() * 2 - $this->angle * pi() * 2 / 360; + + for ($i=0; $i<4; $i++) { + $x = $box[$i * 2]; + $y = $box[$i * 2 + 1]; + $box[$i * 2] = cos($angle) * $x - sin($angle) * $y; + $box[$i * 2 + 1] = sin($angle) * $x + cos($angle) * $y; + } + } + + $box['width'] = intval(abs($box[4] - $box[0])); + $box['height'] = intval(abs($box[5] - $box[1])); + + } else { + + // get current internal font size + $width = $this->getInternalFontWidth(); + $height = $this->getInternalFontHeight(); + + if (strlen($this->text) == 0) { + // no text -> no boxsize + $box['width'] = 0; + $box['height'] = 0; + } else { + // calculate boxsize + $box['width'] = strlen($this->text) * $width; + $box['height'] = $height; + } + } + + return $box; + } + + /** + * Draws font to given image at given position + * + * @param Image $image + * @param integer $posx + * @param integer $posy + * @return void + */ + public function applyToImage(Image $image, $posx = 0, $posy = 0) + { + // parse text color + $color = new Color($this->color); + + if ($this->hasApplicableFontFile()) { + + if ($this->angle != 0 || is_string($this->align) || is_string($this->valign)) { + + $box = $this->getBoxSize(); + + $align = is_null($this->align) ? 'left' : strtolower($this->align); + $valign = is_null($this->valign) ? 'bottom' : strtolower($this->valign); + + // correction on position depending on v/h alignment + switch ($align.'-'.$valign) { + + case 'center-top': + $posx = $posx - round(($box[6]+$box[4])/2); + $posy = $posy - round(($box[7]+$box[5])/2); + break; + + case 'right-top': + $posx = $posx - $box[4]; + $posy = $posy - $box[5]; + break; + + case 'left-top': + $posx = $posx - $box[6]; + $posy = $posy - $box[7]; + break; + + case 'center-center': + case 'center-middle': + $posx = $posx - round(($box[0]+$box[4])/2); + $posy = $posy - round(($box[1]+$box[5])/2); + break; + + case 'right-center': + case 'right-middle': + $posx = $posx - round(($box[2]+$box[4])/2); + $posy = $posy - round(($box[3]+$box[5])/2); + break; + + case 'left-center': + case 'left-middle': + $posx = $posx - round(($box[0]+$box[6])/2); + $posy = $posy - round(($box[1]+$box[7])/2); + break; + + case 'center-bottom': + $posx = $posx - round(($box[0]+$box[2])/2); + $posy = $posy - round(($box[1]+$box[3])/2); + break; + + case 'right-bottom': + $posx = $posx - $box[2]; + $posy = $posy - $box[3]; + break; + + case 'left-bottom': + $posx = $posx - $box[0]; + $posy = $posy - $box[1]; + break; + } + } + + // enable alphablending for imagettftext + imagealphablending($image->getCore(), true); + + // draw ttf text + imagettftext($image->getCore(), $this->getPointSize(), $this->angle, $posx, $posy, $color->getInt(), $this->file, $this->text); + + } else { + + // get box size + $box = $this->getBoxSize(); + $width = $box['width']; + $height = $box['height']; + + // internal font specific position corrections + if ($this->getInternalFont() == 1) { + $top_correction = 1; + $bottom_correction = 2; + } elseif ($this->getInternalFont() == 3) { + $top_correction = 2; + $bottom_correction = 4; + } else { + $top_correction = 3; + $bottom_correction = 4; + } + + // x-position corrections for horizontal alignment + switch (strtolower($this->align)) { + case 'center': + $posx = ceil($posx - ($width / 2)); + break; + + case 'right': + $posx = ceil($posx - $width) + 1; + break; + } + + // y-position corrections for vertical alignment + switch (strtolower($this->valign)) { + case 'center': + case 'middle': + $posy = ceil($posy - ($height / 2)); + break; + + case 'top': + $posy = ceil($posy - $top_correction); + break; + + default: + case 'bottom': + $posy = round($posy - $height + $bottom_correction); + break; + } + + // draw text + imagestring($image->getCore(), $this->getInternalFont(), $posx, $posy, $this->text, $color->getInt()); + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/CircleShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/CircleShape.php new file mode 100644 index 0000000..c512d86 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/CircleShape.php @@ -0,0 +1,40 @@ +width = is_numeric($diameter) ? intval($diameter) : $this->diameter; + $this->height = is_numeric($diameter) ? intval($diameter) : $this->diameter; + $this->diameter = is_numeric($diameter) ? intval($diameter) : $this->diameter; + } + + /** + * Draw current circle on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + return parent::applyToImage($image, $x, $y); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/EllipseShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/EllipseShape.php new file mode 100644 index 0000000..ae5de95 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/EllipseShape.php @@ -0,0 +1,64 @@ +width = is_numeric($width) ? intval($width) : $this->width; + $this->height = is_numeric($height) ? intval($height) : $this->height; + } + + /** + * Draw ellipse instance on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + // parse background color + $background = new Color($this->background); + + if ($this->hasBorder()) { + // slightly smaller ellipse to keep 1px bordered edges clean + imagefilledellipse($image->getCore(), $x, $y, $this->width-1, $this->height-1, $background->getInt()); + + $border_color = new Color($this->border_color); + imagesetthickness($image->getCore(), $this->border_width); + + // gd's imageellipse doesn't respect imagesetthickness so i use imagearc with 359.9 degrees here + imagearc($image->getCore(), $x, $y, $this->width, $this->height, 0, 359.99, $border_color->getInt()); + } else { + imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt()); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/LineShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/LineShape.php new file mode 100644 index 0000000..92e2401 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/LineShape.php @@ -0,0 +1,89 @@ +x = is_numeric($x) ? intval($x) : $this->x; + $this->y = is_numeric($y) ? intval($y) : $this->y; + } + + /** + * Set current line color + * + * @param string $color + * @return void + */ + public function color($color) + { + $this->color = $color; + } + + /** + * Set current line width in pixels + * + * @param integer $width + * @return void + */ + public function width($width) + { + throw new \Intervention\Image\Exception\NotSupportedException( + "Line width is not supported by GD driver." + ); + } + + /** + * Draw current instance of line to given endpoint on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $color = new Color($this->color); + imageline($image->getCore(), $x, $y, $this->x, $this->y, $color->getInt()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/PolygonShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/PolygonShape.php new file mode 100644 index 0000000..c739fbb --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/PolygonShape.php @@ -0,0 +1,48 @@ +points = $points; + } + + /** + * Draw polygon on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $background = new Color($this->background); + imagefilledpolygon($image->getCore(), $this->points, intval(count($this->points) / 2), $background->getInt()); + + if ($this->hasBorder()) { + $border_color = new Color($this->border_color); + imagesetthickness($image->getCore(), $this->border_width); + imagepolygon($image->getCore(), $this->points, intval(count($this->points) / 2), $border_color->getInt()); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/RectangleShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/RectangleShape.php new file mode 100644 index 0000000..757eb5d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Gd/Shapes/RectangleShape.php @@ -0,0 +1,75 @@ +x1 = is_numeric($x1) ? intval($x1) : $this->x1; + $this->y1 = is_numeric($y1) ? intval($y1) : $this->y1; + $this->x2 = is_numeric($x2) ? intval($x2) : $this->x2; + $this->y2 = is_numeric($y2) ? intval($y2) : $this->y2; + } + + /** + * Draw rectangle to given image at certain position + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $background = new Color($this->background); + imagefilledrectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $background->getInt()); + + if ($this->hasBorder()) { + $border_color = new Color($this->border_color); + imagesetthickness($image->getCore(), $this->border_width); + imagerectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $border_color->getInt()); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Image.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Image.php new file mode 100644 index 0000000..c898362 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Image.php @@ -0,0 +1,363 @@ +driver = $driver; + $this->core = $core; + } + + /** + * Magic method to catch all image calls + * usually any AbstractCommand + * + * @param string $name + * @param Array $arguments + * @return mixed + */ + public function __call($name, $arguments) + { + $command = $this->driver->executeCommand($this, $name, $arguments); + return $command->hasOutput() ? $command->getOutput() : $this; + } + + /** + * Starts encoding of current image + * + * @param string $format + * @param integer $quality + * @return \Intervention\Image\Image + */ + public function encode($format = null, $quality = 90) + { + return $this->driver->encode($this, $format, $quality); + } + + /** + * Saves encoded image in filesystem + * + * @param string $path + * @param integer $quality + * @return \Intervention\Image\Image + */ + public function save($path = null, $quality = null) + { + $path = is_null($path) ? $this->basePath() : $path; + + if (is_null($path)) { + throw new Exception\NotWritableException( + "Can't write to undefined path." + ); + } + + $data = $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality); + $saved = @file_put_contents($path, $data); + + if ($saved === false) { + throw new Exception\NotWritableException( + "Can't write image data to path ({$path})" + ); + } + + // set new file info + $this->setFileInfoFromPath($path); + + return $this; + } + + /** + * Runs a given filter on current image + * + * @param FiltersFilterInterface $filter + * @return \Intervention\Image\Image + */ + public function filter(Filters\FilterInterface $filter) + { + return $filter->applyFilter($this); + } + + /** + * Returns current image driver + * + * @return \Intervention\Image\AbstractDriver + */ + public function getDriver() + { + return $this->driver; + } + + /** + * Sets current image driver + * @param AbstractDriver $driver + */ + public function setDriver(AbstractDriver $driver) + { + $this->driver = $driver; + + return $this; + } + + /** + * Returns current image resource/obj + * + * @return mixed + */ + public function getCore() + { + return $this->core; + } + + /** + * Sets current image resource + * + * @param mixed $core + */ + public function setCore($core) + { + $this->core = $core; + + return $this; + } + + /** + * Returns current image backup + * + * @param string $name + * @return mixed + */ + public function getBackup($name = null) + { + $name = is_null($name) ? 'default' : $name; + + if ( ! $this->backupExists($name)) { + throw new \Intervention\Image\Exception\RuntimeException( + "Backup with name ({$name}) not available. Call backup() before reset()." + ); + } + + return $this->backups[$name]; + } + + /** + * Returns all backups attached to image + * + * @return array + */ + public function getBackups() + { + return $this->backups; + } + + /** + * Sets current image backup + * + * @param mixed $resource + * @param string $name + * @return self + */ + public function setBackup($resource, $name = null) + { + $name = is_null($name) ? 'default' : $name; + + $this->backups[$name] = $resource; + + return $this; + } + + /** + * Checks if named backup exists + * + * @param string $name + * @return bool + */ + private function backupExists($name) + { + return array_key_exists($name, $this->backups); + } + + /** + * Checks if current image is already encoded + * + * @return boolean + */ + public function isEncoded() + { + return ! empty($this->encoded); + } + + /** + * Returns encoded image data of current image + * + * @return string + */ + public function getEncoded() + { + return $this->encoded; + } + + /** + * Sets encoded image buffer + * + * @param string $value + */ + public function setEncoded($value) + { + $this->encoded = $value; + + return $this; + } + + /** + * Calculates current image width + * + * @return integer + */ + public function getWidth() + { + return $this->getSize()->width; + } + + /** + * Alias of getWidth() + * + * @return integer + */ + public function width() + { + return $this->getWidth(); + } + + /** + * Calculates current image height + * + * @return integer + */ + public function getHeight() + { + return $this->getSize()->height; + } + + /** + * Alias of getHeight + * + * @return integer + */ + public function height() + { + return $this->getHeight(); + } + + /** + * Reads mime type + * + * @return string + */ + public function mime() + { + return $this->mime; + } + + /** + * Returns encoded image data in string conversion + * + * @return string + */ + public function __toString() + { + return $this->encoded; + } + + /** + * Cloning an image + */ + public function __clone() + { + $this->core = $this->driver->cloneCore($this->core); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManager.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManager.php new file mode 100644 index 0000000..aefb056 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManager.php @@ -0,0 +1,138 @@ + 'gd' + ]; + + /** + * Creates new instance of Image Manager + * + * @param array $config + */ + public function __construct(array $config = []) + { + $this->checkRequirements(); + $this->configure($config); + } + + /** + * Overrides configuration settings + * + * @param array $config + */ + public function configure(array $config = []) + { + $this->config = array_replace($this->config, $config); + + return $this; + } + + /** + * Initiates an Image instance from different input types + * + * @param mixed $data + * + * @return \Intervention\Image\Image + */ + public function make($data) + { + return $this->createDriver()->init($data); + } + + /** + * Creates an empty image canvas + * + * @param integer $width + * @param integer $height + * @param mixed $background + * + * @return \Intervention\Image\Image + */ + public function canvas($width, $height, $background = null) + { + return $this->createDriver()->newImage($width, $height, $background); + } + + /** + * Create new cached image and run callback + * (requires additional package intervention/imagecache) + * + * @param Closure $callback + * @param integer $lifetime + * @param boolean $returnObj + * + * @return Image + */ + public function cache(Closure $callback, $lifetime = null, $returnObj = false) + { + if (class_exists('Intervention\\Image\\ImageCache')) { + // create imagecache + $imagecache = new ImageCache($this); + + // run callback + if (is_callable($callback)) { + $callback($imagecache); + } + + return $imagecache->get($lifetime, $returnObj); + } + + throw new \Intervention\Image\Exception\MissingDependencyException( + "Please install package intervention/imagecache before running this function." + ); + } + + /** + * Creates a driver instance according to config settings + * + * @return \Intervention\Image\AbstractDriver + */ + private function createDriver() + { + if (is_string($this->config['driver'])) { + $drivername = ucfirst($this->config['driver']); + $driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername); + + if (class_exists($driverclass)) { + return new $driverclass; + } + + throw new \Intervention\Image\Exception\NotSupportedException( + "Driver ({$drivername}) could not be instantiated." + ); + } + + if ($this->config['driver'] instanceof AbstractDriver) { + return $this->config['driver']; + } + + throw new \Intervention\Image\Exception\NotSupportedException( + "Unknown driver type." + ); + } + + /** + * Check if all requirements are available + * + * @return void + */ + private function checkRequirements() + { + if ( ! function_exists('finfo_buffer')) { + throw new \Intervention\Image\Exception\MissingDependencyException( + "PHP Fileinfo extension must be installed/enabled to use Intervention Image." + ); + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManagerStatic.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManagerStatic.php new file mode 100644 index 0000000..50bbd9b --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageManagerStatic.php @@ -0,0 +1,87 @@ +configure($config); + } + + /** + * Statically initiates an Image instance from different input types + * + * @param mixed $data + * + * @return \Intervention\Image\Image + */ + public static function make($data) + { + return self::getManager()->make($data); + } + + /** + * Statically creates an empty image canvas + * + * @param integer $width + * @param integer $height + * @param mixed $background + * + * @return \Intervention\Image\Image + */ + public static function canvas($width, $height, $background = null) + { + return self::getManager()->canvas($width, $height, $background); + } + + /** + * Create new cached image and run callback statically + * + * @param Closure $callback + * @param integer $lifetime + * @param boolean $returnObj + * + * @return mixed + */ + public static function cache(Closure $callback, $lifetime = null, $returnObj = false) + { + return self::getManager()->cache($callback, $lifetime, $returnObj); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProvider.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProvider.php new file mode 100644 index 0000000..1e6351d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProvider.php @@ -0,0 +1,85 @@ +provider = $this->getProvider(); + } + + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() + { + if (method_exists($this->provider, 'boot')) { + return $this->provider->boot(); + } + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + return $this->provider->register(); + } + + /** + * Return ServiceProvider according to Laravel version + * + * @return \Intervention\Image\Provider\ProviderInterface + */ + private function getProvider() + { + if ($this->app instanceof \Laravel\Lumen\Application) { + $provider = '\Intervention\Image\ImageServiceProviderLumen'; + } elseif (version_compare(\Illuminate\Foundation\Application::VERSION, '5.0', '<')) { + $provider = '\Intervention\Image\ImageServiceProviderLaravel4'; + } else { + $provider = '\Intervention\Image\ImageServiceProviderLaravel5'; + } + + return new $provider($this->app); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return ['image']; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php new file mode 100644 index 0000000..3b1388f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php @@ -0,0 +1,112 @@ +package('intervention/image'); + + // try to create imagecache route only if imagecache is present + if (class_exists('Intervention\\Image\\ImageCache')) { + + $app = $this->app; + + // load imagecache config + $app['config']->package('intervention/imagecache', __DIR__.'/../../../../imagecache/src/config', 'imagecache'); + $config = $app['config']; + + // create dynamic manipulation route + if (is_string($config->get('imagecache::route'))) { + + // add original to route templates + $config->set('imagecache::templates.original', null); + + // setup image manipulator route + $app['router']->get($config->get('imagecache::route').'/{template}/{filename}', ['as' => 'imagecache', function ($template, $filename) use ($app, $config) { + + // disable session cookies for image route + $app['config']->set('session.driver', 'array'); + + // find file + foreach ($config->get('imagecache::paths') as $path) { + // don't allow '..' in filenames + $image_path = $path.'/'.str_replace('..', '', $filename); + if (file_exists($image_path) && is_file($image_path)) { + break; + } else { + $image_path = false; + } + } + + // abort if file not found + if ($image_path === false) { + $app->abort(404); + } + + // define template callback + $callback = $config->get("imagecache::templates.{$template}"); + + if (is_callable($callback) || class_exists($callback)) { + + // image manipulation based on callback + $content = $app['image']->cache(function ($image) use ($image_path, $callback) { + + switch (true) { + case is_callable($callback): + return $callback($image->make($image_path)); + break; + + case class_exists($callback): + return $image->make($image_path)->filter(new $callback); + break; + } + + }, $config->get('imagecache::lifetime')); + + } else { + + // get original image file contents + $content = file_get_contents($image_path); + } + + // define mime type + $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content); + + // return http response + return new IlluminateResponse($content, 200, [ + 'Content-Type' => $mime, + 'Cache-Control' => 'max-age='.($config->get('imagecache::lifetime')*60).', public', + 'Etag' => md5($content) + ]); + + }])->where(['template' => join('|', array_keys($config->get('imagecache::templates'))), 'filename' => '[ \w\\.\\/\\-]+']); + } + } + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $app = $this->app; + + $app['image'] = $app->share(function ($app) { + return new ImageManager($app['config']->get('image::config')); + }); + + $app->alias('image', 'Intervention\Image\ImageManager'); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel5.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel5.php new file mode 100644 index 0000000..ea04fec --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel5.php @@ -0,0 +1,89 @@ +publishes([ + __DIR__.'/../../config/config.php' => config_path('image.php') + ]); + + // setup intervention/imagecache if package is installed + $this->cacheIsInstalled() ? $this->bootstrapImageCache() : null; + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $app = $this->app; + + // merge default config + $this->mergeConfigFrom( + __DIR__.'/../../config/config.php', + 'image' + ); + + // create image + $app->singleton('image', function ($app) { + return new ImageManager($app['config']->get('image')); + }); + + $app->alias('image', 'Intervention\Image\ImageManager'); + } + + /** + * Bootstrap imagecache + * + * @return void + */ + private function bootstrapImageCache() + { + $app = $this->app; + $config = __DIR__.'/../../../../imagecache/src/config/config.php'; + + $this->publishes([ + $config => config_path('imagecache.php') + ]); + + // merge default config + $this->mergeConfigFrom( + $config, + 'imagecache' + ); + + // imagecache route + if (is_string(config('imagecache.route'))) { + + $filename_pattern = '[ \w\\.\\/\\-\\@\(\)]+'; + + // route to access template applied image file + $app['router']->get(config('imagecache.route').'/{template}/{filename}', [ + 'uses' => 'Intervention\Image\ImageCacheController@getResponse', + 'as' => 'imagecache' + ])->where(['filename' => $filename_pattern]); + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php new file mode 100644 index 0000000..b756a61 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php @@ -0,0 +1,42 @@ +config = $config; + } + + /** + * Register the server provider. + * + * @return void + */ + public function register() + { + $this->getContainer()->share('Intervention\Image\ImageManager', function () { + return new ImageManager($this->config); + }); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php new file mode 100644 index 0000000..4a381cc --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php @@ -0,0 +1,34 @@ +app; + + // merge default config + $this->mergeConfigFrom( + __DIR__.'/../../config/config.php', + 'image' + ); + + // set configuration + $app->configure('image'); + + // create image + $app->singleton('image',function ($app) { + return new ImageManager($app['config']->get('image')); + }); + + $app->alias('image', 'Intervention\Image\ImageManager'); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Color.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Color.php new file mode 100644 index 0000000..39c629f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Color.php @@ -0,0 +1,277 @@ +> 24) & 0xFF; + $r = ($value >> 16) & 0xFF; + $g = ($value >> 8) & 0xFF; + $b = $value & 0xFF; + $a = $this->rgb2alpha($a); + + $this->setPixel($r, $g, $b, $a); + } + + /** + * Initiates color object from given array + * + * @param array $value + * @return \Intervention\Image\AbstractColor + */ + public function initFromArray($array) + { + $array = array_values($array); + + if (count($array) == 4) { + + // color array with alpha value + list($r, $g, $b, $a) = $array; + + } elseif (count($array) == 3) { + + // color array without alpha value + list($r, $g, $b) = $array; + $a = 1; + } + + $this->setPixel($r, $g, $b, $a); + } + + /** + * Initiates color object from given string + * + * @param string $value + * + * @return \Intervention\Image\AbstractColor + */ + public function initFromString($value) + { + if ($color = $this->rgbaFromString($value)) { + $this->setPixel($color[0], $color[1], $color[2], $color[3]); + } + } + + /** + * Initiates color object from given ImagickPixel object + * + * @param ImagickPixel $value + * + * @return \Intervention\Image\AbstractColor + */ + public function initFromObject($value) + { + if (is_a($value, '\ImagickPixel')) { + $this->pixel = $value; + } + } + + /** + * Initiates color object from given R, G and B values + * + * @param integer $r + * @param integer $g + * @param integer $b + * + * @return \Intervention\Image\AbstractColor + */ + public function initFromRgb($r, $g, $b) + { + $this->setPixel($r, $g, $b); + } + + /** + * Initiates color object from given R, G, B and A values + * + * @param integer $r + * @param integer $g + * @param integer $b + * @param float $a + * + * @return \Intervention\Image\AbstractColor + */ + public function initFromRgba($r, $g, $b, $a) + { + $this->setPixel($r, $g, $b, $a); + } + + /** + * Calculates integer value of current color instance + * + * @return integer + */ + public function getInt() + { + $r = $this->getRedValue(); + $g = $this->getGreenValue(); + $b = $this->getBlueValue(); + $a = intval(round($this->getAlphaValue() * 255)); + + return intval(($a << 24) + ($r << 16) + ($g << 8) + $b); + } + + /** + * Calculates hexadecimal value of current color instance + * + * @param string $prefix + * + * @return string + */ + public function getHex($prefix = '') + { + return sprintf('%s%02x%02x%02x', $prefix, + $this->getRedValue(), + $this->getGreenValue(), + $this->getBlueValue() + ); + } + + /** + * Calculates RGB(A) in array format of current color instance + * + * @return array + */ + public function getArray() + { + return [ + $this->getRedValue(), + $this->getGreenValue(), + $this->getBlueValue(), + $this->getAlphaValue() + ]; + } + + /** + * Calculates RGBA in string format of current color instance + * + * @return string + */ + public function getRgba() + { + return sprintf('rgba(%d, %d, %d, %.2F)', + $this->getRedValue(), + $this->getGreenValue(), + $this->getBlueValue(), + $this->getAlphaValue() + ); + } + + /** + * Determines if current color is different from given color + * + * @param AbstractColor $color + * @param integer $tolerance + * @return boolean + */ + public function differs(\Intervention\Image\AbstractColor $color, $tolerance = 0) + { + $color_tolerance = round($tolerance * 2.55); + $alpha_tolerance = round($tolerance); + + $delta = [ + 'r' => abs($color->getRedValue() - $this->getRedValue()), + 'g' => abs($color->getGreenValue() - $this->getGreenValue()), + 'b' => abs($color->getBlueValue() - $this->getBlueValue()), + 'a' => abs($color->getAlphaValue() - $this->getAlphaValue()) + ]; + + return ( + $delta['r'] > $color_tolerance or + $delta['g'] > $color_tolerance or + $delta['b'] > $color_tolerance or + $delta['a'] > $alpha_tolerance + ); + } + + /** + * Returns RGB red value of current color + * + * @return integer + */ + public function getRedValue() + { + return intval(round($this->pixel->getColorValue(\Imagick::COLOR_RED) * 255)); + } + + /** + * Returns RGB green value of current color + * + * @return integer + */ + public function getGreenValue() + { + return intval(round($this->pixel->getColorValue(\Imagick::COLOR_GREEN) * 255)); + } + + /** + * Returns RGB blue value of current color + * + * @return integer + */ + public function getBlueValue() + { + return intval(round($this->pixel->getColorValue(\Imagick::COLOR_BLUE) * 255)); + } + + /** + * Returns RGB alpha value of current color + * + * @return float + */ + public function getAlphaValue() + { + return round($this->pixel->getColorValue(\Imagick::COLOR_ALPHA), 2); + } + + /** + * Initiates ImagickPixel from given RGBA values + * + * @return \ImagickPixel + */ + private function setPixel($r, $g, $b, $a = null) + { + $a = is_null($a) ? 1 : $a; + + return $this->pixel = new \ImagickPixel( + sprintf('rgba(%d, %d, %d, %.2F)', $r, $g, $b, $a) + ); + } + + /** + * Returns current color as ImagickPixel + * + * @return \ImagickPixel + */ + public function getPixel() + { + return $this->pixel; + } + + /** + * Calculates RGA integer alpha value into float value + * + * @param integer $value + * @return float + */ + private function rgb2alpha($value) + { + // (255 -> 1.0) / (0 -> 0.0) + return (float) round($value/255, 2); + } + +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BackupCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BackupCommand.php new file mode 100644 index 0000000..60dedb2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BackupCommand.php @@ -0,0 +1,23 @@ +argument(0)->value(); + + // clone current image resource + $clone = clone $image; + $image->setBackup($clone->getCore(), $backupName); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BlurCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BlurCommand.php new file mode 100644 index 0000000..b037c15 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BlurCommand.php @@ -0,0 +1,19 @@ +argument(0)->between(0, 100)->value(1); + + return $image->getCore()->blurImage(1 * $amount, 0.5 * $amount); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php new file mode 100644 index 0000000..eefb180 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/BrightnessCommand.php @@ -0,0 +1,19 @@ +argument(0)->between(-100, 100)->required()->value(); + + return $image->getCore()->modulateImage(100 + $level, 100, 100); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php new file mode 100644 index 0000000..51142be --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ColorizeCommand.php @@ -0,0 +1,42 @@ +argument(0)->between(-100, 100)->required()->value(); + $green = $this->argument(1)->between(-100, 100)->required()->value(); + $blue = $this->argument(2)->between(-100, 100)->required()->value(); + + // normalize colorize levels + $red = $this->normalizeLevel($red); + $green = $this->normalizeLevel($green); + $blue = $this->normalizeLevel($blue); + + $qrange = $image->getCore()->getQuantumRange(); + + // apply + $image->getCore()->levelImage(0, $red, $qrange['quantumRangeLong'], \Imagick::CHANNEL_RED); + $image->getCore()->levelImage(0, $green, $qrange['quantumRangeLong'], \Imagick::CHANNEL_GREEN); + $image->getCore()->levelImage(0, $blue, $qrange['quantumRangeLong'], \Imagick::CHANNEL_BLUE); + + return true; + } + + private function normalizeLevel($level) + { + if ($level > 0) { + return $level/5; + } else { + return ($level+100)/100; + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ContrastCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ContrastCommand.php new file mode 100644 index 0000000..113a218 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ContrastCommand.php @@ -0,0 +1,19 @@ +argument(0)->between(-100, 100)->required()->value(); + + return $image->getCore()->sigmoidalContrastImage($level > 0, $level / 4, 0); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/CropCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/CropCommand.php new file mode 100644 index 0000000..21c7184 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/CropCommand.php @@ -0,0 +1,43 @@ +argument(0)->type('digit')->required()->value(); + $height = $this->argument(1)->type('digit')->required()->value(); + $x = $this->argument(2)->type('digit')->value(); + $y = $this->argument(3)->type('digit')->value(); + + if (is_null($width) || is_null($height)) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + "Width and height of cutout needs to be defined." + ); + } + + $cropped = new Size($width, $height); + $position = new Point($x, $y); + + // align boxes + if (is_null($x) && is_null($y)) { + $position = $image->getSize()->align('center')->relativePosition($cropped->align('center')); + } + + // crop image core + $image->getCore()->cropImage($cropped->width, $cropped->height, $position->x, $position->y); + $image->getCore()->setImagePage(0,0,0,0); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/DestroyCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/DestroyCommand.php new file mode 100644 index 0000000..d98062d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/DestroyCommand.php @@ -0,0 +1,25 @@ +getCore()->clear(); + + // destroy backups + foreach ($image->getBackups() as $backup) { + $backup->clear(); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ExifCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ExifCommand.php new file mode 100644 index 0000000..924522c --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ExifCommand.php @@ -0,0 +1,62 @@ +preferExtension = false; + } + + /** + * Read Exif data from the given image + * + * @param \Intervention\Image\Image $image + * @return boolean + */ + public function execute($image) + { + if ($this->preferExtension && function_exists('exif_read_data')) { + return parent::execute($image); + } + + $core = $image->getCore(); + + if ( ! method_exists($core, 'getImageProperties')) { + throw new \Intervention\Image\Exception\NotSupportedException( + "Reading Exif data is not supported by this PHP installation." + ); + } + + $requestedKey = $this->argument(0)->value(); + if ($requestedKey !== null) { + $this->setOutput($core->getImageProperty('exif:' . $requestedKey)); + return true; + } + + $exif = []; + $properties = $core->getImageProperties(); + foreach ($properties as $key => $value) { + if (substr($key, 0, 5) !== 'exif:') { + continue; + } + + $exif[substr($key, 5)] = $value; + } + + $this->setOutput($exif); + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FillCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FillCommand.php new file mode 100644 index 0000000..bfac75f --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FillCommand.php @@ -0,0 +1,103 @@ +argument(0)->value(); + $x = $this->argument(1)->type('digit')->value(); + $y = $this->argument(2)->type('digit')->value(); + + $imagick = $image->getCore(); + + try { + // set image filling + $source = new Decoder; + $filling = $source->init($filling); + + } catch (\Intervention\Image\Exception\NotReadableException $e) { + + // set solid color filling + $filling = new Color($filling); + } + + // flood fill if coordinates are set + if (is_int($x) && is_int($y)) { + + // flood fill with texture + if ($filling instanceof Image) { + + // create tile + $tile = clone $image->getCore(); + + // mask away color at position + $tile->transparentPaintImage($tile->getImagePixelColor($x, $y), 0, 0, false); + + // create canvas + $canvas = clone $image->getCore(); + + // fill canvas with texture + $canvas = $canvas->textureImage($filling->getCore()); + + // merge canvas and tile + $canvas->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0); + + // replace image core + $image->setCore($canvas); + + // flood fill with color + } elseif ($filling instanceof Color) { + + // create canvas with filling + $canvas = new \Imagick; + $canvas->newImage($image->getWidth(), $image->getHeight(), $filling->getPixel(), 'png'); + + // create tile to put on top + $tile = clone $image->getCore(); + + // mask away color at pos. + $tile->transparentPaintImage($tile->getImagePixelColor($x, $y), 0, 0, false); + + // save alpha channel of original image + $alpha = clone $image->getCore(); + + // merge original with canvas and tile + $image->getCore()->compositeImage($canvas, \Imagick::COMPOSITE_DEFAULT, 0, 0); + $image->getCore()->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0); + + // restore alpha channel of original image + $image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); + } + + } else { + + if ($filling instanceof Image) { + + // fill whole image with texture + $image->setCore($image->getCore()->textureImage($filling->getCore())); + + } elseif ($filling instanceof Color) { + + // fill whole image with color + $draw = new \ImagickDraw(); + $draw->setFillColor($filling->getPixel()); + $draw->rectangle(0, 0, $image->getWidth(), $image->getHeight()); + $image->getCore()->drawImage($draw); + } + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FitCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FitCommand.php new file mode 100644 index 0000000..f2c60d2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FitCommand.php @@ -0,0 +1,41 @@ +argument(0)->type('digit')->required()->value(); + $height = $this->argument(1)->type('digit')->value($width); + $constraints = $this->argument(2)->type('closure')->value(); + $position = $this->argument(3)->type('string')->value('center'); + + // calculate size + $cropped = $image->getSize()->fit(new Size($width, $height), $position); + $resized = clone $cropped; + $resized = $resized->resize($width, $height, $constraints); + + // crop image + $image->getCore()->cropImage( + $cropped->width, + $cropped->height, + $cropped->pivot->x, + $cropped->pivot->y + ); + + // resize image + $image->getCore()->scaleImage($resized->getWidth(), $resized->getHeight()); + $image->getCore()->setImagePage(0,0,0,0); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FlipCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FlipCommand.php new file mode 100644 index 0000000..cdb03c5 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/FlipCommand.php @@ -0,0 +1,25 @@ +argument(0)->value('h'); + + if (in_array(strtolower($mode), [2, 'v', 'vert', 'vertical'])) { + // flip vertical + return $image->getCore()->flipImage(); + } else { + // flip horizontal + return $image->getCore()->flopImage(); + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GammaCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GammaCommand.php new file mode 100644 index 0000000..e70cbdd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GammaCommand.php @@ -0,0 +1,19 @@ +argument(0)->type('numeric')->required()->value(); + + return $image->getCore()->gammaImage($gamma); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php new file mode 100644 index 0000000..65b1078 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php @@ -0,0 +1,27 @@ +getCore(); + + $this->setOutput(new Size( + $core->getImageWidth(), + $core->getImageHeight() + )); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php new file mode 100644 index 0000000..bb3f472 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/GreyscaleCommand.php @@ -0,0 +1,17 @@ +getCore()->modulateImage(100, 0, 100); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/HeightenCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/HeightenCommand.php new file mode 100644 index 0000000..0b61e50 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/HeightenCommand.php @@ -0,0 +1,28 @@ +argument(0)->type('digit')->required()->value(); + $additionalConstraints = $this->argument(1)->type('closure')->value(); + + $this->arguments[0] = null; + $this->arguments[1] = $height; + $this->arguments[2] = function ($constraint) use ($additionalConstraints) { + $constraint->aspectRatio(); + if(is_callable($additionalConstraints)) + $additionalConstraints($constraint); + }; + + return parent::execute($image); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InsertCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InsertCommand.php new file mode 100644 index 0000000..542feb2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InsertCommand.php @@ -0,0 +1,31 @@ +argument(0)->required()->value(); + $position = $this->argument(1)->type('string')->value(); + $x = $this->argument(2)->type('digit')->value(0); + $y = $this->argument(3)->type('digit')->value(0); + + // build watermark + $watermark = $image->getDriver()->init($source); + + // define insertion point + $image_size = $image->getSize()->align($position, $x, $y); + $watermark_size = $watermark->getSize()->align($position); + $target = $image_size->relativePosition($watermark_size); + + // insert image at position + return $image->getCore()->compositeImage($watermark->getCore(), \Imagick::COMPOSITE_DEFAULT, $target->x, $target->y); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php new file mode 100644 index 0000000..82cddd4 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InterlaceCommand.php @@ -0,0 +1,27 @@ +argument(0)->type('bool')->value(true); + + if ($mode) { + $mode = \Imagick::INTERLACE_LINE; + } else { + $mode = \Imagick::INTERLACE_NO; + } + + $image->getCore()->setInterlaceScheme($mode); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InvertCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InvertCommand.php new file mode 100644 index 0000000..125fbdd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/InvertCommand.php @@ -0,0 +1,17 @@ +getCore()->negateImage(false); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php new file mode 100644 index 0000000..7308180 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/LimitColorsCommand.php @@ -0,0 +1,57 @@ +argument(0)->value(); + $matte = $this->argument(1)->value(); + + // get current image size + $size = $image->getSize(); + + // build 2 color alpha mask from original alpha + $alpha = clone $image->getCore(); + $alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA); + $alpha->transparentPaintImage('#ffffff', 0, 0, false); + $alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA); + $alpha->negateImage(false); + + if ($matte) { + + // get matte color + $mattecolor = $image->getDriver()->parseColor($matte)->getPixel(); + + // create matte image + $canvas = new \Imagick; + $canvas->newImage($size->width, $size->height, $mattecolor, 'png'); + + // lower colors of original and copy to matte + $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false); + $canvas->compositeImage($image->getCore(), \Imagick::COMPOSITE_DEFAULT, 0, 0); + + // copy new alpha to canvas + $canvas->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); + + // replace core + $image->setCore($canvas); + + } else { + + $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false); + $image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); + + } + + return true; + + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/MaskCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/MaskCommand.php new file mode 100644 index 0000000..2dfc697 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/MaskCommand.php @@ -0,0 +1,58 @@ +argument(0)->value(); + $mask_w_alpha = $this->argument(1)->type('bool')->value(false); + + // get imagick + $imagick = $image->getCore(); + + // build mask image from source + $mask = $image->getDriver()->init($mask_source); + + // resize mask to size of current image (if necessary) + $image_size = $image->getSize(); + if ($mask->getSize() != $image_size) { + $mask->resize($image_size->width, $image_size->height); + } + + $imagick->setImageMatte(true); + + if ($mask_w_alpha) { + + // just mask with alpha map + $imagick->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DSTIN, 0, 0); + + } else { + + // get alpha channel of original as greyscale image + $original_alpha = clone $imagick; + $original_alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA); + + // use red channel from mask ask alpha + $mask_alpha = clone $mask->getCore(); + $mask_alpha->compositeImage($mask->getCore(), \Imagick::COMPOSITE_DEFAULT, 0, 0); + // $mask_alpha->setImageAlphaChannel(\Imagick::ALPHACHANNEL_DEACTIVATE); + $mask_alpha->separateImageChannel(\Imagick::CHANNEL_ALL); + + // combine both alphas from original and mask + $original_alpha->compositeImage($mask_alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); + + // mask the image with the alpha combination + $imagick->compositeImage($original_alpha, \Imagick::COMPOSITE_DSTIN, 0, 0); + } + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/OpacityCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/OpacityCommand.php new file mode 100644 index 0000000..57ed006 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/OpacityCommand.php @@ -0,0 +1,21 @@ +argument(0)->between(0, 100)->required()->value(); + + $transparency = $transparency > 0 ? (100 / $transparency) : 1000; + + return $image->getCore()->evaluateImage(\Imagick::EVALUATE_DIVIDE, $transparency, \Imagick::CHANNEL_ALPHA); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PickColorCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PickColorCommand.php new file mode 100644 index 0000000..8daa0f9 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PickColorCommand.php @@ -0,0 +1,29 @@ +argument(0)->type('digit')->required()->value(); + $y = $this->argument(1)->type('digit')->required()->value(); + $format = $this->argument(2)->type('string')->value('array'); + + // pick color + $color = new Color($image->getCore()->getImagePixelColor($x, $y)); + + // format to output + $this->setOutput($color->format($format)); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelCommand.php new file mode 100644 index 0000000..b9e6d39 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelCommand.php @@ -0,0 +1,30 @@ +argument(0)->required()->value(); + $color = new Color($color); + $x = $this->argument(1)->type('digit')->required()->value(); + $y = $this->argument(2)->type('digit')->required()->value(); + + // prepare pixel + $draw = new \ImagickDraw; + $draw->setFillColor($color->getPixel()); + $draw->point($x, $y); + + // apply pixel + return $image->getCore()->drawImage($draw); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelateCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelateCommand.php new file mode 100644 index 0000000..75f2218 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/PixelateCommand.php @@ -0,0 +1,25 @@ +argument(0)->type('digit')->value(10); + + $width = $image->getWidth(); + $height = $image->getHeight(); + + $image->getCore()->scaleImage(max(1, ($width / $size)), max(1, ($height / $size))); + $image->getCore()->scaleImage($width, $height); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResetCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResetCommand.php new file mode 100644 index 0000000..ee5a2cd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResetCommand.php @@ -0,0 +1,37 @@ +argument(0)->value(); + + $backup = $image->getBackup($backupName); + + if ($backup instanceof \Imagick) { + + // destroy current core + $image->getCore()->clear(); + + // clone backup + $backup = clone $backup; + + // reset to new resource + $image->setCore($backup); + + return true; + } + + throw new \Intervention\Image\Exception\RuntimeException( + "Backup not available. Call backup({$backupName}) before reset()." + ); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php new file mode 100644 index 0000000..f394c15 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCanvasCommand.php @@ -0,0 +1,89 @@ +argument(0)->type('digit')->required()->value(); + $height = $this->argument(1)->type('digit')->required()->value(); + $anchor = $this->argument(2)->value('center'); + $relative = $this->argument(3)->type('boolean')->value(false); + $bgcolor = $this->argument(4)->value(); + + $original_width = $image->getWidth(); + $original_height = $image->getHeight(); + + // check of only width or height is set + $width = is_null($width) ? $original_width : intval($width); + $height = is_null($height) ? $original_height : intval($height); + + // check on relative width/height + if ($relative) { + $width = $original_width + $width; + $height = $original_height + $height; + } + + // check for negative width/height + $width = ($width <= 0) ? $width + $original_width : $width; + $height = ($height <= 0) ? $height + $original_height : $height; + + // create new canvas + $canvas = $image->getDriver()->newImage($width, $height, $bgcolor); + + // set copy position + $canvas_size = $canvas->getSize()->align($anchor); + $image_size = $image->getSize()->align($anchor); + $canvas_pos = $image_size->relativePosition($canvas_size); + $image_pos = $canvas_size->relativePosition($image_size); + + if ($width <= $original_width) { + $dst_x = 0; + $src_x = $canvas_pos->x; + $src_w = $canvas_size->width; + } else { + $dst_x = $image_pos->x; + $src_x = 0; + $src_w = $original_width; + } + + if ($height <= $original_height) { + $dst_y = 0; + $src_y = $canvas_pos->y; + $src_h = $canvas_size->height; + } else { + $dst_y = $image_pos->y; + $src_y = 0; + $src_h = $original_height; + } + + // make image area transparent to keep transparency + // even if background-color is set + $rect = new \ImagickDraw; + $fill = $canvas->pickColor(0, 0, 'hex'); + $fill = $fill == '#ff0000' ? '#00ff00' : '#ff0000'; + $rect->setFillColor($fill); + $rect->rectangle($dst_x, $dst_y, $dst_x + $src_w - 1, $dst_y + $src_h - 1); + $canvas->getCore()->drawImage($rect); + $canvas->getCore()->transparentPaintImage($fill, 0, 0, false); + + $canvas->getCore()->setImageColorspace($image->getCore()->getImageColorspace()); + + // copy image into new canvas + $image->getCore()->cropImage($src_w, $src_h, $src_x, $src_y); + $canvas->getCore()->compositeImage($image->getCore(), \Imagick::COMPOSITE_DEFAULT, $dst_x, $dst_y); + $canvas->getCore()->setImagePage(0,0,0,0); + + // set new core to canvas + $image->setCore($canvas->getCore()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCommand.php new file mode 100644 index 0000000..9ccc202 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/ResizeCommand.php @@ -0,0 +1,27 @@ +argument(0)->value(); + $height = $this->argument(1)->value(); + $constraints = $this->argument(2)->type('closure')->value(); + + // resize box + $resized = $image->getSize()->resize($width, $height, $constraints); + + // modify image + $image->getCore()->scaleImage($resized->getWidth(), $resized->getHeight()); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/RotateCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/RotateCommand.php new file mode 100644 index 0000000..3d0eb99 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/RotateCommand.php @@ -0,0 +1,26 @@ +argument(0)->type('numeric')->required()->value(); + $color = $this->argument(1)->value(); + $color = new Color($color); + + // rotate image + $image->getCore()->rotateImage($color->getPixel(), ($angle * -1)); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/SharpenCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/SharpenCommand.php new file mode 100644 index 0000000..4f2fc8c --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/SharpenCommand.php @@ -0,0 +1,19 @@ +argument(0)->between(0, 100)->value(10); + + return $image->getCore()->unsharpMaskImage(1, 1, $amount / 6.25, 0); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/TrimCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/TrimCommand.php new file mode 100644 index 0000000..f095903 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/TrimCommand.php @@ -0,0 +1,120 @@ +argument(0)->type('string')->value(); + $away = $this->argument(1)->value(); + $tolerance = $this->argument(2)->type('numeric')->value(0); + $feather = $this->argument(3)->type('numeric')->value(0); + + $width = $image->getWidth(); + $height = $image->getHeight(); + + $checkTransparency = false; + + // define borders to trim away + if (is_null($away)) { + $away = ['top', 'right', 'bottom', 'left']; + } elseif (is_string($away)) { + $away = [$away]; + } + + // lower border names + foreach ($away as $key => $value) { + $away[$key] = strtolower($value); + } + + // define base color position + switch (strtolower($base)) { + case 'transparent': + case 'trans': + $checkTransparency = true; + $base_x = 0; + $base_y = 0; + break; + + case 'bottom-right': + case 'right-bottom': + $base_x = $width - 1; + $base_y = $height - 1; + break; + + default: + case 'top-left': + case 'left-top': + $base_x = 0; + $base_y = 0; + break; + } + + // pick base color + if ($checkTransparency) { + $base_color = new Color; // color will only be used to compare alpha channel + } else { + $base_color = $image->pickColor($base_x, $base_y, 'object'); + } + + // trim on clone to get only coordinates + $trimed = clone $image->getCore(); + + // add border to trim specific color + $trimed->borderImage($base_color->getPixel(), 1, 1); + + // trim image + $trimed->trimImage(65850 / 100 * $tolerance); + + // get coordinates of trim + $imagePage = $trimed->getImagePage(); + list($crop_x, $crop_y) = [$imagePage['x']-1, $imagePage['y']-1]; + // $trimed->setImagePage(0, 0, 0, 0); + list($crop_width, $crop_height) = [$trimed->width, $trimed->height]; + + // adjust settings if right should not be trimed + if ( ! in_array('right', $away)) { + $crop_width = $crop_width + ($width - ($width - $crop_x)); + } + + // adjust settings if bottom should not be trimed + if ( ! in_array('bottom', $away)) { + $crop_height = $crop_height + ($height - ($height - $crop_y)); + } + + // adjust settings if left should not be trimed + if ( ! in_array('left', $away)) { + $crop_width = $crop_width + $crop_x; + $crop_x = 0; + } + + // adjust settings if top should not be trimed + if ( ! in_array('top', $away)) { + $crop_height = $crop_height + $crop_y; + $crop_y = 0; + } + + // add feather + $crop_width = min($width, ($crop_width + $feather * 2)); + $crop_height = min($height, ($crop_height + $feather * 2)); + $crop_x = max(0, ($crop_x - $feather)); + $crop_y = max(0, ($crop_y - $feather)); + + // finally crop based on page + $image->getCore()->cropImage($crop_width, $crop_height, $crop_x, $crop_y); + $image->getCore()->setImagePage(0,0,0,0); + + $trimed->destroy(); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/WidenCommand.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/WidenCommand.php new file mode 100644 index 0000000..a196753 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Commands/WidenCommand.php @@ -0,0 +1,28 @@ +argument(0)->type('digit')->required()->value(); + $additionalConstraints = $this->argument(1)->type('closure')->value(); + + $this->arguments[0] = $width; + $this->arguments[1] = null; + $this->arguments[2] = function ($constraint) use ($additionalConstraints) { + $constraint->aspectRatio(); + if(is_callable($additionalConstraints)) + $additionalConstraints($constraint); + }; + + return parent::execute($image); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Decoder.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Decoder.php new file mode 100644 index 0000000..6b2b40d --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Decoder.php @@ -0,0 +1,120 @@ +setBackgroundColor(new \ImagickPixel('transparent')); + $core->readImage($path); + $core->setImageType(defined('\Imagick::IMGTYPE_TRUECOLORALPHA') ? \Imagick::IMGTYPE_TRUECOLORALPHA : \Imagick::IMGTYPE_TRUECOLORMATTE); + + } catch (\ImagickException $e) { + throw new \Intervention\Image\Exception\NotReadableException( + "Unable to read image from path ({$path}).", + 0, + $e + ); + } + + // build image + $image = $this->initFromImagick($core); + $image->setFileInfoFromPath($path); + + return $image; + } + + /** + * Initiates new image from GD resource + * + * @param Resource $resource + * @return \Intervention\Image\Image + */ + public function initFromGdResource($resource) + { + throw new \Intervention\Image\Exception\NotSupportedException( + 'Imagick driver is unable to init from GD resource.' + ); + } + + /** + * Initiates new image from Imagick object + * + * @param Imagick $object + * @return \Intervention\Image\Image + */ + public function initFromImagick(\Imagick $object) + { + // currently animations are not supported + // so all images are turned into static + $object = $this->removeAnimation($object); + + // reset image orientation + $object->setImageOrientation(\Imagick::ORIENTATION_UNDEFINED); + + return new Image(new Driver, $object); + } + + /** + * Initiates new image from binary data + * + * @param string $data + * @return \Intervention\Image\Image + */ + public function initFromBinary($binary) + { + $core = new \Imagick; + + try { + + $core->readImageBlob($binary); + + } catch (\ImagickException $e) { + throw new \Intervention\Image\Exception\NotReadableException( + "Unable to read image from binary data.", + 0, + $e + ); + } + + // build image + $image = $this->initFromImagick($core); + $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary); + + return $image; + } + + /** + * Turns object into one frame Imagick object + * by removing all frames except first + * + * @param Imagick $object + * @return Imagick + */ + private function removeAnimation(\Imagick $object) + { + $imagick = new \Imagick; + + foreach ($object as $frame) { + $imagick->addImage($frame->getImage()); + break; + } + + $object->destroy(); + + return $imagick; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Driver.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Driver.php new file mode 100644 index 0000000..1c72e5a --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Driver.php @@ -0,0 +1,70 @@ +coreAvailable()) { + throw new \Intervention\Image\Exception\NotSupportedException( + "ImageMagick module not available with this PHP installation." + ); + } + + $this->decoder = $decoder ? $decoder : new Decoder; + $this->encoder = $encoder ? $encoder : new Encoder; + } + + /** + * Creates new image instance + * + * @param integer $width + * @param integer $height + * @param mixed $background + * @return \Intervention\Image\Image + */ + public function newImage($width, $height, $background = null) + { + $background = new Color($background); + + // create empty core + $core = new \Imagick; + $core->newImage($width, $height, $background->getPixel(), 'png'); + $core->setType(\Imagick::IMGTYPE_UNDEFINED); + $core->setImageType(\Imagick::IMGTYPE_UNDEFINED); + $core->setColorspace(\Imagick::COLORSPACE_UNDEFINED); + + // build image + $image = new \Intervention\Image\Image(new static, $core); + + return $image; + } + + /** + * Reads given string into color object + * + * @param string $value + * @return AbstractColor + */ + public function parseColor($value) + { + return new Color($value); + } + + /** + * Checks if core module installation is available + * + * @return boolean + */ + protected function coreAvailable() + { + return (extension_loaded('imagick') && class_exists('Imagick')); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Encoder.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Encoder.php new file mode 100644 index 0000000..44452f2 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Encoder.php @@ -0,0 +1,168 @@ +image->getCore(); + $imagick->setImageBackgroundColor('white'); + $imagick->setBackgroundColor('white'); + $imagick = $imagick->mergeImageLayers(\Imagick::LAYERMETHOD_MERGE); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + $imagick->setCompressionQuality($this->quality); + $imagick->setImageCompressionQuality($this->quality); + + return $imagick->getImagesBlob(); + } + + /** + * Processes and returns encoded image as PNG string + * + * @return string + */ + protected function processPng() + { + $format = 'png'; + $compression = \Imagick::COMPRESSION_ZIP; + + $imagick = $this->image->getCore(); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + + return $imagick->getImagesBlob(); + } + + /** + * Processes and returns encoded image as GIF string + * + * @return string + */ + protected function processGif() + { + $format = 'gif'; + $compression = \Imagick::COMPRESSION_LZW; + + $imagick = $this->image->getCore(); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + + return $imagick->getImagesBlob(); + } + + protected function processWebp() + { + if ( ! \Imagick::queryFormats('WEBP')) { + throw new \Intervention\Image\Exception\NotSupportedException( + "Webp format is not supported by Imagick installation." + ); + } + + $format = 'webp'; + $compression = \Imagick::COMPRESSION_JPEG; + + $imagick = $this->image->getCore(); + $imagick = $imagick->mergeImageLayers(\Imagick::LAYERMETHOD_MERGE); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + $imagick->setImageCompressionQuality($this->quality); + + return $imagick->getImagesBlob(); + } + + /** + * Processes and returns encoded image as TIFF string + * + * @return string + */ + protected function processTiff() + { + $format = 'tiff'; + $compression = \Imagick::COMPRESSION_UNDEFINED; + + $imagick = $this->image->getCore(); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + $imagick->setCompressionQuality($this->quality); + $imagick->setImageCompressionQuality($this->quality); + + return $imagick->getImagesBlob(); + } + + /** + * Processes and returns encoded image as BMP string + * + * @return string + */ + protected function processBmp() + { + $format = 'bmp'; + $compression = \Imagick::COMPRESSION_UNDEFINED; + + $imagick = $this->image->getCore(); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + + return $imagick->getImagesBlob(); + } + + /** + * Processes and returns encoded image as ICO string + * + * @return string + */ + protected function processIco() + { + $format = 'ico'; + $compression = \Imagick::COMPRESSION_UNDEFINED; + + $imagick = $this->image->getCore(); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + + return $imagick->getImagesBlob(); + } + + /** + * Processes and returns encoded image as PSD string + * + * @return string + */ + protected function processPsd() + { + $format = 'psd'; + $compression = \Imagick::COMPRESSION_UNDEFINED; + + $imagick = $this->image->getCore(); + $imagick->setFormat($format); + $imagick->setImageFormat($format); + $imagick->setCompression($compression); + $imagick->setImageCompression($compression); + + return $imagick->getImagesBlob(); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Font.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Font.php new file mode 100644 index 0000000..9ae2f97 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Font.php @@ -0,0 +1,78 @@ +setStrokeAntialias(true); + $draw->setTextAntialias(true); + + // set font file + if ($this->hasApplicableFontFile()) { + $draw->setFont($this->file); + } else { + throw new \Intervention\Image\Exception\RuntimeException( + "Font file must be provided to apply text to image." + ); + } + + // parse text color + $color = new Color($this->color); + + $draw->setFontSize($this->size); + $draw->setFillColor($color->getPixel()); + + // align horizontal + switch (strtolower($this->align)) { + case 'center': + $align = \Imagick::ALIGN_CENTER; + break; + + case 'right': + $align = \Imagick::ALIGN_RIGHT; + break; + + default: + $align = \Imagick::ALIGN_LEFT; + break; + } + + $draw->setTextAlignment($align); + + // align vertical + if (strtolower($this->valign) != 'bottom') { + + // calculate box size + $dimensions = $image->getCore()->queryFontMetrics($draw, $this->text); + + // corrections on y-position + switch (strtolower($this->valign)) { + case 'center': + case 'middle': + $posy = $posy + $dimensions['textHeight'] * 0.65 / 2; + break; + + case 'top': + $posy = $posy + $dimensions['textHeight'] * 0.65; + break; + } + } + + // apply to image + $image->getCore()->annotateImage($draw, $posx, $posy, $this->angle * (-1), $this->text); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/CircleShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/CircleShape.php new file mode 100644 index 0000000..ebf85a9 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/CircleShape.php @@ -0,0 +1,40 @@ +width = is_numeric($diameter) ? intval($diameter) : $this->diameter; + $this->height = is_numeric($diameter) ? intval($diameter) : $this->diameter; + $this->diameter = is_numeric($diameter) ? intval($diameter) : $this->diameter; + } + + /** + * Draw current circle on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + return parent::applyToImage($image, $x, $y); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/EllipseShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/EllipseShape.php new file mode 100644 index 0000000..a543124 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/EllipseShape.php @@ -0,0 +1,65 @@ +width = is_numeric($width) ? intval($width) : $this->width; + $this->height = is_numeric($height) ? intval($height) : $this->height; + } + + /** + * Draw ellipse instance on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $circle = new \ImagickDraw; + + // set background + $bgcolor = new Color($this->background); + $circle->setFillColor($bgcolor->getPixel()); + + // set border + if ($this->hasBorder()) { + $border_color = new Color($this->border_color); + $circle->setStrokeWidth($this->border_width); + $circle->setStrokeColor($border_color->getPixel()); + } + + $circle->ellipse($x, $y, $this->width / 2, $this->height / 2, 0, 360); + + $image->getCore()->drawImage($circle); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/LineShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/LineShape.php new file mode 100644 index 0000000..3e40363 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/LineShape.php @@ -0,0 +1,93 @@ +x = is_numeric($x) ? intval($x) : $this->x; + $this->y = is_numeric($y) ? intval($y) : $this->y; + } + + /** + * Set current line color + * + * @param string $color + * @return void + */ + public function color($color) + { + $this->color = $color; + } + + /** + * Set current line width in pixels + * + * @param integer $width + * @return void + */ + public function width($width) + { + $this->width = $width; + } + + /** + * Draw current instance of line to given endpoint on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $line = new \ImagickDraw; + + $color = new Color($this->color); + $line->setStrokeColor($color->getPixel()); + $line->setStrokeWidth($this->width); + + $line->line($this->x, $this->y, $x, $y); + $image->getCore()->drawImage($line); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/PolygonShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/PolygonShape.php new file mode 100644 index 0000000..5d1c01a --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/PolygonShape.php @@ -0,0 +1,80 @@ +points = $this->formatPoints($points); + } + + /** + * Draw polygon on given image + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $polygon = new \ImagickDraw; + + // set background + $bgcolor = new Color($this->background); + $polygon->setFillColor($bgcolor->getPixel()); + + // set border + if ($this->hasBorder()) { + $border_color = new Color($this->border_color); + $polygon->setStrokeWidth($this->border_width); + $polygon->setStrokeColor($border_color->getPixel()); + } + + $polygon->polygon($this->points); + + $image->getCore()->drawImage($polygon); + + return true; + } + + /** + * Format polygon points to Imagick format + * + * @param Array $points + * @return Array + */ + private function formatPoints($points) + { + $ipoints = []; + $count = 1; + + foreach ($points as $key => $value) { + if ($count%2 === 0) { + $y = $value; + $ipoints[] = ['x' => $x, 'y' => $y]; + } else { + $x = $value; + } + $count++; + } + + return $ipoints; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/RectangleShape.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/RectangleShape.php new file mode 100644 index 0000000..ad23019 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Imagick/Shapes/RectangleShape.php @@ -0,0 +1,83 @@ +x1 = is_numeric($x1) ? intval($x1) : $this->x1; + $this->y1 = is_numeric($y1) ? intval($y1) : $this->y1; + $this->x2 = is_numeric($x2) ? intval($x2) : $this->x2; + $this->y2 = is_numeric($y2) ? intval($y2) : $this->y2; + } + + /** + * Draw rectangle to given image at certain position + * + * @param Image $image + * @param integer $x + * @param integer $y + * @return boolean + */ + public function applyToImage(Image $image, $x = 0, $y = 0) + { + $rectangle = new \ImagickDraw; + + // set background + $bgcolor = new Color($this->background); + $rectangle->setFillColor($bgcolor->getPixel()); + + // set border + if ($this->hasBorder()) { + $border_color = new Color($this->border_color); + $rectangle->setStrokeWidth($this->border_width); + $rectangle->setStrokeColor($border_color->getPixel()); + } + + $rectangle->rectangle($this->x1, $this->y1, $this->x2, $this->y2); + + $image->getCore()->drawImage($rectangle); + + return true; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Point.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Point.php new file mode 100644 index 0000000..bb17fb7 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Point.php @@ -0,0 +1,64 @@ +x = is_numeric($x) ? intval($x) : 0; + $this->y = is_numeric($y) ? intval($y) : 0; + } + + /** + * Sets X coordinate + * + * @param integer $x + */ + public function setX($x) + { + $this->x = intval($x); + } + + /** + * Sets Y coordinate + * + * @param integer $y + */ + public function setY($y) + { + $this->y = intval($y); + } + + /** + * Sets both X and Y coordinate + * + * @param integer $x + * @param integer $y + */ + public function setPosition($x, $y) + { + $this->setX($x); + $this->setY($y); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Response.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Response.php new file mode 100644 index 0000000..ce27e79 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Response.php @@ -0,0 +1,69 @@ +image = $image; + $this->format = $format ? $format : $image->mime; + $this->quality = $quality ? $quality : 90; + } + + /** + * Builds response according to settings + * + * @return mixed + */ + public function make() + { + $this->image->encode($this->format, $this->quality); + $data = $this->image->getEncoded(); + $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data); + $length = strlen($data); + + if (function_exists('app') && is_a($app = app(), 'Illuminate\Foundation\Application')) { + + $response = \Illuminate\Support\Facades\Response::make($data); + $response->header('Content-Type', $mime); + $response->header('Content-Length', $length); + + } else { + + header('Content-Type: ' . $mime); + header('Content-Length: ' . $length); + $response = $data; + } + + return $response; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Size.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Size.php new file mode 100644 index 0000000..f2babe1 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/Intervention/Image/Size.php @@ -0,0 +1,373 @@ +width = is_numeric($width) ? intval($width) : 1; + $this->height = is_numeric($height) ? intval($height) : 1; + $this->pivot = $pivot ? $pivot : new Point; + } + + /** + * Set the width and height absolutely + * + * @param integer $width + * @param integer $height + */ + public function set($width, $height) + { + $this->width = $width; + $this->height = $height; + } + + /** + * Set current pivot point + * + * @param Point $point + */ + public function setPivot(Point $point) + { + $this->pivot = $point; + } + + /** + * Get the current width + * + * @return integer + */ + public function getWidth() + { + return $this->width; + } + + /** + * Get the current height + * + * @return integer + */ + public function getHeight() + { + return $this->height; + } + + /** + * Calculate the current aspect ratio + * + * @return float + */ + public function getRatio() + { + return $this->width / $this->height; + } + + /** + * Resize to desired width and/or height + * + * @param integer $width + * @param integer $height + * @param Closure $callback + * @return Size + */ + public function resize($width, $height, Closure $callback = null) + { + if (is_null($width) && is_null($height)) { + throw new \Intervention\Image\Exception\InvalidArgumentException( + "Width or height needs to be defined." + ); + } + + // new size with dominant width + $dominant_w_size = clone $this; + $dominant_w_size->resizeHeight($height, $callback); + $dominant_w_size->resizeWidth($width, $callback); + + // new size with dominant height + $dominant_h_size = clone $this; + $dominant_h_size->resizeWidth($width, $callback); + $dominant_h_size->resizeHeight($height, $callback); + + // decide which size to use + if ($dominant_h_size->fitsInto(new self($width, $height))) { + $this->set($dominant_h_size->width, $dominant_h_size->height); + } else { + $this->set($dominant_w_size->width, $dominant_w_size->height); + } + + return $this; + } + + /** + * Scale size according to given constraints + * + * @param integer $width + * @param Closure $callback + * @return Size + */ + private function resizeWidth($width, Closure $callback = null) + { + $constraint = $this->getConstraint($callback); + + if ($constraint->isFixed(Constraint::UPSIZE)) { + $max_width = $constraint->getSize()->getWidth(); + $max_height = $constraint->getSize()->getHeight(); + } + + if (is_numeric($width)) { + + if ($constraint->isFixed(Constraint::UPSIZE)) { + $this->width = ($width > $max_width) ? $max_width : $width; + } else { + $this->width = $width; + } + + if ($constraint->isFixed(Constraint::ASPECTRATIO)) { + $h = intval(round($this->width / $constraint->getSize()->getRatio())); + + if ($constraint->isFixed(Constraint::UPSIZE)) { + $this->height = ($h > $max_height) ? $max_height : $h; + } else { + $this->height = $h; + } + } + } + } + + /** + * Scale size according to given constraints + * + * @param integer $height + * @param Closure $callback + * @return Size + */ + private function resizeHeight($height, Closure $callback = null) + { + $constraint = $this->getConstraint($callback); + + if ($constraint->isFixed(Constraint::UPSIZE)) { + $max_width = $constraint->getSize()->getWidth(); + $max_height = $constraint->getSize()->getHeight(); + } + + if (is_numeric($height)) { + + if ($constraint->isFixed(Constraint::UPSIZE)) { + $this->height = ($height > $max_height) ? $max_height : $height; + } else { + $this->height = $height; + } + + if ($constraint->isFixed(Constraint::ASPECTRATIO)) { + $w = intval(round($this->height * $constraint->getSize()->getRatio())); + + if ($constraint->isFixed(Constraint::UPSIZE)) { + $this->width = ($w > $max_width) ? $max_width : $w; + } else { + $this->width = $w; + } + } + } + } + + /** + * Calculate the relative position to another Size + * based on the pivot point settings of both sizes. + * + * @param Size $size + * @return \Intervention\Image\Point + */ + public function relativePosition(Size $size) + { + $x = $this->pivot->x - $size->pivot->x; + $y = $this->pivot->y - $size->pivot->y; + + return new Point($x, $y); + } + + /** + * Resize given Size to best fitting size of current size. + * + * @param Size $size + * @return \Intervention\Image\Size + */ + public function fit(Size $size, $position = 'center') + { + // create size with auto height + $auto_height = clone $size; + + $auto_height->resize($this->width, null, function ($constraint) { + $constraint->aspectRatio(); + }); + + // decide which version to use + if ($auto_height->fitsInto($this)) { + + $size = $auto_height; + + } else { + + // create size with auto width + $auto_width = clone $size; + + $auto_width->resize(null, $this->height, function ($constraint) { + $constraint->aspectRatio(); + }); + + $size = $auto_width; + } + + $this->align($position); + $size->align($position); + $size->setPivot($this->relativePosition($size)); + + return $size; + } + + /** + * Checks if given size fits into current size + * + * @param Size $size + * @return boolean + */ + public function fitsInto(Size $size) + { + return ($this->width <= $size->width) && ($this->height <= $size->height); + } + + /** + * Aligns current size's pivot point to given position + * and moves point automatically by offset. + * + * @param string $position + * @param integer $offset_x + * @param integer $offset_y + * @return \Intervention\Image\Size + */ + public function align($position, $offset_x = 0, $offset_y = 0) + { + switch (strtolower($position)) { + + case 'top': + case 'top-center': + case 'top-middle': + case 'center-top': + case 'middle-top': + $x = intval($this->width / 2); + $y = 0 + $offset_y; + break; + + case 'top-right': + case 'right-top': + $x = $this->width - $offset_x; + $y = 0 + $offset_y; + break; + + case 'left': + case 'left-center': + case 'left-middle': + case 'center-left': + case 'middle-left': + $x = 0 + $offset_x; + $y = intval($this->height / 2); + break; + + case 'right': + case 'right-center': + case 'right-middle': + case 'center-right': + case 'middle-right': + $x = $this->width - $offset_x; + $y = intval($this->height / 2); + break; + + case 'bottom-left': + case 'left-bottom': + $x = 0 + $offset_x; + $y = $this->height - $offset_y; + break; + + case 'bottom': + case 'bottom-center': + case 'bottom-middle': + case 'center-bottom': + case 'middle-bottom': + $x = intval($this->width / 2); + $y = $this->height - $offset_y; + break; + + case 'bottom-right': + case 'right-bottom': + $x = $this->width - $offset_x; + $y = $this->height - $offset_y; + break; + + case 'center': + case 'middle': + case 'center-center': + case 'middle-middle': + $x = intval($this->width / 2); + $y = intval($this->height / 2); + break; + + default: + case 'top-left': + case 'left-top': + $x = 0 + $offset_x; + $y = 0 + $offset_y; + break; + } + + $this->pivot->setPosition($x, $y); + + return $this; + } + + /** + * Runs constraints on current size + * + * @param Closure $callback + * @return \Intervention\Image\Constraint + */ + private function getConstraint(Closure $callback = null) + { + $constraint = new Constraint(clone $this); + + if (is_callable($callback)) { + $callback($constraint); + } + + return $constraint; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/intervention/image/src/config/config.php b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/config/config.php new file mode 100644 index 0000000..2b1d2c3 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/intervention/image/src/config/config.php @@ -0,0 +1,20 @@ + 'gd' + +]; diff --git a/server/plugins/manogi/mediathumb/vendor/manogi/mediathumb/resize_helper.php b/server/plugins/manogi/mediathumb/vendor/manogi/mediathumb/resize_helper.php new file mode 100644 index 0000000..317b981 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/manogi/mediathumb/resize_helper.php @@ -0,0 +1,179 @@ +exists($original_path)) { + return ''; + } + + + + // get the image as data + $original_file = Storage::disk($disk)->get($original_path); + + + + // define directory for thumbnail + $thumb_directory = $disk_folder.'/'.$mediathumb_folder.'/'; + + + // make new filename for folder names and filename + $new_filename = str_replace('/', '-', substr($img, 1)); + + // store position of the dot before the extension + $last_dot_position = strrpos($new_filename, '.'); + + // get the extension + $extension = substr($new_filename, $last_dot_position+1); + + // get the new filename without extension + $filename_body = str_slug(substr($new_filename, 0, $last_dot_position)); + + + + // get filesize and filetime for extending the filename for the purpose of + // creating a new thumb in case a new file with the same name is uploadsed + // (meaning the orginal file is overwritten) + $filesize = Storage::disk($disk)->size($original_path); + $filetime = Storage::disk($disk)->lastModified($original_path); + + // make the string to add to the filename to for 2 purposes: + // a) to make sure the that for the SAME image a thumbnail is only generated once + // b) to make sure that a new thumb is generated if the original is overwritten + $version_string = $mode.'-'.$size.'-'.$quality.'-'.$filesize.'-'.$filetime; + + // create the complete new filename and hash the version string to make it shorter + $new_filename = $filename_body.'-'.md5($version_string).'.'.$extension; + + // define complete path of the new file (without the root path) + $new_path = $thumb_directory.$new_filename; + + + // create the thumb directory if it does not exist + if (!Storage::disk($disk)->exists($thumb_directory)) { + Storage::disk($disk)->makeDirectory($thumb_directory); + } + + // create the thumb, but only if it does not exist + if (!Storage::disk($disk)->exists($new_path)) { + if ($extension == 'gif') { + Storage::disk($disk)->put($new_path, $original_file); + } else { + try { + $image = Image::make($original_file); + $final_mode = $mode; + if ($mode == 'auto') { + $final_mode = 'width'; + + $ratio = $image->width()/$image->height(); + if ($ratio < 1) { + $final_mode = 'height'; + } + } + if ($final_mode == 'width') { + $image->resize($size, null, function ($constraint) { + $constraint->aspectRatio(); + $constraint->upsize(); + }); + } elseif ($final_mode == 'height') { + $image->resize(null, $size, function ($constraint) { + $constraint->aspectRatio(); + $constraint->upsize(); + }); + } + + $image_stream = $image->stream($extension, $quality); + Storage::disk($disk)->put($new_path, $image_stream->__toString()); + } catch (Exception $e) { + $error = 'Intervention Image Error : '.$e->getMessage(); + } + } + } + + + // return image path + return asset(config('cms.storage.'.$resource.'.path').'/'.$mediathumb_folder.'/'.$new_filename); + } +} + + +// Alias for mediathumbResize() +if (!function_exists('mediathumbGetThumb')) { + function mediathumbGetThumb($img, $mode = null, $size = null, $quality = null) + { + return mediathumbResize($img, $mode, $size, $quality); + } +} + +// Alias for mediathumbResize() +if (!function_exists('getMediathumb')) { + function getMediathumb($img, $mode = null, $size = null, $quality = null) + { + return mediathumbResize($img, $mode, $size, $quality); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/CHANGELOG.md b/server/plugins/manogi/mediathumb/vendor/psr/http-message/CHANGELOG.md new file mode 100644 index 0000000..74b1ef9 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/CHANGELOG.md @@ -0,0 +1,36 @@ +# Changelog + +All notable changes to this project will be documented in this file, in reverse chronological order by release. + +## 1.0.1 - 2016-08-06 + +### Added + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Updated all `@return self` annotation references in interfaces to use + `@return static`, which more closelly follows the semantics of the + specification. +- Updated the `MessageInterface::getHeaders()` return annotation to use the + value `string[][]`, indicating the format is a nested array of strings. +- Updated the `@link` annotation for `RequestInterface::withRequestTarget()` + to point to the correct section of RFC 7230. +- Updated the `ServerRequestInterface::withUploadedFiles()` parameter annotation + to add the parameter name (`$uploadedFiles`). +- Updated a `@throws` annotation for the `UploadedFileInterface::moveTo()` + method to correctly reference the method parameter (it was referencing an + incorrect parameter name previously). + +## 1.0.0 - 2016-05-18 + +Initial stable release; reflects accepted PSR-7 specification. diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/LICENSE b/server/plugins/manogi/mediathumb/vendor/psr/http-message/LICENSE new file mode 100644 index 0000000..c2d8e45 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 PHP Framework Interoperability Group + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/README.md b/server/plugins/manogi/mediathumb/vendor/psr/http-message/README.md new file mode 100644 index 0000000..2818533 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/README.md @@ -0,0 +1,13 @@ +PSR Http Message +================ + +This repository holds all interfaces/classes/traits related to +[PSR-7](http://www.php-fig.org/psr/psr-7/). + +Note that this is not a HTTP message implementation of its own. It is merely an +interface that describes a HTTP message. See the specification for more details. + +Usage +----- + +We'll certainly need some stuff in here. \ No newline at end of file diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/composer.json b/server/plugins/manogi/mediathumb/vendor/psr/http-message/composer.json new file mode 100644 index 0000000..b0d2937 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/composer.json @@ -0,0 +1,26 @@ +{ + "name": "psr/http-message", + "description": "Common interface for HTTP messages", + "keywords": ["psr", "psr-7", "http", "http-message", "request", "response"], + "homepage": "https://github.com/php-fig/http-message", + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/MessageInterface.php b/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/MessageInterface.php new file mode 100644 index 0000000..dd46e5e --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/MessageInterface.php @@ -0,0 +1,187 @@ +getHeaders() as $name => $values) { + * echo $name . ": " . implode(", ", $values); + * } + * + * // Emit headers iteratively: + * foreach ($message->getHeaders() as $name => $values) { + * foreach ($values as $value) { + * header(sprintf('%s: %s', $name, $value), false); + * } + * } + * + * While header names are not case-sensitive, getHeaders() will preserve the + * exact case in which headers were originally specified. + * + * @return string[][] Returns an associative array of the message's headers. Each + * key MUST be a header name, and each value MUST be an array of strings + * for that header. + */ + public function getHeaders(); + + /** + * Checks if a header exists by the given case-insensitive name. + * + * @param string $name Case-insensitive header field name. + * @return bool Returns true if any header names match the given header + * name using a case-insensitive string comparison. Returns false if + * no matching header name is found in the message. + */ + public function hasHeader($name); + + /** + * Retrieves a message header value by the given case-insensitive name. + * + * This method returns an array of all the header values of the given + * case-insensitive header name. + * + * If the header does not appear in the message, this method MUST return an + * empty array. + * + * @param string $name Case-insensitive header field name. + * @return string[] An array of string values as provided for the given + * header. If the header does not appear in the message, this method MUST + * return an empty array. + */ + public function getHeader($name); + + /** + * Retrieves a comma-separated string of the values for a single header. + * + * This method returns all of the header values of the given + * case-insensitive header name as a string concatenated together using + * a comma. + * + * NOTE: Not all header values may be appropriately represented using + * comma concatenation. For such headers, use getHeader() instead + * and supply your own delimiter when concatenating. + * + * If the header does not appear in the message, this method MUST return + * an empty string. + * + * @param string $name Case-insensitive header field name. + * @return string A string of values as provided for the given header + * concatenated together using a comma. If the header does not appear in + * the message, this method MUST return an empty string. + */ + public function getHeaderLine($name); + + /** + * Return an instance with the provided value replacing the specified header. + * + * While header names are case-insensitive, the casing of the header will + * be preserved by this function, and returned from getHeaders(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new and/or updated header and value. + * + * @param string $name Case-insensitive header field name. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withHeader($name, $value); + + /** + * Return an instance with the specified header appended with the given value. + * + * Existing values for the specified header will be maintained. The new + * value(s) will be appended to the existing list. If the header did not + * exist previously, it will be added. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new header and/or value. + * + * @param string $name Case-insensitive header field name to add. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withAddedHeader($name, $value); + + /** + * Return an instance without the specified header. + * + * Header resolution MUST be done without case-sensitivity. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the named header. + * + * @param string $name Case-insensitive header field name to remove. + * @return static + */ + public function withoutHeader($name); + + /** + * Gets the body of the message. + * + * @return StreamInterface Returns the body as a stream. + */ + public function getBody(); + + /** + * Return an instance with the specified message body. + * + * The body MUST be a StreamInterface object. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return a new instance that has the + * new body stream. + * + * @param StreamInterface $body Body. + * @return static + * @throws \InvalidArgumentException When the body is not valid. + */ + public function withBody(StreamInterface $body); +} diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/RequestInterface.php b/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/RequestInterface.php new file mode 100644 index 0000000..a96d4fd --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/RequestInterface.php @@ -0,0 +1,129 @@ +getQuery()` + * or from the `QUERY_STRING` server param. + * + * @return array + */ + public function getQueryParams(); + + /** + * Return an instance with the specified query string arguments. + * + * These values SHOULD remain immutable over the course of the incoming + * request. They MAY be injected during instantiation, such as from PHP's + * $_GET superglobal, or MAY be derived from some other value such as the + * URI. In cases where the arguments are parsed from the URI, the data + * MUST be compatible with what PHP's parse_str() would return for + * purposes of how duplicate query parameters are handled, and how nested + * sets are handled. + * + * Setting query string arguments MUST NOT change the URI stored by the + * request, nor the values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated query string arguments. + * + * @param array $query Array of query string arguments, typically from + * $_GET. + * @return static + */ + public function withQueryParams(array $query); + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @return array An array tree of UploadedFileInterface instances; an empty + * array MUST be returned if no data is present. + */ + public function getUploadedFiles(); + + /** + * Create a new instance with the specified uploaded files. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array $uploadedFiles An array tree of UploadedFileInterface instances. + * @return static + * @throws \InvalidArgumentException if an invalid structure is provided. + */ + public function withUploadedFiles(array $uploadedFiles); + + /** + * Retrieve any parameters provided in the request body. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, this method MUST + * return the contents of $_POST. + * + * Otherwise, this method may return any results of deserializing + * the request body content; as parsing returns structured content, the + * potential types MUST be arrays or objects only. A null value indicates + * the absence of body content. + * + * @return null|array|object The deserialized body parameters, if any. + * These will typically be an array or object. + */ + public function getParsedBody(); + + /** + * Return an instance with the specified body parameters. + * + * These MAY be injected during instantiation. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, use this method + * ONLY to inject the contents of $_POST. + * + * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of + * deserializing the request body content. Deserialization/parsing returns + * structured data, and, as such, this method ONLY accepts arrays or objects, + * or a null value if nothing was available to parse. + * + * As an example, if content negotiation determines that the request data + * is a JSON payload, this method could be used to create a request + * instance with the deserialized parameters. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param null|array|object $data The deserialized body data. This will + * typically be in an array or object. + * @return static + * @throws \InvalidArgumentException if an unsupported argument type is + * provided. + */ + public function withParsedBody($data); + + /** + * Retrieve attributes derived from the request. + * + * The request "attributes" may be used to allow injection of any + * parameters derived from the request: e.g., the results of path + * match operations; the results of decrypting cookies; the results of + * deserializing non-form-encoded message bodies; etc. Attributes + * will be application and request specific, and CAN be mutable. + * + * @return array Attributes derived from the request. + */ + public function getAttributes(); + + /** + * Retrieve a single derived request attribute. + * + * Retrieves a single derived request attribute as described in + * getAttributes(). If the attribute has not been previously set, returns + * the default value as provided. + * + * This method obviates the need for a hasAttribute() method, as it allows + * specifying a default value to return if the attribute is not found. + * + * @see getAttributes() + * @param string $name The attribute name. + * @param mixed $default Default value to return if the attribute does not exist. + * @return mixed + */ + public function getAttribute($name, $default = null); + + /** + * Return an instance with the specified derived request attribute. + * + * This method allows setting a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated attribute. + * + * @see getAttributes() + * @param string $name The attribute name. + * @param mixed $value The value of the attribute. + * @return static + */ + public function withAttribute($name, $value); + + /** + * Return an instance that removes the specified derived request attribute. + * + * This method allows removing a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the attribute. + * + * @see getAttributes() + * @param string $name The attribute name. + * @return static + */ + public function withoutAttribute($name); +} diff --git a/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/StreamInterface.php b/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/StreamInterface.php new file mode 100644 index 0000000..f68f391 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/psr/http-message/src/StreamInterface.php @@ -0,0 +1,158 @@ + + * [user-info@]host[:port] + * + * + * If the port component is not set or is the standard port for the current + * scheme, it SHOULD NOT be included. + * + * @see https://tools.ietf.org/html/rfc3986#section-3.2 + * @return string The URI authority, in "[user-info@]host[:port]" format. + */ + public function getAuthority(); + + /** + * Retrieve the user information component of the URI. + * + * If no user information is present, this method MUST return an empty + * string. + * + * If a user is present in the URI, this will return that value; + * additionally, if the password is also present, it will be appended to the + * user value, with a colon (":") separating the values. + * + * The trailing "@" character is not part of the user information and MUST + * NOT be added. + * + * @return string The URI user information, in "username[:password]" format. + */ + public function getUserInfo(); + + /** + * Retrieve the host component of the URI. + * + * If no host is present, this method MUST return an empty string. + * + * The value returned MUST be normalized to lowercase, per RFC 3986 + * Section 3.2.2. + * + * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 + * @return string The URI host. + */ + public function getHost(); + + /** + * Retrieve the port component of the URI. + * + * If a port is present, and it is non-standard for the current scheme, + * this method MUST return it as an integer. If the port is the standard port + * used with the current scheme, this method SHOULD return null. + * + * If no port is present, and no scheme is present, this method MUST return + * a null value. + * + * If no port is present, but a scheme is present, this method MAY return + * the standard port for that scheme, but SHOULD return null. + * + * @return null|int The URI port. + */ + public function getPort(); + + /** + * Retrieve the path component of the URI. + * + * The path can either be empty or absolute (starting with a slash) or + * rootless (not starting with a slash). Implementations MUST support all + * three syntaxes. + * + * Normally, the empty path "" and absolute path "/" are considered equal as + * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically + * do this normalization because in contexts with a trimmed base path, e.g. + * the front controller, this difference becomes significant. It's the task + * of the user to handle both "" and "/". + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.3. + * + * As an example, if the value should include a slash ("/") not intended as + * delimiter between path segments, that value MUST be passed in encoded + * form (e.g., "%2F") to the instance. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.3 + * @return string The URI path. + */ + public function getPath(); + + /** + * Retrieve the query string of the URI. + * + * If no query string is present, this method MUST return an empty string. + * + * The leading "?" character is not part of the query and MUST NOT be + * added. + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.4. + * + * As an example, if a value in a key/value pair of the query string should + * include an ampersand ("&") not intended as a delimiter between values, + * that value MUST be passed in encoded form (e.g., "%26") to the instance. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.4 + * @return string The URI query string. + */ + public function getQuery(); + + /** + * Retrieve the fragment component of the URI. + * + * If no fragment is present, this method MUST return an empty string. + * + * The leading "#" character is not part of the fragment and MUST NOT be + * added. + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.5. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.5 + * @return string The URI fragment. + */ + public function getFragment(); + + /** + * Return an instance with the specified scheme. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified scheme. + * + * Implementations MUST support the schemes "http" and "https" case + * insensitively, and MAY accommodate other schemes if required. + * + * An empty scheme is equivalent to removing the scheme. + * + * @param string $scheme The scheme to use with the new instance. + * @return static A new instance with the specified scheme. + * @throws \InvalidArgumentException for invalid or unsupported schemes. + */ + public function withScheme($scheme); + + /** + * Return an instance with the specified user information. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified user information. + * + * Password is optional, but the user information MUST include the + * user; an empty string for the user is equivalent to removing user + * information. + * + * @param string $user The user name to use for authority. + * @param null|string $password The password associated with $user. + * @return static A new instance with the specified user information. + */ + public function withUserInfo($user, $password = null); + + /** + * Return an instance with the specified host. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified host. + * + * An empty host value is equivalent to removing the host. + * + * @param string $host The hostname to use with the new instance. + * @return static A new instance with the specified host. + * @throws \InvalidArgumentException for invalid hostnames. + */ + public function withHost($host); + + /** + * Return an instance with the specified port. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified port. + * + * Implementations MUST raise an exception for ports outside the + * established TCP and UDP port ranges. + * + * A null value provided for the port is equivalent to removing the port + * information. + * + * @param null|int $port The port to use with the new instance; a null value + * removes the port information. + * @return static A new instance with the specified port. + * @throws \InvalidArgumentException for invalid ports. + */ + public function withPort($port); + + /** + * Return an instance with the specified path. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified path. + * + * The path can either be empty or absolute (starting with a slash) or + * rootless (not starting with a slash). Implementations MUST support all + * three syntaxes. + * + * If the path is intended to be domain-relative rather than path relative then + * it must begin with a slash ("/"). Paths not starting with a slash ("/") + * are assumed to be relative to some base path known to the application or + * consumer. + * + * Users can provide both encoded and decoded path characters. + * Implementations ensure the correct encoding as outlined in getPath(). + * + * @param string $path The path to use with the new instance. + * @return static A new instance with the specified path. + * @throws \InvalidArgumentException for invalid paths. + */ + public function withPath($path); + + /** + * Return an instance with the specified query string. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified query string. + * + * Users can provide both encoded and decoded query characters. + * Implementations ensure the correct encoding as outlined in getQuery(). + * + * An empty query string value is equivalent to removing the query string. + * + * @param string $query The query string to use with the new instance. + * @return static A new instance with the specified query string. + * @throws \InvalidArgumentException for invalid query strings. + */ + public function withQuery($query); + + /** + * Return an instance with the specified URI fragment. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified URI fragment. + * + * Users can provide both encoded and decoded fragment characters. + * Implementations ensure the correct encoding as outlined in getFragment(). + * + * An empty fragment value is equivalent to removing the fragment. + * + * @param string $fragment The fragment to use with the new instance. + * @return static A new instance with the specified fragment. + */ + public function withFragment($fragment); + + /** + * Return the string representation as a URI reference. + * + * Depending on which components of the URI are present, the resulting + * string is either a full URI or relative reference according to RFC 3986, + * Section 4.1. The method concatenates the various components of the URI, + * using the appropriate delimiters: + * + * - If a scheme is present, it MUST be suffixed by ":". + * - If an authority is present, it MUST be prefixed by "//". + * - The path can be concatenated without delimiters. But there are two + * cases where the path has to be adjusted to make the URI reference + * valid as PHP does not allow to throw an exception in __toString(): + * - If the path is rootless and an authority is present, the path MUST + * be prefixed by "/". + * - If the path is starting with more than one "/" and no authority is + * present, the starting slashes MUST be reduced to one. + * - If a query is present, it MUST be prefixed by "?". + * - If a fragment is present, it MUST be prefixed by "#". + * + * @see http://tools.ietf.org/html/rfc3986#section-4.1 + * @return string + */ + public function __toString(); +} diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/LICENSE b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/LICENSE new file mode 100644 index 0000000..c24dddb --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Albert Lacarta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/README.md b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/README.md new file mode 100644 index 0000000..b07d715 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/README.md @@ -0,0 +1,119 @@ +urodoz/truncateHTML +============ + +> PHP library to handle truncate action on HTML strings + + +Features +-------- + +- Truncates an HTML string keeping consistency on open/close tags +- No external dependencies. +- PSR-4 compatible. +- Compatible with PHP >= 5.3.3 and +- Integrations for [Symfony2](http://symfony.com) and [Twig](http://twig.sensiolabs.org). + + +Installation +------------ + +You can install urodoz/truncateHTML through [Composer](https://getcomposer.org): + +```shell +$ composer require urodoz/truncate-html:@stable +``` + +Usage +----- + +Truncate an HTML string: + +```php +use Urodoz\Truncate\TruncateService; + +$truncateService = new TruncateService(); +echo $truncateService->truncate($htmlString, 100); //Truncating to 100 characters +``` + +Integrations +------------ + +### Symfony2 + +TruncateHTML contains a Symfony2 bundle and service definition that allow you to use it as a service in your Symfony2 application. +The code resides in the `Urodoz\Truncate\Bridge\Symfony` namespace and you only need to add the bundle class to your `AppKernel.php`: + +```php +# app/AppKernel.php + +class AppKernel extends Kernel +{ + public function registerBundles() + { + $bundles = array( + // ... + new Urodoz\Truncate\Bridge\Symfony\UrodozTruncateBundle(), + ); + // ... + } + + // ... +} +``` + +You can now use the `urodoz_truncate` service everywhere in your application, for example, in your controller: + +```php +$truncatedString = $this->get('urodoz_truncate')->truncate($htmlString, 100); +``` + +### Twig + +If you use the Symfony2 framework with Twig you can use the Twig filter `truncateHTML` in your templates after you have setup Symfony2 integrations (see above). + +```twig +{{ truncateHTML(content, 250) }} +``` + +If you use Twig outside of the Symfony2 framework you first need to add the extension to your environment: + +```php +use Urodoz\Truncate\Bridge\Twig\TruncateExtension; +use Urodoz\Truncate\TruncateService; + +$twig = new Twig_Environment($loader); +$twig->addFunction(new TruncateExtension(TruncateService::create())); +``` + +You can find more information about registering extensions in the [Twig documentation](http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension). + +Author +------- + +- [Albert Lacarta](https://github.com/urodoz) + + +License +------- + +The MIT License (MIT) + +Copyright (c) 2014 Albert Lacarta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/phpunit.xml.dist b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/phpunit.xml.dist new file mode 100644 index 0000000..e924931 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/phpunit.xml.dist @@ -0,0 +1,14 @@ + + + + + + tests + + + + + src + + + diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateBundle.php b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateBundle.php new file mode 100644 index 0000000..c93fed5 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateBundle.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Urodoz\Truncate\Bridge\Symfony; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\Bundle; + +/** + * UrodozTruncateBundle + * + * @package org.urodoz.truncatehtml + * @author Albert Lacarta + * @license http://www.opensource.org/licenses/MIT The MIT License + */ +class UrodozTruncateBundle extends Bundle +{ + /** + * {@inheritDoc} + */ + public function build(ContainerBuilder $container) + { + parent::build($container); + $extension = new UrodozTruncateExtension(); + $extension->load(array(), $container); + $container->registerExtension($extension); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateExtension.php b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateExtension.php new file mode 100644 index 0000000..e945044 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Symfony/UrodozTruncateExtension.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Urodoz\Truncate\Bridge\Symfony; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +/** + * UrodozTruncateBundle + * + * @package org.urodoz.truncatehtml + * @author Albert Lacarta + * @license http://www.opensource.org/licenses/MIT The MIT License + */ +class UrodozTruncateExtension extends Extension +{ + /** + * {@inheritDoc} + * + * @param mixed[] $configs + * @param ContainerBuilder $container + */ + public function load(array $configs, ContainerBuilder $container) + { + $container->setDefinition('urodoz_truncate', new Definition('Urodoz\Truncate\TruncateService')); + $container->setDefinition( + 'urodoz_truncate.twig.truncateHTML', + new Definition( + 'Urodoz\Truncate\Bridge\Twig\TruncateExtension', + array(new Reference('urodoz_truncate')) + ) + )->addTag('twig.extension'); + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Twig/TruncateExtension.php b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Twig/TruncateExtension.php new file mode 100644 index 0000000..cb9b136 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/Bridge/Twig/TruncateExtension.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Urodoz\Truncate\Bridge\Twig; + +use Urodoz\Truncate\TruncateInterface; + +/** + * TruncateExtension + * + * @package org.urodoz.truncatehtml + * @author Albert Lacarta + * @license http://www.opensource.org/licenses/MIT The MIT License + */ +class TruncateExtension extends \Twig_Extension +{ + + /** + * @var TruncateInterface + */ + private $truncateService; + + public function __construct(TruncateInterface $truncateService) + { + $this->truncateService = $truncateService; + } + + /** + * Returns the Twig functions of this extension. + * + * @return \Twig_SimpleFilter[] + */ + public function getFunctions() + { + return array( + "truncateHTML" => new \Twig_Function_Method($this, "truncateHTML"), + ); + } + + /** + * Truncate HTML filter. + * + * @param string $string + * @param string $separator + * + * @return string + */ + public function truncateHTML($string, $length = 100) + { + return $this->truncateService->truncate($string, $length); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return 'urodoztruncatehtml_extension'; + } +} diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateInterface.php b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateInterface.php new file mode 100644 index 0000000..a3b02db --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateInterface.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Urodoz\Truncate; + +/** + * TruncateInterface + * + * @package org.urodoz.truncatehtml + * @author Albert Lacarta + * @license http://www.opensource.org/licenses/MIT The MIT License + */ +interface TruncateInterface +{ + + /** + * Truncates the HTML keeping consistency on open/closing HTML tags + * + * @param string $text + * @param int $length + * @param string $ending + * @param bool $exact + * @param bool $considerHtml + * @return string The truncated string + */ + public function truncate( + $text, + $length = 100, + $ending = '...', + $exact = false, + $considerHtml = true + ); + +} diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateService.php b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateService.php new file mode 100644 index 0000000..0f5b8d9 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/src/TruncateService.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Urodoz\Truncate; + +/** + * TruncateService + * + * @package org.urodoz.truncatehtml + * @author Albert Lacarta + * @license http://www.opensource.org/licenses/MIT The MIT License + */ +class TruncateService implements TruncateInterface +{ + + /** + * Static method to create new instance of {@see Slugify}. + * + * @return Slugify + */ + public static function create() + { + return new static(); + } + + /** + * @inheritDoc + */ + public function truncate( + $text, + $length = 100, + $ending = '...', + $exact = false, + $considerHtml = true + ) { + if ($considerHtml) { + // if the plain text is shorter than the maximum length, return the whole text + if (strlen(preg_replace('/<.*?>/', '', $text)) <= $length) { + return $text; + } + // splits all html-tags to scanable lines + preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); + $total_length = strlen($ending); + $open_tags = array(); + $truncate = ''; + foreach ($lines as $line_matchings) { + // if there is any html-tag in this line, handle it and add it (uncounted) to the output + if (!empty($line_matchings[1])) { + // if it's an "empty element" with or without xhtml-conform closing slash + if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) { + // do nothing + // if tag is a closing tag + } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) { + // delete tag from $open_tags list + $pos = array_search($tag_matchings[1], $open_tags); + if ($pos !== false) { + unset($open_tags[$pos]); + } + // if tag is an opening tag + } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) { + // add tag to the beginning of $open_tags list + array_unshift($open_tags, strtolower($tag_matchings[1])); + } + // add html-tag to $truncate'd text + $truncate .= $line_matchings[1]; + } + // calculate the length of the plain text part of the line; handle entities as one character + $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])); + if ($total_length+$content_length> $length) { + // the number of characters which are left + $left = $length - $total_length; + $entities_length = 0; + // search for html entities + if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) { + // calculate the real length of all entities in the legal range + foreach ($entities[0] as $entity) { + if ($entity[1]+1-$entities_length <= $left) { + $left--; + $entities_length += strlen($entity[0]); + } else { + // no more characters left + break; + } + } + } + $truncate .= substr($line_matchings[2], 0, $left+$entities_length); + // maximum lenght is reached, so get off the loop + break; + } else { + $truncate .= $line_matchings[2]; + $total_length += $content_length; + } + // if the maximum length is reached, get off the loop + if($total_length>= $length) { + break; + } + } + } else { + if (strlen($text) <= $length) { + return $text; + } else { + $truncate = substr($text, 0, $length - strlen($ending)); + } + } + // if the words shouldn't be cut in the middle... + if (!$exact) { + // ...search the last occurance of a space... + $spacepos = strrpos($truncate, ' '); + if (isset($spacepos)) { + // ...and cut the text in this position + $truncate = substr($truncate, 0, $spacepos); + } + } + // add the defined ending to the text + $truncate .= $ending; + if($considerHtml) { + // close all unclosed html-tags + foreach ($open_tags as $tag) { + $truncate .= ''; + } + } + return $truncate; + } + +} diff --git a/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/tests/TruncateServiceTest.php b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/tests/TruncateServiceTest.php new file mode 100644 index 0000000..4dec2a5 --- /dev/null +++ b/server/plugins/manogi/mediathumb/vendor/urodoz/truncate-html/tests/TruncateServiceTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Urodoz\Truncate; + +use Urodoz\Truncate\TruncateService; + +/** + * TruncateService + * + * @package org.urodoz.truncatehtml + * @author Albert Lacarta + * @license http://www.opensource.org/licenses/MIT The MIT License + */ +class TruncateServiceTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var TruncateService + */ + private $truncateService; + + public function setUp() + { + $this->truncateService = new TruncateService(); + } + + public function provider() + { + return array( + array('

    Hello world!

    ', 10, '

    Hello...

    '), + array('

    Hello world!

    ', 30, '

    Hello world!

    '), + array('

    Hello World! blah blah blah

    ', 20, '

    Hello World!...

    '), + array('OneTwo Three', 10, 'OneTwo...'), + array('

    Hello world!

    ', 10, '

    Hello...

    '), + array('

    Hello world!

    ', 20, '

    Hello world!

    '), + ); + } + + /** + * @dataProvider provider + */ + public function testTruncate($htmlString, $length, $expected) + { + $truncatedText = $this->truncateService->truncate($htmlString, $length); + $this->assertEquals($expected, $truncatedText); + } + +} diff --git a/server/plugins/rainlab/builder/LICENCE.md b/server/plugins/rainlab/builder/LICENCE.md new file mode 100644 index 0000000..d68943e --- /dev/null +++ b/server/plugins/rainlab/builder/LICENCE.md @@ -0,0 +1,19 @@ +# MIT license + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/server/plugins/rainlab/builder/Plugin.php b/server/plugins/rainlab/builder/Plugin.php new file mode 100644 index 0000000..ed484ab --- /dev/null +++ b/server/plugins/rainlab/builder/Plugin.php @@ -0,0 +1,148 @@ + 'rainlab.builder::lang.plugin.name', + 'description' => 'rainlab.builder::lang.plugin.description', + 'author' => 'Alexey Bobkov, Samuel Georges', + 'icon' => 'icon-wrench', + 'homepage' => 'https://github.com/rainlab/builder-plugin' + ]; + } + + public function registerComponents() + { + return [ + 'RainLab\Builder\Components\RecordList' => 'builderList', + 'RainLab\Builder\Components\RecordDetails' => 'builderDetails' + ]; + } + + public function registerPermissions() + { + return [ + 'rainlab.builder.manage_plugins' => [ + 'tab' => 'rainlab.builder::lang.plugin.name', + 'label' => 'rainlab.builder::lang.plugin.manage_plugins'] + ]; + } + + public function registerNavigation() + { + return [ + 'builder' => [ + 'label' => 'rainlab.builder::lang.plugin.name', + 'url' => Backend::url('rainlab/builder'), + 'icon' => 'icon-wrench', + 'iconSvg' => 'plugins/rainlab/builder/assets/images/builder-icon.svg', + 'permissions' => ['rainlab.builder.manage_plugins'], + 'order' => 400, + + 'sideMenu' => [ + 'database' => [ + 'label' => 'rainlab.builder::lang.database.menu_label', + 'icon' => 'icon-hdd-o', + 'url' => 'javascript:;', + 'attributes' => ['data-menu-item'=>'database'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ], + 'models' => [ + 'label' => 'rainlab.builder::lang.model.menu_label', + 'icon' => 'icon-random', + 'url' => 'javascript:;', + 'attributes' => ['data-menu-item'=>'models'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ], + 'permissions' => [ + 'label' => 'rainlab.builder::lang.permission.menu_label', + 'icon' => 'icon-unlock-alt', + 'url' => '#', + 'attributes' => ['data-no-side-panel'=>'true', 'data-builder-command'=>'permission:cmdOpenPermissions', 'data-menu-item'=>'permissions'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ], + 'menus' => [ + 'label' => 'rainlab.builder::lang.menu.menu_label', + 'icon' => 'icon-location-arrow', + 'url' => 'javascript:;', + 'attributes' => ['data-no-side-panel'=>'true', 'data-builder-command'=>'menus:cmdOpenMenus', 'data-menu-item'=>'menus'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ], + 'controllers' => [ + 'label' => 'rainlab.builder::lang.controller.menu_label', + 'icon' => 'icon-asterisk', + 'url' => 'javascript:;', + 'attributes' => ['data-menu-item'=>'controllers'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ], + 'versions' => [ + 'label' => 'rainlab.builder::lang.version.menu_label', + 'icon' => 'icon-code-fork', + 'url' => 'javascript:;', + 'attributes' => ['data-menu-item'=>'version'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ], + 'localization' => [ + 'label' => 'rainlab.builder::lang.localization.menu_label', + 'icon' => 'icon-globe', + 'url' => 'javascript:;', + 'attributes' => ['data-menu-item'=>'localization'], + 'permissions' => ['rainlab.builder.manage_plugins'] + ] + ] + + ] + ]; + } + + public function registerSettings() + { + return [ + 'config' => [ + 'label' => 'Builder', + 'icon' => 'icon-wrench', + 'description' => 'Set your author name and namespace for plugin creation.', + 'class' => 'RainLab\Builder\Models\Settings', + 'permissions' => ['rainlab.builder.manage_plugins'], + 'order' => 600 + ] + ]; + } + + public function boot() + { + Event::listen('pages.builder.registerControls', function($controlLibrary) { + new StandardControlsRegistry($controlLibrary); + }); + + Event::listen('pages.builder.registerControllerBehaviors', function($behaviorLibrary) { + new StandardBehaviorsRegistry($behaviorLibrary); + }); + + // Register reserved keyword validation + Validator::resolver(function ($translator, $data, $rules, $messages, $customAttributes) { + return new ReservedValidator($translator, $data, $rules, $messages, $customAttributes); + }); + } + + public function register() + { + /* + * Register asset bundles + */ + CombineAssets::registerCallback(function ($combiner) { + $combiner->registerBundle('$/rainlab/builder/assets/js/build.js'); + }); + } +} diff --git a/server/plugins/rainlab/builder/assets/css/builder.css b/server/plugins/rainlab/builder/assets/css/builder.css new file mode 100644 index 0000000..516239c --- /dev/null +++ b/server/plugins/rainlab/builder/assets/css/builder.css @@ -0,0 +1,1209 @@ +.builder-building-area { + background: white; +} +.builder-building-area ul.builder-control-list { + padding: 20px; + margin-bottom: 0; + list-style: none; +} +.builder-building-area ul.builder-control-list:before, +.builder-building-area ul.builder-control-list:after { + content: " "; + display: table; +} +.builder-building-area ul.builder-control-list:after { + clear: both; +} +.builder-building-area ul.builder-control-list > li.control { + position: relative; + margin-bottom: 20px; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.builder-building-area ul.builder-control-list > li.control[data-unknown] { + cursor: default; +} +.builder-building-area ul.builder-control-list > li.control.placeholder, +.builder-building-area ul.builder-control-list > li.control.loading-control { + padding: 10px 12px; + position: relative; + text-align: center; + border: 2px dotted #dde0e2; + margin-top: 20px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + color: #dae0e0; +} +.builder-building-area ul.builder-control-list > li.control.placeholder i, +.builder-building-area ul.builder-control-list > li.control.loading-control i { + margin-right: 8px; +} +.builder-building-area ul.builder-control-list > li.control.clear-row { + display: none; + margin-bottom: 0; +} +.builder-building-area ul.builder-control-list > li.control.loading-control { + border-color: #bdc3c7; + text-align: left; +} +.builder-building-area ul.builder-control-list > li.control.updating-control:after, +.builder-building-area ul.builder-control-list > li.control.loading-control:before { + background-image: url(../../../../../modules/system/assets/ui/images/loader-transparent.svg); + background-size: 15px 15px; + background-position: 50% 50%; + display: inline-block; + width: 15px; + height: 15px; + content: ' '; + margin-right: 13px; + position: relative; + top: 2px; + -webkit-animation: spin 1s linear infinite; + animation: spin 1s linear infinite; +} +.builder-building-area ul.builder-control-list > li.control.loading-control:after { + content: attr(data-builder-loading-text); + display: inline-block; +} +.builder-building-area ul.builder-control-list > li.control.updating-control:after { + position: absolute; + right: -8px; + top: 5px; +} +.builder-building-area ul.builder-control-list > li.control.updating-control:before { + content: ''; + position: absolute; + right: 0; + top: 0; + width: 25px; + height: 25px; + background: rgba(127, 127, 127, 0.1); + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.builder-building-area ul.builder-control-list > li.control.drag-over { + color: #2581b8; + border-color: #2581b8; +} +.builder-building-area ul.builder-control-list > li.control.span-full { + width: 100%; + float: left; +} +.builder-building-area ul.builder-control-list > li.control.span-left { + float: left; + width: 48.5%; + clear: left; +} +.builder-building-area ul.builder-control-list > li.control.span-right { + float: right; + width: 48.5%; + clear: right; +} +.builder-building-area ul.builder-control-list > li.control.span-right + li.clear-row { + display: block; + clear: both; +} +.builder-building-area ul.builder-control-list > li.control > div.remove-control { + display: none; +} +.builder-building-area ul.builder-control-list > li.control:not(.placeholder):not(.loading-control):not(.updating-control):hover > div.remove-control { + font-family: sans-serif; + display: block; + position: absolute; + right: 0; + top: 0; + cursor: pointer; + width: 21px; + height: 21px; + padding-left: 6px; + font-size: 16px; + font-weight: bold; + line-height: 21px; + -webkit-border-radius: 20px; + -moz-border-radius: 20px; + border-radius: 20px; + background: #ecf0f1; + color: #95a5a6!important; +} +.builder-building-area ul.builder-control-list > li.control:not(.placeholder):not(.loading-control):not(.updating-control):hover > div.remove-control:hover { + color: white!important; + background: #c03f31; +} +.builder-building-area ul.builder-control-list > li.control:not(.placeholder):not(.loading-control):not(.updating-control):hover[data-control-type=hint] > div.remove-control, +.builder-building-area ul.builder-control-list > li.control:not(.placeholder):not(.loading-control):not(.updating-control):hover[data-control-type=partial] > div.remove-control { + top: 12px; + right: 12px; +} +.builder-building-area ul.builder-control-list > li.control[data-control-type=hint].updating-control:before, +.builder-building-area ul.builder-control-list > li.control[data-control-type=partial].updating-control:before { + right: 12px; + top: 7; +} +.builder-building-area ul.builder-control-list > li.control[data-control-type=hint].updating-control:after, +.builder-building-area ul.builder-control-list > li.control[data-control-type=partial].updating-control:after { + right: 4px; + top: 13px; +} +.builder-building-area ul.builder-control-list > li.control > .control-wrapper, +.builder-building-area ul.builder-control-list > li.control > .control-static-contents { + position: relative; + -webkit-transition: margin 0.1s; + transition: margin 0.1s; +} +.builder-building-area ul.builder-control-list > li.placeholder:hover, +.builder-building-area ul.builder-control-list > li.placeholder.popover-highlight, +.builder-building-area ul.builder-control-list > li.placeholder.control-palette-open { + background-color: #2581b8 !important; + color: white!important; + border-style: solid; + border-color: #2581b8; +} +.builder-building-area ul.builder-control-list > li.control:not(.placeholder):not(.loading-control):not([data-unknown]):hover > .control-wrapper *, +.builder-building-area ul.builder-control-list > li.control.inspector-open:not(.placeholder):not(.loading-control) > .control-wrapper * { + color: #2581b8 !important; +} +.builder-building-area ul.builder-control-list > li.control.drag-over:not(.placeholder):before { + position: absolute; + content: ''; + top: 0; + left: 0; + width: 10px; + height: 100%; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + background-color: #2581b8; +} +.builder-building-area ul.builder-control-list > li.control.drag-over:not(.placeholder) > .control-wrapper, +.builder-building-area ul.builder-control-list > li.control.drag-over:not(.placeholder) > .control-static-contents { + margin-left: 20px; + margin-right: -20px; +} +.builder-building-area .control-body.field-disabled, +.builder-building-area .control-body.field-hidden { + opacity: 0.5; + filter: alpha(opacity=50); +} +.builder-building-area .builder-control-label { + margin-bottom: 10px; + color: #555555; + font-size: 14px; + font-weight: 600; +} +.builder-building-area .builder-control-label.required:after { + vertical-align: super; + font-size: 60%; + content: " *"; +} +.builder-building-area .builder-control-label:empty { + margin-bottom: 0; +} +.builder-building-area .builder-control-comment-above { + margin-bottom: 8px; + margin-top: -3px; +} +.builder-building-area .builder-control-comment-below { + margin-top: 6px; +} +.builder-building-area .builder-control-comment-above, +.builder-building-area .builder-control-comment-below { + color: #737373; + font-size: 12px; +} +.builder-building-area .builder-control-comment-above:empty, +.builder-building-area .builder-control-comment-below:empty { + display: none; +} +html.gecko.mac .builder-building-area div[data-root-control-wrapper] { + margin-right: 17px; +} +.builder-building-area .builder-blueprint-control-text, +.builder-building-area .builder-blueprint-control-textarea, +.builder-building-area .builder-blueprint-control-partial, +.builder-building-area .builder-blueprint-control-unknown, +.builder-building-area .builder-blueprint-control-dropdown { + padding: 10px 12px; + border: 2px solid #bdc3c7; + color: #95a5a6; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.builder-building-area .builder-blueprint-control-text i, +.builder-building-area .builder-blueprint-control-textarea i, +.builder-building-area .builder-blueprint-control-partial i, +.builder-building-area .builder-blueprint-control-unknown i, +.builder-building-area .builder-blueprint-control-dropdown i { + margin-right: 5px; +} +.builder-building-area li.control:hover > .control-wrapper .builder-blueprint-control-text, +.builder-building-area li.inspector-open > .control-wrapper .builder-blueprint-control-text, +.builder-building-area li.control:hover > .control-wrapper .builder-blueprint-control-textarea, +.builder-building-area li.inspector-open > .control-wrapper .builder-blueprint-control-textarea, +.builder-building-area li.control:hover > .control-wrapper .builder-blueprint-control-dropdown, +.builder-building-area li.inspector-open > .control-wrapper .builder-blueprint-control-dropdown { + border-color: #2581b8; +} +.builder-building-area li.control:hover > .control-wrapper .builder-blueprint-control-dropdown:before, +.builder-building-area li.inspector-open > .control-wrapper .builder-blueprint-control-dropdown:before { + background-color: #2581b8; +} +.builder-building-area .builder-blueprint-control-textarea.size-tiny { + min-height: 50px; +} +.builder-building-area .builder-blueprint-control-textarea.size-small { + min-height: 100px; +} +.builder-building-area .builder-blueprint-control-textarea.size-large { + min-height: 200px; +} +.builder-building-area .builder-blueprint-control-textarea.size-huge { + min-height: 250px; +} +.builder-building-area .builder-blueprint-control-textarea.size-giant { + min-height: 350px; +} +.builder-building-area .builder-blueprint-control-section { + border-bottom: 1px solid #bdc3c7; + padding-bottom: 4px; +} +.builder-building-area .builder-blueprint-control-section .builder-control-label { + font-size: 16px; + margin-bottom: 6px; +} +.builder-building-area .builder-blueprint-control-unknown { + border-color: #eee; + background: #eee; +} +.builder-building-area .builder-blueprint-control-partial { + border-color: #eee; + background: #eee; +} +.builder-building-area .builder-blueprint-control-dropdown { + position: relative; +} +.builder-building-area .builder-blueprint-control-dropdown:before, +.builder-building-area .builder-blueprint-control-dropdown:after { + position: absolute; + content: ''; +} +.builder-building-area .builder-blueprint-control-dropdown:before { + top: 0; + width: 2px; + background: #bdc3c7; + right: 40px; + height: 100%; +} +.builder-building-area .builder-blueprint-control-dropdown:after { + font-family: FontAwesome; + font-weight: normal; + font-style: normal; + text-decoration: inherit; + -webkit-font-smoothing: antialiased; + *margin-right: .3em; + content: "\f107"; + color: inherit; + right: 15px; + top: 12px; + font-size: 20px; + line-height: 20px; +} +.builder-building-area .builder-blueprint-control-checkbox:before { + float: left; + content: ' '; + border: 2px solid #bdc3c7; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + width: 17px; + height: 17px; + position: relative; + top: 2px; +} +.builder-building-area .builder-blueprint-control-checkbox .builder-control-label { + margin-left: 25px; + font-weight: normal; +} +.builder-building-area .builder-blueprint-control-checkbox .builder-control-comment-below { + margin-left: 25px; +} +.builder-building-area li.control:hover > .control-wrapper .builder-blueprint-control-checkbox:before, +.builder-building-area li.inspector-open > .control-wrapper .builder-blueprint-control-checkbox:before { + border-color: #2581b8; +} +.builder-building-area .builder-blueprint-control-switch { + position: relative; +} +.builder-building-area .builder-blueprint-control-switch:before, +.builder-building-area .builder-blueprint-control-switch:after { + position: absolute; + content: ' '; + -webkit-border-radius: 30px; + -moz-border-radius: 30px; + border-radius: 30px; +} +.builder-building-area .builder-blueprint-control-switch:before { + background-color: #bdc3c7; + width: 34px; + height: 18px; + top: 2px; + left: 2px; +} +.builder-building-area .builder-blueprint-control-switch:after { + background-color: white; + width: 14px; + height: 14px; + top: 4px; + left: 4px; + margin-left: 16px; +} +.builder-building-area .builder-blueprint-control-switch .builder-control-label { + margin-left: 45px; + font-weight: normal; +} +.builder-building-area .builder-blueprint-control-switch .builder-control-comment-below { + margin-left: 45px; +} +.builder-building-area li.control:hover > .control-wrapper .builder-blueprint-control-switch:before, +.builder-building-area li.inspector-open > .control-wrapper .builder-blueprint-control-switch:before { + background-color: #2581b8; +} +.builder-building-area .builder-blueprint-control-repeater-body > .repeater-button { + padding: 8px 13px; + background: #bdc3c7; + color: white; + display: inline-block; + margin-bottom: 10px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; +} +.builder-building-area ul.builder-control-list > li.control:hover > .control-wrapper > .control-body .builder-blueprint-control-repeater-body > .repeater-button, +.builder-building-area ul.builder-control-list > li.inspector-open > .control-wrapper > .control-body .builder-blueprint-control-repeater-body > .repeater-button { + background: #2581b8; + color: white!important; +} +.builder-building-area ul.builder-control-list > li.control:hover > .control-wrapper > .control-body .builder-blueprint-control-repeater-body > .repeater-button span, +.builder-building-area ul.builder-control-list > li.inspector-open > .control-wrapper > .control-body .builder-blueprint-control-repeater-body > .repeater-button span { + color: white!important; +} +.builder-building-area .builder-blueprint-control-repeater { + position: relative; +} +.builder-building-area .builder-blueprint-control-repeater:before { + content: ''; + position: absolute; + width: 2px; + top: 0; + left: 2px; + height: 100%; + background: #bdc3c7; +} +.builder-building-area .builder-blueprint-control-repeater:after { + content: ''; + position: absolute; + width: 6px; + height: 6px; + top: 14px; + left: 0; + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + background: #bdc3c7; +} +.builder-building-area .builder-blueprint-control-repeater > ul.builder-control-list { + padding-right: 0; + padding-bottom: 0; + padding-top: 10px; +} +.builder-building-area li.control:hover > .builder-blueprint-control-repeater:before, +.builder-building-area li.inspector-open > .builder-blueprint-control-repeater:before, +.builder-building-area li.control:hover > .builder-blueprint-control-repeater:after, +.builder-building-area li.inspector-open > .builder-blueprint-control-repeater:after { + background-color: #2581b8; +} +.builder-building-area .builder-blueprint-control-radiolist ul, +.builder-building-area .builder-blueprint-control-checkboxlist ul { + list-style: none; + padding: 0; + color: #95a5a6; +} +.builder-building-area .builder-blueprint-control-radiolist ul li, +.builder-building-area .builder-blueprint-control-checkboxlist ul li { + margin-bottom: 3px; +} +.builder-building-area .builder-blueprint-control-radiolist ul li:last-child, +.builder-building-area .builder-blueprint-control-checkboxlist ul li:last-child { + margin-bottom: 0; +} +.builder-building-area .builder-blueprint-control-radiolist ul li i, +.builder-building-area .builder-blueprint-control-checkboxlist ul li i { + margin-right: 5px; +} +.builder-building-area .builder-blueprint-control-text.fileupload.image { + width: 100px; + height: 100px; + text-align: center; +} +.builder-building-area .builder-blueprint-control-text.fileupload.image i { + line-height: 77px; + margin-right: 0; +} +.builder-controllers-builder-area { + background: white; +} +.builder-controllers-builder-area ul.controller-behavior-list { + padding: 20px; + margin-bottom: 0; + list-style: none; +} +.builder-controllers-builder-area ul.controller-behavior-list:before, +.builder-controllers-builder-area ul.controller-behavior-list:after { + content: " "; + display: table; +} +.builder-controllers-builder-area ul.controller-behavior-list:after { + clear: both; +} +.builder-controllers-builder-area ul.controller-behavior-list li h4 { + text-align: center; + border-bottom: 1px dotted #bdc3c7; + margin: 0 -20px 40px; +} +.builder-controllers-builder-area ul.controller-behavior-list li h4 span { + display: inline-block; + color: white; + margin: 0 auto; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + background: #bdc3c7; + padding: 7px 10px; + font-size: 13px; + line-height: 100%; + position: relative; + top: 14px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container { + margin-bottom: 40px; + cursor: pointer; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container:before, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container:after { + content: " "; + display: table; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container:after { + clear: both; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .list-behavior, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior { + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + border: 2px solid #bdc3c7; + padding: 25px 10px 25px 10px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .list-behavior table, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table { + border-collapse: collapse; + width: 100%; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .list-behavior table td, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table td { + padding: 0 15px 15px 15px; + border-right: 1px solid #bdc3c7; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .list-behavior table td:last-child, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table td:last-child { + border-right: none; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .list-behavior table .placeholder, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table .placeholder { + background: #EEF2F4; + height: 25px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .list-behavior table tbody tr:last-child td, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table tbody tr:last-child td { + padding-bottom: 0; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table i.icon-bars, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table .placeholder { + float: left; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .reorder-behavior table i.icon-bars { + margin-right: 15px; + color: #D6DDE0; + font-size: 28px; + line-height: 28px; + position: relative; + top: -2px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.form { + padding: 25px 25px 0 25px; + border: 2px solid #bdc3c7; + margin-bottom: 20px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.form:before, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.form:after { + content: " "; + display: table; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.form:after { + clear: both; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field.left { + float: left; + width: 48%; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field.right { + float: right; + width: 45%; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field div.label { + background: #EEF2F4; + height: 25px; + margin-bottom: 10px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field div.label.size-3 { + width: 100px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field div.label.size-5 { + width: 150px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field div.label.size-2 { + width: 60px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.field div.control { + background: #EEF2F4; + height: 35px; + margin-bottom: 25px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.button { + background: #EEF2F4; + height: 35px; + margin-right: 20px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.button.size-5 { + width: 100px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.button.size-3 { + width: 60px; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container .form-behavior div.button:first-child { + margin-right: 0; +} +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container:hover *, +.builder-controllers-builder-area ul.controller-behavior-list .behavior-container.inspector-open * { + border-color: #2581b8 !important; +} +html.gecko.mac .builder-controllers-builder-area ul.controller-behavior-list { + padding-right: 40px; +} +.builder-tabs > .tabs { + position: relative; +} +.builder-tabs > .tabs .tab-control { + position: absolute; + display: block; +} +.builder-tabs > .tabs .tab-control.inspector-trigger { + font-size: 14px; + padding-left: 5px; + padding-right: 5px; + cursor: pointer; +} +.builder-tabs > .tabs .tab-control.inspector-trigger span { + display: block; + width: 3px; + height: 3px; + margin-bottom: 2px; + background: #95a5a6; +} +.builder-tabs > .tabs .tab-control.inspector-trigger span:last-child { + margin-bottom: 0; +} +.builder-tabs > .tabs .tab-control.inspector-trigger:hover span, +.builder-tabs > .tabs .tab-control.inspector-trigger.inspector-open span { + background: #0181b9; +} +.builder-tabs > .tabs .tab-control.inspector-trigger.global { + top: 5px; + right: 15px; +} +.builder-tabs > .tabs > ul.tabs { + margin: 0; + list-style: none; + font-size: 0; + white-space: nowrap; + overflow: hidden; + position: relative; +} +.builder-tabs > .tabs > ul.tabs > li { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + display: inline-block; + font-size: 13px; + white-space: nowrap; + position: relative; + cursor: pointer; +} +.builder-tabs > .tabs > ul.tabs > li > div.tab-container { + position: relative; + color: #bdc3c7!important; +} +.builder-tabs > .tabs > ul.tabs > li > div.tab-container > div { + -webkit-transition: padding 0.1s; + transition: padding 0.1s; + position: relative; +} +.builder-tabs > .tabs > ul.tabs > li:hover > div { + color: #95a5a6!important; +} +.builder-tabs > .tabs > ul.tabs > li .tab-control { + display: none; +} +.builder-tabs > .tabs > ul.tabs > li .tab-control.close-btn { + font-size: 15px; + top: 7px; + right: 18px; + line-height: 15px; + height: 15px; + width: 15px; + text-align: center; + cursor: pointer; + color: #95a5a6; +} +.builder-tabs > .tabs > ul.tabs > li .tab-control.close-btn:hover { + color: #0181b9 !important; +} +.builder-tabs > .tabs > ul.tabs > li .tab-control.inspector-trigger { + right: 34px; + top: 10px; +} +.builder-tabs > .tabs > ul.tabs > li.active > div.tab-container { + color: #95a5a6!important; +} +.builder-tabs > .tabs > ul.tabs > li.active .tab-control { + display: block; +} +.builder-tabs > .tabs > ul.panels { + padding: 0; + list-style: none; +} +.builder-tabs > .tabs > ul.panels > li { + display: none; +} +.builder-tabs > .tabs > ul.panels > li.active { + display: block; +} +.builder-tabs.primary > .tabs > ul.tabs { + padding: 0 20px 0 40px; + height: 31px; +} +.builder-tabs.primary > .tabs > ul.tabs:after { + position: absolute; + content: ''; + display: block; + height: 2px; + left: 0; + bottom: 0; + width: 100%; + background: #bdc3c7; + z-index: 106; +} +.builder-tabs.primary > .tabs > ul.tabs > li { + bottom: -2px; + margin-left: -20px; + z-index: 105; +} +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container { + padding: 0 21px 0 21px; + height: 27px; +} +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container > div { + padding: 5px 5px 0 5px; + border-top: 2px solid #e5e5e5; +} +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container > div > span { + position: relative; + top: -2px; + -webkit-transition: top 0.1s; + transition: top 0.1s; +} +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container:before, +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container:after { + content: ''; + display: block; + position: absolute; + top: 0; + height: 27px; + width: 21px; + background: transparent url(../images/tab.png) no-repeat; +} +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container:before { + left: 0; + background-position: 0 -27px; +} +.builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container:after { + right: 0; + background-position: -75px -27px; +} +.builder-tabs.primary > .tabs > ul.tabs > li.active { + z-index: 107; +} +.builder-tabs.primary > .tabs > ul.tabs > li.active > div.tab-container:before { + background-position: 0 0; +} +.builder-tabs.primary > .tabs > ul.tabs > li.active > div.tab-container:after { + background-position: -75px 0; +} +.builder-tabs.primary > .tabs > ul.tabs > li.active > div.tab-container > div { + padding-right: 30px; + border-top: 2px solid #bdc3c7; +} +.builder-tabs.primary > .tabs > ul.tabs > li.active > div.tab-container > div > span { + top: 0; +} +.builder-tabs.primary > .tabs > ul.tabs > li.active:before { + position: absolute; + content: ''; + display: block; + height: 3px; + left: 0; + bottom: 0; + width: 100%; + background: white; +} +.builder-tabs.primary > .tabs > ul.tabs > li.new-tab { + background: transparent url(../images/tab.png) no-repeat; + background-position: -24px 0; + width: 27px; + height: 22px; + margin-left: -11px; + top: 4px; + position: relative; + cursor: pointer; +} +.builder-tabs.primary > .tabs > ul.tabs > li.new-tab:hover { + background-position: -24px -32px; +} +.builder-tabs.secondary > .tabs ul.tabs { + margin-left: 12px; + padding-left: 0; +} +.builder-tabs.secondary > .tabs ul.tabs > li { + border-right: 1px solid #bdc3c7; + padding-right: 1px; +} +.builder-tabs.secondary > .tabs ul.tabs > li > div.tab-container > div { + padding: 4px 10px; +} +.builder-tabs.secondary > .tabs ul.tabs > li > div.tab-container > div span { + font-size: 14px; +} +.builder-tabs.secondary > .tabs ul.tabs > li .tab-control { + right: 23px; + top: 7px; +} +.builder-tabs.secondary > .tabs ul.tabs > li .tab-control.close-btn { + right: 6px; + top: 5px; +} +.builder-tabs.secondary > .tabs ul.tabs > li.new-tab { + background: transparent; + border: 2px solid #e4e4e4; + width: 27px; + height: 22px; + left: 9px; + top: 7px; + position: relative; + cursor: pointer; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.builder-tabs.secondary > .tabs ul.tabs > li.new-tab:hover { + background-color: #2581b8; + border-color: #2581b8; +} +.builder-tabs.secondary > .tabs ul.tabs > li.active { + padding-right: 10px; +} +.builder-tabs.secondary > .tabs ul.tabs > li.active > div.tab-container > div { + color: #555555; + padding-right: 30px; +} +html.gecko .builder-tabs.primary > .tabs > ul.tabs > li { + bottom: -3px; +} +html.gecko .builder-tabs.primary > .tabs > ul.tabs > li > div.tab-container > div { + padding-top: 5px; +} +.builder-menu-editor { + background: white; +} +.builder-menu-editor .builder-menu-editor-workspace { + padding: 30px; +} +.builder-menu-editor ul.builder-menu { + font-size: 0; + padding: 0; + cursor: pointer; +} +.builder-menu-editor ul.builder-menu > li { + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} +.builder-menu-editor ul.builder-menu > li div.item-container:hover, +.builder-menu-editor ul.builder-menu > li.inspector-open > div.item-container { + background: #2581b8 !important; + color: white!important; +} +.builder-menu-editor ul.builder-menu > li div.item-container:hover a, +.builder-menu-editor ul.builder-menu > li.inspector-open > div.item-container a { + color: white!important; +} +.builder-menu-editor ul.builder-menu > li div.item-container { + position: relative; +} +.builder-menu-editor ul.builder-menu > li div.item-container .close-btn { + color: white; + position: absolute; + display: none; + width: 15px; + height: 15px; + right: 5px; + top: 5px; + font-size: 14px; + text-align: center; + line-height: 14px; +} +.builder-menu-editor ul.builder-menu > li div.item-container:hover .close-btn { + display: block; + text-decoration: none; + opacity: 0.5; + filter: alpha(opacity=50); +} +.builder-menu-editor ul.builder-menu > li div.item-container:hover .close-btn:hover { + opacity: 1; + filter: alpha(opacity=100); +} +.builder-menu-editor ul.builder-menu > li.add { + font-size: 16px; + text-align: center; + border: 2px dotted #dde0e2; +} +.builder-menu-editor ul.builder-menu > li.add a { + text-decoration: none; + color: #bdc3c7; +} +.builder-menu-editor ul.builder-menu > li.add span.title { + font-size: 14px; +} +.builder-menu-editor ul.builder-menu > li.add:hover { + border: 2px dotted #2581b8; + background: #2581b8 !important; +} +.builder-menu-editor ul.builder-menu > li.add:hover a { + color: white; +} +.builder-menu-editor ul.builder-menu > li.list-sortable-placeholder { + border: 2px dotted #2581b8; + height: 10px; + background: transparent; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li { + display: inline-block; + vertical-align: top; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li.item { + margin: 0 20px 20px 0; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li > div.item-container { + background: #ecf0f1; + color: #708080; + padding: 20px 25px; + height: 64px; + white-space: nowrap; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li > div.item-container i { + font-size: 24px; + margin-right: 10px; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li > div.item-container span.title { + font-size: 14px; + line-height: 100%; + position: relative; + top: -3px; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li.add { + height: 64px; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li.add a { + padding: 20px 15px; + height: 60px; + display: block; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li.add a i { + margin-right: 5px; +} +.builder-menu-editor ul.builder-menu.builder-main-menu > li.add a span { + position: relative; + top: -1px; +} +.builder-menu-editor ul.builder-menu.builder-submenu { + margin-top: 1px; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li { + display: block; + width: 120px; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li i { + display: block; + margin-bottom: 7px; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li span.title { + display: block; + font-size: 12px; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li.item { + margin: 0 0 1px 0; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li > div.item-container { + background: #f3f5f5; + color: #94a5a6; + padding: 18px 13px; + text-align: center; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li > div.item-container i { + font-size: 24px; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li.add { + margin-top: 20px; +} +.builder-menu-editor ul.builder-menu.builder-submenu > li.add a { + padding: 10px 20px; + display: block; +} +.localization-input-container input[type=text].string-editor { + padding-right: 20px!important; +} +.localization-input-container .localization-trigger { + position: absolute; + display: none; + width: 10px; + height: 10px; + font-size: 14px; + color: #95a5a6; + outline: none; +} +.localization-input-container .localization-trigger:hover, +.localization-input-container .localization-trigger:active, +.localization-input-container .localization-trigger:focus { + color: #2581b8; + text-decoration: none; +} +table.inspector-fields td.active .localization-input-container .localization-trigger, +table.data td.active .localization-input-container .localization-trigger { + display: block; +} +table.data td.active .localization-input-container .localization-trigger { + top: 5px!important; + right: 7px!important; +} +.control-table td[data-column-type=builderLocalization] input[type=text] { + padding-right: 20px!important; +} +.control-table td[data-column-type=builderLocalization] input[type=text] { + width: 100%; + height: 100%; + display: block; + outline: none; + border: none; + padding: 6px 10px 6px; +} +html.chrome .control-table td[data-column-type=builderLocalization] input[type=text] { + padding: 6px 10px 7px!important; +} +html.safari .control-table td[data-column-type=builderLocalization] input[type=text], +html.gecko .control-table td[data-column-type=builderLocalization] input[type=text] { + padding: 5px 10px 5px; +} +.autocomplete.dropdown-menu.table-widget-autocomplete.localization li a { + white-space: normal; + word-wrap: break-word; +} +table.data td[data-column-type=builderLocalization] .loading-indicator-container.size-small .loading-indicator { + padding-bottom: 0!important; +} +table.data td[data-column-type=builderLocalization] .loading-indicator-container.size-small .loading-indicator span { + left: auto; + right: 6px; +} +.control-filelist ul li.group.model > h4 a:after { + content: "\f074"; + top: 10px; +} +.control-filelist ul li.group.form > h4 a:after { + content: "\f14a"; +} +.control-filelist ul li.group.list > h4 a:after { + content: "\f00b"; + top: 10px; +} +.control-filelist ul li.group > ul > li.group > ul > li > a { + padding-left: 73px; + margin-left: -20px; +} +.control-filelist ul li.with-icon span.title, +.control-filelist ul li.with-icon span.description { + padding-left: 22px; +} +.control-filelist ul li.with-icon i.list-icon { + position: absolute; + left: 20px; + top: 12px; + color: #405261; +} +.control-filelist ul li.with-icon i.list-icon.mute { + color: #8f8f8f; +} +.control-filelist ul li.with-icon i.list-icon.icon-check-square { + color: #8da85e; +} +html.gecko .control-filelist ul li.group { + margin-right: 10px; +} +.builder-inspector-container { + width: 350px; + border-left: 1px solid #d9d9d9; +} +.builder-inspector-container:empty { + display: none!important; +} +form.hide-secondary-tabs div.control-tabs.secondary-tabs ul.nav.nav-tabs { + display: none; +} +.form-group.size-quarter { + width: 23.5%; +} +.form-group.size-three-quarter { + width: 73.5%; +} +form[data-entity=database] div.field-datatable { + position: absolute; + width: 100%; + height: 100%; +} +form[data-entity=database] div.field-datatable div[data-control=table] { + position: absolute; + width: 100%; + height: 100%; +} +form[data-entity=database] div.field-datatable div[data-control=table] div.table-container { + position: absolute; + width: 100%; + height: 100%; +} +form[data-entity=database] div.field-datatable div[data-control=table] div.table-container div.control-scrollbar { + top: 70px; + bottom: 0; + position: absolute; + max-height: none!important; + height: auto!important; +} +div.control-table .toolbar a.builder-custom-table-button:before { + line-height: 17px; + font-size: 21px; + color: #323e50; + margin-right: 5px; + top: 3px; + opacity: 1; + filter: alpha(opacity=100); +} +.control-tabs.auxiliary-tabs { + background: white; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs { + padding-left: 20px; + padding-bottom: 2px; + background: white; + position: relative; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs:before, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs:before { + content: ' '; + display: block; + position: absolute; + width: 100%; + height: 1px; + background: #95a5a6; + top: 0; + left: 0; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs > li, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs > li { + margin-right: 2px; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs > li > a, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs > li > a { + background: white; + color: #bdc3c7; + border-left: 1px solid #ecf0f1!important; + border-right: 1px solid #ecf0f1!important; + border-bottom: 1px solid #ecf0f1!important; + padding: 4px 10px; + line-height: 100%; + -webkit-border-radius: 0 0 4px 4px; + -moz-border-radius: 0 0 4px 4px; + border-radius: 0 0 4px 4px; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs > li > a > span.title > span, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs > li > a > span.title > span { + margin-bottom: 0; + font-size: 13px; + height: auto; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs > li.active, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs > li.active { + top: 0; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs > li.active:before, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs > li.active:before { + content: ' '; + display: block; + position: absolute; + width: 100%; + height: 1px; + background: white; + top: 0; + left: 0; + top: -1px; +} +.control-tabs.auxiliary-tabs > ul.nav-tabs > li.active a, +.control-tabs.auxiliary-tabs > div > ul.nav-tabs > li.active a { + padding-top: 5px; + border-left: 1px solid #95a5a6!important; + border-right: 1px solid #95a5a6!important; + border-bottom: 1px solid #95a5a6!important; + color: #95a5a6; +} +.control-tabs.auxiliary-tabs > div.tab-content > .tab-pane { + background: white; +} diff --git a/server/plugins/rainlab/builder/assets/images/builder-icon.svg b/server/plugins/rainlab/builder/assets/images/builder-icon.svg new file mode 100644 index 0000000..99c5de6 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/images/builder-icon.svg @@ -0,0 +1,17 @@ + + + + Group + Created with Sketch. + + + + + + + + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/images/tab.png b/server/plugins/rainlab/builder/assets/images/tab.png new file mode 100644 index 0000000000000000000000000000000000000000..9227f65fd94d86d33a7ff0bd1d2169044484028e GIT binary patch literal 3002 zcmbVOc{o&iA3w&HHF1k5jj2XrmctBYvKtdIl945mSq>)5Ofw@hN|x#}w@uxI5t5ht~-Bwq2kGKkYZ3Y=@VnB9CAZofj!eU?918i( zL=@wQ`ioRB%@66$6F^8JmWW~DtwE$62@4VlBoMShTH`?*9EitRlQ1AiCfJcdTjci( z1xFLGBgy_0>i1ai&Jh(Y67k76TtY$uHo*qV6GY)a5{ZPvTjQ*)F|Y+jDB+42VhmTf za^3?460!swzKFx)BIi6Zn7nwABMN5vR|;`_8tre#T;caZ!6n0q8GIaw#pB}Q=JNVx zEfo1f|E2Md*1`Y@AHw-VLSDRp1@|Lzz%W3Fg<-OpEC!w(NwTrGpZD`mcq)P5ZbKm1 z+Sz~<5cD9rfi`Zg1Y29s4G*7FDDzk^u296_vY`3c960uOEb(8lWOo6?5b*>7JYMYl z6!=B+L_A?MkB@YBN3NkUSRC%$-eRstf2B-;1e~1^n=0VNA-@%w%=rfbLN}qO{}vAilfunS%KuEx{1H5kbFY8v0N(tq zB!~;kM*!;tvwtNA0Mr#;6xRT8*GOngY=FlP1&X+;ThI*lhptkG?JaTc=-^ z(2Jj(mKbk&^QP^#>y%4j`t@}RzfGIu)~jc3lf)X$UW3K0%g6g4It)+bDjlgGpUFFA zB9}KPD=Wpn9T`$GQ8H|0@7mqMa^v>$^~V}h-5vGbvg|~bBCU+U9WxKDj*MQ_>8d~Q z;KPpAinaQ`4kfo}MC+{AuHW+X&q8GMsi<*R;i=1RG4fsV$MS&=yoTBda>BbB@^g{# zw7PnCWVF)9O;s)0iAJ+i`nz=}ES_#HyUR?CvU_f5z%1iyKQCo0^ zrgNqI$cW{PRb&q`n0*-d5@9CGuc=!bUiN^Rtt-Y+XV*vfEHb>-+1S#SW?FeP>_@)8rFDhh}VC^HW8Klx~C zr{@fC3E9#(YMQo3OUHeMZKGy}QUwy7c4$=PQh%XX(zTcG{IR-b(9tw7?6^A7D(;$8 z=RjwjK48#mT~4WQ15xnc<+I&PQ64T!*8Zs&;u>~p5Q_2n%4)O;kU^513CK2@8ZcCdJ^9gSyk?% zg7-<>;hvwzny#qn` z8qS}`zr3^akU640;$c^KP~gGw-Xw`^@{EGe~@RMrB$yC*4pNDd8ili1E!-gT^k-fxKA5J2GuLp-6 zp$(OHHP}su9wUO9%AH8!Po5jsM-?8F`BIe!(==7SOu8V)HrubeB`?~}e7^YpM@?|` z^@d!9d? zUrMAE!B%p)Uv$IGMcP)K3PtIo0!Q!8V=|*L{B-W&DJt_;(7ya_+;`A5&Edg8ztYmu zC-tAP#&bhK+KflZepT}&oU(wN?#dYaT zG#mBFe4~sGE!(g9r&bZcb?ZVsP!`K~6|}YnU35Y+jWrrlg3tRDqnrGlO~Q*yE>koZZC05}qTVpf;gsXnN8W>|Sdn5x(uvl2jO`Ork(KzC-XQ~gDw%`0BH)PED#Du06; z<2vbg!+Y8;ENnHq=(95A+5JUlolB%czID2R5tkQ^t%d2>`!rcz)dT1oiqMIxUD(-0 zb;ff(T=F9Zo+I>2q}M}wE(T91k=ao5i6p8=c-%$GXo)le-;er;KW5)GRD&Zk7BTDr2&pD5me>V2HG!3-KjUd0Il%$PF zq0%oeR_5r^0Ip9F+IrpLf!aL_sF&vQw@UTs%%vhKv?ia>&HW8jL!%I5Ee?ZP^Gb?tGs^- QIrlg1<>5;ybBjp(57AEVD*ylh literal 0 HcmV?d00001 diff --git a/server/plugins/rainlab/builder/assets/js/build-min.js b/server/plugins/rainlab/builder/assets/js/build-min.js new file mode 100644 index 0000000..49f2352 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/build-min.js @@ -0,0 +1,809 @@ + ++function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +var Base=$.oc.foundation.base,BaseProto=Base.prototype +var DataRegistry=function(){this.data={} +this.requestCache={} +this.callbackCache={} +Base.call(this)} +DataRegistry.prototype.set=function(plugin,type,subtype,data,params){this.storeData(plugin,type,subtype,data) +if(type=='localization'&&!subtype){this.localizationUpdated(plugin,params)}} +DataRegistry.prototype.get=function($formElement,plugin,type,subtype,callback){if(this.data[plugin]===undefined||this.data[plugin][type]===undefined||this.data[plugin][type][subtype]===undefined||this.isCacheObsolete(this.data[plugin][type][subtype].timestamp)){return this.loadDataFromServer($formElement,plugin,type,subtype,callback)} +callback(this.data[plugin][type][subtype].data)} +DataRegistry.prototype.makeCacheKey=function(plugin,type,subtype){var key=plugin+'-'+type +if(subtype){key+='-'+subtype} +return key} +DataRegistry.prototype.isCacheObsolete=function(timestamp){return(Date.now()-timestamp)>60000*5} +DataRegistry.prototype.loadDataFromServer=function($formElement,plugin,type,subtype,callback){var self=this,cacheKey=this.makeCacheKey(plugin,type,subtype) +if(this.requestCache[cacheKey]===undefined){this.requestCache[cacheKey]=$formElement.request('onPluginDataRegistryGetData',{data:{registry_plugin_code:plugin,registry_data_type:type,registry_data_subtype:subtype}}).done(function(data){if(data.registryData===undefined){throw new Error('Invalid data registry response.')} +self.storeData(plugin,type,subtype,data.registryData) +self.applyCallbacks(cacheKey,data.registryData) +self.requestCache[cacheKey]=undefined})} +this.addCallbackToQueue(callback,cacheKey) +return this.requestCache[cacheKey]} +DataRegistry.prototype.addCallbackToQueue=function(callback,key){if(this.callbackCache[key]===undefined){this.callbackCache[key]=[]} +this.callbackCache[key].push(callback)} +DataRegistry.prototype.applyCallbacks=function(key,registryData){if(this.callbackCache[key]===undefined){return} +for(var i=this.callbackCache[key].length-1;i>=0;i--){this.callbackCache[key][i](registryData);} +delete this.callbackCache[key]} +DataRegistry.prototype.storeData=function(plugin,type,subtype,data){if(this.data[plugin]===undefined){this.data[plugin]={}} +if(this.data[plugin][type]===undefined){this.data[plugin][type]={}} +var dataItem={timestamp:Date.now(),data:data} +this.data[plugin][type][subtype]=dataItem} +DataRegistry.prototype.clearCache=function(plugin,type){if(this.data[plugin]===undefined){return} +if(this.data[plugin][type]===undefined){return} +this.data[plugin][type]=undefined} +DataRegistry.prototype.getLocalizationString=function($formElement,plugin,key,callback){this.get($formElement,plugin,'localization',null,function(data){if(data[key]!==undefined){callback(data[key]) +return} +callback(key)})} +DataRegistry.prototype.localizationUpdated=function(plugin,params){$.oc.builder.localizationInput.updatePluginInputs(plugin) +if(params===undefined||!params.suppressLanguageEditorUpdate){$.oc.builder.indexController.entityControllers.localization.languageUpdated(plugin)} +$.oc.builder.indexController.entityControllers.localization.updateOnScreenStrings(plugin)} +$.oc.builder.dataRegistry=new DataRegistry()}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.foundation.base,BaseProto=Base.prototype +var EntityBase=function(typeName,indexController){if(typeName===undefined){throw new Error('The Builder entity type name should be set in the base constructor call.')} +if(indexController===undefined){throw new Error('The Builder index controller should be set when creating an entity controller.')} +this.typeName=typeName +this.indexController=indexController +Base.call(this)} +EntityBase.prototype=Object.create(BaseProto) +EntityBase.prototype.constructor=EntityBase +EntityBase.prototype.registerHandlers=function(){} +EntityBase.prototype.invokeCommand=function(command,ev){if(/^cmd[a-zA-Z0-9]+$/.test(command)){if(this[command]!==undefined){this[command].apply(this,[ev])} +else{throw new Error('Unknown command: '+command)}} +else{throw new Error('Invalid command: '+command)}} +EntityBase.prototype.newTabId=function(){return this.typeName+Math.random()} +EntityBase.prototype.makeTabId=function(objectName){return this.typeName+'-'+objectName} +EntityBase.prototype.getMasterTabsActivePane=function(){return this.indexController.getMasterTabActivePane()} +EntityBase.prototype.getMasterTabsObject=function(){return this.indexController.masterTabsObj} +EntityBase.prototype.getSelectedPlugin=function(){var activeItem=$('#PluginList-pluginList-plugin-list > ul > li.active') +return activeItem.data('id')} +EntityBase.prototype.getIndexController=function(){return this.indexController} +EntityBase.prototype.updateMasterTabIdAndTitle=function($tabPane,responseData){var tabsObject=this.getMasterTabsObject() +tabsObject.updateIdentifier($tabPane,responseData.tabId) +tabsObject.updateTitle($tabPane,responseData.tabTitle)} +EntityBase.prototype.unhideFormDeleteButton=function($tabPane){$('[data-control=delete-button]',$tabPane).removeClass('hide')} +EntityBase.prototype.forceCloseTab=function($tabPane){$tabPane.trigger('close.oc.tab',[{force:true}])} +EntityBase.prototype.unmodifyTab=function($tabPane){this.indexController.unchangeTab($tabPane)} +$.oc.builder.entityControllers.base=EntityBase;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Plugin=function(indexController){Base.call(this,'plugin',indexController) +this.popupZIndex=5050} +Plugin.prototype=Object.create(BaseProto) +Plugin.prototype.constructor=Plugin +Plugin.prototype.cmdMakePluginActive=function(ev){var $target=$(ev.currentTarget),selectedPluginCode=$target.data('pluginCode') +this.makePluginActive(selectedPluginCode)} +Plugin.prototype.cmdCreatePlugin=function(ev){var $target=$(ev.currentTarget) +$target.one('shown.oc.popup',this.proxy(this.onPluginPopupShown)) +$target.popup({handler:'onPluginLoadPopup',zIndex:this.popupZIndex})} +Plugin.prototype.cmdApplyPluginSettings=function(ev){var $form=$(ev.currentTarget),self=this +$.oc.stripeLoadIndicator.show() +$form.request('onPluginSave').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(function(data){$form.trigger('close.oc.popup') +self.applyPluginSettingsDone(data)})} +Plugin.prototype.cmdEditPluginSettings=function(ev){var $target=$(ev.currentTarget) +$target.one('shown.oc.popup',this.proxy(this.onPluginPopupShown)) +$target.popup({handler:'onPluginLoadPopup',zIndex:this.popupZIndex,extraData:{pluginCode:$target.data('pluginCode')}})} +Plugin.prototype.onPluginPopupShown=function(ev,button,popup){$(popup).find('input[name=name]').focus()} +Plugin.prototype.applyPluginSettingsDone=function(data){if(data.responseData!==undefined&&data.responseData.isNewPlugin!==undefined){this.makePluginActive(data.responseData.pluginCode,true)}} +Plugin.prototype.makePluginActive=function(pluginCode,updatePluginList){var $form=$('#builder-plugin-selector-panel form').first() +$.oc.stripeLoadIndicator.show() +$form.request('onPluginSetActive',{data:{pluginCode:pluginCode,updatePluginList:(updatePluginList?1:0)}}).always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.makePluginActiveDone))} +Plugin.prototype.makePluginActiveDone=function(data){var pluginCode=data.responseData.pluginCode +$('#builder-plugin-selector-panel [data-control=filelist]').fileList('markActive',pluginCode)} +$.oc.builder.entityControllers.plugin=Plugin;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var DatabaseTable=function(indexController){Base.call(this,'databaseTable',indexController)} +DatabaseTable.prototype=Object.create(BaseProto) +DatabaseTable.prototype.constructor=DatabaseTable +DatabaseTable.prototype.cmdCreateTable=function(ev){var result=this.indexController.openOrLoadMasterTab($(ev.target),'onDatabaseTableCreateOrOpen',this.newTabId()) +if(result!==false){result.done(this.proxy(this.onTableLoaded,this))}} +DatabaseTable.prototype.cmdOpenTable=function(ev){var table=$(ev.currentTarget).data('id'),result=this.indexController.openOrLoadMasterTab($(ev.target),'onDatabaseTableCreateOrOpen',this.makeTabId(table),{table_name:table}) +if(result!==false){result.done(this.proxy(this.onTableLoaded,this))}} +DatabaseTable.prototype.cmdSaveTable=function(ev){var $target=$(ev.currentTarget) +if(!this.validateTable($target)){return} +var data={'columns':this.getTableData($target)} +$target.popup({extraData:data,handler:'onDatabaseTableValidateAndShowPopup'})} +DatabaseTable.prototype.cmdSaveMigration=function(ev){var $target=$(ev.currentTarget) +$.oc.stripeLoadIndicator.show() +$target.request('onDatabaseTableMigrationApply').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.saveMigrationDone))} +DatabaseTable.prototype.cmdDeleteTable=function(ev){var $target=$(ev.currentTarget) +$.oc.confirm($target.data('confirm'),this.proxy(this.deleteConfirmed))} +DatabaseTable.prototype.cmdUnModifyForm=function(){var $masterTabPane=this.getMasterTabsActivePane() +this.unmodifyTab($masterTabPane)} +DatabaseTable.prototype.cmdAddTimestamps=function(ev){var $target=$(ev.currentTarget),added=this.addTimeStampColumns($target,['created_at','updated_at']) +if(!added){alert($target.closest('form').attr('data-lang-timestamps-exist'))}} +DatabaseTable.prototype.cmdAddSoftDelete=function(ev){var $target=$(ev.currentTarget),added=this.addTimeStampColumns($target,['deleted_at']) +if(!added){alert($target.closest('form').attr('data-lang-soft-deleting-exist'))}} +DatabaseTable.prototype.onTableCellChanged=function(ev,column,value,rowIndex){var $target=$(ev.target) +if($target.data('alias')!='columns'){return} +if($target.closest('form').data('entity')!='database'){return} +var updatedRow={} +if(column=='auto_increment'&&value){updatedRow.unsigned=1 +updatedRow.primary_key=1} +if(column=='unsigned'&&!value){updatedRow.auto_increment=0} +if(column=='primary_key'&&value){updatedRow.allow_null=0} +if(column=='allow_null'&&value){updatedRow.primary_key=0} +if(column=='primary_key'&&!value){updatedRow.auto_increment=0} +$target.table('setRowValues',rowIndex,updatedRow)} +DatabaseTable.prototype.onTableLoaded=function(){$(document).trigger('render') +var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form'),$toolbar=$masterTabPane.find('div[data-control=table] div.toolbar'),$button=$('') +$button.text($form.attr('data-lang-add-timestamps'));$toolbar.append($button) +$button=$('') +$button.text($form.attr('data-lang-add-soft-delete'));$toolbar.append($button)} +DatabaseTable.prototype.registerHandlers=function(){this.indexController.$masterTabs.on('oc.tableCellChanged',this.proxy(this.onTableCellChanged))} +DatabaseTable.prototype.validateTable=function($target){var tableObj=this.getTableControlObject($target) +tableObj.unfocusTable() +return tableObj.validate()} +DatabaseTable.prototype.getTableData=function($target){var tableObj=this.getTableControlObject($target) +return tableObj.dataSource.getAllData()} +DatabaseTable.prototype.getTableControlObject=function($target){var $form=$target.closest('form'),$table=$form.find('[data-control=table]'),tableObj=$table.data('oc.table') +if(!tableObj){throw new Error('Table object is not found on the database table tab')} +return tableObj} +DatabaseTable.prototype.saveMigrationDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +$('#builderTableMigrationPopup').trigger('close.oc.popup') +var $masterTabPane=this.getMasterTabsActivePane(),tabsObject=this.getMasterTabsObject() +if(data.builderResponseData.operation!='delete'){$masterTabPane.find('input[name=table_name]').val(data.builderResponseData.builderObjectName) +this.updateMasterTabIdAndTitle($masterTabPane,data.builderResponseData) +this.unhideFormDeleteButton($masterTabPane) +this.getTableList().fileList('markActive',data.builderResponseData.tabId) +this.getIndexController().unchangeTab($masterTabPane)} +else{this.forceCloseTab($masterTabPane)} +$.oc.builder.dataRegistry.clearCache(data.builderResponseData.pluginCode,'model-columns')} +DatabaseTable.prototype.getTableList=function(){return $('#layout-side-panel form[data-content-id=database] [data-control=filelist]')} +DatabaseTable.prototype.deleteConfirmed=function(){var $masterTabPane=this.getMasterTabsActivePane() +$masterTabPane.find('form').popup({handler:'onDatabaseTableShowDeletePopup'})} +DatabaseTable.prototype.getColumnNames=function($target){var tableObj=this.getTableControlObject($target) +tableObj.unfocusTable() +var data=this.getTableData($target),result=[] +for(var index in data){if(data[index].name!==undefined){result.push($.trim(data[index].name))}} +return result} +DatabaseTable.prototype.addTimeStampColumns=function($target,columns) +{var existingColumns=this.getColumnNames($target),added=false +for(var index in columns){var column=columns[index] +if($.inArray(column,existingColumns)==-1){this.addTimeStampColumn($target,column) +added=true}} +if(added){$target.trigger('change')} +return added} +DatabaseTable.prototype.addTimeStampColumn=function($target,column){var tableObj=this.getTableControlObject($target),currentData=this.getTableData($target),rowData={name:column,type:'timestamp','default':null,allow_null:true} +tableObj.addRecord('bottom',true) +tableObj.setRowValues(currentData.length-1,rowData) +tableObj.addRecord('bottom',false) +tableObj.deleteRecord()} +$.oc.builder.entityControllers.databaseTable=DatabaseTable;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Model=function(indexController){Base.call(this,'model',indexController)} +Model.prototype=Object.create(BaseProto) +Model.prototype.constructor=Model +Model.prototype.cmdCreateModel=function(ev){var $target=$(ev.currentTarget) +$target.one('shown.oc.popup',this.proxy(this.onModelPopupShown)) +$target.popup({handler:'onModelLoadPopup'})} +Model.prototype.cmdApplyModelSettings=function(ev){var $form=$(ev.currentTarget),self=this +$.oc.stripeLoadIndicator.show() +$form.request('onModelSave').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(function(data){$form.trigger('close.oc.popup') +self.applyModelSettingsDone(data)})} +Model.prototype.onModelPopupShown=function(ev,button,popup){$(popup).find('input[name=className]').focus()} +Model.prototype.applyModelSettingsDone=function(data){if(data.builderResponseData.registryData!==undefined){var registryData=data.builderResponseData.registryData +$.oc.builder.dataRegistry.set(registryData.pluginCode,'model-classes',null,registryData.models)}} +$.oc.builder.entityControllers.model=Model;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var ModelForm=function(indexController){Base.call(this,'modelForm',indexController)} +ModelForm.prototype=Object.create(BaseProto) +ModelForm.prototype.constructor=ModelForm +ModelForm.prototype.cmdCreateForm=function(ev){var $link=$(ev.currentTarget),data={model_class:$link.data('modelClass')} +this.indexController.openOrLoadMasterTab($link,'onModelFormCreateOrOpen',this.newTabId(),data)} +ModelForm.prototype.cmdSaveForm=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form'),$rootContainer=$('[data-root-control-wrapper] > [data-control-container]',$form),$inspectorContainer=$form.find('.inspector-container'),controls=$.oc.builder.formbuilder.domToPropertyJson.convert($rootContainer.get(0)) +if(!$.oc.inspector.manager.applyValuesFromContainer($inspectorContainer)){return} +if(controls===false){$.oc.flashMsg({'text':$.oc.builder.formbuilder.domToPropertyJson.getLastError(),'class':'error','interval':5}) +return} +var data={controls:controls} +$target.request('onModelFormSave',{data:data}).done(this.proxy(this.saveFormDone))} +ModelForm.prototype.cmdOpenForm=function(ev){var form=$(ev.currentTarget).data('form'),model=$(ev.currentTarget).data('modelClass') +this.indexController.openOrLoadMasterTab($(ev.target),'onModelFormCreateOrOpen',this.makeTabId(model+'-'+form),{file_name:form,model_class:model})} +ModelForm.prototype.cmdDeleteForm=function(ev){var $target=$(ev.currentTarget) +$.oc.confirm($target.data('confirm'),this.proxy(this.deleteConfirmed))} +ModelForm.prototype.cmdAddControl=function(ev){$.oc.builder.formbuilder.controlPalette.addControl(ev)} +ModelForm.prototype.cmdUndockControlPalette=function(ev){$.oc.builder.formbuilder.controlPalette.undockFromContainer(ev)} +ModelForm.prototype.cmdDockControlPalette=function(ev){$.oc.builder.formbuilder.controlPalette.dockToContainer(ev)} +ModelForm.prototype.cmdCloseControlPalette=function(ev){$.oc.builder.formbuilder.controlPalette.closeInContainer(ev)} +ModelForm.prototype.saveFormDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +$masterTabPane.find('input[name=file_name]').val(data.builderResponseData.builderObjectName) +this.updateMasterTabIdAndTitle($masterTabPane,data.builderResponseData) +this.unhideFormDeleteButton($masterTabPane) +this.getModelList().fileList('markActive',data.builderResponseData.tabId) +this.getIndexController().unchangeTab($masterTabPane) +this.updateDataRegistry(data)} +ModelForm.prototype.updateDataRegistry=function(data){if(data.builderResponseData.registryData!==undefined){var registryData=data.builderResponseData.registryData +$.oc.builder.dataRegistry.set(registryData.pluginCode,'model-forms',registryData.modelClass,registryData.forms)}} +ModelForm.prototype.deleteConfirmed=function(){var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form') +$.oc.stripeLoadIndicator.show() +$form.request('onModelFormDelete').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.deleteDone))} +ModelForm.prototype.deleteDone=function(data){var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane) +this.forceCloseTab($masterTabPane) +this.updateDataRegistry(data)} +ModelForm.prototype.getModelList=function(){return $('#layout-side-panel form[data-content-id=models] [data-control=filelist]')} +$.oc.builder.entityControllers.modelForm=ModelForm;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var ModelList=function(indexController){this.cachedModelFieldsPromises={} +Base.call(this,'modelList',indexController)} +ModelList.prototype=Object.create(BaseProto) +ModelList.prototype.constructor=ModelList +ModelList.prototype.registerHandlers=function(){$(document).on('autocompleteitems.oc.table','form[data-sub-entity="model-list"] [data-control=table]',this.proxy(this.onAutocompleteItems))} +ModelList.prototype.cmdCreateList=function(ev){var $link=$(ev.currentTarget),data={model_class:$link.data('modelClass')} +var result=this.indexController.openOrLoadMasterTab($link,'onModelListCreateOrOpen',this.newTabId(),data) +if(result!==false){result.done(this.proxy(this.onListLoaded,this))}} +ModelList.prototype.cmdSaveList=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form') +if(!this.validateTable($target)){return} +$target.request('onModelListSave',{data:{columns:this.getTableData($target)}}).done(this.proxy(this.saveListDone))} +ModelList.prototype.cmdOpenList=function(ev){var list=$(ev.currentTarget).data('list'),model=$(ev.currentTarget).data('modelClass') +var result=this.indexController.openOrLoadMasterTab($(ev.target),'onModelListCreateOrOpen',this.makeTabId(model+'-'+list),{file_name:list,model_class:model}) +if(result!==false){result.done(this.proxy(this.onListLoaded,this))}} +ModelList.prototype.cmdDeleteList=function(ev){var $target=$(ev.currentTarget) +$.oc.confirm($target.data('confirm'),this.proxy(this.deleteConfirmed))} +ModelList.prototype.cmdAddDatabaseColumns=function(ev){var $target=$(ev.currentTarget) +$.oc.stripeLoadIndicator.show() +$target.request('onModelListLoadDatabaseColumns').done(this.proxy(this.databaseColumnsLoaded)).always($.oc.builder.indexController.hideStripeIndicatorProxy)} +ModelList.prototype.saveListDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +$masterTabPane.find('input[name=file_name]').val(data.builderResponseData.builderObjectName) +this.updateMasterTabIdAndTitle($masterTabPane,data.builderResponseData) +this.unhideFormDeleteButton($masterTabPane) +this.getModelList().fileList('markActive',data.builderResponseData.tabId) +this.getIndexController().unchangeTab($masterTabPane) +this.updateDataRegistry(data)} +ModelList.prototype.deleteConfirmed=function(){var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form') +$.oc.stripeLoadIndicator.show() +$form.request('onModelListDelete').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.deleteDone))} +ModelList.prototype.deleteDone=function(data){var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane) +this.forceCloseTab($masterTabPane) +this.updateDataRegistry(data)} +ModelList.prototype.getTableControlObject=function($target){var $form=$target.closest('form'),$table=$form.find('[data-control=table]'),tableObj=$table.data('oc.table') +if(!tableObj){throw new Error('Table object is not found on the model list tab')} +return tableObj} +ModelList.prototype.getModelList=function(){return $('#layout-side-panel form[data-content-id=models] [data-control=filelist]')} +ModelList.prototype.validateTable=function($target){var tableObj=this.getTableControlObject($target) +tableObj.unfocusTable() +return tableObj.validate()} +ModelList.prototype.getTableData=function($target){var tableObj=this.getTableControlObject($target) +return tableObj.dataSource.getAllData()} +ModelList.prototype.loadModelFields=function(table,callback){var $form=$(table).closest('form'),modelClass=$form.find('input[name=model_class]').val(),cachedFields=$form.data('oc.model-field-cache') +if(cachedFields!==undefined){callback(cachedFields) +return} +if(this.cachedModelFieldsPromises[modelClass]===undefined){this.cachedModelFieldsPromises[modelClass]=$form.request('onModelFormGetModelFields',{data:{'as_plain_list':1}})} +if(callback===undefined){return} +this.cachedModelFieldsPromises[modelClass].done(function(data){$form.data('oc.model-field-cache',data.responseData.options) +callback(data.responseData.options)})} +ModelList.prototype.updateDataRegistry=function(data){if(data.builderResponseData.registryData!==undefined){var registryData=data.builderResponseData.registryData +$.oc.builder.dataRegistry.set(registryData.pluginCode,'model-lists',registryData.modelClass,registryData.lists) +$.oc.builder.dataRegistry.clearCache(registryData.pluginCode,'plugin-lists')}} +ModelList.prototype.databaseColumnsLoaded=function(data){if(!$.isArray(data.responseData.columns)){alert('Invalid server response')} +var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form'),existingColumns=this.getColumnNames($form),columnsAdded=false +for(var i in data.responseData.columns){var column=data.responseData.columns[i],type=this.mapType(column.type) +if($.inArray(column.name,existingColumns)!==-1){continue} +this.addColumn($form,column.name,type) +columnsAdded=true} +if(!columnsAdded){alert($form.attr('data-lang-all-database-columns-exist'))} +else{$form.trigger('change')}} +ModelList.prototype.mapType=function(type){switch(type){case'integer':return'number' +case'timestamp':return'datetime' +default:return'text'}} +ModelList.prototype.addColumn=function($target,column,type){var tableObj=this.getTableControlObject($target),currentData=this.getTableData($target),rowData={field:column,label:column,type:type} +tableObj.addRecord('bottom',true) +tableObj.setRowValues(currentData.length-1,rowData) +tableObj.addRecord('bottom',false) +tableObj.deleteRecord()} +ModelList.prototype.getColumnNames=function($target){var tableObj=this.getTableControlObject($target) +tableObj.unfocusTable() +var data=this.getTableData($target),result=[] +for(var index in data){if(data[index].field!==undefined){result.push($.trim(data[index].field))}} +return result} +ModelList.prototype.onAutocompleteItems=function(ev,data){if(data.columnConfiguration.fillFrom==='model-fields'){ev.preventDefault() +this.loadModelFields(ev.target,data.callback) +return false}} +ModelList.prototype.onListLoaded=function(){$(document).trigger('render') +var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form'),$toolbar=$masterTabPane.find('div[data-control=table] div.toolbar'),$button=$('') +$button.text($form.attr('data-lang-add-database-columns'));$toolbar.append($button)} +$.oc.builder.entityControllers.modelList=ModelList;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Permission=function(indexController){Base.call(this,'permissions',indexController)} +Permission.prototype=Object.create(BaseProto) +Permission.prototype.constructor=Permission +Permission.prototype.registerHandlers=function(){this.indexController.$masterTabs.on('oc.tableNewRow',this.proxy(this.onTableRowCreated))} +Permission.prototype.cmdOpenPermissions=function(ev){var currentPlugin=this.getSelectedPlugin() +if(!currentPlugin){alert('Please select a plugin first') +return} +this.indexController.openOrLoadMasterTab($(ev.target),'onPermissionsOpen',this.makeTabId(currentPlugin))} +Permission.prototype.cmdSavePermissions=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form') +if(!this.validateTable($target)){return} +$target.request('onPermissionsSave',{data:{permissions:this.getTableData($target)}}).done(this.proxy(this.savePermissionsDone))} +Permission.prototype.getTableControlObject=function($target){var $form=$target.closest('form'),$table=$form.find('[data-control=table]'),tableObj=$table.data('oc.table') +if(!tableObj){throw new Error('Table object is not found on permissions tab')} +return tableObj} +Permission.prototype.validateTable=function($target){var tableObj=this.getTableControlObject($target) +tableObj.unfocusTable() +return tableObj.validate()} +Permission.prototype.getTableData=function($target){var tableObj=this.getTableControlObject($target) +return tableObj.dataSource.getAllData()} +Permission.prototype.savePermissionsDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane) +$.oc.builder.dataRegistry.clearCache(data.builderResponseData.pluginCode,'permissions')} +Permission.prototype.onTableRowCreated=function(ev,recordData){var $target=$(ev.target) +if($target.data('alias')!='permissions'){return} +var $form=$target.closest('form') +if($form.data('entity')!='permissions'){return} +var pluginCode=$form.find('input[name=plugin_code]').val() +recordData.permission=pluginCode.toLowerCase()+'.';} +$.oc.builder.entityControllers.permission=Permission;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Menus=function(indexController){Base.call(this,'menus',indexController)} +Menus.prototype=Object.create(BaseProto) +Menus.prototype.constructor=Menus +Menus.prototype.cmdOpenMenus=function(ev){var currentPlugin=this.getSelectedPlugin() +if(!currentPlugin){alert('Please select a plugin first') +return} +this.indexController.openOrLoadMasterTab($(ev.target),'onMenusOpen',this.makeTabId(currentPlugin))} +Menus.prototype.cmdSaveMenus=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form'),$inspectorContainer=$form.find('.inspector-container') +if(!$.oc.inspector.manager.applyValuesFromContainer($inspectorContainer)){return} +var menus=$.oc.builder.menubuilder.controller.getJson($form.get(0)) +$target.request('onMenusSave',{data:{menus:menus}}).done(this.proxy(this.saveMenusDone))} +Menus.prototype.cmdAddMainMenuItem=function(ev){$.oc.builder.menubuilder.controller.addMainMenuItem(ev)} +Menus.prototype.cmdAddSideMenuItem=function(ev){$.oc.builder.menubuilder.controller.addSideMenuItem(ev)} +Menus.prototype.cmdDeleteMenuItem=function(ev){$.oc.builder.menubuilder.controller.deleteMenuItem(ev)} +Menus.prototype.saveMenusDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane)} +$.oc.builder.entityControllers.menus=Menus;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Version=function(indexController){Base.call(this,'version',indexController) +this.hiddenHints={}} +Version.prototype=Object.create(BaseProto) +Version.prototype.constructor=Version +Version.prototype.cmdCreateVersion=function(ev){var $link=$(ev.currentTarget),versionType=$link.data('versionType') +this.indexController.openOrLoadMasterTab($link,'onVersionCreateOrOpen',this.newTabId(),{version_type:versionType})} +Version.prototype.cmdSaveVersion=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form') +$target.request('onVersionSave').done(this.proxy(this.saveVersionDone))} +Version.prototype.cmdOpenVersion=function(ev){var versionNumber=$(ev.currentTarget).data('id'),pluginCode=$(ev.currentTarget).data('pluginCode') +this.indexController.openOrLoadMasterTab($(ev.target),'onVersionCreateOrOpen',this.makeTabId(pluginCode+'-'+versionNumber),{original_version:versionNumber})} +Version.prototype.cmdDeleteVersion=function(ev){var $target=$(ev.currentTarget) +$.oc.confirm($target.data('confirm'),this.proxy(this.deleteConfirmed))} +Version.prototype.cmdApplyVersion=function(ev){var $target=$(ev.currentTarget),$pane=$target.closest('div.tab-pane'),self=this +this.showHintPopup($pane,'builder-version-apply',function(){$target.request('onVersionApply').done(self.proxy(self.applyVersionDone))})} +Version.prototype.cmdRollbackVersion=function(ev){var $target=$(ev.currentTarget),$pane=$target.closest('div.tab-pane'),self=this +this.showHintPopup($pane,'builder-version-rollback',function(){$target.request('onVersionRollback').done(self.proxy(self.rollbackVersionDone))})} +Version.prototype.saveVersionDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +this.updateUiAfterSave($masterTabPane,data) +if(!data.builderResponseData.isApplied){this.showSavedNotAppliedHint($masterTabPane)}} +Version.prototype.showSavedNotAppliedHint=function($masterTabPane){this.showHintPopup($masterTabPane,'builder-version-save-unapplied')} +Version.prototype.showHintPopup=function($masterTabPane,code,callback){if(this.getDontShowHintAgain(code,$masterTabPane)){if(callback){callback.apply(this)} +return} +$masterTabPane.one('hide.oc.popup',this.proxy(this.onHintPopupHide)) +if(callback){$masterTabPane.one('shown.oc.popup',function(ev,$element,$modal){$modal.find('form').one('submit',function(ev){callback.apply(this) +ev.preventDefault() +$(ev.target).trigger('close.oc.popup') +return false})})} +$masterTabPane.popup({content:this.getPopupContent($masterTabPane,code)})} +Version.prototype.onHintPopupHide=function(ev,$element,$modal){var cbValue=$modal.find('input[type=checkbox][name=dont_show_again]').is(':checked'),code=$modal.find('input[type=hidden][name=hint_code]').val() +$modal.find('form').off('submit') +if(!cbValue){return} +var $form=this.getMasterTabsActivePane().find('form[data-entity="versions"]') +$form.request('onHideBackendHint',{data:{name:code}}) +this.setDontShowHintAgain(code)} +Version.prototype.setDontShowHintAgain=function(code){this.hiddenHints[code]=true} +Version.prototype.getDontShowHintAgain=function(code,$pane){if(this.hiddenHints[code]!==undefined){return this.hiddenHints[code]} +return $pane.find('input[type=hidden][data-hint-hidden="'+code+'"]').val()=="true"} +Version.prototype.getPopupContent=function($pane,code){var template=$pane.find('script[data-version-hint-template="'+code+'"]') +if(template.length===0){throw new Error('Version popup template not found: '+code)} +return template.html()} +Version.prototype.updateUiAfterSave=function($masterTabPane,data){$masterTabPane.find('input[name=original_version]').val(data.builderResponseData.savedVersion) +this.updateMasterTabIdAndTitle($masterTabPane,data.builderResponseData) +this.unhideFormDeleteButton($masterTabPane) +this.getVersionList().fileList('markActive',data.builderResponseData.tabId) +this.getIndexController().unchangeTab($masterTabPane)} +Version.prototype.deleteConfirmed=function(){var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form') +$.oc.stripeLoadIndicator.show() +$form.request('onVersionDelete').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.deleteDone))} +Version.prototype.deleteDone=function(){var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane) +this.forceCloseTab($masterTabPane)} +Version.prototype.applyVersionDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +this.updateUiAfterSave($masterTabPane,data) +this.updateVersionsButtons()} +Version.prototype.rollbackVersionDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +this.updateUiAfterSave($masterTabPane,data) +this.updateVersionsButtons()} +Version.prototype.getVersionList=function(){return $('#layout-side-panel form[data-content-id=version] [data-control=filelist]')} +Version.prototype.updateVersionsButtons=function(){var tabsObject=this.getMasterTabsObject(),$tabs=tabsObject.$tabsContainer.find('> li'),$versionList=this.getVersionList() +for(var i=$tabs.length-1;i>=0;i--){var $tab=$($tabs[i]),tabId=$tab.data('tabId') +if(!tabId||String(tabId).length==0){continue} +var $versionLi=$versionList.find('li[data-id="'+tabId+'"]') +if(!$versionLi.length){continue} +var isApplied=$versionLi.data('applied'),$pane=tabsObject.findPaneFromTab($tab) +if(isApplied){$pane.find('[data-builder-command="version:cmdApplyVersion"]').addClass('hide') +$pane.find('[data-builder-command="version:cmdRollbackVersion"]').removeClass('hide')} +else{$pane.find('[data-builder-command="version:cmdApplyVersion"]').removeClass('hide') +$pane.find('[data-builder-command="version:cmdRollbackVersion"]').addClass('hide')}}} +$.oc.builder.entityControllers.version=Version;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Localization=function(indexController){Base.call(this,'localization',indexController)} +Localization.prototype=Object.create(BaseProto) +Localization.prototype.constructor=Localization +Localization.prototype.cmdCreateLanguage=function(ev){this.indexController.openOrLoadMasterTab($(ev.target),'onLanguageCreateOrOpen',this.newTabId())} +Localization.prototype.cmdOpenLanguage=function(ev){var language=$(ev.currentTarget).data('id'),pluginCode=$(ev.currentTarget).data('pluginCode') +this.indexController.openOrLoadMasterTab($(ev.target),'onLanguageCreateOrOpen',this.makeTabId(pluginCode+'-'+language),{original_language:language})} +Localization.prototype.cmdSaveLanguage=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form') +$target.request('onLanguageSave').done(this.proxy(this.saveLanguageDone))} +Localization.prototype.cmdDeleteLanguage=function(ev){var $target=$(ev.currentTarget) +$.oc.confirm($target.data('confirm'),this.proxy(this.deleteConfirmed))} +Localization.prototype.cmdCopyMissingStrings=function(ev){var $form=$(ev.currentTarget),language=$form.find('select[name=language]').val(),$masterTabPane=this.getMasterTabsActivePane() +$form.trigger('close.oc.popup') +$.oc.stripeLoadIndicator.show() +$masterTabPane.find('form').request('onLanguageCopyStringsFrom',{data:{copy_from:language}}).always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.copyStringsFromDone))} +Localization.prototype.languageUpdated=function(plugin){var languageForm=this.findDefaultLanguageForm(plugin) +if(!languageForm){return} +var $languageForm=$(languageForm) +if(!$languageForm.hasClass('oc-data-changed')){this.updateLanguageFromServer($languageForm)} +else{this.mergeLanguageFromServer($languageForm)}} +Localization.prototype.updateOnScreenStrings=function(plugin){var stringElements=document.body.querySelectorAll('span[data-localization-key][data-plugin="'+plugin+'"]') +$.oc.builder.dataRegistry.get($('#builder-plugin-selector-panel form'),plugin,'localization',null,function(data){for(var i=stringElements.length-1;i>=0;i--){var stringElement=stringElements[i],stringKey=stringElement.getAttribute('data-localization-key') +if(data[stringKey]!==undefined){stringElement.textContent=data[stringKey]} +else{stringElement.textContent=stringKey}}})} +Localization.prototype.saveLanguageDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +$masterTabPane.find('input[name=original_language]').val(data.builderResponseData.language) +this.updateMasterTabIdAndTitle($masterTabPane,data.builderResponseData) +this.unhideFormDeleteButton($masterTabPane) +this.getLanguageList().fileList('markActive',data.builderResponseData.tabId) +this.getIndexController().unchangeTab($masterTabPane) +if(data.builderResponseData.registryData!==undefined){var registryData=data.builderResponseData.registryData +$.oc.builder.dataRegistry.set(registryData.pluginCode,'localization',null,registryData.strings,{suppressLanguageEditorUpdate:true}) +$.oc.builder.dataRegistry.set(registryData.pluginCode,'localization','sections',registryData.sections)}} +Localization.prototype.getLanguageList=function(){return $('#layout-side-panel form[data-content-id=localization] [data-control=filelist]')} +Localization.prototype.getCodeEditor=function($tab){return $tab.find('div[data-field-name=strings] div[data-control=codeeditor]').data('oc.codeEditor').editor} +Localization.prototype.deleteConfirmed=function(){var $masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form') +$.oc.stripeLoadIndicator.show() +$form.request('onLanguageDelete').always($.oc.builder.indexController.hideStripeIndicatorProxy).done(this.proxy(this.deleteDone))} +Localization.prototype.deleteDone=function(){var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane) +this.forceCloseTab($masterTabPane)} +Localization.prototype.copyStringsFromDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var responseData=data.builderResponseData,$masterTabPane=this.getMasterTabsActivePane(),$form=$masterTabPane.find('form'),codeEditor=this.getCodeEditor($masterTabPane),newStringMessage=$form.data('newStringMessage'),mismatchMessage=$form.data('structureMismatch') +codeEditor.getSession().setValue(responseData.strings) +var annotations=[] +for(var i=responseData.updatedLines.length-1;i>=0;i--){var line=responseData.updatedLines[i] +annotations.push({row:line,column:0,text:newStringMessage,type:'warning'})} +codeEditor.getSession().setAnnotations(annotations) +if(responseData.mismatch){$.oc.alert(mismatchMessage)}} +Localization.prototype.findDefaultLanguageForm=function(plugin){var forms=document.body.querySelectorAll('form[data-entity=localization]') +for(var i=forms.length-1;i>=0;i--){var form=forms[i],pluginInput=form.querySelector('input[name=plugin_code]'),languageInput=form.querySelector('input[name=original_language]') +if(!pluginInput||pluginInput.value!=plugin){continue} +if(!languageInput){continue} +if(form.getAttribute('data-default-language')==languageInput.value){return form}} +return null} +Localization.prototype.updateLanguageFromServer=function($languageForm){var self=this +$languageForm.request('onLanguageGetStrings').done(function(data){self.updateLanguageFromServerDone($languageForm,data)})} +Localization.prototype.updateLanguageFromServerDone=function($languageForm,data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var responseData=data.builderResponseData,$tabPane=$languageForm.closest('.tab-pane'),codeEditor=this.getCodeEditor($tabPane) +if(!responseData.strings){return} +codeEditor.getSession().setValue(responseData.strings) +this.unmodifyTab($tabPane)} +Localization.prototype.mergeLanguageFromServer=function($languageForm){var language=$languageForm.find('input[name=original_language]').val(),self=this +$languageForm.request('onLanguageCopyStringsFrom',{data:{copy_from:language}}).done(function(data){self.mergeLanguageFromServerDone($languageForm,data)})} +Localization.prototype.mergeLanguageFromServerDone=function($languageForm,data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var responseData=data.builderResponseData,$tabPane=$languageForm.closest('.tab-pane'),codeEditor=this.getCodeEditor($tabPane) +codeEditor.getSession().setValue(responseData.strings) +codeEditor.getSession().setAnnotations([])} +$.oc.builder.entityControllers.localization=Localization;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +if($.oc.builder.entityControllers===undefined) +$.oc.builder.entityControllers={} +var Base=$.oc.builder.entityControllers.base,BaseProto=Base.prototype +var Controller=function(indexController){Base.call(this,'controller',indexController)} +Controller.prototype=Object.create(BaseProto) +Controller.prototype.constructor=Controller +Controller.prototype.cmdCreateController=function(ev){var $form=$(ev.currentTarget),self=this,pluginCode=$form.data('pluginCode'),behaviorsSelected=$form.find('input[name="behaviors[]"]:checked').length,promise=null +if(behaviorsSelected){promise=this.indexController.openOrLoadMasterTab($form,'onControllerCreate',this.makeTabId(pluginCode+'-new-controller'),{})} +else{promise=$form.request('onControllerCreate')} +promise.done(function(data){$form.trigger('close.oc.popup') +self.updateDataRegistry(data)}).always($.oc.builder.indexController.hideStripeIndicatorProxy)} +Controller.prototype.cmdOpenController=function(ev){var controller=$(ev.currentTarget).data('id'),pluginCode=$(ev.currentTarget).data('pluginCode') +this.indexController.openOrLoadMasterTab($(ev.target),'onControllerOpen',this.makeTabId(pluginCode+'-'+controller),{controller:controller})} +Controller.prototype.cmdSaveController=function(ev){var $target=$(ev.currentTarget),$form=$target.closest('form'),$inspectorContainer=$form.find('.inspector-container') +if(!$.oc.inspector.manager.applyValuesFromContainer($inspectorContainer)){return} +$target.request('onControllerSave').done(this.proxy(this.saveControllerDone))} +Controller.prototype.saveControllerDone=function(data){if(data['builderResponseData']===undefined){throw new Error('Invalid response data')} +var $masterTabPane=this.getMasterTabsActivePane() +this.getIndexController().unchangeTab($masterTabPane)} +Controller.prototype.updateDataRegistry=function(data){if(data.builderResponseData.registryData!==undefined){var registryData=data.builderResponseData.registryData +$.oc.builder.dataRegistry.set(registryData.pluginCode,'controller-urls',null,registryData.urls)}} +Controller.prototype.getControllerList=function(){return $('#layout-side-panel form[data-content-id=controller] [data-control=filelist]')} +$.oc.builder.entityControllers.controller=Controller;}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +var Base=$.oc.foundation.base,BaseProto=Base.prototype +var Builder=function(){Base.call(this) +this.$masterTabs=null +this.masterTabsObj=null +this.hideStripeIndicatorProxy=null +this.entityControllers={} +this.init()} +Builder.prototype=Object.create(BaseProto) +Builder.prototype.constructor=Builder +Builder.prototype.dispose=function(){BaseProto.dispose.call(this)} +Builder.prototype.openOrLoadMasterTab=function($form,serverHandlerName,tabId,data){if(this.masterTabsObj.goTo(tabId)) +return false +var requestData=data===undefined?{}:data +$.oc.stripeLoadIndicator.show() +var promise=$form.request(serverHandlerName,{data:requestData}).done(this.proxy(this.addMasterTab)).always(this.hideStripeIndicatorProxy) +return promise} +Builder.prototype.getMasterTabActivePane=function(){return this.$masterTabs.find('> .tab-content > .tab-pane.active')} +Builder.prototype.unchangeTab=function($pane){$pane.find('form').trigger('unchange.oc.changeMonitor')} +Builder.prototype.triggerCommand=function(command,ev){var commandParts=command.split(':') +if(commandParts.length===2){var entity=commandParts[0],commandToExecute=commandParts[1] +if(this.entityControllers[entity]===undefined){throw new Error('Unknown entity type: '+entity)} +this.entityControllers[entity].invokeCommand(commandToExecute,ev)}} +Builder.prototype.init=function(){this.$masterTabs=$('#builder-master-tabs') +this.$sidePanel=$('#builder-side-panel') +this.masterTabsObj=this.$masterTabs.data('oc.tab') +this.hideStripeIndicatorProxy=this.proxy(this.hideStripeIndicator) +new $.oc.tabFormExpandControls(this.$masterTabs) +this.createEntityControllers() +this.registerHandlers()} +Builder.prototype.createEntityControllers=function(){for(var controller in $.oc.builder.entityControllers){if(controller=="base"){continue} +this.entityControllers[controller]=new $.oc.builder.entityControllers[controller](this)}} +Builder.prototype.registerHandlers=function(){$(document).on('click','[data-builder-command]',this.proxy(this.onCommand)) +$(document).on('submit','[data-builder-command]',this.proxy(this.onCommand)) +this.$masterTabs.on('changed.oc.changeMonitor',this.proxy(this.onFormChanged)) +this.$masterTabs.on('unchanged.oc.changeMonitor',this.proxy(this.onFormUnchanged)) +this.$masterTabs.on('shown.bs.tab',this.proxy(this.onTabShown)) +this.$masterTabs.on('afterAllClosed.oc.tab',this.proxy(this.onAllTabsClosed)) +this.$masterTabs.on('closed.oc.tab',this.proxy(this.onTabClosed)) +this.$masterTabs.on('autocompleteitems.oc.inspector',this.proxy(this.onDataRegistryItems)) +this.$masterTabs.on('dropdownoptions.oc.inspector',this.proxy(this.onDataRegistryItems)) +for(var controller in this.entityControllers){if(this.entityControllers[controller].registerHandlers!==undefined){this.entityControllers[controller].registerHandlers()}}} +Builder.prototype.hideStripeIndicator=function(){$.oc.stripeLoadIndicator.hide()} +Builder.prototype.addMasterTab=function(data){this.masterTabsObj.addTab(data.tabTitle,data.tab,data.tabId,'oc-'+data.tabIcon) +if(data.isNewRecord){var $masterTabPane=this.getMasterTabActivePane() +$masterTabPane.find('form').one('ready.oc.changeMonitor',this.proxy(this.onChangeMonitorReady))}} +Builder.prototype.updateModifiedCounter=function(){var counters={database:{menu:'database',count:0},models:{menu:'models',count:0},permissions:{menu:'permissions',count:0},menus:{menu:'menus',count:0},versions:{menu:'versions',count:0},localization:{menu:'localization',count:0},controller:{menu:'controllers',count:0}} +$('> div.tab-content > div.tab-pane[data-modified] > form',this.$masterTabs).each(function(){var entity=$(this).data('entity') +counters[entity].count++}) +$.each(counters,function(type,data){$.oc.sideNav.setCounter('builder/'+data.menu,data.count);})} +Builder.prototype.getFormPluginCode=function(formElement){var $form=$(formElement).closest('form'),$input=$form.find('input[name="plugin_code"]'),code=$input.val() +if(!code){throw new Error('Plugin code input is not found in the form.')} +return code} +Builder.prototype.setPageTitle=function(title){$.oc.layout.setPageTitle(title.length?(title+' | '):title)} +Builder.prototype.getFileLists=function(){return $('[data-control=filelist]',this.$sidePanel)} +Builder.prototype.dataToInspectorArray=function(data){var result=[] +for(var key in data){var item={title:data[key],value:key} +result.push(item)} +return result} +Builder.prototype.onCommand=function(ev){if(ev.currentTarget.tagName=='FORM'&&ev.type=='click'){return} +var command=$(ev.currentTarget).data('builderCommand') +this.triggerCommand(command,ev) +var $target=$(ev.currentTarget) +if(ev.currentTarget.tagName==='A'&&$target.attr('role')=='menuitem'&&$target.attr('href')=='javascript:;'){return} +ev.preventDefault() +return false} +Builder.prototype.onFormChanged=function(ev){$('.form-tabless-fields',ev.target).trigger('modified.oc.tab') +this.updateModifiedCounter()} +Builder.prototype.onFormUnchanged=function(ev){$('.form-tabless-fields',ev.target).trigger('unmodified.oc.tab') +this.updateModifiedCounter()} +Builder.prototype.onTabShown=function(ev){var $tabControl=$(ev.target).closest('[data-control=tab]') +if($tabControl.attr('id')!=this.$masterTabs.attr('id')){return} +var dataId=$(ev.target).closest('li').attr('data-tab-id'),title=$(ev.target).attr('title') +if(title){this.setPageTitle(title)} +this.getFileLists().fileList('markActive',dataId) +$(window).trigger('resize')} +Builder.prototype.onAllTabsClosed=function(ev){this.setPageTitle('') +this.getFileLists().fileList('markActive',null)} +Builder.prototype.onTabClosed=function(ev,tab,pane){$(pane).find('form').off('ready.oc.changeMonitor',this.proxy(this.onChangeMonitorReady)) +this.updateModifiedCounter()} +Builder.prototype.onChangeMonitorReady=function(ev){$(ev.target).trigger('change')} +Builder.prototype.onDataRegistryItems=function(ev,data){var self=this +if(data.propertyDefinition.fillFrom=='model-classes'||data.propertyDefinition.fillFrom=='model-forms'||data.propertyDefinition.fillFrom=='model-lists'||data.propertyDefinition.fillFrom=='controller-urls'||data.propertyDefinition.fillFrom=='model-columns'||data.propertyDefinition.fillFrom=='plugin-lists'||data.propertyDefinition.fillFrom=='permissions'){ev.preventDefault() +var subtype=null,subtypeProperty=data.propertyDefinition.subtypeFrom +if(subtypeProperty!==undefined){subtype=data.values[subtypeProperty]} +$.oc.builder.dataRegistry.get($(ev.target),this.getFormPluginCode(ev.target),data.propertyDefinition.fillFrom,subtype,function(response){data.callback({options:self.dataToInspectorArray(response)})})}} +$(document).ready(function(){$.oc.builder.indexController=new Builder()})}(window.jQuery);+function($){"use strict";if($.oc.builder===undefined) +$.oc.builder={} +var Base=$.oc.foundation.base,BaseProto=Base.prototype +var LocalizationInput=function(input,form,options){this.input=input +this.form=form +this.options=$.extend({},LocalizationInput.DEFAULTS,options) +this.disposed=false +this.initialized=false +this.newStringPopupMarkup=null +Base.call(this) +this.init()} +LocalizationInput.prototype=Object.create(BaseProto) +LocalizationInput.prototype.constructor=LocalizationInput +LocalizationInput.prototype.dispose=function(){this.unregisterHandlers() +this.form=null +this.options.beforePopupShowCallback=null +this.options.afterPopupHideCallback=null +this.options=null +this.disposed=true +this.newStringPopupMarkup=null +if(this.initialized){$(this.input).autocomplete('destroy')} +$(this.input).removeData('localization-input') +this.input=null +BaseProto.dispose.call(this)} +LocalizationInput.prototype.init=function(){if(!this.options.plugin){throw new Error('The options.plugin value should be set in the localization input object.')} +var $input=$(this.input) +$input.data('localization-input',this) +$input.attr('data-builder-localization-input','true') +$input.attr('data-builder-localization-plugin',this.options.plugin) +this.getContainer().addClass('localization-input-container') +this.registerHandlers() +this.loadDataAndBuild()} +LocalizationInput.prototype.buildAddLink=function(){var $container=this.getContainer() +if($container.find('a.localization-trigger').length>0){return} +var trigger=document.createElement('a') +trigger.setAttribute('class','oc-icon-plus localization-trigger') +trigger.setAttribute('href','#') +var pos=$container.position() +$(trigger).css({top:pos.top+4,right:7}) +$container.append(trigger)} +LocalizationInput.prototype.loadDataAndBuild=function(){this.showLoadingIndicator() +var result=$.oc.builder.dataRegistry.get(this.form,this.options.plugin,'localization',null,this.proxy(this.dataLoaded)),self=this +if(result){result.always(function(){self.hideLoadingIndicator()})}} +LocalizationInput.prototype.reload=function(){$.oc.builder.dataRegistry.get(this.form,this.options.plugin,'localization',null,this.proxy(this.dataLoaded))} +LocalizationInput.prototype.dataLoaded=function(data){if(this.disposed){return} +var $input=$(this.input),autocomplete=$input.data('autocomplete') +if(!autocomplete){this.hideLoadingIndicator() +var autocompleteOptions={source:this.preprocessData(data),matchWidth:true} +autocompleteOptions=$.extend(autocompleteOptions,this.options.autocompleteOptions) +$(this.input).autocomplete(autocompleteOptions) +this.initialized=true} +else{autocomplete.source=this.preprocessData(data)}} +LocalizationInput.prototype.preprocessData=function(data){var dataClone=$.extend({},data) +for(var key in dataClone){dataClone[key]=key+' - '+dataClone[key]} +return dataClone} +LocalizationInput.prototype.getContainer=function(){return $(this.input).closest('.autocomplete-container')} +LocalizationInput.prototype.showLoadingIndicator=function(){var $container=this.getContainer() +$container.addClass('loading-indicator-container size-small') +$container.loadIndicator()} +LocalizationInput.prototype.hideLoadingIndicator=function(){var $container=this.getContainer() +$container.loadIndicator('hide') +$container.loadIndicator('destroy') +$container.removeClass('loading-indicator-container')} +LocalizationInput.prototype.loadAndShowPopup=function(){if(this.newStringPopupMarkup===null){$.oc.stripeLoadIndicator.show() +$(this.input).request('onLanguageLoadAddStringForm').done(this.proxy(this.popupMarkupLoaded)).always(function(){$.oc.stripeLoadIndicator.hide()})} +else{this.showPopup()}} +LocalizationInput.prototype.popupMarkupLoaded=function(responseData){this.newStringPopupMarkup=responseData.markup +this.showPopup()} +LocalizationInput.prototype.showPopup=function(){var $input=$(this.input) +$input.popup({content:this.newStringPopupMarkup}) +var $content=$input.data('oc.popup').$content,$keyInput=$content.find('#language_string_key') +$.oc.builder.dataRegistry.get(this.form,this.options.plugin,'localization','sections',function(data){$keyInput.autocomplete({source:data,matchWidth:true})}) +$content.find('form').on('submit',this.proxy(this.onSubmitPopupForm))} +LocalizationInput.prototype.stringCreated=function(data){if(data.localizationData===undefined||data.registryData===undefined){throw new Error('Invalid server response.')} +var $input=$(this.input) +$input.val(data.localizationData.key) +$.oc.builder.dataRegistry.set(this.options.plugin,'localization',null,data.registryData.strings) +$.oc.builder.dataRegistry.set(this.options.plugin,'localization','sections',data.registryData.sections) +$input.data('oc.popup').hide() +$input.trigger('change')} +LocalizationInput.prototype.onSubmitPopupForm=function(ev){var $form=$(ev.target) +$.oc.stripeLoadIndicator.show() +$form.request('onLanguageCreateString',{data:{plugin_code:this.options.plugin}}).done(this.proxy(this.stringCreated)).always(function(){$.oc.stripeLoadIndicator.hide()}) +ev.preventDefault() +return false} +LocalizationInput.prototype.onPopupHidden=function(ev,link,popup){$(popup).find('#language_string_key').autocomplete('destroy') +$(popup).find('form').on('submit',this.proxy(this.onSubmitPopupForm)) +if(this.options.afterPopupHideCallback){this.options.afterPopupHideCallback()}} +LocalizationInput.updatePluginInputs=function(plugin){var inputs=document.body.querySelectorAll('input[data-builder-localization-input][data-builder-localization-plugin="'+plugin+'"]') +for(var i=inputs.length-1;i>=0;i--){$(inputs[i]).data('localization-input').reload()}} +LocalizationInput.prototype.unregisterHandlers=function(){this.input.removeEventListener('focus',this.proxy(this.onInputFocus)) +this.getContainer().off('click','a.localization-trigger',this.proxy(this.onTriggerClick)) +$(this.input).off('hidden.oc.popup',this.proxy(this.onPopupHidden))} +LocalizationInput.prototype.registerHandlers=function(){this.input.addEventListener('focus',this.proxy(this.onInputFocus)) +this.getContainer().on('click','a.localization-trigger',this.proxy(this.onTriggerClick)) +$(this.input).on('hidden.oc.popup',this.proxy(this.onPopupHidden))} +LocalizationInput.prototype.onInputFocus=function(){this.buildAddLink()} +LocalizationInput.prototype.onTriggerClick=function(ev){if(this.options.beforePopupShowCallback){this.options.beforePopupShowCallback()} +this.loadAndShowPopup() +ev.preventDefault() +return false} +LocalizationInput.DEFAULTS={plugin:null,autocompleteOptions:{},beforePopupShowCallback:null,afterPopupHideCallback:null} +$.oc.builder.localizationInput=LocalizationInput}(window.jQuery);+function($){"use strict";var Base=$.oc.inspector.propertyEditors.string,BaseProto=Base.prototype +var LocalizationEditor=function(inspector,propertyDefinition,containerCell,group){this.localizationInput=null +Base.call(this,inspector,propertyDefinition,containerCell,group)} +LocalizationEditor.prototype=Object.create(BaseProto) +LocalizationEditor.prototype.constructor=Base +LocalizationEditor.prototype.dispose=function(){this.removeLocalizationInput() +BaseProto.dispose.call(this)} +LocalizationEditor.prototype.build=function(){var container=document.createElement('div'),editor=document.createElement('input'),placeholder=this.propertyDefinition.placeholder!==undefined?this.propertyDefinition.placeholder:'',value=this.inspector.getPropertyValue(this.propertyDefinition.property) +editor.setAttribute('type','text') +editor.setAttribute('class','string-editor') +editor.setAttribute('placeholder',placeholder) +container.setAttribute('class','autocomplete-container') +if(value===undefined){value=this.propertyDefinition.default} +if(value===undefined){value=''} +editor.value=value +$.oc.foundation.element.addClass(this.containerCell,'text autocomplete') +container.appendChild(editor) +this.containerCell.appendChild(container) +this.buildLocalizationEditor()} +LocalizationEditor.prototype.buildLocalizationEditor=function(){this.localizationInput=new $.oc.builder.localizationInput(this.getInput(),this.getForm(),{plugin:this.getPluginCode(),beforePopupShowCallback:this.proxy(this.onPopupShown,this),afterPopupHideCallback:this.proxy(this.onPopupHidden,this)})} +LocalizationEditor.prototype.removeLocalizationInput=function(){this.localizationInput.dispose() +this.localizationInput=null} +LocalizationEditor.prototype.supportsExternalParameterEditor=function(){return false} +LocalizationEditor.prototype.registerHandlers=function(){BaseProto.registerHandlers.call(this) +$(this.getInput()).on('change',this.proxy(this.onInputKeyUp))} +LocalizationEditor.prototype.unregisterHandlers=function(){BaseProto.unregisterHandlers.call(this) +$(this.getInput()).off('change',this.proxy(this.onInputKeyUp))} +LocalizationEditor.prototype.getForm=function(){var inspectableElement=this.getRootSurface().getInspectableElement() +if(!inspectableElement){throw new Error('Cannot determine inspectable element in the Builder localization editor.')} +return $(inspectableElement).closest('form')} +LocalizationEditor.prototype.getPluginCode=function(){var $form=this.getForm(),$input=$form.find('input[name=plugin_code]') +if(!$input.length){throw new Error('The input "plugin_code" should be defined in the form in order to use the localization Inspector editor.')} +return $input.val()} +LocalizationEditor.prototype.onPopupShown=function(){this.getRootSurface().popupDisplayed()} +LocalizationEditor.prototype.onPopupHidden=function(){this.getRootSurface().popupHidden()} +$.oc.inspector.propertyEditors.builderLocalization=LocalizationEditor}(window.jQuery);+function($){"use strict";if($.oc.table===undefined) +throw new Error("The $.oc.table namespace is not defined. Make sure that the table.js script is loaded.");if($.oc.table.processor===undefined) +throw new Error("The $.oc.table.processor namespace is not defined. Make sure that the table.processor.base.js script is loaded.");var Base=$.oc.table.processor.string,BaseProto=Base.prototype +var LocalizationProcessor=function(tableObj,columnName,columnConfiguration){this.localizationInput=null +this.popupDisplayed=false +Base.call(this,tableObj,columnName,columnConfiguration)} +LocalizationProcessor.prototype=Object.create(BaseProto) +LocalizationProcessor.prototype.constructor=LocalizationProcessor +LocalizationProcessor.prototype.dispose=function(){this.removeLocalizationInput() +BaseProto.dispose.call(this)} +LocalizationProcessor.prototype.onUnfocus=function(){if(!this.activeCell||this.popupDisplayed) +return +this.removeLocalizationInput() +BaseProto.onUnfocus.call(this)} +LocalizationProcessor.prototype.onBeforePopupShow=function(){this.popupDisplayed=true} +LocalizationProcessor.prototype.onAfterPopupHide=function(){this.popupDisplayed=false} +LocalizationProcessor.prototype.renderCell=function(value,cellContentContainer){BaseProto.renderCell.call(this,value,cellContentContainer)} +LocalizationProcessor.prototype.buildEditor=function(cellElement,cellContentContainer,isClick){BaseProto.buildEditor.call(this,cellElement,cellContentContainer,isClick) +$.oc.foundation.element.addClass(cellContentContainer,'autocomplete-container') +this.buildLocalizationEditor()} +LocalizationProcessor.prototype.buildLocalizationEditor=function(){var input=this.getInput() +this.localizationInput=new $.oc.builder.localizationInput(input,$(input),{plugin:this.getPluginCode(input),beforePopupShowCallback:$.proxy(this.onBeforePopupShow,this),afterPopupHideCallback:$.proxy(this.onAfterPopupHide,this),autocompleteOptions:{menu:'',bodyContainer:true}})} +LocalizationProcessor.prototype.getInput=function(){if(!this.activeCell){return null} +return this.activeCell.querySelector('.string-input')} +LocalizationProcessor.prototype.getPluginCode=function(input){var $form=$(input).closest('form'),$input=$form.find('input[name=plugin_code]') +if(!$input.length){throw new Error('The input "plugin_code" should be defined in the form in order to use the localization table processor.')} +return $input.val()} +LocalizationProcessor.prototype.removeLocalizationInput=function(){if(!this.localizationInput){return} +this.localizationInput.dispose() +this.localizationInput=null} +$.oc.table.processor.builderLocalization=LocalizationProcessor;}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/build.js b/server/plugins/rainlab/builder/assets/js/build.js new file mode 100644 index 0000000..965eba0 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/build.js @@ -0,0 +1,20 @@ +/* + +=require builder.dataregistry.js +=require builder.index.entity.base.js +=require builder.index.entity.plugin.js +=require builder.index.entity.databasetable.js +=require builder.index.entity.model.js +=require builder.index.entity.modelform.js +=require builder.index.entity.modellist.js +=require builder.index.entity.permission.js +=require builder.index.entity.menus.js +=require builder.index.entity.version.js +=require builder.index.entity.localization.js +=require builder.index.entity.controller.js +=require builder.index.js +=require builder.localizationinput.js +=require builder.inspector.editor.localization.js +=require builder.table.processor.localization.js + +*/ diff --git a/server/plugins/rainlab/builder/assets/js/builder.dataregistry.js b/server/plugins/rainlab/builder/assets/js/builder.dataregistry.js new file mode 100644 index 0000000..bb39ba4 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.dataregistry.js @@ -0,0 +1,170 @@ +/* + * Builder client-side plugin data registry + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var DataRegistry = function() { + this.data = {} + this.requestCache = {} + this.callbackCache = {} + + Base.call(this) + } + + /* + * Example: + * $.oc.builder.dataRegistry.set('rainlab.blog', 'model.forms', 'Categories', formsArray) + * $.oc.builder.dataRegistry.set('rainlab.blog', 'localization', null, stringsArray) // The registry contains only default language + */ + DataRegistry.prototype.set = function(plugin, type, subtype, data, params) { + this.storeData(plugin, type, subtype, data) + + if (type == 'localization' && !subtype) { + this.localizationUpdated(plugin, params) + } + } + + /* + * Example: + * $.oc.builder.dataRegistry.get($form, 'rainlab.blog', 'model.forms', 'Categories', function(data){ ... }) + */ + DataRegistry.prototype.get = function($formElement, plugin, type, subtype, callback) { + if (this.data[plugin] === undefined + || this.data[plugin][type] === undefined + || this.data[plugin][type][subtype] === undefined + || this.isCacheObsolete(this.data[plugin][type][subtype].timestamp)) { + + return this.loadDataFromServer($formElement, plugin, type, subtype, callback) + } + + callback(this.data[plugin][type][subtype].data) + } + + // INTERNAL METHODS + // ============================ + + DataRegistry.prototype.makeCacheKey = function(plugin, type, subtype) { + var key = plugin + '-' + type + + if (subtype) { + key += '-' + subtype + } + + return key + } + + DataRegistry.prototype.isCacheObsolete = function(timestamp) { + return (Date.now() - timestamp) > 60000*5 // 5 minutes cache TTL + } + + DataRegistry.prototype.loadDataFromServer = function($formElement, plugin, type, subtype, callback) { + var self = this, + cacheKey = this.makeCacheKey(plugin, type, subtype) + + if (this.requestCache[cacheKey] === undefined) { + this.requestCache[cacheKey] = $formElement.request('onPluginDataRegistryGetData', { + data: { + registry_plugin_code: plugin, + registry_data_type: type, + registry_data_subtype: subtype + } + }).done( + function(data) { + if (data.registryData === undefined) { + throw new Error('Invalid data registry response.') + } + + self.storeData(plugin, type, subtype, data.registryData) + self.applyCallbacks(cacheKey, data.registryData) + + self.requestCache[cacheKey] = undefined + } + ) + } + + this.addCallbackToQueue(callback, cacheKey) + + return this.requestCache[cacheKey] + } + + DataRegistry.prototype.addCallbackToQueue = function(callback, key) { + if (this.callbackCache[key] === undefined) { + this.callbackCache[key] = [] + } + + this.callbackCache[key].push(callback) + } + + DataRegistry.prototype.applyCallbacks = function(key, registryData) { + if (this.callbackCache[key] === undefined) { + return + } + + for (var i=this.callbackCache[key].length-1; i>=0; i--) { + this.callbackCache[key][i](registryData); + } + + delete this.callbackCache[key] + } + + DataRegistry.prototype.storeData = function(plugin, type, subtype, data) { + if (this.data[plugin] === undefined) { + this.data[plugin] = {} + } + + if (this.data[plugin][type] === undefined) { + this.data[plugin][type] = {} + } + + var dataItem = { + timestamp: Date.now(), + data: data + } + + this.data[plugin][type][subtype] = dataItem + } + + DataRegistry.prototype.clearCache = function(plugin, type) { + if (this.data[plugin] === undefined) { + return + } + + if (this.data[plugin][type] === undefined) { + return + } + + this.data[plugin][type] = undefined + } + + // LOCALIZATION-SPECIFIC METHODS + // ============================ + + DataRegistry.prototype.getLocalizationString = function($formElement, plugin, key, callback) { + this.get($formElement, plugin, 'localization', null, function(data){ + if (data[key] !== undefined) { + callback(data[key]) + return + } + + callback(key) + }) + } + + DataRegistry.prototype.localizationUpdated = function(plugin, params) { + $.oc.builder.localizationInput.updatePluginInputs(plugin) + + if (params === undefined || !params.suppressLanguageEditorUpdate) { + $.oc.builder.indexController.entityControllers.localization.languageUpdated(plugin) + } + + $.oc.builder.indexController.entityControllers.localization.updateOnScreenStrings(plugin) + } + + $.oc.builder.dataRegistry = new DataRegistry() +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.base.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.base.js new file mode 100644 index 0000000..38ff0a4 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.base.js @@ -0,0 +1,100 @@ +/* + * Base class for Builder Index entity controllers + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var EntityBase = function(typeName, indexController) { + if (typeName === undefined) { + throw new Error('The Builder entity type name should be set in the base constructor call.') + } + + if (indexController === undefined) { + throw new Error('The Builder index controller should be set when creating an entity controller.') + } + + // The type name is used mostly for referring to + // DOM objects. + this.typeName = typeName + + this.indexController = indexController + + Base.call(this) + } + + EntityBase.prototype = Object.create(BaseProto) + EntityBase.prototype.constructor = EntityBase + + EntityBase.prototype.registerHandlers = function() { + + } + + EntityBase.prototype.invokeCommand = function(command, ev) { + if (/^cmd[a-zA-Z0-9]+$/.test(command)) { + if (this[command] !== undefined) { + this[command].apply(this, [ev]) + } + else { + throw new Error('Unknown command: '+command) + } + } + else { + throw new Error('Invalid command: '+command) + } + } + + EntityBase.prototype.newTabId = function() { + return this.typeName + Math.random() + } + + EntityBase.prototype.makeTabId = function(objectName) { + return this.typeName + '-' + objectName + } + + EntityBase.prototype.getMasterTabsActivePane = function() { + return this.indexController.getMasterTabActivePane() + } + + EntityBase.prototype.getMasterTabsObject = function() { + return this.indexController.masterTabsObj + } + + EntityBase.prototype.getSelectedPlugin = function() { + var activeItem = $('#PluginList-pluginList-plugin-list > ul > li.active') + + return activeItem.data('id') + } + + EntityBase.prototype.getIndexController = function() { + return this.indexController + } + + EntityBase.prototype.updateMasterTabIdAndTitle = function($tabPane, responseData) { + var tabsObject = this.getMasterTabsObject() + + tabsObject.updateIdentifier($tabPane, responseData.tabId) + tabsObject.updateTitle($tabPane, responseData.tabTitle) + } + + EntityBase.prototype.unhideFormDeleteButton = function($tabPane) { + $('[data-control=delete-button]', $tabPane).removeClass('hide') + } + + EntityBase.prototype.forceCloseTab = function($tabPane) { + $tabPane.trigger('close.oc.tab', [{force: true}]) + } + + EntityBase.prototype.unmodifyTab = function($tabPane) { + this.indexController.unchangeTab($tabPane) + } + + $.oc.builder.entityControllers.base = EntityBase; +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.controller.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.controller.js new file mode 100644 index 0000000..1cb12e3 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.controller.js @@ -0,0 +1,109 @@ +/* + * Builder Index controller Controller entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Controller = function(indexController) { + Base.call(this, 'controller', indexController) + } + + Controller.prototype = Object.create(BaseProto) + Controller.prototype.constructor = Controller + + // PUBLIC METHODS + // ============================ + + Controller.prototype.cmdCreateController = function(ev) { + var $form = $(ev.currentTarget), + self = this, + pluginCode = $form.data('pluginCode'), + behaviorsSelected = $form.find('input[name="behaviors[]"]:checked').length, + promise = null + + // If behaviors were selected, open a new tab after the + // controller is saved. Otherwise just update the controller + // list. + if (behaviorsSelected) { + promise = this.indexController.openOrLoadMasterTab( + $form, + 'onControllerCreate', + this.makeTabId(pluginCode+'-new-controller'), + {} + ) + } + else { + promise = $form.request('onControllerCreate') + } + + promise.done(function(data){ + $form.trigger('close.oc.popup') + self.updateDataRegistry(data) + }).always($.oc.builder.indexController.hideStripeIndicatorProxy) + } + + Controller.prototype.cmdOpenController = function(ev) { + var controller = $(ev.currentTarget).data('id'), + pluginCode = $(ev.currentTarget).data('pluginCode') + + this.indexController.openOrLoadMasterTab($(ev.target), 'onControllerOpen', this.makeTabId(pluginCode+'-'+controller), { + controller: controller + }) + } + + Controller.prototype.cmdSaveController = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form'), + $inspectorContainer = $form.find('.inspector-container') + + if (!$.oc.inspector.manager.applyValuesFromContainer($inspectorContainer)) { + return + } + + $target.request('onControllerSave').done( + this.proxy(this.saveControllerDone) + ) + } + + // EVENT HANDLERS + // ============================ + + // INTERNAL METHODS + // ============================ + + Controller.prototype.saveControllerDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + } + + Controller.prototype.updateDataRegistry = function(data) { + if (data.builderResponseData.registryData !== undefined) { + var registryData = data.builderResponseData.registryData + + $.oc.builder.dataRegistry.set(registryData.pluginCode, 'controller-urls', null, registryData.urls) + } + } + + Controller.prototype.getControllerList = function() { + return $('#layout-side-panel form[data-content-id=controller] [data-control=filelist]') + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.controller = Controller; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.databasetable.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.databasetable.js new file mode 100644 index 0000000..0802fb7 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.databasetable.js @@ -0,0 +1,303 @@ +/* + * Builder Index controller Database Table entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var DatabaseTable = function(indexController) { + Base.call(this, 'databaseTable', indexController) + } + + DatabaseTable.prototype = Object.create(BaseProto) + DatabaseTable.prototype.constructor = DatabaseTable + + // PUBLIC METHODS + // ============================ + + DatabaseTable.prototype.cmdCreateTable = function(ev) { + var result = this.indexController.openOrLoadMasterTab($(ev.target), 'onDatabaseTableCreateOrOpen', this.newTabId()) + + if (result !== false) { + result.done(this.proxy(this.onTableLoaded, this)) + } + } + + DatabaseTable.prototype.cmdOpenTable = function(ev) { + var table = $(ev.currentTarget).data('id'), + result = this.indexController.openOrLoadMasterTab($(ev.target), 'onDatabaseTableCreateOrOpen', this.makeTabId(table), { + table_name: table + }) + + if (result !== false) { + result.done(this.proxy(this.onTableLoaded, this)) + } + } + + DatabaseTable.prototype.cmdSaveTable = function(ev) { + var $target = $(ev.currentTarget) + + // The process of saving a database table: + // - validate client-side + // - validate columns on the server + // - display a popup asking to enter the migration text + // - generate the migration on the server and execute it + // - drop the form modified flag + + if (!this.validateTable($target)) { + return + } + + var data = { + 'columns': this.getTableData($target) + } + + $target.popup({ + extraData: data, + handler: 'onDatabaseTableValidateAndShowPopup' + }) + } + + DatabaseTable.prototype.cmdSaveMigration = function(ev) { + var $target = $(ev.currentTarget) + + $.oc.stripeLoadIndicator.show() + $target.request('onDatabaseTableMigrationApply').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.saveMigrationDone) + ) + } + + DatabaseTable.prototype.cmdDeleteTable = function(ev) { + var $target = $(ev.currentTarget) + $.oc.confirm($target.data('confirm'), this.proxy(this.deleteConfirmed)) + } + + DatabaseTable.prototype.cmdUnModifyForm = function() { + var $masterTabPane = this.getMasterTabsActivePane() + this.unmodifyTab($masterTabPane) + } + + DatabaseTable.prototype.cmdAddTimestamps = function(ev) { + var $target = $(ev.currentTarget), + added = this.addTimeStampColumns($target, ['created_at', 'updated_at']) + + if (!added) { + alert($target.closest('form').attr('data-lang-timestamps-exist')) + } + } + + DatabaseTable.prototype.cmdAddSoftDelete = function(ev) { + var $target = $(ev.currentTarget), + added = this.addTimeStampColumns($target, ['deleted_at']) + + if (!added) { + alert($target.closest('form').attr('data-lang-soft-deleting-exist')) + } + } + + // EVENT HANDLERS + // ============================ + + DatabaseTable.prototype.onTableCellChanged = function(ev, column, value, rowIndex) { + var $target = $(ev.target) + + if ($target.data('alias') != 'columns') { + return + } + + if ($target.closest('form').data('entity') != 'database') { + return + } + + // Some migration-related rules are enforced here: + // + // 1. Checking Autoincrement checkbox automatically checks the Unsigned checkbox (this corresponds to the + // logic internally implemented in Laravel schema builder) and PK + // 2. Unchecking Unsigned unchecks Autoincrement + // 3. Checking the PK column unchecks Nullable + // 4. Checking Nullable unchecks PK + // 6. Unchecking the PK unchecks Autoincrement + + var updatedRow = {} + + if (column == 'auto_increment' && value) { + updatedRow.unsigned = 1 + updatedRow.primary_key = 1 + } + + if (column == 'unsigned' && !value) { + updatedRow.auto_increment = 0 + } + + if (column == 'primary_key' && value) { + updatedRow.allow_null = 0 + } + + if (column == 'allow_null' && value) { + updatedRow.primary_key = 0 + } + + if (column == 'primary_key' && !value) { + updatedRow.auto_increment = 0 + } + + $target.table('setRowValues', rowIndex, updatedRow) + } + + DatabaseTable.prototype.onTableLoaded = function() { + $(document).trigger('render') + + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form'), + $toolbar = $masterTabPane.find('div[data-control=table] div.toolbar'), + $button = $('') + + $button.text($form.attr('data-lang-add-timestamps')); + $toolbar.append($button) + + $button = $('') + $button.text($form.attr('data-lang-add-soft-delete')); + $toolbar.append($button) + } + + // INTERNAL METHODS + // ============================ + + DatabaseTable.prototype.registerHandlers = function() { + this.indexController.$masterTabs.on('oc.tableCellChanged', this.proxy(this.onTableCellChanged)) + } + + DatabaseTable.prototype.validateTable = function($target) { + var tableObj = this.getTableControlObject($target) + + tableObj.unfocusTable() + return tableObj.validate() + } + + DatabaseTable.prototype.getTableData = function($target) { + var tableObj = this.getTableControlObject($target) + + return tableObj.dataSource.getAllData() + } + + DatabaseTable.prototype.getTableControlObject = function($target) { + var $form = $target.closest('form'), + $table = $form.find('[data-control=table]'), + tableObj = $table.data('oc.table') + + if (!tableObj) { + throw new Error('Table object is not found on the database table tab') + } + + return tableObj + } + + DatabaseTable.prototype.saveMigrationDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + $('#builderTableMigrationPopup').trigger('close.oc.popup') + + var $masterTabPane = this.getMasterTabsActivePane(), + tabsObject = this.getMasterTabsObject() + + if (data.builderResponseData.operation != 'delete') { + $masterTabPane.find('input[name=table_name]').val(data.builderResponseData.builderObjectName) + this.updateMasterTabIdAndTitle($masterTabPane, data.builderResponseData) + this.unhideFormDeleteButton($masterTabPane) + + this.getTableList().fileList('markActive', data.builderResponseData.tabId) + this.getIndexController().unchangeTab($masterTabPane) + } + else { + this.forceCloseTab($masterTabPane) + } + + $.oc.builder.dataRegistry.clearCache(data.builderResponseData.pluginCode, 'model-columns') + } + + DatabaseTable.prototype.getTableList = function() { + return $('#layout-side-panel form[data-content-id=database] [data-control=filelist]') + } + + DatabaseTable.prototype.deleteConfirmed = function() { + var $masterTabPane = this.getMasterTabsActivePane() + + $masterTabPane.find('form').popup({ + handler: 'onDatabaseTableShowDeletePopup' + }) + } + + DatabaseTable.prototype.getColumnNames = function($target) { + var tableObj = this.getTableControlObject($target) + + tableObj.unfocusTable() + + var data = this.getTableData($target), + result = [] + + for (var index in data) { + if (data[index].name !== undefined) { + result.push($.trim(data[index].name)) + } + } + + return result + } + + DatabaseTable.prototype.addTimeStampColumns = function($target, columns) + { + var existingColumns = this.getColumnNames($target), + added = false + + for (var index in columns) { + var column = columns[index] + + if ($.inArray(column, existingColumns) == -1) { + this.addTimeStampColumn($target, column) + added = true + } + } + + if (added) { + $target.trigger('change') + } + + return added + } + + DatabaseTable.prototype.addTimeStampColumn = function($target, column) { + var tableObj = this.getTableControlObject($target), + currentData = this.getTableData($target), + rowData = { + name: column, + type: 'timestamp', + 'default': null, + allow_null: true // Simplifies the case when a timestamp is added to a table with data + } + + tableObj.addRecord('bottom', true) + tableObj.setRowValues(currentData.length-1, rowData) + + // Forces the table to apply values + // from the data source + tableObj.addRecord('bottom', false) + tableObj.deleteRecord() + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.databaseTable = DatabaseTable; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.localization.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.localization.js new file mode 100644 index 0000000..40f92fe --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.localization.js @@ -0,0 +1,282 @@ +/* + * Builder Index controller Localization entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Localization = function(indexController) { + Base.call(this, 'localization', indexController) + } + + Localization.prototype = Object.create(BaseProto) + Localization.prototype.constructor = Localization + + // PUBLIC METHODS + // ============================ + + Localization.prototype.cmdCreateLanguage = function(ev) { + this.indexController.openOrLoadMasterTab($(ev.target), 'onLanguageCreateOrOpen', this.newTabId()) + } + + Localization.prototype.cmdOpenLanguage = function(ev) { + var language = $(ev.currentTarget).data('id'), + pluginCode = $(ev.currentTarget).data('pluginCode') + + this.indexController.openOrLoadMasterTab($(ev.target), 'onLanguageCreateOrOpen', this.makeTabId(pluginCode+'-'+language), { + original_language: language + }) + } + + Localization.prototype.cmdSaveLanguage = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form') + + $target.request('onLanguageSave').done( + this.proxy(this.saveLanguageDone) + ) + } + + Localization.prototype.cmdDeleteLanguage = function(ev) { + var $target = $(ev.currentTarget) + $.oc.confirm($target.data('confirm'), this.proxy(this.deleteConfirmed)) + } + + Localization.prototype.cmdCopyMissingStrings = function(ev) { + var $form = $(ev.currentTarget), + language = $form.find('select[name=language]').val(), + $masterTabPane = this.getMasterTabsActivePane() + + $form.trigger('close.oc.popup') + + $.oc.stripeLoadIndicator.show() + $masterTabPane.find('form').request('onLanguageCopyStringsFrom', { + data: { + copy_from: language + } + }).always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.copyStringsFromDone) + ) + } + + // EVENT HANDLERS + // ============================ + + // INTERNAL BUILDER API + // ============================ + + Localization.prototype.languageUpdated = function(plugin) { + var languageForm = this.findDefaultLanguageForm(plugin) + + if (!languageForm) { + return + } + + var $languageForm = $(languageForm) + + if (!$languageForm.hasClass('oc-data-changed')) { + this.updateLanguageFromServer($languageForm) + } + else { + // If there are changes - merge language from server + // in the background. As this operation is not 100% + // reliable, it could be a good idea to display a + // warning when the user navigates to the tab. + + this.mergeLanguageFromServer($languageForm) + } + } + + Localization.prototype.updateOnScreenStrings = function(plugin) { + var stringElements = document.body.querySelectorAll('span[data-localization-key][data-plugin="'+plugin+'"]') + + $.oc.builder.dataRegistry.get($('#builder-plugin-selector-panel form'), plugin, 'localization', null, function(data){ + for (var i=stringElements.length-1; i>=0; i--) { + var stringElement = stringElements[i], + stringKey = stringElement.getAttribute('data-localization-key') + + if (data[stringKey] !== undefined) { + stringElement.textContent = data[stringKey] + } + else { + stringElement.textContent = stringKey + } + } + }) + } + + // INTERNAL METHODS + // ============================ + + Localization.prototype.saveLanguageDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + $masterTabPane.find('input[name=original_language]').val(data.builderResponseData.language) + this.updateMasterTabIdAndTitle($masterTabPane, data.builderResponseData) + this.unhideFormDeleteButton($masterTabPane) + + this.getLanguageList().fileList('markActive', data.builderResponseData.tabId) + this.getIndexController().unchangeTab($masterTabPane) + + if (data.builderResponseData.registryData !== undefined) { + var registryData = data.builderResponseData.registryData + + $.oc.builder.dataRegistry.set(registryData.pluginCode, 'localization', null, registryData.strings, {suppressLanguageEditorUpdate: true}) + $.oc.builder.dataRegistry.set(registryData.pluginCode, 'localization', 'sections', registryData.sections) + } + } + + Localization.prototype.getLanguageList = function() { + return $('#layout-side-panel form[data-content-id=localization] [data-control=filelist]') + } + + Localization.prototype.getCodeEditor = function($tab) { + return $tab.find('div[data-field-name=strings] div[data-control=codeeditor]').data('oc.codeEditor').editor + } + + Localization.prototype.deleteConfirmed = function() { + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form') + + $.oc.stripeLoadIndicator.show() + $form.request('onLanguageDelete').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.deleteDone) + ) + } + + Localization.prototype.deleteDone = function() { + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + this.forceCloseTab($masterTabPane) + } + + Localization.prototype.copyStringsFromDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var responseData = data.builderResponseData, + $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form'), + codeEditor = this.getCodeEditor($masterTabPane), + newStringMessage = $form.data('newStringMessage'), + mismatchMessage = $form.data('structureMismatch') + + codeEditor.getSession().setValue(responseData.strings) + + var annotations = [] + for (var i=responseData.updatedLines.length-1; i>=0; i--) { + var line = responseData.updatedLines[i] + + annotations.push({ + row: line, + column: 0, + text: newStringMessage, + type: 'warning' + }) + } + + codeEditor.getSession().setAnnotations(annotations) + + if (responseData.mismatch) { + $.oc.alert(mismatchMessage) + } + } + + Localization.prototype.findDefaultLanguageForm = function(plugin) { + var forms = document.body.querySelectorAll('form[data-entity=localization]') + + for (var i=forms.length-1; i>=0; i--) { + var form = forms[i], + pluginInput = form.querySelector('input[name=plugin_code]'), + languageInput = form.querySelector('input[name=original_language]') + + if (!pluginInput || pluginInput.value != plugin) { + continue + } + + if (!languageInput) { + continue + } + + if (form.getAttribute('data-default-language') == languageInput.value) { + return form + } + } + + return null + } + + Localization.prototype.updateLanguageFromServer = function($languageForm) { + var self = this + + $languageForm.request('onLanguageGetStrings').done(function(data) { + self.updateLanguageFromServerDone($languageForm, data) + }) + } + + Localization.prototype.updateLanguageFromServerDone = function($languageForm, data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var responseData = data.builderResponseData, + $tabPane = $languageForm.closest('.tab-pane'), + codeEditor = this.getCodeEditor($tabPane) + + if (!responseData.strings) { + return + } + + codeEditor.getSession().setValue(responseData.strings) + this.unmodifyTab($tabPane) + } + + Localization.prototype.mergeLanguageFromServer = function($languageForm) { + var language = $languageForm.find('input[name=original_language]').val(), + self = this + + $languageForm.request('onLanguageCopyStringsFrom', { + data: { + copy_from: language + } + }).done(function(data) { + self.mergeLanguageFromServerDone($languageForm, data) + }) + } + + Localization.prototype.mergeLanguageFromServerDone = function($languageForm, data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var responseData = data.builderResponseData, + $tabPane = $languageForm.closest('.tab-pane'), + codeEditor = this.getCodeEditor($tabPane) + + codeEditor.getSession().setValue(responseData.strings) + codeEditor.getSession().setAnnotations([]) + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.localization = Localization; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.menus.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.menus.js new file mode 100644 index 0000000..5330bfb --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.menus.js @@ -0,0 +1,86 @@ +/* + * Builder Index controller Menus entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Menus = function(indexController) { + Base.call(this, 'menus', indexController) + } + + Menus.prototype = Object.create(BaseProto) + Menus.prototype.constructor = Menus + + // PUBLIC METHODS + // ============================ + + Menus.prototype.cmdOpenMenus = function(ev) { + var currentPlugin = this.getSelectedPlugin() + + if (!currentPlugin) { + alert('Please select a plugin first') + return + } + + this.indexController.openOrLoadMasterTab($(ev.target), 'onMenusOpen', this.makeTabId(currentPlugin)) + } + + Menus.prototype.cmdSaveMenus = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form'), + $inspectorContainer = $form.find('.inspector-container') + + if (!$.oc.inspector.manager.applyValuesFromContainer($inspectorContainer)) { + return + } + + var menus = $.oc.builder.menubuilder.controller.getJson($form.get(0)) + + $target.request('onMenusSave', { + data: { + menus: menus + } + }).done( + this.proxy(this.saveMenusDone) + ) + } + + Menus.prototype.cmdAddMainMenuItem = function(ev) { + $.oc.builder.menubuilder.controller.addMainMenuItem(ev) + } + + Menus.prototype.cmdAddSideMenuItem = function(ev) { + $.oc.builder.menubuilder.controller.addSideMenuItem(ev) + } + + Menus.prototype.cmdDeleteMenuItem = function(ev) { + $.oc.builder.menubuilder.controller.deleteMenuItem(ev) + } + + // INTERNAL METHODS + // ============================ + + Menus.prototype.saveMenusDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.menus = Menus; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.model.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.model.js new file mode 100644 index 0000000..10a1cd9 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.model.js @@ -0,0 +1,72 @@ +/* + * Builder Index controller Model entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Model = function(indexController) { + Base.call(this, 'model', indexController) + } + + Model.prototype = Object.create(BaseProto) + Model.prototype.constructor = Model + + // PUBLIC METHODS + // ============================ + + Model.prototype.cmdCreateModel = function(ev) { + var $target = $(ev.currentTarget) + + $target.one('shown.oc.popup', this.proxy(this.onModelPopupShown)) + + $target.popup({ + handler: 'onModelLoadPopup' + }) + } + + Model.prototype.cmdApplyModelSettings = function(ev) { + var $form = $(ev.currentTarget), + self = this + + $.oc.stripeLoadIndicator.show() + $form.request('onModelSave').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done(function(data){ + $form.trigger('close.oc.popup') + + self.applyModelSettingsDone(data) + }) + } + + // EVENT HANDLERS + // ============================ + + Model.prototype.onModelPopupShown = function(ev, button, popup) { + $(popup).find('input[name=className]').focus() + } + + // INTERNAL METHODS + // ============================ + + Model.prototype.applyModelSettingsDone = function(data) { + if (data.builderResponseData.registryData !== undefined) { + var registryData = data.builderResponseData.registryData + + $.oc.builder.dataRegistry.set(registryData.pluginCode, 'model-classes', null, registryData.models) + } + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.model = Model; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.modelform.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.modelform.js new file mode 100644 index 0000000..1361845 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.modelform.js @@ -0,0 +1,155 @@ +/* + * Builder Index controller Model Form entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var ModelForm = function(indexController) { + Base.call(this, 'modelForm', indexController) + } + + ModelForm.prototype = Object.create(BaseProto) + ModelForm.prototype.constructor = ModelForm + + // PUBLIC METHODS + // ============================ + + ModelForm.prototype.cmdCreateForm = function(ev) { + var $link = $(ev.currentTarget), + data = { + model_class: $link.data('modelClass') + } + + this.indexController.openOrLoadMasterTab($link, 'onModelFormCreateOrOpen', this.newTabId(), data) + } + + ModelForm.prototype.cmdSaveForm = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form'), + $rootContainer = $('[data-root-control-wrapper] > [data-control-container]', $form), + $inspectorContainer = $form.find('.inspector-container'), + controls = $.oc.builder.formbuilder.domToPropertyJson.convert($rootContainer.get(0)) + + if (!$.oc.inspector.manager.applyValuesFromContainer($inspectorContainer)) { + return + } + + if (controls === false) { + $.oc.flashMsg({ + 'text': $.oc.builder.formbuilder.domToPropertyJson.getLastError(), + 'class': 'error', + 'interval': 5 + }) + + return + } + + var data = { + controls: controls + } + + $target.request('onModelFormSave', { + data: data + }).done( + this.proxy(this.saveFormDone) + ) + } + + ModelForm.prototype.cmdOpenForm = function(ev) { + var form = $(ev.currentTarget).data('form'), + model = $(ev.currentTarget).data('modelClass') + + this.indexController.openOrLoadMasterTab($(ev.target), 'onModelFormCreateOrOpen', this.makeTabId(model+'-'+form), { + file_name: form, + model_class: model + }) + } + + ModelForm.prototype.cmdDeleteForm = function(ev) { + var $target = $(ev.currentTarget) + $.oc.confirm($target.data('confirm'), this.proxy(this.deleteConfirmed)) + } + + ModelForm.prototype.cmdAddControl = function(ev) { + $.oc.builder.formbuilder.controlPalette.addControl(ev) + } + + ModelForm.prototype.cmdUndockControlPalette = function(ev) { + $.oc.builder.formbuilder.controlPalette.undockFromContainer(ev) + } + + ModelForm.prototype.cmdDockControlPalette = function(ev) { + $.oc.builder.formbuilder.controlPalette.dockToContainer(ev) + } + + ModelForm.prototype.cmdCloseControlPalette = function(ev) { + $.oc.builder.formbuilder.controlPalette.closeInContainer(ev) + } + + // INTERNAL METHODS + // ============================ + + ModelForm.prototype.saveFormDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + $masterTabPane.find('input[name=file_name]').val(data.builderResponseData.builderObjectName) + this.updateMasterTabIdAndTitle($masterTabPane, data.builderResponseData) + this.unhideFormDeleteButton($masterTabPane) + + this.getModelList().fileList('markActive', data.builderResponseData.tabId) + this.getIndexController().unchangeTab($masterTabPane) + + this.updateDataRegistry(data) + } + + ModelForm.prototype.updateDataRegistry = function(data) { + if (data.builderResponseData.registryData !== undefined) { + var registryData = data.builderResponseData.registryData + + $.oc.builder.dataRegistry.set(registryData.pluginCode, 'model-forms', registryData.modelClass, registryData.forms) + } + } + + ModelForm.prototype.deleteConfirmed = function() { + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form') + + $.oc.stripeLoadIndicator.show() + $form.request('onModelFormDelete').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.deleteDone) + ) + } + + ModelForm.prototype.deleteDone = function(data) { + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + this.forceCloseTab($masterTabPane) + + this.updateDataRegistry(data) + } + + ModelForm.prototype.getModelList = function() { + return $('#layout-side-panel form[data-content-id=models] [data-control=filelist]') + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.modelForm = ModelForm; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.modellist.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.modellist.js new file mode 100644 index 0000000..7f8be68 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.modellist.js @@ -0,0 +1,304 @@ +/* + * Builder Index controller Model List entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var ModelList = function(indexController) { + this.cachedModelFieldsPromises = {} + + Base.call(this, 'modelList', indexController) + } + + ModelList.prototype = Object.create(BaseProto) + ModelList.prototype.constructor = ModelList + + ModelList.prototype.registerHandlers = function() { + $(document).on('autocompleteitems.oc.table', 'form[data-sub-entity="model-list"] [data-control=table]', this.proxy(this.onAutocompleteItems)) + } + + // PUBLIC METHODS + // ============================ + + ModelList.prototype.cmdCreateList = function(ev) { + var $link = $(ev.currentTarget), + data = { + model_class: $link.data('modelClass') + } + + var result = this.indexController.openOrLoadMasterTab($link, 'onModelListCreateOrOpen', this.newTabId(), data) + + if (result !== false) { + result.done(this.proxy(this.onListLoaded, this)) + } + } + + ModelList.prototype.cmdSaveList = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form') + + if (!this.validateTable($target)) { + return + } + + $target.request('onModelListSave', { + data: { + columns: this.getTableData($target) + } + }).done( + this.proxy(this.saveListDone) + ) + } + + ModelList.prototype.cmdOpenList = function(ev) { + var list = $(ev.currentTarget).data('list'), + model = $(ev.currentTarget).data('modelClass') + + var result = this.indexController.openOrLoadMasterTab($(ev.target), 'onModelListCreateOrOpen', this.makeTabId(model+'-'+list), { + file_name: list, + model_class: model + }) + + if (result !== false) { + result.done(this.proxy(this.onListLoaded, this)) + } + } + + ModelList.prototype.cmdDeleteList = function(ev) { + var $target = $(ev.currentTarget) + $.oc.confirm($target.data('confirm'), this.proxy(this.deleteConfirmed)) + } + + ModelList.prototype.cmdAddDatabaseColumns = function(ev) { + var $target = $(ev.currentTarget) + + $.oc.stripeLoadIndicator.show() + $target.request('onModelListLoadDatabaseColumns').done( + this.proxy(this.databaseColumnsLoaded) + ).always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ) + } + + // INTERNAL METHODS + // ============================ + + ModelList.prototype.saveListDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + $masterTabPane.find('input[name=file_name]').val(data.builderResponseData.builderObjectName) + this.updateMasterTabIdAndTitle($masterTabPane, data.builderResponseData) + this.unhideFormDeleteButton($masterTabPane) + + this.getModelList().fileList('markActive', data.builderResponseData.tabId) + this.getIndexController().unchangeTab($masterTabPane) + + this.updateDataRegistry(data) + } + + ModelList.prototype.deleteConfirmed = function() { + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form') + + $.oc.stripeLoadIndicator.show() + $form.request('onModelListDelete').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.deleteDone) + ) + } + + ModelList.prototype.deleteDone = function(data) { + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + this.forceCloseTab($masterTabPane) + + this.updateDataRegistry(data) + } + + ModelList.prototype.getTableControlObject = function($target) { + var $form = $target.closest('form'), + $table = $form.find('[data-control=table]'), + tableObj = $table.data('oc.table') + + if (!tableObj) { + throw new Error('Table object is not found on the model list tab') + } + + return tableObj + } + + ModelList.prototype.getModelList = function() { + return $('#layout-side-panel form[data-content-id=models] [data-control=filelist]') + } + + ModelList.prototype.validateTable = function($target) { + var tableObj = this.getTableControlObject($target) + + tableObj.unfocusTable() + return tableObj.validate() + } + + ModelList.prototype.getTableData = function($target) { + var tableObj = this.getTableControlObject($target) + + return tableObj.dataSource.getAllData() + } + + ModelList.prototype.loadModelFields = function(table, callback) { + var $form = $(table).closest('form'), + modelClass = $form.find('input[name=model_class]').val(), + cachedFields = $form.data('oc.model-field-cache') + + if (cachedFields !== undefined) { + callback(cachedFields) + + return + } + + if (this.cachedModelFieldsPromises[modelClass] === undefined) { + this.cachedModelFieldsPromises[modelClass] = $form.request('onModelFormGetModelFields', { + data: { + 'as_plain_list': 1 + } + }) + } + + if (callback === undefined) { + return + } + + this.cachedModelFieldsPromises[modelClass].done(function(data){ + $form.data('oc.model-field-cache', data.responseData.options) + + callback(data.responseData.options) + }) + } + + ModelList.prototype.updateDataRegistry = function(data) { + if (data.builderResponseData.registryData !== undefined) { + var registryData = data.builderResponseData.registryData + + $.oc.builder.dataRegistry.set(registryData.pluginCode, 'model-lists', registryData.modelClass, registryData.lists) + + $.oc.builder.dataRegistry.clearCache(registryData.pluginCode, 'plugin-lists') + } + } + + ModelList.prototype.databaseColumnsLoaded = function(data) { + if (!$.isArray(data.responseData.columns)) { + alert('Invalid server response') + } + + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form'), + existingColumns = this.getColumnNames($form), + columnsAdded = false + + for (var i in data.responseData.columns) { + var column = data.responseData.columns[i], + type = this.mapType(column.type) + + if ($.inArray(column.name, existingColumns) !== -1) { + continue + } + + this.addColumn($form, column.name, type) + columnsAdded = true + } + + if (!columnsAdded) { + alert($form.attr('data-lang-all-database-columns-exist')) + } + else { + $form.trigger('change') + } + } + + ModelList.prototype.mapType = function(type) { + switch (type) { + case 'integer' : return 'number' + case 'timestamp' : return 'datetime' + default: return 'text' + } + } + + ModelList.prototype.addColumn = function($target, column, type) { + var tableObj = this.getTableControlObject($target), + currentData = this.getTableData($target), + rowData = { + field: column, + label: column, + type: type + } + + tableObj.addRecord('bottom', true) + tableObj.setRowValues(currentData.length-1, rowData) + + // Forces the table to apply values + // from the data source + tableObj.addRecord('bottom', false) + tableObj.deleteRecord() + } + + ModelList.prototype.getColumnNames = function($target) { + var tableObj = this.getTableControlObject($target) + + tableObj.unfocusTable() + + var data = this.getTableData($target), + result = [] + + for (var index in data) { + if (data[index].field !== undefined) { + result.push($.trim(data[index].field)) + } + } + + return result + } + + // EVENT HANDLERS + // ============================ + + ModelList.prototype.onAutocompleteItems = function(ev, data) { + if (data.columnConfiguration.fillFrom === 'model-fields') { + ev.preventDefault() + + this.loadModelFields(ev.target, data.callback) + + return false + } + } + + ModelList.prototype.onListLoaded = function() { + $(document).trigger('render') + + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form'), + $toolbar = $masterTabPane.find('div[data-control=table] div.toolbar'), + $button = $('') + + $button.text($form.attr('data-lang-add-database-columns')); + $toolbar.append($button) + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.modelList = ModelList; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.permission.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.permission.js new file mode 100644 index 0000000..a74732b --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.permission.js @@ -0,0 +1,122 @@ +/* + * Builder Index controller Permission entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Permission = function(indexController) { + Base.call(this, 'permissions', indexController) + } + + Permission.prototype = Object.create(BaseProto) + Permission.prototype.constructor = Permission + + Permission.prototype.registerHandlers = function() { + this.indexController.$masterTabs.on('oc.tableNewRow', this.proxy(this.onTableRowCreated)) + } + + // PUBLIC METHODS + // ============================ + + Permission.prototype.cmdOpenPermissions = function(ev) { + var currentPlugin = this.getSelectedPlugin() + + if (!currentPlugin) { + alert('Please select a plugin first') + return + } + + this.indexController.openOrLoadMasterTab($(ev.target), 'onPermissionsOpen', this.makeTabId(currentPlugin)) + } + + Permission.prototype.cmdSavePermissions = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form') + + if (!this.validateTable($target)) { + return + } + + $target.request('onPermissionsSave', { + data: { + permissions: this.getTableData($target) + } + }).done( + this.proxy(this.savePermissionsDone) + ) + } + + // INTERNAL METHODS + // ============================ + + Permission.prototype.getTableControlObject = function($target) { + var $form = $target.closest('form'), + $table = $form.find('[data-control=table]'), + tableObj = $table.data('oc.table') + + if (!tableObj) { + throw new Error('Table object is not found on permissions tab') + } + + return tableObj + } + + Permission.prototype.validateTable = function($target) { + var tableObj = this.getTableControlObject($target) + + tableObj.unfocusTable() + return tableObj.validate() + } + + Permission.prototype.getTableData = function($target) { + var tableObj = this.getTableControlObject($target) + + return tableObj.dataSource.getAllData() + } + + Permission.prototype.savePermissionsDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + $.oc.builder.dataRegistry.clearCache(data.builderResponseData.pluginCode, 'permissions') + } + + // EVENT HANDLERS + // ============================ + + Permission.prototype.onTableRowCreated = function(ev, recordData) { + var $target = $(ev.target) + + if ($target.data('alias') != 'permissions') { + return + } + + var $form = $target.closest('form') + + if ($form.data('entity') != 'permissions') { + return + } + + var pluginCode = $form.find('input[name=plugin_code]').val() + + recordData.permission = pluginCode.toLowerCase() + '.'; + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.permission = Permission; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.plugin.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.plugin.js new file mode 100644 index 0000000..7468e3e --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.plugin.js @@ -0,0 +1,116 @@ +/* + * Builder Index controller Plugin entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Plugin = function(indexController) { + Base.call(this, 'plugin', indexController) + + this.popupZIndex = 5050 // This popup should be above the flyout overlay, which z-index is 5000 + } + + Plugin.prototype = Object.create(BaseProto) + Plugin.prototype.constructor = Plugin + + // PUBLIC METHODS + // ============================ + + Plugin.prototype.cmdMakePluginActive = function(ev) { + var $target = $(ev.currentTarget), + selectedPluginCode = $target.data('pluginCode') + + this.makePluginActive(selectedPluginCode) + } + + Plugin.prototype.cmdCreatePlugin = function(ev) { + var $target = $(ev.currentTarget) + + $target.one('shown.oc.popup', this.proxy(this.onPluginPopupShown)) + + $target.popup({ + handler: 'onPluginLoadPopup', + zIndex: this.popupZIndex + }) + } + + Plugin.prototype.cmdApplyPluginSettings = function(ev) { + var $form = $(ev.currentTarget), + self = this + + $.oc.stripeLoadIndicator.show() + $form.request('onPluginSave').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done(function(data){ + $form.trigger('close.oc.popup') + + self.applyPluginSettingsDone(data) + }) + } + + Plugin.prototype.cmdEditPluginSettings = function(ev) { + var $target = $(ev.currentTarget) + + $target.one('shown.oc.popup', this.proxy(this.onPluginPopupShown)) + + $target.popup({ + handler: 'onPluginLoadPopup', + zIndex: this.popupZIndex, + extraData: { + pluginCode: $target.data('pluginCode') + } + }) + } + + // EVENT HANDLERS + // ============================ + + Plugin.prototype.onPluginPopupShown = function(ev, button, popup) { + $(popup).find('input[name=name]').focus() + } + + // INTERNAL METHODS + // ============================ + + Plugin.prototype.applyPluginSettingsDone = function(data) { + if (data.responseData !== undefined && data.responseData.isNewPlugin !== undefined) { + this.makePluginActive(data.responseData.pluginCode, true) + } + } + + Plugin.prototype.makePluginActive = function(pluginCode, updatePluginList) { + var $form = $('#builder-plugin-selector-panel form').first() + + $.oc.stripeLoadIndicator.show() + $form.request('onPluginSetActive', { + data: { + pluginCode: pluginCode, + updatePluginList: (updatePluginList ? 1 : 0) + } + }).always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.makePluginActiveDone) + ) + } + + Plugin.prototype.makePluginActiveDone = function(data) { + var pluginCode = data.responseData.pluginCode + + $('#builder-plugin-selector-panel [data-control=filelist]').fileList('markActive', pluginCode) + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.plugin = Plugin; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.entity.version.js b/server/plugins/rainlab/builder/assets/js/builder.index.entity.version.js new file mode 100644 index 0000000..f63a278 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.entity.version.js @@ -0,0 +1,272 @@ +/* + * Builder Index controller Version entity controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.entityControllers === undefined) + $.oc.builder.entityControllers = {} + + var Base = $.oc.builder.entityControllers.base, + BaseProto = Base.prototype + + var Version = function(indexController) { + Base.call(this, 'version', indexController) + + this.hiddenHints = {} + } + + Version.prototype = Object.create(BaseProto) + Version.prototype.constructor = Version + + // PUBLIC METHODS + // ============================ + + Version.prototype.cmdCreateVersion = function(ev) { + var $link = $(ev.currentTarget), + versionType = $link.data('versionType') + + this.indexController.openOrLoadMasterTab($link, 'onVersionCreateOrOpen', this.newTabId(), { + version_type: versionType + }) + } + + Version.prototype.cmdSaveVersion = function(ev) { + var $target = $(ev.currentTarget), + $form = $target.closest('form') + + $target.request('onVersionSave').done( + this.proxy(this.saveVersionDone) + ) + } + + Version.prototype.cmdOpenVersion = function(ev) { + var versionNumber = $(ev.currentTarget).data('id'), + pluginCode = $(ev.currentTarget).data('pluginCode') + + this.indexController.openOrLoadMasterTab($(ev.target), 'onVersionCreateOrOpen', this.makeTabId(pluginCode+'-'+versionNumber), { + original_version: versionNumber + }) + } + + Version.prototype.cmdDeleteVersion = function(ev) { + var $target = $(ev.currentTarget) + $.oc.confirm($target.data('confirm'), this.proxy(this.deleteConfirmed)) + } + + Version.prototype.cmdApplyVersion = function(ev) { + var $target = $(ev.currentTarget), + $pane = $target.closest('div.tab-pane'), + self = this + + this.showHintPopup($pane, 'builder-version-apply', function(){ + $target.request('onVersionApply').done( + self.proxy(self.applyVersionDone) + ) + }) + } + + Version.prototype.cmdRollbackVersion = function(ev) { + var $target = $(ev.currentTarget), + $pane = $target.closest('div.tab-pane'), + self = this + + + this.showHintPopup($pane, 'builder-version-rollback', function(){ + $target.request('onVersionRollback').done( + self.proxy(self.rollbackVersionDone) + ) + }) + } + + // INTERNAL METHODS + // ============================ + + Version.prototype.saveVersionDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + this.updateUiAfterSave($masterTabPane, data) + + if (!data.builderResponseData.isApplied) { + this.showSavedNotAppliedHint($masterTabPane) + } + } + + Version.prototype.showSavedNotAppliedHint = function($masterTabPane) { + this.showHintPopup($masterTabPane, 'builder-version-save-unapplied') + } + + Version.prototype.showHintPopup = function($masterTabPane, code, callback) { + if (this.getDontShowHintAgain(code, $masterTabPane)) { + if (callback) { + callback.apply(this) + } + + return + } + + $masterTabPane.one('hide.oc.popup', this.proxy(this.onHintPopupHide)) + + if (callback) { + $masterTabPane.one('shown.oc.popup', function(ev, $element, $modal) { + $modal.find('form').one('submit', function(ev) { + callback.apply(this) + ev.preventDefault() + + $(ev.target).trigger('close.oc.popup') + + return false + }) + }) + } + + $masterTabPane.popup({ + content: this.getPopupContent($masterTabPane, code) + }) + } + + Version.prototype.onHintPopupHide = function(ev, $element, $modal) { + var cbValue = $modal.find('input[type=checkbox][name=dont_show_again]').is(':checked'), + code = $modal.find('input[type=hidden][name=hint_code]').val() + + $modal.find('form').off('submit') + + if (!cbValue) { + return + } + + var $form = this.getMasterTabsActivePane().find('form[data-entity="versions"]') + + $form.request('onHideBackendHint', { + data: { + name: code + } + }) + + this.setDontShowHintAgain(code) + } + + Version.prototype.setDontShowHintAgain = function(code) { + this.hiddenHints[code] = true + } + + Version.prototype.getDontShowHintAgain = function(code, $pane) { + if (this.hiddenHints[code] !== undefined) { + return this.hiddenHints[code] + } + + return $pane.find('input[type=hidden][data-hint-hidden="'+code+'"]').val() == "true" + } + + Version.prototype.getPopupContent = function($pane, code) { + var template = $pane.find('script[data-version-hint-template="'+code+'"]') + + if (template.length === 0) { + throw new Error('Version popup template not found: '+code) + } + + return template.html() + } + + Version.prototype.updateUiAfterSave = function($masterTabPane, data) { + $masterTabPane.find('input[name=original_version]').val(data.builderResponseData.savedVersion) + this.updateMasterTabIdAndTitle($masterTabPane, data.builderResponseData) + this.unhideFormDeleteButton($masterTabPane) + + this.getVersionList().fileList('markActive', data.builderResponseData.tabId) + this.getIndexController().unchangeTab($masterTabPane) + } + + Version.prototype.deleteConfirmed = function() { + var $masterTabPane = this.getMasterTabsActivePane(), + $form = $masterTabPane.find('form') + + $.oc.stripeLoadIndicator.show() + $form.request('onVersionDelete').always( + $.oc.builder.indexController.hideStripeIndicatorProxy + ).done( + this.proxy(this.deleteDone) + ) + } + + Version.prototype.deleteDone = function() { + var $masterTabPane = this.getMasterTabsActivePane() + + this.getIndexController().unchangeTab($masterTabPane) + this.forceCloseTab($masterTabPane) + } + + Version.prototype.applyVersionDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + this.updateUiAfterSave($masterTabPane, data) + + this.updateVersionsButtons() + } + + Version.prototype.rollbackVersionDone = function(data) { + if (data['builderResponseData'] === undefined) { + throw new Error('Invalid response data') + } + + var $masterTabPane = this.getMasterTabsActivePane() + + this.updateUiAfterSave($masterTabPane, data) + + this.updateVersionsButtons() + } + + Version.prototype.getVersionList = function() { + return $('#layout-side-panel form[data-content-id=version] [data-control=filelist]') + } + + Version.prototype.updateVersionsButtons = function() { + var tabsObject = this.getMasterTabsObject(), + $tabs = tabsObject.$tabsContainer.find('> li'), + $versionList = this.getVersionList() + + // Find all version tabs and update Apply and Rollback buttons + // basing on the version statuses in the version list. + for (var i=$tabs.length-1; i>=0; i--) { + var $tab = $($tabs[i]), + tabId = $tab.data('tabId') + + if (!tabId || String(tabId).length == 0) { + continue + } + + var $versionLi = $versionList.find('li[data-id="'+tabId+'"]') + if (!$versionLi.length) { + continue + } + + var isApplied = $versionLi.data('applied'), + $pane = tabsObject.findPaneFromTab($tab) + + if (isApplied) { + $pane.find('[data-builder-command="version:cmdApplyVersion"]').addClass('hide') + $pane.find('[data-builder-command="version:cmdRollbackVersion"]').removeClass('hide') + } + else { + $pane.find('[data-builder-command="version:cmdApplyVersion"]').removeClass('hide') + $pane.find('[data-builder-command="version:cmdRollbackVersion"]').addClass('hide') + } + } + + } + + // REGISTRATION + // ============================ + + $.oc.builder.entityControllers.version = Version; + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.index.js b/server/plugins/rainlab/builder/assets/js/builder.index.js new file mode 100644 index 0000000..c73c6dc --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.index.js @@ -0,0 +1,294 @@ +/* + * Builder client-side Index page controller + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var Builder = function() { + Base.call(this) + + this.$masterTabs = null + this.masterTabsObj = null + this.hideStripeIndicatorProxy = null + this.entityControllers = {} + + this.init() + } + + Builder.prototype = Object.create(BaseProto) + Builder.prototype.constructor = Builder + + Builder.prototype.dispose = function() { + // We don't really care about disposing the + // index controller, as it's used only once + // and always exists during the page life. + BaseProto.dispose.call(this) + } + + // PUBLIC METHODS + // ============================ + + Builder.prototype.openOrLoadMasterTab = function($form, serverHandlerName, tabId, data) { + if (this.masterTabsObj.goTo(tabId)) + return false + + var requestData = data === undefined ? {} : data + + $.oc.stripeLoadIndicator.show() + var promise = $form.request( + serverHandlerName, + { data: requestData } + ) + .done(this.proxy(this.addMasterTab)) + .always( + this.hideStripeIndicatorProxy + ) + + return promise + } + + Builder.prototype.getMasterTabActivePane = function() { + return this.$masterTabs.find('> .tab-content > .tab-pane.active') + } + + Builder.prototype.unchangeTab = function($pane) { + $pane.find('form').trigger('unchange.oc.changeMonitor') + } + + Builder.prototype.triggerCommand = function(command, ev) { + var commandParts = command.split(':') + + if (commandParts.length === 2) { + var entity = commandParts[0], + commandToExecute = commandParts[1] + + if (this.entityControllers[entity] === undefined) { + throw new Error('Unknown entity type: ' + entity) + } + + this.entityControllers[entity].invokeCommand(commandToExecute, ev) + } + } + + // INTERNAL METHODS + // ============================ + + Builder.prototype.init = function() { + this.$masterTabs = $('#builder-master-tabs') + this.$sidePanel = $('#builder-side-panel') + + this.masterTabsObj = this.$masterTabs.data('oc.tab') + this.hideStripeIndicatorProxy = this.proxy(this.hideStripeIndicator) + new $.oc.tabFormExpandControls(this.$masterTabs) + + this.createEntityControllers() + this.registerHandlers() + } + + Builder.prototype.createEntityControllers = function() { + for (var controller in $.oc.builder.entityControllers) { + if (controller == "base") { + continue + } + + this.entityControllers[controller] = new $.oc.builder.entityControllers[controller](this) + } + } + + Builder.prototype.registerHandlers = function() { + $(document).on('click', '[data-builder-command]', this.proxy(this.onCommand)) + $(document).on('submit', '[data-builder-command]', this.proxy(this.onCommand)) + + this.$masterTabs.on('changed.oc.changeMonitor', this.proxy(this.onFormChanged)) + this.$masterTabs.on('unchanged.oc.changeMonitor', this.proxy(this.onFormUnchanged)) + this.$masterTabs.on('shown.bs.tab', this.proxy(this.onTabShown)) + this.$masterTabs.on('afterAllClosed.oc.tab', this.proxy(this.onAllTabsClosed)) + this.$masterTabs.on('closed.oc.tab', this.proxy(this.onTabClosed)) + this.$masterTabs.on('autocompleteitems.oc.inspector', this.proxy(this.onDataRegistryItems)) + this.$masterTabs.on('dropdownoptions.oc.inspector', this.proxy(this.onDataRegistryItems)) + + for (var controller in this.entityControllers) { + if (this.entityControllers[controller].registerHandlers !== undefined) { + this.entityControllers[controller].registerHandlers() + } + } + } + + Builder.prototype.hideStripeIndicator = function() { + $.oc.stripeLoadIndicator.hide() + } + + Builder.prototype.addMasterTab = function(data) { + this.masterTabsObj.addTab(data.tabTitle, data.tab, data.tabId, 'oc-' + data.tabIcon) + + if (data.isNewRecord) { + var $masterTabPane = this.getMasterTabActivePane() + + $masterTabPane.find('form').one('ready.oc.changeMonitor', this.proxy(this.onChangeMonitorReady)) + } + } + + Builder.prototype.updateModifiedCounter = function() { + var counters = { + database: { menu: 'database', count: 0 }, + models: { menu: 'models', count: 0 }, + permissions: { menu: 'permissions', count: 0 }, + menus: { menu: 'menus', count: 0 }, + versions: { menu: 'versions', count: 0 }, + localization: { menu: 'localization', count: 0 }, + controller: { menu: 'controllers', count: 0 } + } + + $('> div.tab-content > div.tab-pane[data-modified] > form', this.$masterTabs).each(function(){ + var entity = $(this).data('entity') + counters[entity].count++ + }) + + $.each(counters, function(type, data){ + $.oc.sideNav.setCounter('builder/' + data.menu, data.count); + }) + } + + Builder.prototype.getFormPluginCode = function(formElement) { + var $form = $(formElement).closest('form'), + $input = $form.find('input[name="plugin_code"]'), + code = $input.val() + + if (!code) { + throw new Error('Plugin code input is not found in the form.') + } + + return code + } + + Builder.prototype.setPageTitle = function(title) { + $.oc.layout.setPageTitle(title.length ? (title + ' | ') : title) + } + + Builder.prototype.getFileLists = function() { + return $('[data-control=filelist]', this.$sidePanel) + } + + Builder.prototype.dataToInspectorArray = function(data) { + var result = [] + + for (var key in data) { + var item = { + title: data[key], + value: key + } + result.push(item) + } + + return result + } + + // EVENT HANDLERS + // ============================ + + Builder.prototype.onCommand = function(ev) { + if (ev.currentTarget.tagName == 'FORM' && ev.type == 'click') { + // The form elements could have data-builder-command attribute, + // but for them we only handle the submit event and ignore clicks. + + return + } + + var command = $(ev.currentTarget).data('builderCommand') + this.triggerCommand(command, ev) + + // Prevent default for everything except drop-down menu items + // + var $target = $(ev.currentTarget) + if (ev.currentTarget.tagName === 'A' && $target.attr('role') == 'menuitem' && $target.attr('href') == 'javascript:;') { + return + } + + ev.preventDefault() + return false + } + + Builder.prototype.onFormChanged = function(ev) { + $('.form-tabless-fields', ev.target).trigger('modified.oc.tab') + this.updateModifiedCounter() + } + + Builder.prototype.onFormUnchanged = function(ev) { + $('.form-tabless-fields', ev.target).trigger('unmodified.oc.tab') + this.updateModifiedCounter() + } + + Builder.prototype.onTabShown = function(ev) { + var $tabControl = $(ev.target).closest('[data-control=tab]') + + if ($tabControl.attr('id') != this.$masterTabs.attr('id')) { + return + } + + var dataId = $(ev.target).closest('li').attr('data-tab-id'), + title = $(ev.target).attr('title') + + if (title) { + this.setPageTitle(title) + } + + this.getFileLists().fileList('markActive', dataId) + + $(window).trigger('resize') + } + + Builder.prototype.onAllTabsClosed = function(ev) { + this.setPageTitle('') + this.getFileLists().fileList('markActive', null) + } + + Builder.prototype.onTabClosed = function(ev, tab, pane) { + $(pane).find('form').off('ready.oc.changeMonitor', this.proxy(this.onChangeMonitorReady)) + + this.updateModifiedCounter() + } + + Builder.prototype.onChangeMonitorReady = function(ev) { + $(ev.target).trigger('change') + } + + Builder.prototype.onDataRegistryItems = function(ev, data) { + var self = this + + if (data.propertyDefinition.fillFrom == 'model-classes' || + data.propertyDefinition.fillFrom == 'model-forms' || + data.propertyDefinition.fillFrom == 'model-lists' || + data.propertyDefinition.fillFrom == 'controller-urls' || + data.propertyDefinition.fillFrom == 'model-columns' || + data.propertyDefinition.fillFrom == 'plugin-lists' || + data.propertyDefinition.fillFrom == 'permissions') { + ev.preventDefault() + + var subtype = null, + subtypeProperty = data.propertyDefinition.subtypeFrom + + if (subtypeProperty !== undefined) { + subtype = data.values[subtypeProperty] + } + + $.oc.builder.dataRegistry.get($(ev.target), this.getFormPluginCode(ev.target), data.propertyDefinition.fillFrom, subtype, function(response){ + data.callback({ + options: self.dataToInspectorArray(response) + }) + }) + } + } + + // INITIALIZATION + // ============================ + + $(document).ready(function(){ + $.oc.builder.indexController = new Builder() + }) + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.inspector.editor.localization.js b/server/plugins/rainlab/builder/assets/js/builder.inspector.editor.localization.js new file mode 100644 index 0000000..1dfc831 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.inspector.editor.localization.js @@ -0,0 +1,114 @@ +/* + * Inspector localization editor class. + */ ++function ($) { "use strict"; + + var Base = $.oc.inspector.propertyEditors.string, + BaseProto = Base.prototype + + var LocalizationEditor = function(inspector, propertyDefinition, containerCell, group) { + this.localizationInput = null + + Base.call(this, inspector, propertyDefinition, containerCell, group) + } + + LocalizationEditor.prototype = Object.create(BaseProto) + LocalizationEditor.prototype.constructor = Base + + LocalizationEditor.prototype.dispose = function() { + this.removeLocalizationInput() + + BaseProto.dispose.call(this) + } + + LocalizationEditor.prototype.build = function() { + var container = document.createElement('div'), + editor = document.createElement('input'), + placeholder = this.propertyDefinition.placeholder !== undefined ? this.propertyDefinition.placeholder : '', + value = this.inspector.getPropertyValue(this.propertyDefinition.property) + + editor.setAttribute('type', 'text') + editor.setAttribute('class', 'string-editor') + editor.setAttribute('placeholder', placeholder) + + container.setAttribute('class', 'autocomplete-container') + + if (value === undefined) { + value = this.propertyDefinition.default + } + + if (value === undefined) { + value = '' + } + + editor.value = value + + $.oc.foundation.element.addClass(this.containerCell, 'text autocomplete') + + container.appendChild(editor) + this.containerCell.appendChild(container) + + this.buildLocalizationEditor() + } + + LocalizationEditor.prototype.buildLocalizationEditor = function() { + this.localizationInput = new $.oc.builder.localizationInput(this.getInput(), this.getForm(), { + plugin: this.getPluginCode(), + beforePopupShowCallback: this.proxy(this.onPopupShown, this), + afterPopupHideCallback: this.proxy(this.onPopupHidden, this) + }) + } + + LocalizationEditor.prototype.removeLocalizationInput = function() { + this.localizationInput.dispose() + + this.localizationInput = null + } + + LocalizationEditor.prototype.supportsExternalParameterEditor = function() { + return false + } + + LocalizationEditor.prototype.registerHandlers = function() { + BaseProto.registerHandlers.call(this) + + $(this.getInput()).on('change', this.proxy(this.onInputKeyUp)) + } + + LocalizationEditor.prototype.unregisterHandlers = function() { + BaseProto.unregisterHandlers.call(this) + + $(this.getInput()).off('change', this.proxy(this.onInputKeyUp)) + } + + LocalizationEditor.prototype.getForm = function() { + var inspectableElement = this.getRootSurface().getInspectableElement() + + if (!inspectableElement) { + throw new Error('Cannot determine inspectable element in the Builder localization editor.') + } + + return $(inspectableElement).closest('form') + } + + LocalizationEditor.prototype.getPluginCode = function() { + var $form = this.getForm(), + $input = $form.find('input[name=plugin_code]') + + if (!$input.length) { + throw new Error('The input "plugin_code" should be defined in the form in order to use the localization Inspector editor.') + } + + return $input.val() + } + + LocalizationEditor.prototype.onPopupShown = function() { + this.getRootSurface().popupDisplayed() + } + + LocalizationEditor.prototype.onPopupHidden = function() { + this.getRootSurface().popupHidden() + } + + $.oc.inspector.propertyEditors.builderLocalization = LocalizationEditor +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.localizationinput.js b/server/plugins/rainlab/builder/assets/js/builder.localizationinput.js new file mode 100644 index 0000000..c2ec839 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.localizationinput.js @@ -0,0 +1,299 @@ +/* + * Builder localization input control + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var LocalizationInput = function(input, form, options) { + this.input = input + this.form = form + this.options = $.extend({}, LocalizationInput.DEFAULTS, options) + this.disposed = false + this.initialized = false + this.newStringPopupMarkup = null + + Base.call(this) + + this.init() + } + + LocalizationInput.prototype = Object.create(BaseProto) + LocalizationInput.prototype.constructor = LocalizationInput + + LocalizationInput.prototype.dispose = function() { + this.unregisterHandlers() + + this.form = null + this.options.beforePopupShowCallback = null + this.options.afterPopupHideCallback = null + this.options = null + this.disposed = true + this.newStringPopupMarkup = null + + if (this.initialized) { + $(this.input).autocomplete('destroy') + } + + $(this.input).removeData('localization-input') + + this.input = null + + BaseProto.dispose.call(this) + } + + LocalizationInput.prototype.init = function() { + if (!this.options.plugin) { + throw new Error('The options.plugin value should be set in the localization input object.') + } + + var $input = $(this.input) + + $input.data('localization-input', this) + $input.attr('data-builder-localization-input', 'true') + $input.attr('data-builder-localization-plugin', this.options.plugin) + + this.getContainer().addClass('localization-input-container') + + this.registerHandlers() + this.loadDataAndBuild() + } + + LocalizationInput.prototype.buildAddLink = function() { + var $container = this.getContainer() + + if ($container.find('a.localization-trigger').length > 0) { + return + } + + var trigger = document.createElement('a') + + trigger.setAttribute('class', 'oc-icon-plus localization-trigger') + trigger.setAttribute('href', '#') + + var pos = $container.position() + $(trigger).css({ + top: pos.top + 4, + right: 7 + }) + + $container.append(trigger) + } + + LocalizationInput.prototype.loadDataAndBuild = function() { + this.showLoadingIndicator() + + var result = $.oc.builder.dataRegistry.get(this.form, this.options.plugin, 'localization', null, this.proxy(this.dataLoaded)), + self = this + + if (result) { + result.always(function(){ + self.hideLoadingIndicator() + }) + } + } + + LocalizationInput.prototype.reload = function() { + $.oc.builder.dataRegistry.get(this.form, this.options.plugin, 'localization', null, this.proxy(this.dataLoaded)) + } + + LocalizationInput.prototype.dataLoaded = function(data) { + if (this.disposed) { + return + } + + var $input = $(this.input), + autocomplete = $input.data('autocomplete') + + if (!autocomplete) { + this.hideLoadingIndicator() + + var autocompleteOptions = { + source: this.preprocessData(data), + matchWidth: true + } + + autocompleteOptions = $.extend(autocompleteOptions, this.options.autocompleteOptions) + + $(this.input).autocomplete(autocompleteOptions) + + this.initialized = true + } + else { + autocomplete.source = this.preprocessData(data) + } + } + + LocalizationInput.prototype.preprocessData = function(data) { + var dataClone = $.extend({}, data) + + for (var key in dataClone) { + dataClone[key] = key + ' - ' + dataClone[key] + } + + return dataClone + } + + LocalizationInput.prototype.getContainer = function() { + return $(this.input).closest('.autocomplete-container') + } + + LocalizationInput.prototype.showLoadingIndicator = function() { + var $container = this.getContainer() + + $container.addClass('loading-indicator-container size-small') + $container.loadIndicator() + } + + LocalizationInput.prototype.hideLoadingIndicator = function() { + var $container = this.getContainer() + + $container.loadIndicator('hide') + $container.loadIndicator('destroy') + + $container.removeClass('loading-indicator-container') + } + + // POPUP + // ============================ + + LocalizationInput.prototype.loadAndShowPopup = function() { + if (this.newStringPopupMarkup === null) { + $.oc.stripeLoadIndicator.show() + $(this.input).request('onLanguageLoadAddStringForm') + .done( + this.proxy(this.popupMarkupLoaded) + ).always(function(){ + $.oc.stripeLoadIndicator.hide() + }) + } + else { + this.showPopup() + } + } + + LocalizationInput.prototype.popupMarkupLoaded = function(responseData) { + this.newStringPopupMarkup = responseData.markup + + this.showPopup() + } + + LocalizationInput.prototype.showPopup = function() { + var $input = $(this.input) + + $input.popup({ + content: this.newStringPopupMarkup + }) + + var $content = $input.data('oc.popup').$content, + $keyInput = $content.find('#language_string_key') + + $.oc.builder.dataRegistry.get(this.form, this.options.plugin, 'localization', 'sections', function(data){ + $keyInput.autocomplete({ + source: data, + matchWidth: true + }) + }) + + $content.find('form').on('submit', this.proxy(this.onSubmitPopupForm)) + } + + LocalizationInput.prototype.stringCreated = function(data) { + if (data.localizationData === undefined || data.registryData === undefined) { + throw new Error('Invalid server response.') + } + + var $input = $(this.input) + + $input.val(data.localizationData.key) + + $.oc.builder.dataRegistry.set(this.options.plugin, 'localization', null, data.registryData.strings) + $.oc.builder.dataRegistry.set(this.options.plugin, 'localization', 'sections', data.registryData.sections) + + $input.data('oc.popup').hide() + + $input.trigger('change') + } + + LocalizationInput.prototype.onSubmitPopupForm = function(ev) { + var $form = $(ev.target) + + $.oc.stripeLoadIndicator.show() + $form.request('onLanguageCreateString', { + data: { + plugin_code: this.options.plugin + } + }) + .done( + this.proxy(this.stringCreated) + ).always(function(){ + $.oc.stripeLoadIndicator.hide() + }) + + ev.preventDefault() + return false + } + + LocalizationInput.prototype.onPopupHidden = function(ev, link, popup) { + $(popup).find('#language_string_key').autocomplete('destroy') + $(popup).find('form').on('submit', this.proxy(this.onSubmitPopupForm)) + + if (this.options.afterPopupHideCallback) { + this.options.afterPopupHideCallback() + } + } + + LocalizationInput.updatePluginInputs = function(plugin) { + var inputs = document.body.querySelectorAll('input[data-builder-localization-input][data-builder-localization-plugin="'+plugin+'"]') + + for (var i=inputs.length-1; i>=0; i--) { + $(inputs[i]).data('localization-input').reload() + } + } + + // EVENT HANDLERS + // ============================ + + LocalizationInput.prototype.unregisterHandlers = function() { + this.input.removeEventListener('focus', this.proxy(this.onInputFocus)) + + this.getContainer().off('click', 'a.localization-trigger', this.proxy(this.onTriggerClick)) + $(this.input).off('hidden.oc.popup', this.proxy(this.onPopupHidden)) + } + + LocalizationInput.prototype.registerHandlers = function() { + this.input.addEventListener('focus', this.proxy(this.onInputFocus)) + + this.getContainer().on('click', 'a.localization-trigger', this.proxy(this.onTriggerClick)) + $(this.input).on('hidden.oc.popup', this.proxy(this.onPopupHidden)) + } + + LocalizationInput.prototype.onInputFocus = function() { + this.buildAddLink() + } + + LocalizationInput.prototype.onTriggerClick = function(ev) { + if (this.options.beforePopupShowCallback) { + this.options.beforePopupShowCallback() + } + + this.loadAndShowPopup() + + ev.preventDefault() + return false + } + + LocalizationInput.DEFAULTS = { + plugin: null, + autocompleteOptions: {}, + beforePopupShowCallback: null, + afterPopupHideCallback: null + } + + $.oc.builder.localizationInput = LocalizationInput + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/js/builder.table.processor.localization.js b/server/plugins/rainlab/builder/assets/js/builder.table.processor.localization.js new file mode 100644 index 0000000..f54a89e --- /dev/null +++ b/server/plugins/rainlab/builder/assets/js/builder.table.processor.localization.js @@ -0,0 +1,126 @@ +/* + * Localiztion cell processor for the table control. + */ + ++function ($) { "use strict"; + + // NAMESPACE CHECK + // ============================ + + if ($.oc.table === undefined) + throw new Error("The $.oc.table namespace is not defined. Make sure that the table.js script is loaded."); + + if ($.oc.table.processor === undefined) + throw new Error("The $.oc.table.processor namespace is not defined. Make sure that the table.processor.base.js script is loaded."); + + // CLASS DEFINITION + // ============================ + + var Base = $.oc.table.processor.string, + BaseProto = Base.prototype + + var LocalizationProcessor = function(tableObj, columnName, columnConfiguration) { + // + // State properties + // + + this.localizationInput = null + this.popupDisplayed = false + + // + // Parent constructor + // + + Base.call(this, tableObj, columnName, columnConfiguration) + } + + LocalizationProcessor.prototype = Object.create(BaseProto) + LocalizationProcessor.prototype.constructor = LocalizationProcessor + + LocalizationProcessor.prototype.dispose = function() { + this.removeLocalizationInput() + + BaseProto.dispose.call(this) + } + + /* + * Forces the processor to hide the editor when the user navigates + * away from the cell. Processors can update the sell value in this method. + * Processors must clear the reference to the active cell in this method. + */ + LocalizationProcessor.prototype.onUnfocus = function() { + if (!this.activeCell || this.popupDisplayed) + return + + this.removeLocalizationInput() + + BaseProto.onUnfocus.call(this) + } + + LocalizationProcessor.prototype.onBeforePopupShow = function() { + this.popupDisplayed = true + } + + LocalizationProcessor.prototype.onAfterPopupHide = function() { + this.popupDisplayed = false + } + + /* + * Renders the cell in the normal (no edit) mode + */ + LocalizationProcessor.prototype.renderCell = function(value, cellContentContainer) { + BaseProto.renderCell.call(this, value, cellContentContainer) + } + + LocalizationProcessor.prototype.buildEditor = function(cellElement, cellContentContainer, isClick) { + BaseProto.buildEditor.call(this, cellElement, cellContentContainer, isClick) + + $.oc.foundation.element.addClass(cellContentContainer, 'autocomplete-container') + this.buildLocalizationEditor() + } + + LocalizationProcessor.prototype.buildLocalizationEditor = function() { + var input = this.getInput() + + this.localizationInput = new $.oc.builder.localizationInput(input, $(input), { + plugin: this.getPluginCode(input), + beforePopupShowCallback: $.proxy(this.onBeforePopupShow, this), + afterPopupHideCallback: $.proxy(this.onAfterPopupHide, this), + autocompleteOptions: { + menu: '', + bodyContainer: true + } + }) + } + + LocalizationProcessor.prototype.getInput = function() { + if (!this.activeCell) { + return null + } + + return this.activeCell.querySelector('.string-input') + } + + LocalizationProcessor.prototype.getPluginCode = function(input) { + var $form = $(input).closest('form'), + $input = $form.find('input[name=plugin_code]') + + if (!$input.length) { + throw new Error('The input "plugin_code" should be defined in the form in order to use the localization table processor.') + } + + return $input.val() + } + + LocalizationProcessor.prototype.removeLocalizationInput = function() { + if (!this.localizationInput) { + return + } + + this.localizationInput.dispose() + + this.localizationInput = null + } + + $.oc.table.processor.builderLocalization = LocalizationProcessor; +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/behaviors.less b/server/plugins/rainlab/builder/assets/less/behaviors.less new file mode 100644 index 0000000..d06e292 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/behaviors.less @@ -0,0 +1,167 @@ +.builder-controllers-builder-area { + background: white; + + ul.controller-behavior-list { + .clearfix(); + + padding: 20px; + margin-bottom: 0; + list-style: none; + + li { + h4 { + text-align: center; + border-bottom: 1px dotted @builder-control-border-color; + margin: 0 -20px 40px; + + span { + display: inline-block; + color: white; + margin: 0 auto; + .border-radius(8px); + background: @builder-control-border-color; + padding: 7px 10px; + font-size: 13px; + line-height: 100%; + position: relative; + top: 14px; + } + } + } + + .behavior-container { + margin-bottom: 40px; + .clearfix(); + cursor: pointer; + + .list-behavior, .reorder-behavior { + .border-radius(4px); + border: 2px solid @builder-control-border-color; + padding: 25px 10px 25px 10px; + + table { + border-collapse: collapse; + width: 100%; + + td { + padding: 0 15px 15px 15px; + + border-right: 1px solid @builder-control-border-color; + + &:last-child { + border-right: none; + } + } + + .placeholder { + background: #EEF2F4; + height: 25px; + } + + tbody tr:last-child td { + padding-bottom: 0; + } + } + } + + .reorder-behavior { + table { + i.icon-bars, .placeholder { + float: left; + } + + i.icon-bars { + margin-right: 15px; + color: #D6DDE0; + font-size: 28px; + line-height: 28px; + position: relative; + top: -2px; + } + } + } + + .form-behavior { + div.form { + .clearfix(); + + padding: 25px 25px 0 25px; + border: 2px solid @builder-control-border-color; + margin-bottom: 20px; + .border-radius(4px); + } + + div.field { + &.left { + float: left; + width: 48%; + } + + &.right { + float: right; + width: 45%; + } + + div.label { + background: #EEF2F4; + height: 25px; + margin-bottom: 10px; + + &.size-3 { + width: 100px; + } + + &.size-5 { + width: 150px; + } + + &.size-2 { + width: 60px; + } + } + + div.control { + background: #EEF2F4; + height: 35px; + margin-bottom: 25px; + } + } + + div.button { + background: #EEF2F4; + height: 35px; + margin-right: 20px; + .border-radius(4px); + + &.size-5 { + width: 100px; + } + + &.size-3 { + width: 60px; + } + + &:first-child { + margin-right: 0; + } + } + } + + &:hover, &.inspector-open { + * { + border-color: @builder-hover-color!important; + } + } + } + } +} + +// Fix for the Mac firefox + +html.gecko.mac { + .builder-controllers-builder-area { + ul.controller-behavior-list { + padding-right: 40px; + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/builder.less b/server/plugins/rainlab/builder/assets/less/builder.less new file mode 100644 index 0000000..45e8ba5 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/builder.less @@ -0,0 +1,198 @@ +@import "../../../../../modules/backend/assets/less/core/boot.less"; + +@builder-control-border-color: #bdc3c7; +@builder-control-text-color: #95a5a6; +@builder-hover-color: #2581b8; + +@import "buildingarea.less"; +@import "controlblueprint.less"; +@import "behaviors.less"; +@import "tabs.less"; +@import "menus.less"; +@import "localization.less"; + +.control-filelist ul li.group.model > h4 a:after { + content: @random; + top: 10px; +} + +.control-filelist ul li.group.form > h4 a:after { + content: @check-square; +} + +.control-filelist ul li.group.list > h4 a:after { + content: @th-list; + top: 10px; +} + +.control-filelist ul li.group > ul > li.group > ul > li > a { + padding-left: 73px; + margin-left: -20px; +} + +.control-filelist ul li.with-icon { + span.title, span.description { + padding-left: 22px; + } + + i.list-icon { + position: absolute; + left: 20px; + top: 12px; + color: #405261; + + &.mute { + color: #8f8f8f; + } + + &.icon-check-square { + color: #8da85e; + } + } +} + +html.gecko .control-filelist ul li.group { + margin-right: 10px; +} + +.builder-inspector-container { + width: 350px; + border-left: 1px solid #d9d9d9; + + &:empty { + display: none!important; + } +} + +form.hide-secondary-tabs { + div.control-tabs.secondary-tabs { + ul.nav.nav-tabs { + display: none; + } + } +} + +.form-group { + &.size-quarter { + width: 23.5%; + } + + &.size-three-quarter { + width: 73.5%; + } +} + +// Full height database columns table + +form[data-entity=database] { + div.field-datatable { + position: absolute; + width: 100%; + height: 100%; + + div[data-control=table] { + position: absolute; + width: 100%; + height: 100%; + + div.table-container { + position: absolute; + width: 100%; + height: 100%; + + div.control-scrollbar { + top: 70px; + bottom: 0; + position: absolute; + max-height: none!important; + height: auto!important; + } + } + } + } +} + +// Custom buttons for the toolbar + +div.control-table .toolbar a.builder-custom-table-button { + &:before { + line-height: 17px; + font-size: 21px; + color: #323e50; + margin-right: 5px; + top: 3px; + .opacity(1); + } +} + +// TODO: Move the aux tab styles to the tab.less + +.control-tabs { + &.auxiliary-tabs { + background: white; + + .border-top(@color) { + content: ' '; + display: block; + position: absolute; + width: 100%; + height: 1px; + background: @color; + top: 0; + left: 0; + } + + > ul.nav-tabs, > div > ul.nav-tabs { + padding-left: 20px; + padding-bottom: 2px; + background: white; + position: relative; + + &:before { + .border-top(#95a5a6); + } + + > li { + margin-right: 2px; + + > a { + background: white; + color: #bdc3c7; + border-left: 1px solid #ecf0f1!important; + border-right: 1px solid #ecf0f1!important; + border-bottom: 1px solid #ecf0f1!important; + padding: 4px 10px; + line-height: 100%; + .border-radius(0 0 4px 4px); + + > span.title > span { + margin-bottom: 0; + font-size: 13px; + height: auto; + } + } + + &.active{ + top: 0; + + &:before { + .border-top(white); + top: -1px; + } + + a { + padding-top: 5px; + border-left: 1px solid #95a5a6!important; + border-right: 1px solid #95a5a6!important; + border-bottom: 1px solid #95a5a6!important; + color: #95a5a6; + } + } + } + } + + > div.tab-content > .tab-pane { + background: white; + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/buildingarea.less b/server/plugins/rainlab/builder/assets/less/buildingarea.less new file mode 100644 index 0000000..96ea040 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/buildingarea.less @@ -0,0 +1,251 @@ +.builder-building-area { + background: white; + + ul.builder-control-list { + .clearfix(); + + padding: 20px; + margin-bottom: 0; + list-style: none; + > li.control { + position: relative; + margin-bottom: 20px; + cursor: pointer; + .user-select(none); + + &[data-unknown] { + cursor: default; + } + + &.placeholder, &.loading-control { + padding: 10px 12px; + position: relative; + text-align: center; + border: 2px dotted #dde0e2; + margin-top: 20px; + .border-radius(4px); + color: #dae0e0; + + i { + margin-right: 8px; + } + } + + &.clear-row { + display: none; + margin-bottom: 0; + } + + &.loading-control { + border-color: #bdc3c7; + text-align: left; + } + + &.updating-control:after, + &.loading-control:before { + background-image:url(../../../../../modules/system/assets/ui/images/loader-transparent.svg); + background-size: 15px 15px; + background-position: 50% 50%; + display: inline-block; + width: 15px; + height: 15px; + content: ' '; + margin-right: 13px; + position: relative; + top: 2px; + .animation(spin 1s linear infinite); + } + + &.loading-control:after { + content: attr(data-builder-loading-text); + display: inline-block; + } + + &.updating-control:after { + position: absolute; + right: -8px; + top: 5px; + } + + &.updating-control:before { + content: ''; + position: absolute; + right: 0; + top: 0; + width: 25px; + height: 25px; + background: rgba(127, 127, 127, 0.1); + .border-radius(4px); + } + + &.drag-over { + color: @builder-hover-color; + border-color: @builder-hover-color; + } + + &.span-full { + width: 100%; + float: left; + } + + &.span-left { + float: left; + width: 48.5%; + clear: left; + } + + &.span-right { + float: right; + width: 48.5%; + clear: right; + } + + &.span-right + li.clear-row { + display: block; + clear: both; + } + + > div.remove-control { + display: none; + } + + &:not(.placeholder):not(.loading-control):not(.updating-control):hover > { + > div.remove-control { + font-family: sans-serif; + display: block; + position: absolute; + right: 0; + top: 0; + cursor: pointer; + width: 21px; + height: 21px; + padding-left: 6px; + font-size: 16px; + font-weight: bold; + line-height: 21px; + .border-radius(20px); + background: #ecf0f1; + color: #95a5a6 !important; + + &:hover { + color: white !important; + background: #c03f31; + } + } + + &[data-control-type=hint], &[data-control-type=partial] { + > div.remove-control { + top: 12px; + right: 12px; + } + } + } + + &[data-control-type=hint], &[data-control-type=partial] { + &.updating-control { + &:before { + right: 12px; + top: 7; + } + + &:after { + right: 4px; + top: 13px; + } + } + } + + > .control-wrapper, + > .control-static-contents { + position: relative; + .transition(margin 0.1s); + } + } + + > li.placeholder:hover, + > li.placeholder.popover-highlight, + > li.placeholder.control-palette-open { + background-color: @builder-hover-color!important; + color: white!important; + border-style: solid; + border-color: @builder-hover-color; + } + + > li.control:not(.placeholder):not(.loading-control):not([data-unknown]):hover > .control-wrapper *, + > li.control.inspector-open:not(.placeholder):not(.loading-control) > .control-wrapper * { + color: @builder-hover-color!important; + } + + > li.control.drag-over:not(.placeholder) { + &:before { + position: absolute; + content: ''; + top: 0; + left: 0; + width: 10px; + height: 100%; + .border-radius(5px); + background-color: @builder-hover-color; + } + + > .control-wrapper, + > .control-static-contents { + margin-left: 20px; + margin-right: -20px; + } + } + } + + .control-body { + &.field-disabled, + &.field-hidden { + .opacity(0.5); + } + } + + .builder-control-label { + margin-bottom: 10px; + color: #555555; + font-size: 14px; + font-weight: 600; + + &.required:after { + vertical-align: super; + font-size: 60%; + content: " *"; + } + } + + .builder-control-label:empty { + margin-bottom: 0; + } + + .builder-control-comment-above { + margin-bottom: 8px; + margin-top: -3px; + } + + .builder-control-comment-below { + margin-top: 6px; + } + + .builder-control-comment-above, + .builder-control-comment-below { + color: #737373; + font-size: 12px; + + &:empty { + display: none; + } + } +} + +html.gecko.mac { + // Fixes a quirk in FireFox on mac + + .builder-building-area { + div[data-root-control-wrapper] { + margin-right: 17px; + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/controlblueprint.less b/server/plugins/rainlab/builder/assets/less/controlblueprint.less new file mode 100644 index 0000000..3f2f786 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/controlblueprint.less @@ -0,0 +1,260 @@ +.builder-building-area { + .builder-blueprint-control-text, + .builder-blueprint-control-textarea, + .builder-blueprint-control-partial, + .builder-blueprint-control-unknown, + .builder-blueprint-control-dropdown { + padding: 10px 12px; + border: 2px solid @builder-control-border-color; + color: @builder-control-text-color; + .border-radius(4px); + + i { + margin-right: 5px; + } + } + + li.control:hover, li.inspector-open { + > .control-wrapper { + .builder-blueprint-control-text, + .builder-blueprint-control-textarea, + .builder-blueprint-control-dropdown { + border-color: @builder-hover-color; + } + + .builder-blueprint-control-dropdown:before { + background-color: @builder-hover-color; + } + } + } + + .builder-blueprint-control-textarea { + &.size-tiny { min-height: @size-tiny; } + &.size-small { min-height: @size-small; } + &.size-large { min-height: @size-large; } + &.size-huge { min-height: @size-huge; } + &.size-giant { min-height: @size-giant; } + } + + .builder-blueprint-control-section { + border-bottom: 1px solid @builder-control-border-color; + padding-bottom: 4px; + + .builder-control-label { + font-size: 16px; + margin-bottom: 6px; + } + } + + .builder-blueprint-control-unknown { + border-color: #eee; + background: #eee; + } + + .builder-blueprint-control-partial { + border-color: #eee; + background: #eee; + } + + .builder-blueprint-control-dropdown { + position: relative; + + &:before, &:after { + position: absolute; + content: ''; + } + + &:before { + top: 0; + width: 2px; + background: @builder-control-border-color; + right: 40px; + height: 100%; + } + + &:after { + .icon(@angle-down); + color: inherit; + right: 15px; + top: 12px; + font-size: 20px; + line-height: 20px; + } + } + + .builder-blueprint-control-checkbox { + &:before { + float: left; + content: ' '; + border: 2px solid @builder-control-border-color; + .border-radius(4px); + width: 17px; + height: 17px; + position: relative; + top: 2px; + } + + .builder-control-label { + margin-left: 25px; + font-weight: normal; + } + + .builder-control-comment-below { + margin-left: 25px; + } + } + + li.control:hover, li.inspector-open { + > .control-wrapper { + .builder-blueprint-control-checkbox:before { + border-color: @builder-hover-color; + } + } + } + + .builder-blueprint-control-switch { + position: relative; + + &:before, &:after { + position: absolute; + content: ' '; + .border-radius(30px); + } + + &:before { + background-color: @builder-control-border-color; + + width: 34px; + height: 18px; + top: 2px; + left: 2px; + } + + &:after { + background-color: white; + + width: 14px; + height: 14px; + top: 4px; + left: 4px; + margin-left: 16px; + } + + .builder-control-label { + margin-left: 45px; + font-weight: normal; + } + + .builder-control-comment-below { + margin-left: 45px; + } + } + + li.control:hover, li.inspector-open { + > .control-wrapper { + .builder-blueprint-control-switch:before { + background-color: @builder-hover-color; + } + } + } + + .builder-blueprint-control-repeater-body { + > .repeater-button { + padding: 8px 13px; + background: @builder-control-border-color; + color: white; + display: inline-block; + margin-bottom: 10px; + .border-radius(2px); + } + } + + ul.builder-control-list > li.control:hover, + ul.builder-control-list > li.inspector-open { + > .control-wrapper > .control-body { + .builder-blueprint-control-repeater-body { + > .repeater-button { + background: @builder-hover-color; + color: white!important; + span { + color: white!important; + } + } + } + } + } + + .builder-blueprint-control-repeater { + position: relative; + + &:before { + content: ''; + position: absolute; + width: 2px; + top: 0; + left: 2px; + height: 100%; + background: @builder-control-border-color; + } + + &:after { + content: ''; + position: absolute; + width: 6px; + height: 6px; + top: 14px; + left: 0; + .border-radius(6px); + background: @builder-control-border-color; + } + + > ul.builder-control-list { + padding-right: 0; + padding-bottom: 0; + padding-top: 10px; + } + } + + li.control:hover, li.inspector-open { + > .builder-blueprint-control-repeater { + &:before, &:after { + background-color: @builder-hover-color; + } + } + } + + .builder-blueprint-control-radiolist, + .builder-blueprint-control-checkboxlist { + ul { + list-style: none; + padding: 0; + color: @builder-control-text-color; + + li { + margin-bottom: 3px; + + &:last-child { + margin-bottom: 0; + } + + i { + margin-right: 5px; + } + } + } + } + + .builder-blueprint-control-text { + &.fileupload.image { + width: 100px; + height: 100px; + text-align: center; + + i { + line-height: 77px; + margin-right: 0; + } + } + } + +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/localization.less b/server/plugins/rainlab/builder/assets/less/localization.less new file mode 100644 index 0000000..a8637ff --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/localization.less @@ -0,0 +1,86 @@ +.localization-input-container { + // position: relative; + + input[type=text].string-editor { + padding-right: 20px!important; + } + + .localization-trigger { + position: absolute; + display: none; + width: 10px; + height: 10px; + font-size: 14px; + color: #95a5a6; + + outline: none; + + &:hover, &:active, &:focus { + color: #2581b8; + text-decoration: none; + } + } +} + +table.inspector-fields td.active, +table.data td.active { + .localization-input-container .localization-trigger { + display: block; + } +} + +table.data td.active .localization-input-container .localization-trigger { + top: 5px!important; + right: 7px!important; +} + +.control-table td[data-column-type=builderLocalization] input[type=text] { + padding-right: 20px!important; +} + +.control-table { + td[data-column-type=builderLocalization] { + input[type=text] { + width: 100%; + height: 100%; + display: block; + outline: none; + border: none; + padding: 6px 10px 6px; + } + } +} + +html.chrome { + .control-table { + td[data-column-type=builderLocalization] { + input[type=text] { + padding: 6px 10px 7px!important; + } + } + } +} + +html.safari, html.gecko { + .control-table { + td[data-column-type=builderLocalization] { + input[type=text] { + padding: 5px 10px 5px; + } + } + } +} + +.autocomplete.dropdown-menu.table-widget-autocomplete.localization li a { + white-space: normal; + word-wrap: break-word; +} + +table.data td[data-column-type=builderLocalization] .loading-indicator-container.size-small .loading-indicator { + padding-bottom: 0!important; + + span { + left: auto; + right: 6px; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/menus.less b/server/plugins/rainlab/builder/assets/less/menus.less new file mode 100644 index 0000000..3be02dd --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/menus.less @@ -0,0 +1,177 @@ +.builder-menu-editor { + background: white; + + .builder-menu-editor-workspace { + padding: 30px; + } + + ul.builder-menu { + font-size: 0; + padding: 0; + cursor: pointer; + + > li { + .border-radius(4px); + + div.item-container:hover, &.inspector-open > div.item-container { + background: @builder-hover-color!important; + color: white!important; + + a { + color: white!important; + } + } + + div.item-container { + position: relative; + + .close-btn { + color: white; + position: absolute; + display: none; + width: 15px; + height: 15px; + right: 5px; + top: 5px; + font-size: 14px; + text-align: center; + line-height: 14px; + } + + &:hover .close-btn { + display: block; + text-decoration: none; + .opacity(0.5); + + &:hover { + .opacity(1); + } + } + } + + &.add { + font-size: 16px; + text-align: center; + border: 2px dotted #dde0e2; + + a { + text-decoration: none; + color: #bdc3c7; + } + + span.title { + font-size: 14px; + } + + &:hover { + border: 2px dotted @builder-hover-color; + background: @builder-hover-color!important; + + a { + color: white; + } + } + } + + &.list-sortable-placeholder { + border: 2px dotted @builder-hover-color; + height: 10px; + background: transparent; + } + } + + &.builder-main-menu { + > li { + display: inline-block; + vertical-align: top; + + &.item { + margin: 0 20px 20px 0; + } + + > div.item-container { + background: #ecf0f1; + color: #708080; + padding: 20px 25px; + height: 64px; + white-space: nowrap; + + i { + font-size: 24px; + margin-right: 10px; + } + + span.title { + font-size: 14px; + line-height: 100%; + position: relative; + top: -3px; + } + } + + &.add { + height: 64px; + + a { + padding: 20px 15px; + height: 60px; + display: block; + + i { + margin-right: 5px; + } + + span { + position: relative; + top: -1px; + } + } + } + } + } + + &.builder-submenu { + margin-top: 1px; + + > li { + display: block; + width: 120px; + + i { + display: block; + margin-bottom: 7px; + } + + span.title { + display: block; + font-size: 12px; + } + + &.item { + margin: 0 0 1px 0; + } + + > div.item-container { + background: #f3f5f5; + color: #94a5a6; + padding: 18px 13px; + text-align: center; + + i { + font-size: 24px; + } + } + + &.add { + margin-top: 20px; + + a { + padding: 10px 20px; + display: block; + } + + } + } + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/assets/less/tabs.less b/server/plugins/rainlab/builder/assets/less/tabs.less new file mode 100644 index 0000000..0aa9202 --- /dev/null +++ b/server/plugins/rainlab/builder/assets/less/tabs.less @@ -0,0 +1,307 @@ +.builder-tabs { + > .tabs { + position: relative; + + .tab-control { + position: absolute; + display: block; + + &.inspector-trigger { + font-size: 14px; + padding-left: 5px; + padding-right: 5px; + cursor: pointer; + + span { + display: block; + width: 3px; + height: 3px; + margin-bottom: 2px; + background: #95a5a6; + + &:last-child { + margin-bottom: 0; + } + } + + &:hover, &.inspector-open { + span { + background: @link-color; + } + } + + &.global { + top: 5px; + right: 15px; + } + } + } + + > ul.tabs { + margin: 0; + list-style: none; + font-size: 0; + white-space: nowrap; + overflow: hidden; + position: relative; + + > li { + .user-select(none); + display: inline-block; + font-size: 13px; + white-space: nowrap; + position: relative; + cursor: pointer; + + > div.tab-container { + position: relative; + color: #bdc3c7!important; + + > div { + .transition(padding .1s); + position: relative; + } + } + + &:hover > div { + color: #95a5a6!important; + } + + .tab-control { + display: none; + + &.close-btn { + font-size: 15px; + top: 7px; + right: 18px; + line-height: 15px; + height: 15px; + width: 15px; + text-align: center; + cursor: pointer; + color: #95a5a6; + + &:hover { + color: @link-color!important; + } + } + + &.inspector-trigger{ + right: 34px; + top: 10px; + } + } + + &.active { + > div.tab-container { + color: #95a5a6!important; + } + + .tab-control { + display: block; + } + } + } + } + + > ul.panels { + padding: 0; + list-style: none; + + > li { + display: none; + + &.active { + display: block; + } + } + } + } + + &.primary { + > .tabs { + > ul.tabs { + padding: 0 20px 0 40px; + height: 31px; + + &:after { + position: absolute; + content: ''; + display: block; + height: 2px; + left: 0; + bottom: 0; + width: 100%; + background: #bdc3c7; + z-index: 106; + } + + > li { + bottom: -2px; + margin-left: -20px; + z-index: 105; + + > div.tab-container { + padding: 0 21px 0 21px; + height: 27px; + + > div { + padding: 5px 5px 0 5px; + border-top: 2px solid #e5e5e5; + + > span { + position: relative; + top: -2px; + .transition(top .1s); + } + } + + &:before, &:after { + content: ''; + display: block; + position: absolute; + top: 0; + height: 27px; + width: 21px; + background: transparent url(../images/tab.png) no-repeat; + } + + &:before { + left: 0; + background-position: 0 -27px; + } + + &:after { + right: 0; + background-position: -75px -27px; + } + } + + &.active { + z-index: 107; + + > div.tab-container { + + &:before { + background-position: 0 0; + } + + &:after { + background-position: -75px 0; + } + + > div { + padding-right: 30px; + border-top: 2px solid #bdc3c7; + + > span { + top: 0; + } + } + } + + &:before { + position: absolute; + content: ''; + display: block; + height: 3px; + left: 0; + bottom: 0; + width: 100%; + background: white; + } + } + + &.new-tab { + background: transparent url(../images/tab.png) no-repeat; + background-position: -24px 0; + width: 27px; + height: 22px; + + margin-left: -11px; + top: 4px; + position: relative; + cursor: pointer; + + &:hover { + background-position: -24px -32px; + } + } + } + } + } + } + + &.secondary { + > .tabs { + ul.tabs { + margin-left: 12px; + padding-left: 0; + + > li { + border-right: 1px solid #bdc3c7; + padding-right: 1px; + + > div.tab-container { + > div { + padding: 4px 10px; + + span { + font-size: 14px; + } + } + } + + .tab-control { + right: 23px; + top: 7px; + + &.close-btn { + right: 6px; + top: 5px; + } + } + + &.new-tab { + background: transparent; + border: 2px solid #e4e4e4; + width: 27px; + height: 22px; + left: 9px; + top: 7px; + position: relative; + cursor: pointer; + .border-radius(4px); + + &:hover { + background-color: #2581b8; + border-color: #2581b8; + } + } + + &.active { + padding-right: 10px; + + > div.tab-container { + > div { + color: #555555; + padding-right: 30px; + } + } + } + } + } + } + } +} + +html.gecko { + .builder-tabs.primary > .tabs > ul.tabs > li { + // Fixes a visual glitch in FireFox, noticed in v. 42 on Mac. + // + bottom: -3px; + > div.tab-container > div { + padding-top: 5px; + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexControllerOperations.php b/server/plugins/rainlab/builder/behaviors/IndexControllerOperations.php new file mode 100644 index 0000000..b87fc4e --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexControllerOperations.php @@ -0,0 +1,172 @@ +getPluginCode(); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $widget = $this->makeBaseFormWidget($controller, $options); + $this->vars['controller'] = $controller; + + $result = [ + 'tabTitle' => $this->getTabName($widget->model), + 'tabIcon' => 'icon-asterisk', + 'tabId' => $this->getTabId($pluginCodeObj->toCode(), $controller), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode() + ]) + ]; + + return $result; + } + + public function onControllerCreate() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $model = $this->loadOrCreateBaseModel(null, $options); + $model->fill($_POST); + $model->save(); + + $this->vars['controller'] = $model->controller; + + $result = $this->controller->widget->controllerList->updateList(); + + if ($model->behaviors) { + // Create a new tab only for controllers + // with behaviors. + + $widget = $this->makeBaseFormWidget($model->controller, $options); + + $tab = [ + 'tabTitle' => $this->getTabName($widget->model), + 'tabIcon' => 'icon-asterisk', + 'tabId' => $this->getTabId($pluginCodeObj->toCode(), $model->controller), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode() + ]) + ]; + + $result = array_merge($result, $tab); + } + + $this->mergeRegistryDataIntoResult($result, $pluginCodeObj); + + return $result; + } + + public function onControllerSave() + { + $controller = Input::get('controller'); + + $model = $this->loadModelFromPost(); + $model->fill($_POST); + $model->save(); + + Flash::success(Lang::get('rainlab.builder::lang.controller.saved')); + + $result['builderResponseData'] = []; + + return $result; + } + + public function onControllerShowCreatePopup() + { + $pluginCodeObj = $this->getPluginCode(); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $this->baseFormConfigFile = '~/plugins/rainlab/builder/classes/controllermodel/new-controller-fields.yaml'; + $widget = $this->makeBaseFormWidget(null, $options); + + return $this->makePartial('create-controller-popup-form', [ + 'form'=>$widget, + 'pluginCode' => $pluginCodeObj->toCode() + ]); + } + + protected function getTabName($model) + { + $pluginName = Lang::get($model->getModelPluginName()); + + return $pluginName.'/'.$model->controller; + } + + protected function getTabId($pluginCode, $controller) + { + return 'controller-'.$pluginCode.'-'.$controller; + } + + protected function loadModelFromPost() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $controller = Input::get('controller'); + + return $this->loadOrCreateBaseModel($controller, $options); + } + + protected function loadOrCreateBaseModel($controller, $options = []) + { + $model = new ControllerModel(); + + if (isset($options['pluginCode'])) { + $model->setPluginCode($options['pluginCode']); + } + + if (!$controller) { + return $model; + } + + $model->load($controller); + return $model; + } + + protected function mergeRegistryDataIntoResult(&$result, $pluginCodeObj) + { + if (!array_key_exists('builderResponseData', $result)) { + $result['builderResponseData'] = []; + } + + $pluginCode = $pluginCodeObj->toCode(); + $result['builderResponseData']['registryData'] = [ + 'urls' => ControllerModel::getPluginRegistryData($pluginCode, null), + 'pluginCode' => $pluginCode + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexDataRegistry.php b/server/plugins/rainlab/builder/behaviors/IndexDataRegistry.php new file mode 100644 index 0000000..c96ea42 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexDataRegistry.php @@ -0,0 +1,66 @@ + $result]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexDatabaseTableOperations.php b/server/plugins/rainlab/builder/behaviors/IndexDatabaseTableOperations.php new file mode 100644 index 0000000..41d5bb3 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexDatabaseTableOperations.php @@ -0,0 +1,198 @@ +getPluginCode(); + + $widget = $this->makeBaseFormWidget($tableName); + $this->vars['tableName'] = $tableName; + + $result = [ + 'tabTitle' => $this->getTabTitle($tableName), + 'tabIcon' => 'icon-hdd-o', + 'tabId' => $this->getTabId($tableName), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode(), + 'tableName' => $tableName + ]) + ]; + + return $result; + } + + public function onDatabaseTableValidateAndShowPopup() + { + $tableName = Input::get('table_name'); + + $model = $this->loadOrCreateBaseModel($tableName); + $model->fill($this->processColumnData($_POST)); + + $pluginCode = Request::input('plugin_code'); + $model->setPluginCode($pluginCode); + $model->validate(); + + $migration = $model->generateCreateOrUpdateMigration(); + + if (!$migration) { + return $this->makePartial('migration-popup-form', [ + 'noChanges' => true + ]); + } + + return $this->makePartial('migration-popup-form', [ + 'form' => $this->makeMigrationFormWidget($migration), + 'operation' => $model->isNewModel() ? 'create' : 'update', + 'table' => $model->name, + 'pluginCode' => $pluginCode + ]); + } + + public function onDatabaseTableMigrationApply() + { + $pluginCode = new PluginCode(Request::input('plugin_code')); + $model = new MigrationModel(); + $model->setPluginCodeObj($pluginCode); + + $model->fill($_POST); + + $operation = Input::get('operation'); + $table = Input::get('table'); + + $model->scriptFileName = 'builder_table_'.$operation.'_'.$table; + $model->makeScriptFileNameUnique(); + + $codeGenerator = new TableMigrationCodeGenerator(); + $model->code = $codeGenerator->wrapMigrationCode($model->scriptFileName, $model->code, $pluginCode); + + try { + $model->save(); + } + catch (Exception $ex) { + throw new ApplicationException($ex->getMessage()); + } + + $result = $this->controller->widget->databaseTabelList->updateList(); + + $result = array_merge( + $result, + $this->controller->widget->versionList->refreshActivePlugin() + ); + + $result['builderResponseData'] = [ + 'builderObjectName'=>$table, + 'tabId' => $this->getTabId($table), + 'tabTitle' => $table, + 'tableName' => $table, + 'operation' => $operation, + 'pluginCode' => $pluginCode->toCode() + ]; + + return $result; + } + + public function onDatabaseTableShowDeletePopup() + { + $tableName = Input::get('table_name'); + + $model = $this->loadOrCreateBaseModel($tableName); + $pluginCode = Request::input('plugin_code'); + $model->setPluginCode($pluginCode); + + $migration = $model->generateDropMigration(); + + return $this->makePartial('migration-popup-form', [ + 'form' => $this->makeMigrationFormWidget($migration), + 'operation' => 'delete', + 'table' => $model->name, + 'pluginCode' => $pluginCode + ]); + } + + protected function getTabTitle($tableName) + { + if (!strlen($tableName)) { + return Lang::get('rainlab.builder::lang.database.tab_new_table'); + } + + return $tableName; + } + + protected function getTabId($tableName) + { + if (!strlen($tableName)) { + return 'databaseTable-'.uniqid(time()); + } + + return 'databaseTable-'.$tableName; + } + + protected function loadOrCreateBaseModel($tableName, $options = []) + { + $model = new DatabaseTableModel(); + + if (!$tableName) { + $model->name = $this->getPluginCode()->toDatabasePrefix().'_'; + + return $model; + } + + $model->load($tableName); + return $model; + } + + protected function makeMigrationFormWidget($migration) + { + $widgetConfig = $this->makeConfig($this->migrationFormConfigFile); + + $widgetConfig->model = $migration; + $widgetConfig->alias = 'form_migration_'.uniqid(); + + $form = $this->makeWidget('Backend\Widgets\Form', $widgetConfig); + $form->context = FormController::CONTEXT_CREATE; + + return $form; + } + + protected function processColumnData($postData) + { + if (!array_key_exists('columns', $postData)) { + return $postData; + } + + $booleanColumns = ['unsigned', 'allow_null', 'auto_increment', 'primary_key']; + foreach ($postData['columns'] as &$row) { + foreach ($row as $column=>$value) { + if (in_array($column, $booleanColumns) && $value == 'false') { + $row[$column] = false; + } + } + } + + return $postData; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexLocalizationOperations.php b/server/plugins/rainlab/builder/behaviors/IndexLocalizationOperations.php new file mode 100644 index 0000000..ce2de16 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexLocalizationOperations.php @@ -0,0 +1,218 @@ +getPluginCode(); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $widget = $this->makeBaseFormWidget($language, $options); + $this->vars['originalLanguage'] = $language; + + if ($widget->model->isNewModel()) { + $widget->model->initContent(); + } + + $result = [ + 'tabTitle' => $this->getTabName($widget->model), + 'tabIcon' => 'icon-globe', + 'tabId' => $this->getTabId($pluginCodeObj->toCode(), $language), + 'isNewRecord' => $widget->model->isNewModel(), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode(), + 'language' => $language, + 'defaultLanguage' => LocalizationModel::getDefaultLanguage() + ]) + ]; + + return $result; + } + + public function onLanguageSave() + { + $model = $this->loadOrCreateLocalizationFromPost(); + $model->fill($_POST); + $model->save(false); + + Flash::success(Lang::get('rainlab.builder::lang.localization.saved')); + $result = $this->controller->widget->languageList->updateList(); + + $result['builderResponseData'] = [ + 'tabId' => $this->getTabId($model->getPluginCodeObj()->toCode(), $model->language), + 'tabTitle' => $this->getTabName($model), + 'language' => $model->language + ]; + + if ($model->language === LocalizationModel::getDefaultLanguage()) { + $pluginCode = $model->getPluginCodeObj()->toCode(); + + $registryData = [ + 'strings' => LocalizationModel::getPluginRegistryData($pluginCode, null), + 'sections' => LocalizationModel::getPluginRegistryData($pluginCode, 'sections'), + 'pluginCode' => $pluginCode + ]; + + $result['builderResponseData']['registryData'] = $registryData; + } + + return $result; + } + + public function onLanguageDelete() + { + $model = $this->loadOrCreateLocalizationFromPost(); + + $model->deleteModel(); + + return $this->controller->widget->languageList->updateList(); + } + + public function onLanguageShowCopyStringsPopup() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + $language = trim(Input::get('original_language')); + + $languages = LocalizationModel::listPluginLanguages($pluginCodeObj); + + if (strlen($language)) { + $languages = array_diff($languages, [$language]); + } + + return $this->makePartial('copy-strings-popup-form', ['languages'=>$languages]); + } + + public function onLanguageCopyStringsFrom() + { + $sourceLanguage = Request::input('copy_from'); + $destinationText = Request::input('strings'); + + $model = new LocalizationModel(); + $model->setPluginCode(Request::input('plugin_code')); + + $responseData = $model->copyStringsFrom($destinationText, $sourceLanguage); + + return ['builderResponseData' => $responseData]; + } + + public function onLanguageLoadAddStringForm() + { + return [ + 'markup' => $this->makePartial('new-string-popup') + ]; + } + + public function onLanguageCreateString() + { + $stringKey = trim(Request::input('key')); + $stringValue = trim(Request::input('value')); + + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + $pluginCode = $pluginCodeObj->toCode(); + $options = [ + 'pluginCode' => $pluginCode + ]; + + $defaultLanguage = LocalizationModel::getDefaultLanguage(); + if (LocalizationModel::languageFileExists($pluginCode, $defaultLanguage)) { + $model = $this->loadOrCreateBaseModel($defaultLanguage, $options); + } + else { + $model = LocalizationModel::initModel($pluginCode, $defaultLanguage); + } + + $newStringKey = $model->createStringAndSave($stringKey, $stringValue); + $pluginCode = $pluginCodeObj->toCode(); + + return [ + 'localizationData' => [ + 'key' => $newStringKey, + 'value' => $stringValue + ], + 'registryData' => [ + 'strings' => LocalizationModel::getPluginRegistryData($pluginCode, null), + 'sections' => LocalizationModel::getPluginRegistryData($pluginCode, 'sections') + ] + ]; + } + + public function onLanguageGetStrings() + { + $model = $this->loadOrCreateLocalizationFromPost(); + + return ['builderResponseData' => [ + 'strings' => $model ? $model->strings : null + ]]; + } + + protected function loadOrCreateLocalizationFromPost() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $originalLanguage = Input::get('original_language'); + + return $this->loadOrCreateBaseModel($originalLanguage, $options); + } + + protected function getTabName($model) + { + $pluginName = Lang::get($model->getModelPluginName()); + + if (!strlen($model->language)) { + return $pluginName.'/'.Lang::get('rainlab.builder::lang.localization.tab_new_language'); + } + + return $pluginName.'/'.$model->language; + } + + protected function getTabId($pluginCode, $language) + { + if (!strlen($language)) { + return 'localization-'.$pluginCode.'-'.uniqid(time()); + } + + return 'localization-'.$pluginCode.'-'.$language; + } + + protected function loadOrCreateBaseModel($language, $options = []) + { + $model = new LocalizationModel(); + + if (isset($options['pluginCode'])) { + $model->setPluginCode($options['pluginCode']); + } + + if (!$language) { + return $model; + } + + $model->load($language); + return $model; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexMenusOperations.php b/server/plugins/rainlab/builder/behaviors/IndexMenusOperations.php new file mode 100644 index 0000000..753e02a --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexMenusOperations.php @@ -0,0 +1,75 @@ +getPluginCode(); + + $pluginCode = $pluginCodeObj->toCode(); + $widget = $this->makeBaseFormWidget($pluginCode); + + $result = [ + 'tabTitle' => $widget->model->getPluginName().'/'.Lang::get('rainlab.builder::lang.menu.tab'), + 'tabIcon' => 'icon-location-arrow', + 'tabId' => $this->getTabId($pluginCode), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode() + ]) + ]; + + return $result; + } + + public function onMenusSave() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + + $pluginCode = $pluginCodeObj->toCode(); + $model = $this->loadOrCreateBaseModel($pluginCodeObj->toCode()); + $model->setPluginCodeObj($pluginCodeObj); + $model->fill($_POST); + $model->save(); + + Flash::success(Lang::get('rainlab.builder::lang.menu.saved')); + + $result['builderResponseData'] = [ + 'tabId' => $this->getTabId($pluginCode), + 'tabTitle' => $model->getPluginName().'/'.Lang::get('rainlab.builder::lang.menu.tab'), + ]; + + return $result; + } + + protected function getTabId($pluginCode) + { + return 'menus-'.$pluginCode; + } + + protected function loadOrCreateBaseModel($pluginCode, $options = []) + { + $model = new MenusModel(); + + $model->loadPlugin($pluginCode); + return $model; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexModelFormOperations.php b/server/plugins/rainlab/builder/behaviors/IndexModelFormOperations.php new file mode 100644 index 0000000..c4e01ef --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexModelFormOperations.php @@ -0,0 +1,186 @@ +alias = 'defaultFormBuilder'; + $formBulder->bindToController(); + } + + public function onModelFormCreateOrOpen() + { + $fileName = Input::get('file_name'); + $modelClass = Input::get('model_class'); + + $pluginCodeObj = $this->getPluginCode(); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode(), + 'modelClass' => $modelClass + ]; + + $widget = $this->makeBaseFormWidget($fileName, $options); + $this->vars['fileName'] = $fileName; + + $result = [ + 'tabTitle' => $widget->model->getDisplayName(Lang::get('rainlab.builder::lang.form.tab_new_form')), + 'tabIcon' => 'icon-check-square', + 'tabId' => $this->getTabId($modelClass, $fileName), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode(), + 'fileName' => $fileName, + 'modelClass' => $modelClass + ]) + ]; + + return $result; + } + + public function onModelFormSave() + { + $model = $this->loadOrCreateFormFromPost(); + + $model->fill($_POST); + $model->save(); + + $result = $this->controller->widget->modelList->updateList(); + + Flash::success(Lang::get('rainlab.builder::lang.form.saved')); + + $modelClass = Input::get('model_class'); + $result['builderResponseData'] = [ + 'builderObjectName' => $model->fileName, + 'tabId' => $this->getTabId($modelClass, $model->fileName), + 'tabTitle' => $model->getDisplayName(Lang::get('rainlab.builder::lang.form.tab_new_form')) + ]; + + $this->mergeRegistryDataIntoResult($result, $model, $modelClass); + + return $result; + } + + public function onModelFormDelete() + { + $model = $this->loadOrCreateFormFromPost(); + + $model->deleteModel(); + + $result = $this->controller->widget->modelList->updateList(); + + $modelClass = Input::get('model_class'); + $this->mergeRegistryDataIntoResult($result, $model, $modelClass); + + return $result; + } + + public function onModelFormGetModelFields() + { + $columnNames = ModelModel::getModelFields($this->getPluginCode(), Input::get('model_class')); + $asPlainList = Input::get('as_plain_list'); + + $result = []; + foreach ($columnNames as $columnName) { + if (!$asPlainList) { + $result[] = [ + 'title' => $columnName, + 'value' => $columnName + ]; + } + else { + $result[$columnName] = $columnName; + } + } + + return [ + 'responseData' => [ + 'options' => $result + ] + ]; + } + + protected function loadOrCreateFormFromPost() + { + $pluginCode = Request::input('plugin_code'); + $modelClass = Input::get('model_class'); + $fileName = Input::get('file_name'); + + $options = [ + 'pluginCode' => $pluginCode, + 'modelClass' => $modelClass + ]; + + return $this->loadOrCreateBaseModel($fileName, $options); + } + + protected function getTabId($modelClass, $fileName) + { + if (!strlen($fileName)) { + return 'modelForm-'.uniqid(time()); + } + + return 'modelForm-'.$modelClass.'-'.$fileName; + } + + protected function loadOrCreateBaseModel($fileName, $options = []) + { + $model = new ModelFormModel(); + + if (isset($options['pluginCode']) && isset($options['modelClass'])) { + $model->setPluginCode($options['pluginCode']); + $model->setModelClassName($options['modelClass']); + } + + if (!$fileName) { + $model->initDefaults(); + + return $model; + } + + $model->loadForm($fileName); + return $model; + } + + protected function mergeRegistryDataIntoResult(&$result, $model, $modelClass) + { + if (!array_key_exists('builderResponseData', $result)) { + $result['builderResponseData'] = []; + } + + $fullClassName = $model->getPluginCodeObj()->toPluginNamespace().'\\Models\\'.$modelClass; + $pluginCode = $model->getPluginCodeObj()->toCode(); + $result['builderResponseData']['registryData'] = [ + 'forms' => ModelFormModel::getPluginRegistryData($pluginCode, $modelClass), + 'pluginCode' => $pluginCode, + 'modelClass' => $fullClassName + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexModelListOperations.php b/server/plugins/rainlab/builder/behaviors/IndexModelListOperations.php new file mode 100644 index 0000000..daaebcf --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexModelListOperations.php @@ -0,0 +1,176 @@ +getPluginCode(); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode(), + 'modelClass' => $modelClass + ]; + + $widget = $this->makeBaseFormWidget($fileName, $options); + $this->vars['fileName'] = $fileName; + + $result = [ + 'tabTitle' => $widget->model->getDisplayName(Lang::get('rainlab.builder::lang.list.tab_new_list')), + 'tabIcon' => 'icon-list', + 'tabId' => $this->getTabId($modelClass, $fileName), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode(), + 'fileName' => $fileName, + 'modelClass' => $modelClass + ]) + ]; + + return $result; + } + + public function onModelListSave() + { + $model = $this->loadOrCreateListFromPost(); + $model->fill($_POST); + $model->save(); + + $result = $this->controller->widget->modelList->updateList(); + + Flash::success(Lang::get('rainlab.builder::lang.list.saved')); + + $modelClass = Input::get('model_class'); + $result['builderResponseData'] = [ + 'builderObjectName' => $model->fileName, + 'tabId' => $this->getTabId($modelClass, $model->fileName), + 'tabTitle' => $model->getDisplayName(Lang::get('rainlab.builder::lang.list.tab_new_list')) + ]; + + $this->mergeRegistryDataIntoResult($result, $model, $modelClass); + + return $result; + } + + public function onModelListDelete() + { + $model = $this->loadOrCreateListFromPost(); + + $model->deleteModel(); + + $result = $this->controller->widget->modelList->updateList(); + + $modelClass = Input::get('model_class'); + $this->mergeRegistryDataIntoResult($result, $model, $modelClass); + + return $result; + } + + public function onModelListGetModelFields() + { + $columnNames = ModelModel::getModelFields($this->getPluginCode(), Input::get('model_class')); + + $result = []; + foreach ($columnNames as $columnName) { + $result[] = [ + 'title' => $columnName, + 'value' => $columnName + ]; + } + + return [ + 'responseData' => [ + 'options' => $result + ] + ]; + } + + public function onModelListLoadDatabaseColumns() + { + $columns = ModelModel::getModelColumnsAndTypes($this->getPluginCode(), Input::get('model_class')); + + return [ + 'responseData' => [ + 'columns' => $columns + ] + ]; + } + + protected function loadOrCreateListFromPost() + { + $pluginCode = Request::input('plugin_code'); + $modelClass = Input::get('model_class'); + $fileName = Input::get('file_name'); + + $options = [ + 'pluginCode' => $pluginCode, + 'modelClass' => $modelClass + ]; + + return $this->loadOrCreateBaseModel($fileName, $options); + } + + protected function getTabId($modelClass, $fileName) + { + if (!strlen($fileName)) { + return 'modelForm-'.uniqid(time()); + } + + return 'modelList-'.$modelClass.'-'.$fileName; + } + + protected function loadOrCreateBaseModel($fileName, $options = []) + { + $model = new ModelListModel(); + + if (isset($options['pluginCode']) && isset($options['modelClass'])) { + $model->setPluginCode($options['pluginCode']); + $model->setModelClassName($options['modelClass']); + } + + if (!$fileName) { + $model->initDefaults(); + + return $model; + } + + $model->loadForm($fileName); + return $model; + } + + protected function mergeRegistryDataIntoResult(&$result, $model, $modelClass) + { + if (!array_key_exists('builderResponseData', $result)) { + $result['builderResponseData'] = []; + } + + $fullClassName = $model->getPluginCodeObj()->toPluginNamespace().'\\Models\\'.$modelClass; + $pluginCode = $model->getPluginCodeObj()->toCode(); + $result['builderResponseData']['registryData'] = [ + 'lists' => ModelListModel::getPluginRegistryData($pluginCode, $modelClass), + 'pluginCode' => $pluginCode, + 'modelClass' => $fullClassName + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexModelOperations.php b/server/plugins/rainlab/builder/behaviors/IndexModelOperations.php new file mode 100644 index 0000000..5d583fb --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexModelOperations.php @@ -0,0 +1,69 @@ +getPluginCode(); + + try { + $widget = $this->makeBaseFormWidget(null); + $this->vars['form'] = $widget; + $widget->model->setPluginCodeObj($pluginCodeObj); + $this->vars['pluginCode'] = $pluginCodeObj->toCode(); + } + catch (ApplicationException $ex) { + $this->vars['errorMessage'] = $ex->getMessage(); + } + + return $this->makePartial('model-popup-form'); + } + + public function onModelSave() + { + $pluginCode = Request::input('plugin_code'); + + $model = $this->loadOrCreateBaseModel(null); + $model->setPluginCode($pluginCode); + + $model->fill($_POST); + $model->save(); + + $result = $this->controller->widget->modelList->updateList(); + + $builderResponseData = [ + 'registryData' => [ + 'models' => ModelModel::getPluginRegistryData($pluginCode, null), + 'pluginCode' => $pluginCode + ] + ]; + + $result['builderResponseData'] = $builderResponseData; + + return $result; + } + + protected function loadOrCreateBaseModel($className, $options = []) + { + // Editing model is not supported, always return + // a new object. + + return new ModelModel(); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexPermissionsOperations.php b/server/plugins/rainlab/builder/behaviors/IndexPermissionsOperations.php new file mode 100644 index 0000000..dc1d138 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexPermissionsOperations.php @@ -0,0 +1,76 @@ +getPluginCode(); + + $pluginCode = $pluginCodeObj->toCode(); + $widget = $this->makeBaseFormWidget($pluginCode); + + $result = [ + 'tabTitle' => Lang::get($widget->model->getPluginName()).'/'.Lang::get('rainlab.builder::lang.permission.tab'), + 'tabIcon' => 'icon-unlock-alt', + 'tabId' => $this->getTabId($pluginCode), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode() + ]) + ]; + + return $result; + } + + public function onPermissionsSave() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + + $pluginCode = $pluginCodeObj->toCode(); + $model = $this->loadOrCreateBaseModel($pluginCodeObj->toCode()); + $model->setPluginCodeObj($pluginCodeObj); + $model->fill($_POST); + $model->save(); + + Flash::success(Lang::get('rainlab.builder::lang.permission.saved')); + + $result['builderResponseData'] = [ + 'tabId' => $this->getTabId($pluginCode), + 'tabTitle' => $model->getPluginName().'/'.Lang::get('rainlab.builder::lang.permission.tab'), + 'pluginCode' => $pluginCode + ]; + + return $result; + } + + protected function getTabId($pluginCode) + { + return 'permissions-'.$pluginCode; + } + + protected function loadOrCreateBaseModel($pluginCode, $options = []) + { + $model = new PermissionsModel(); + + $model->loadPlugin($pluginCode); + return $model; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexPluginOperations.php b/server/plugins/rainlab/builder/behaviors/IndexPluginOperations.php new file mode 100644 index 0000000..14ccffc --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexPluginOperations.php @@ -0,0 +1,91 @@ +vars['form'] = $this->makeBaseFormWidget($pluginCode); + $this->vars['pluginCode'] = $pluginCode; + } + catch (ApplicationException $ex) { + $this->vars['errorMessage'] = $ex->getMessage(); + } + + return $this->makePartial('plugin-popup-form'); + } + + public function onPluginSave() + { + $pluginCode = Input::get('pluginCode'); + + $model = $this->loadOrCreateBaseModel($pluginCode); + $model->fill($_POST); + $model->save(); + + if (!$pluginCode) { + $result = []; + + $result['responseData'] = [ + 'pluginCode' => $model->getPluginCode(), + 'isNewPlugin' => 1 + ]; + + return $result; + } else { + $result = []; + + $result['responseData'] = [ + 'pluginCode' => $model->getPluginCode() + ]; + + return array_merge($result, $this->controller->updatePluginList()); + } + } + + public function onPluginSetActive() + { + $pluginCode = Input::get('pluginCode'); + $updatePluginList = Input::get('updatePluginList'); + + $result = $this->controller->setBuilderActivePlugin($pluginCode, false); + + if ($updatePluginList) { + $result = array_merge($result, $this->controller->updatePluginList()); + } + + $result['responseData'] = ['pluginCode'=>$pluginCode]; + + return $result; + } + + protected function loadOrCreateBaseModel($pluginCode, $options = []) + { + $model = new PluginBaseModel(); + + if (!$pluginCode) { + $model->initDefaults(); + return $model; + } + + $model->loadPlugin($pluginCode); + return $model; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/IndexVersionsOperations.php b/server/plugins/rainlab/builder/behaviors/IndexVersionsOperations.php new file mode 100644 index 0000000..d5f7b05 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/IndexVersionsOperations.php @@ -0,0 +1,178 @@ +getPluginCode(); + + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $widget = $this->makeBaseFormWidget($versionNumber, $options); + $this->vars['originalVersion'] = $versionNumber; + + if ($widget->model->isNewModel()) { + $versionType = Input::get('version_type'); + $widget->model->initVersion($versionType); + } + + $result = [ + 'tabTitle' => $this->getTabName($versionNumber, $widget->model), + 'tabIcon' => 'icon-code-fork', + 'tabId' => $this->getTabId($pluginCodeObj->toCode(), $versionNumber), + 'isNewRecord' => $widget->model->isNewModel(), + 'tab' => $this->makePartial('tab', [ + 'form' => $widget, + 'pluginCode' => $pluginCodeObj->toCode(), + 'originalVersion' => $versionNumber + ]) + ]; + + return $result; + } + + public function onVersionSave() + { + $model = $this->loadOrCreateListFromPost(); + $model->fill($_POST); + $model->save(false); + + Flash::success(Lang::get('rainlab.builder::lang.version.saved')); + $result = $this->controller->widget->versionList->updateList(); + + $result['builderResponseData'] = [ + 'tabId' => $this->getTabId($model->getPluginCodeObj()->toCode(), $model->version), + 'tabTitle' => $this->getTabName($model->version, $model), + 'savedVersion' => $model->version, + 'isApplied' => $model->isApplied() + ]; + + return $result; + } + + public function onVersionDelete() + { + $model = $this->loadOrCreateListFromPost(); + + $model->deleteModel(); + + return $this->controller->widget->versionList->updateList(); + } + + public function onVersionApply() + { + // Save the version before applying it + // + $model = $this->loadOrCreateListFromPost(); + $model->fill($_POST); + $model->save(false); + + // Apply the version + // + $model->apply(); + + Flash::success(Lang::get('rainlab.builder::lang.version.applied')); + $result = $this->controller->widget->versionList->updateList(); + + $result['builderResponseData'] = [ + 'tabId' => $this->getTabId($model->getPluginCodeObj()->toCode(), $model->version), + 'tabTitle' => $this->getTabName($model->version, $model), + 'savedVersion' => $model->version + ]; + + return $result; + } + + public function onVersionRollback() + { + // Save the version before rolling it back + // + $model = $this->loadOrCreateListFromPost(); + $model->fill($_POST); + $model->save(false); + + // Rollback the version + // + $model->rollback(); + + Flash::success(Lang::get('rainlab.builder::lang.version.rolled_back')); + $result = $this->controller->widget->versionList->updateList(); + + $result['builderResponseData'] = [ + 'tabId' => $this->getTabId($model->getPluginCodeObj()->toCode(), $model->version), + 'tabTitle' => $this->getTabName($model->version, $model), + 'savedVersion' => $model->version + ]; + + return $result; + } + + protected function loadOrCreateListFromPost() + { + $pluginCodeObj = new PluginCode(Request::input('plugin_code')); + $options = [ + 'pluginCode' => $pluginCodeObj->toCode() + ]; + + $versionNumber = Input::get('original_version'); + + return $this->loadOrCreateBaseModel($versionNumber, $options); + } + + protected function getTabName($version, $model) + { + $pluginName = Lang::get($model->getModelPluginName()); + + if (!strlen($version)) { + return $pluginName.'/'.Lang::get('rainlab.builder::lang.version.tab_new_version'); + } + + return $pluginName.'/v'.$version; + } + + protected function getTabId($pluginCode, $version) + { + if (!strlen($version)) { + return 'version-'.$pluginCode.'-'.uniqid(time()); + } + + return 'version-'.$pluginCode.'-'.$version; + } + + protected function loadOrCreateBaseModel($versionNumber, $options = []) + { + $model = new MigrationModel(); + + if (isset($options['pluginCode'])) { + $model->setPluginCode($options['pluginCode']); + } + + if (!$versionNumber) { + return $model; + } + + $model->load($versionNumber); + return $model; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_create-controller-popup-form.htm b/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_create-controller-popup-form.htm new file mode 100644 index 0000000..9e77dc9 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_create-controller-popup-form.htm @@ -0,0 +1,26 @@ +'controller:cmdCreateController', + 'data-plugin-code' => $pluginCode +]) ?> + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_tab.htm new file mode 100644 index 0000000..7e10672 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_tab.htm @@ -0,0 +1,11 @@ + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'controller', + 'onsubmit' => 'return false' +]) ?> + render() ?> + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_toolbar.htm new file mode 100644 index 0000000..c520b12 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexcontrolleroperations/partials/_toolbar.htm @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_migration-popup-form.htm b/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_migration-popup-form.htm new file mode 100644 index 0000000..4fc0d18 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_migration-popup-form.htm @@ -0,0 +1,49 @@ +'databaseTable:cmdSaveMigration', + 'id'=>'builderTableMigrationPopup' +]) ?> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_tab.htm new file mode 100644 index 0000000..4d690a0 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_tab.htm @@ -0,0 +1,15 @@ + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'database', + 'onsubmit' => 'return false', + 'data-lang-add-timestamps' => e(trans('rainlab.builder::lang.database.btn_add_timestamps')), + 'data-lang-add-soft-delete' => e(trans('rainlab.builder::lang.database.btn_add_soft_deleting')), + 'data-lang-timestamps-exist' => e(trans('rainlab.builder::lang.database.timestamps_exist')), + 'data-lang-soft-deleting-exist' => e(trans('rainlab.builder::lang.database.soft_deleting_exist')), +]) ?> + render() ?> + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_toolbar.htm new file mode 100644 index 0000000..51cb08e --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexdatabasetableoperations/partials/_toolbar.htm @@ -0,0 +1,17 @@ +
    + + + + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_copy-strings-popup-form.htm b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_copy-strings-popup-form.htm new file mode 100644 index 0000000..2480da4 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_copy-strings-popup-form.htm @@ -0,0 +1,41 @@ +'localization:cmdCopyMissingStrings' +]) ?> + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_new-string-popup.htm b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_new-string-popup.htm new file mode 100644 index 0000000..a410d7a --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_new-string-popup.htm @@ -0,0 +1,42 @@ +'return false' +]) ?> + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_tab.htm new file mode 100644 index 0000000..7b68bb2 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_tab.htm @@ -0,0 +1,15 @@ + 'layout hide-secondary-tabs', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-new-string-message' => e(trans('rainlab.builder::lang.localization.new_string_warning')), + 'data-structure-mismatch' => e(trans('rainlab.builder::lang.localization.structure_mismatch')), + 'data-entity' => 'localization', + 'data-default-language' => e($defaultLanguage), + 'onsubmit' => 'return false' +]) ?> + render() ?> + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_toolbar.htm new file mode 100644 index 0000000..85b3e7c --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexlocalizationoperations/partials/_toolbar.htm @@ -0,0 +1,27 @@ +
    + + + + + + + + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_tab.htm new file mode 100644 index 0000000..db93b35 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_tab.htm @@ -0,0 +1,11 @@ + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'menus', + 'onsubmit' => 'return false' +]) ?> + render() ?> + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_toolbar.htm new file mode 100644 index 0000000..ba880c5 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmenusoperations/partials/_toolbar.htm @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_tab.htm new file mode 100644 index 0000000..ae1ba27 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_tab.htm @@ -0,0 +1,13 @@ + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'models', + 'onsubmit' => 'return false' +]) ?> + render() ?> + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_toolbar.htm new file mode 100644 index 0000000..f24de8c --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmodelformoperations/partials/_toolbar.htm @@ -0,0 +1,17 @@ +
    + + + + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_tab.htm new file mode 100644 index 0000000..aa1139f --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_tab.htm @@ -0,0 +1,16 @@ + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'models', + 'onsubmit' => 'return false', + 'data-sub-entity' => 'model-list', + 'data-lang-add-database-columns' => e(trans('rainlab.builder::lang.list.btn_add_database_columns')), + 'data-lang-all-database-columns-exist' => e(trans('rainlab.builder::lang.list.all_database_columns_exist')), +]) ?> + render() ?> + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_toolbar.htm new file mode 100644 index 0000000..eb8ecdf --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmodellistoperations/partials/_toolbar.htm @@ -0,0 +1,17 @@ +
    + + + + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexmodeloperations/partials/_model-popup-form.htm b/server/plugins/rainlab/builder/behaviors/indexmodeloperations/partials/_model-popup-form.htm new file mode 100644 index 0000000..19eeb3c --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexmodeloperations/partials/_model-popup-form.htm @@ -0,0 +1,32 @@ +'model:cmdApplyModelSettings' +]) ?> + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_tab.htm new file mode 100644 index 0000000..bea6379 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_tab.htm @@ -0,0 +1,11 @@ + 'layout', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'permissions', + 'onsubmit' => 'return false' +]) ?> + render() ?> + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_toolbar.htm new file mode 100644 index 0000000..6e416a5 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexpermissionsoperations/partials/_toolbar.htm @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-popup-form.htm b/server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-popup-form.htm new file mode 100644 index 0000000..2ad850f --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-popup-form.htm @@ -0,0 +1,33 @@ +'plugin:cmdApplyPluginSettings' +]) ?> + + + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-update-hint.htm b/server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-update-hint.htm new file mode 100644 index 0000000..0feedb0 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexpluginoperations/partials/_plugin-update-hint.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_tab.htm b/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_tab.htm new file mode 100644 index 0000000..526aa3c --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_tab.htm @@ -0,0 +1,42 @@ + 'layout hide-secondary-tabs', + 'data-change-monitor' => 'true', + 'data-window-close-confirm' => e(trans('backend::lang.form.confirm_tab_close')), + 'data-entity' => 'versions', + 'onsubmit' => 'return false' +]) ?> + render() ?> + + + + + + + + + + + + + + + diff --git a/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_toolbar.htm b/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_toolbar.htm new file mode 100644 index 0000000..a44d9ee --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_toolbar.htm @@ -0,0 +1,33 @@ +
    + + + + + + + + + + + + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_version-hint-block.htm b/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_version-hint-block.htm new file mode 100644 index 0000000..03bf8c0 --- /dev/null +++ b/server/plugins/rainlab/builder/behaviors/indexversionsoperations/partials/_version-hint-block.htm @@ -0,0 +1,28 @@ + +
    + + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/BaseModel.php b/server/plugins/rainlab/builder/classes/BaseModel.php new file mode 100644 index 0000000..ad61820 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/BaseModel.php @@ -0,0 +1,131 @@ +updatedData = []; + + foreach ($attributes as $key => $value) { + if (!in_array($key, static::$fillable)) { + continue; + } + + $methodName = 'set'.ucfirst($key); + if (method_exists($this, $methodName)) { + $this->$methodName($value); + } + else { + if (is_scalar($value) && strpos($value, ' ') !== false) { + $value = trim($value); + } + + $this->$key = $value; + } + + $this->updatedData[$key] = $value; + } + } + + public function validate() + { + $existingData = []; + foreach (static::$fillable as $field) { + $existingData[$field] = $this->$field; + } + + $validation = Validator::make( + array_merge($existingData, $this->updatedData), + $this->validationRules, + $this->validationMessages + ); + + if ($validation->fails()) { + throw new ValidationException($validation); + } + + if (!$this->isNewModel()) { + $this->validateBeforeCreate(); + } + } + + public function isNewModel() + { + return $this->exists === false; + } + + /** + * Sets a string code of a plugin the model is associated with + * @param string $code Specifies the plugin code + */ + public function setPluginCode($code) + { + $this->pluginCodeObj = new PluginCode($code); + } + + /** + * Sets a code object of a plugin the model is associated with + * @param PluginCode $obj Specifies the plugin code object + */ + public function setPluginCodeObj($obj) + { + $this->pluginCodeObj = $obj; + } + + protected function validateBeforeCreate() + { + } + + public function getModelPluginName() + { + $pluginCodeObj = $this->getPluginCodeObj(); + $pluginCode = $pluginCodeObj->toCode(); + + $vector = PluginVector::createFromPluginCode($pluginCode); + if ($vector) { + return $vector->getPluginName(); + } + + return null; + } + + public function getPluginCodeObj() + { + if (!$this->pluginCodeObj) { + throw new SystemException(sprintf('The active plugin is not set in the %s object.', get_class($this))); + } + + return $this->pluginCodeObj; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/BehaviorDesignTimeProviderBase.php b/server/plugins/rainlab/builder/classes/BehaviorDesignTimeProviderBase.php new file mode 100644 index 0000000..e6fd42b --- /dev/null +++ b/server/plugins/rainlab/builder/classes/BehaviorDesignTimeProviderBase.php @@ -0,0 +1,34 @@ +modelListCache !== null) { + return $this->modelListCache; + } + + $key = 'builder-global-model-list'; + $cached = Cache::get($key, false); + + if ($cached !== false && ($cached = @unserialize($cached)) !== false) { + return $this->modelListCache = $cached; + } + + $plugins = PluginBaseModel::listAllPluginCodes(); + + $result = []; + foreach ($plugins as $pluginCode) { + try { + $pluginCodeObj = new PluginCode($pluginCode); + + $models = ModelModel::listPluginModels($pluginCodeObj); + + $pluginCodeStr = $pluginCodeObj->toCode(); + $pluginModelsNamespace = $pluginCodeObj->toPluginNamespace().'\\Models\\'; + foreach ($models as $model) { + $fullClassName = $pluginModelsNamespace.$model->className; + + $result[$fullClassName] = $pluginCodeStr.' - '.$model->className; + } + } + catch (Exception $ex) { + // Ignore invalid plugins and models + } + } + + Cache::put($key, serialize($result), 1); + + return $this->modelListCache = $result; + } + + public function getModelClassDesignTime() + { + $modelClass = trim(Input::get('modelClass')); + + if ($modelClass && !is_scalar($modelClass)) { + throw new ApplicationException('Model class name should be a string.'); + } + + if (!strlen($modelClass)) { + $models = $this->listGlobalModels(); + $modelClass = key($models); + } + + if (!ModelModel::validateModelClassName($modelClass)) { + throw new ApplicationException('Invalid model class name.'); + } + + return $modelClass; + } + + public function listModelColumnNames() + { + $modelClass = $this->getModelClassDesignTime(); + + $key = md5('builder-global-model-list-'.$modelClass); + $cached = Cache::get($key, false); + + if ($cached !== false && ($cached = @unserialize($cached)) !== false) { + return $cached; + } + + $pluginCodeObj = PluginCode::createFromNamespace($modelClass); + + $modelClassParts = explode('\\', $modelClass); // The full class name is already validated in PluginCode::createFromNamespace() + $modelClass = array_pop($modelClassParts); + + $columnNames = ModelModel::getModelFields($pluginCodeObj, $modelClass); + + $result = []; + foreach ($columnNames as $columnName) { + $result[$columnName] = $columnName; + } + + Cache::put($key, serialize($result), 1); + + return $result; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ControlDesignTimeProviderBase.php b/server/plugins/rainlab/builder/classes/ControlDesignTimeProviderBase.php new file mode 100644 index 0000000..c0243d5 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ControlDesignTimeProviderBase.php @@ -0,0 +1,42 @@ +groupedControls !== null) { + return $returnGrouped ? $this->groupedControls : $this->controls; + } + + $this->groupedControls = [ + $this->resolveControlGroupName(self::GROUP_STANDARD) => [], + $this->resolveControlGroupName(self::GROUP_WIDGETS) => [] + ]; + + Event::fire('pages.builder.registerControls', [$this]); + + foreach ($this->controls as $controlType=>$controlInfo) { + $controlGroup = $this->resolveControlGroupName($controlInfo['group']); + + if (!array_key_exists($controlGroup, $this->groupedControls)) { + $this->groupedControls[$controlGroup] = []; + } + + $this->groupedControls[$controlGroup][$controlType] = $controlInfo; + } + + return $returnGrouped ? $this->groupedControls : $this->controls; + } + + /** + * Returns information about a control by its code. + * @param string $code Specifies the control code. + * @return array Returns an associative array or null if the control is not registered. + */ + public function getControlInfo($code) + { + $controls = $this->listControls(false); + + if (array_key_exists($code, $controls)) { + return $controls[$code]; + } + + return [ + 'properties' => [], + 'designTimeProvider' => self::DEFAULT_DESIGN_TIME_PROVIDER, + 'name' => $code, + 'description' => null, + 'unknownControl' => true + ]; + } + + /** + * Registers a control. + * @param string $code Specifies the control code, for example "codeeditor". + * @param string $name Specifies the control name, for example "Code editor". + * @param string $description Specifies the control descritpion, can be empty. + * @param string|integer $controlGroup Specifies the control group. + * Control groups are used to create tabs in the Control Palette in Form Builder. + * The group could one of the ControlLibrary::GROUP_ constants or a string. + * @param string $icon Specifies the control icon for the Control Palette. + * @see http://octobercms.com/docs/ui/icon + * @param array $properties Specifies the control properties. + * The property definitions should be compatible with Inspector properties, similarly + * to the Component properties: http://octobercms.com/docs/plugin/components#component-properties + * Use the getStandardProperties() of the ControlLibrary to get the standard control properties. + * @param string $designTimeProviderClass Specifies the control design-time provider class name. + * The class should extend RainLab\Builder\Classes\ControlDesignTimeProviderBase. If the class is not provided, + * the default control design and design settings will be used. + */ + public function registerControl($code, $name, $description, $controlGroup, $icon, $properties, $designTimeProviderClass) + { + if (!$designTimeProviderClass) { + $designTimeProviderClass = self::DEFAULT_DESIGN_TIME_PROVIDER; + } + + $this->controls[$code] = [ + 'group' => $controlGroup, + 'name' => $name, + 'description' => $description, + 'icon' => $icon, + 'properties' => $properties, + 'designTimeProvider' => $designTimeProviderClass + ]; + } + + public function getStandardProperties($excludeProperties = [], $addProperties = []) + { + $result = [ + 'label' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_label_title'), + 'type' => 'builderLocalization', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_label_required') + ] + ] + ], + 'oc.comment' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_comment_title'), + 'type' => 'builderLocalization', + ], + 'oc.commentPosition' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_comment_position'), + 'type' => 'dropdown', + 'options' => [ + 'above' => Lang::get('rainlab.builder::lang.form.property_comment_position_above'), + 'below' => Lang::get('rainlab.builder::lang.form.property_comment_position_below') + ], + 'ignoreIfEmpty' => true, + ], + 'span' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_span_title'), + 'type' => 'dropdown', + 'default' => 'full', + 'options' => [ + 'left' => Lang::get('rainlab.builder::lang.form.span_left'), + 'right' => Lang::get('rainlab.builder::lang.form.span_right'), + 'full' => Lang::get('rainlab.builder::lang.form.span_full'), + 'auto' => Lang::get('rainlab.builder::lang.form.span_auto') + ] + ], + 'placeholder' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_placeholder_title'), + 'type' => 'builderLocalization', + ], + 'default' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_default_title'), + 'type' => 'builderLocalization', + ], + 'cssClass' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_css_class_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_css_class_description'), + 'type' => 'string' + ], + 'disabled' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_disabled_title'), + 'type' => 'checkbox' + ], + 'hidden' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_hidden_title'), + 'type' => 'checkbox' + ], + 'required' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_required_title'), + 'type' => 'checkbox' + ], + 'stretch' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_stretch_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_stretch_description'), + 'type' => 'checkbox' + ], + 'context' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_context_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_context_description'), + 'type' => 'set', + 'items' => [ + 'create' => Lang::get('rainlab.builder::lang.form.property_context_create'), + 'update' => Lang::get('rainlab.builder::lang.form.property_context_update'), + 'preview' => Lang::get('rainlab.builder::lang.form.property_context_preview') + ], + 'default' => ['create', 'update', 'preview'], + 'ignoreIfDefault' => true + ] + ]; + + $result = array_merge($result, $addProperties); + + $advancedProperties = [ + 'defaultFrom' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_default_from_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_default_from_description'), + 'type' => 'dropdown', + 'group' => Lang::get('rainlab.builder::lang.form.property_group_advanced'), + 'ignoreIfEmpty' => true, + 'fillFrom' => 'form-controls' + ], + 'dependsOn' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_dependson_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_dependson_description'), + 'type' => 'stringList', + 'group' => Lang::get('rainlab.builder::lang.form.property_group_advanced'), + ], + 'trigger' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_trigger_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_trigger_description'), + 'type' => 'object', + 'group' => Lang::get('rainlab.builder::lang.form.property_group_advanced'), + 'ignoreIfPropertyEmpty' => 'field', + 'properties' => [ + [ + 'property' => 'action', + 'title' => Lang::get('rainlab.builder::lang.form.property_trigger_action'), + 'type' => 'dropdown', + 'options' => [ + 'show' => Lang::get('rainlab.builder::lang.form.property_trigger_show'), + 'hide' => Lang::get('rainlab.builder::lang.form.property_trigger_hide'), + 'enable' => Lang::get('rainlab.builder::lang.form.property_trigger_enable'), + 'disable' => Lang::get('rainlab.builder::lang.form.property_trigger_disable'), + 'empty' => Lang::get('rainlab.builder::lang.form.property_trigger_empty') + ] + ], + [ + 'property' => 'field', + 'title' => Lang::get('rainlab.builder::lang.form.property_trigger_field'), + 'description' => Lang::get('rainlab.builder::lang.form.property_trigger_field_description'), + 'type' => 'dropdown', + 'fillFrom' => 'form-controls' + ], + [ + 'property' => 'condition', + 'title' => Lang::get('rainlab.builder::lang.form.property_trigger_condition'), + 'description' => Lang::get('rainlab.builder::lang.form.property_trigger_condition_description'), + 'type' => 'autocomplete', + 'items' => [ + 'checked' => Lang::get('rainlab.builder::lang.form.property_trigger_condition_checked'), + 'unchecked' => Lang::get('rainlab.builder::lang.form.property_trigger_condition_unchecked'), + 'value[somevalue]' => Lang::get('rainlab.builder::lang.form.property_trigger_condition_somevalue'), + ] + ] + ] + ], + 'preset' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_preset_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_preset_description'), + 'type' => 'object', + 'group' => Lang::get('rainlab.builder::lang.form.property_group_advanced'), + 'ignoreIfPropertyEmpty' => 'field', + 'properties' => [ + [ + 'property' => 'field', + 'title' => Lang::get('rainlab.builder::lang.form.property_preset_field'), + 'description' => Lang::get('rainlab.builder::lang.form.property_preset_field_description'), + 'type' => 'dropdown', + 'fillFrom' => 'form-controls' + ], + [ + 'property' => 'type', + 'title' => Lang::get('rainlab.builder::lang.form.property_preset_type'), + 'description' => Lang::get('rainlab.builder::lang.form.property_preset_type_description'), + 'type' => 'dropdown', + 'options' => [ + 'url' => 'URL', + 'file' => 'File', + 'slug' => 'Slug', + 'camel' => 'Camel' + ] + ] + ] + ], + 'attributes' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_attributes_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_attributes_description'), + 'type' => 'dictionary', + 'group' => Lang::get('rainlab.builder::lang.form.property_group_advanced'), + ], + 'containerAttributes' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_container_attributes_title'), + 'description' => Lang::get('rainlab.builder::lang.form.property_container_attributes_description'), + 'type' => 'dictionary', + 'group' => Lang::get('rainlab.builder::lang.form.property_group_advanced'), + ] + ]; + + $result = array_merge($result, $advancedProperties); + + foreach ($excludeProperties as $property) { + if (array_key_exists($property, $result)) { + unset($result[$property]); + } + } + + return $result; + } + + protected function resolveControlGroupName($group) + { + if ($group === self::GROUP_STANDARD) { + return Lang::get('rainlab.builder::lang.form.control_group_standard'); + } + + if ($group === self::GROUP_WIDGETS) { + return Lang::get('rainlab.builder::lang.form.control_group_widgets'); + } + + return Lang::get($group); + } +} diff --git a/server/plugins/rainlab/builder/classes/ControllerBehaviorLibrary.php b/server/plugins/rainlab/builder/classes/ControllerBehaviorLibrary.php new file mode 100644 index 0000000..ffc1a04 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ControllerBehaviorLibrary.php @@ -0,0 +1,78 @@ +listBehaviors(); + + if (!array_key_exists($behaviorClassName, $behaviors)) { + return null; + } + + return $behaviors[$behaviorClassName]; + } + + /** + * Registers a controller behavior. + * @param string $class Specifies the behavior class name. + * @param string $name Specifies the behavior name, for example "Form behavior". + * @param string $description Specifies the behavior description. + * @param array $properties Specifies the behavior properties. + * The property definitions should be compatible with Inspector properties, similarly + * to the Component properties: http://octobercms.com/docs/plugin/components#component-properties + * @param string $configFilePropertyName Specifies the name of the controller property that contains the configuration file name for the behavior. + * @param string $designTimeProviderClass Specifies the behavior design-time provider class name. + * The class should extend RainLab\Builder\Classes\BehaviorDesignTimeProviderBase. If the class is not provided, + * the default control design and design settings will be used. + * @param string $configFileName Default behavior configuration file name, for example config_form.yaml. + * @param array $viewTemplates An array of view templates that are required for the behavior. + * The templates are used when a new controller is created. The templates should be specified as paths + * to Twig files in the format ['~/plugins/author/plugin/behaviors/behaviorname/templates/view.htm.tpl']. + */ + public function registerBehavior($class, $name, $description, $properties, $configFilePropertyName, $designTimeProviderClass, $configFileName, $viewTemplates = []) + { + if (!$designTimeProviderClass) { + $designTimeProviderClass = self::DEFAULT_DESIGN_TIME_PROVIDER; + } + + $this->behaviors[$class] = [ + 'class' => $class, + 'name' => Lang::get($name), + 'description' => Lang::get($description), + 'properties' => $properties, + 'designTimeProvider' => $designTimeProviderClass, + 'viewTemplates' => $viewTemplates, + 'configFileName' => $configFileName, + 'configPropertyName' => $configFilePropertyName + ]; + } + + public function listBehaviors() + { + if ($this->behaviors !== null) { + return $this->behaviors; + } + + $this->behaviors = []; + + Event::fire('pages.builder.registerControllerBehaviors', [$this]); + + return $this->behaviors; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ControllerFileParser.php b/server/plugins/rainlab/builder/classes/ControllerFileParser.php new file mode 100644 index 0000000..6283242 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ControllerFileParser.php @@ -0,0 +1,125 @@ +stream = new PhpSourceStream($fileContents); + } + + public function listBehaviors() + { + $this->stream->reset(); + + while ($this->stream->forward()) { + $tokenCode = $this->stream->getCurrentCode(); + + if ($tokenCode == T_PUBLIC) { + $behaviors = $this->extractBehaviors(); + if ($behaviors !== false) { + return $behaviors; + } + } + } + } + + public function getStringPropertyValue($property) + { + $this->stream->reset(); + + while ($this->stream->forward()) { + $tokenCode = $this->stream->getCurrentCode(); + + if ($tokenCode == T_PUBLIC) { + $value = $this->extractPropertyValue($property); + if ($value !== false) { + return $value; + } + } + } + } + + protected function extractBehaviors() + { + if ($this->stream->getNextExpected(T_WHITESPACE) === null) { + return false; + } + + if ($this->stream->getNextExpected(T_VARIABLE) === null) { + return false; + } + + if ($this->stream->getCurrentText() != '$implement') { + return false; + } + + if ($this->stream->getNextExpectedTerminated(['=', T_WHITESPACE], ['[', T_ARRAY]) === null) { + return false; + } + + if ($this->stream->getCurrentText() === 'array') { + // For the array syntax 'array(' - forward to the next + // character after the opening bracket + + if ($this->stream->getNextExpectedTerminated(['(', T_WHITESPACE], [T_CONSTANT_ENCAPSED_STRING]) === null) { + return false; + } + + $this->stream->back(); + } + + $result = []; + while ($line = $this->stream->getNextExpectedTerminated([T_CONSTANT_ENCAPSED_STRING, T_WHITESPACE], [',', ']', ')'])) { + $line = $this->stream->unquotePhpString(trim($line)); + if (!strlen($line)) { + continue; + } + + $result[] = $this->normalizeBehaviorClassName($line); + } + + return $result; + } + + protected function extractPropertyValue($property) + { + if ($this->stream->getNextExpected(T_WHITESPACE) === null) { + return false; + } + + if ($this->stream->getNextExpected(T_VARIABLE) === null) { + return false; + } + + if ($this->stream->getCurrentText() != '$'.$property) { + return false; + } + + if ($this->stream->getNextExpectedTerminated(['=', T_WHITESPACE], [T_CONSTANT_ENCAPSED_STRING]) === null) { + return null; + } + + $value = trim($this->stream->getCurrentText()); + $value = $this->stream->unquotePhpString($value); + + if ($value === false) { + return null; + } + + return $value; + } + + protected function normalizeBehaviorClassName($className) + { + $className = str_replace('.', '\\', trim($className)); + return ltrim($className, '\\'); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ControllerGenerator.php b/server/plugins/rainlab/builder/classes/ControllerGenerator.php new file mode 100644 index 0000000..08ed4b1 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ControllerGenerator.php @@ -0,0 +1,341 @@ +sourceModel = $source; + } + + public function generate() + { + $this->filesGenerated = []; + $this->templateVars = []; + + try { + $this->validateBehaviorViewTemplates(); + $this->validateBehaviorConfigSettings(); + $this->validateControllerUnique(); + + $this->setTemplateVars(); + $this->generateControllerFile(); + $this->generateConfigFiles(); + $this->generateViews(); + } + catch (Exception $ex) { + $this->rollback(); + + throw $ex; + } + } + + public function setTemplateVariable($var, $value) + { + $this->templateVars[$var] = $value; + } + + protected function validateBehaviorViewTemplates() + { + if (!$this->sourceModel->behaviors) { + return; + } + + $this->templateFiles = []; + + $controllerPath = $this->sourceModel->getControllerFilePath(true); + $behaviorLibrary = ControllerBehaviorLibrary::instance(); + + $knownTemplates = []; + foreach ($this->sourceModel->behaviors as $behaviorClass) { + $behaviorInfo = $behaviorLibrary->getBehaviorInfo($behaviorClass); + if (!$behaviorInfo) { + throw new ValidationException([ + 'behaviors' => Lang::get('rainlab.builder::lang.controller.error_unknown_behavior', [ + 'class' => $behaviorClass + ]) + ]); + } + + foreach ($behaviorInfo['viewTemplates'] as $viewTemplate) { + $templateFileName = basename($viewTemplate); + $templateBaseName = pathinfo($templateFileName, PATHINFO_FILENAME); + + if (in_array($templateFileName, $knownTemplates)) { + throw new ValidationException([ + 'behaviors' => Lang::get('rainlab.builder::lang.controller.error_behavior_view_conflict', [ + 'view' => $templateBaseName + ]) + ]); + + throw new ApplicationException(); + } + + $knownTemplates[] = $templateFileName; + + $filePath = File::symbolizePath($viewTemplate); + if (!File::isFile($filePath)) { + throw new ValidationException([ + 'behaviors' => Lang::get('rainlab.builder::lang.controller.error_behavior_view_file_not_found', [ + 'class' => $behaviorClass, + 'view' => $templateFileName + ]) + ]); + } + + $destFilePath = $controllerPath.'/'.$templateBaseName; + if (File::isFile($destFilePath)) { + throw new ValidationException([ + 'behaviors' => Lang::get('rainlab.builder::lang.controller.error_behavior_view_file_exists', [ + 'view' => $destFilePath + ]) + ]); + } + + $this->templateFiles[$filePath] = $destFilePath; + } + } + } + + protected function validateBehaviorConfigSettings() + { + if (!$this->sourceModel->behaviors) { + return; + } + + $this->configTemplateProperties = []; + + $controllerPath = $this->sourceModel->getControllerFilePath(true); + $behaviorLibrary = ControllerBehaviorLibrary::instance(); + + $knownConfgFiles = []; + foreach ($this->sourceModel->behaviors as $behaviorClass) { + $behaviorInfo = $behaviorLibrary->getBehaviorInfo($behaviorClass); + $configFileName = $behaviorInfo['configFileName']; + + if (!strlen($configFileName)) { + continue; + } + + if (in_array($configFileName, $knownConfgFiles)) { + throw new ValidationException([ + 'behaviors' => Lang::get('rainlab.builder::lang.controller.error_behavior_config_conflict', [ + 'file' => $configFileName + ]) + ]); + + throw new ApplicationException(); + } + + $knownConfgFiles[] = $configFileName; + + $destFilePath = $controllerPath.'/'.$configFileName; + if (File::isFile($destFilePath)) { + throw new ValidationException([ + 'behaviors' => Lang::get('rainlab.builder::lang.controller.error_behavior_config_file_exists', [ + 'file' => $destFilePath + ]) + ]); + } + + $configPropertyName = $behaviorInfo['configPropertyName']; + $this->configTemplateProperties[$configPropertyName] = $configFileName; + } + } + + protected function validateControllerUnique() + { + $controlerFilePath = $this->sourceModel->getControllerFilePath(); + + if (File::isFile($controlerFilePath)) { + throw new ValidationException([ + 'controller' => Lang::get('rainlab.builder::lang.controller.error_controller_exists', [ + 'file' => basename($controlerFilePath) + ]) + ]); + } + } + + protected function setTemplateVars() + { + $pluginCodeObj = $this->sourceModel->getPluginCodeObj(); + + $this->templateVars['pluginNamespace'] = $pluginCodeObj->toPluginNamespace(); + $this->templateVars['pluginCode'] = $pluginCodeObj->toCode(); + $this->templateVars['permissions'] = $this->sourceModel->permissions; + $this->templateVars['controller'] = $this->sourceModel->controller; + $this->templateVars['baseModelClassName'] = $this->sourceModel->baseModelClassName; + + $this->templateVars['controllerUrl'] = $pluginCodeObj->toUrl().'/'.strtolower($this->sourceModel->controller); + + $menuItem = $this->sourceModel->menuItem; + if ($menuItem) { + $itemParts = explode('||', $menuItem); + $this->templateVars['menuItem'] = $itemParts[0]; + + if (count($itemParts) > 1) { + $this->templateVars['sideMenuItem'] = $itemParts[1]; + } + } + + if ($this->sourceModel->behaviors) { + $this->templateVars['behaviors'] = $this->sourceModel->behaviors; + + } + else { + $this->templateVars['behaviors'] = []; + } + + $this->templateVars['behaviorConfigVars'] = $this->configTemplateProperties; + } + + protected function getTemplatePath($template) + { + return __DIR__.'/controllergenerator/templates/'.$template; + } + + protected function parseTemplate($templatePath, $vars = []) + { + $template = File::get($templatePath); + + $vars = array_merge($this->templateVars, $vars); + $code = Twig::parse($template, $vars); + + return $code; + } + + protected function writeFile($path, $data) + { + $fileDirectory = dirname($path); + if (!File::isDirectory($fileDirectory)) { + if (!File::makeDirectory($fileDirectory, 0777, true, true)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.common.error_make_dir', [ + 'name' => $fileDirectory + ])); + } + } + + if (@File::put($path, $data) === false) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_save_file', [ + 'file' => basename($path) + ])); + } + + @File::chmod($path); + $this->filesGenerated[] = $path; + } + + protected function rollback() + { + foreach ($this->filesGenerated as $path) { + @unlink($path); + } + } + + protected function generateControllerFile() + { + $templateParts = []; + $code = $this->parseTemplate($this->getTemplatePath('controller-config-vars.php.tpl')); + if (strlen($code)) { + $templateParts[] = $code; + } + + $code = $this->parseTemplate($this->getTemplatePath('controller-permissions.php.tpl')); + if (strlen($code)) { + $templateParts[] = $code; + } + + if (count($templateParts)) { + $templateParts = "\n".implode("\n", $templateParts); + } + else { + $templateParts = ""; + } + + $code = $this->parseTemplate($this->getTemplatePath('controller.php.tpl'), [ + 'templateParts' => $templateParts + ]); + + $controlerFilePath = $this->sourceModel->getControllerFilePath(); + + $this->writeFile($controlerFilePath, $code); + } + + protected function getBehaviorDesignTimeProvider($providerClass) + { + if (array_key_exists($providerClass, $this->designTimeProviders)) { + return $this->designTimeProviders[$providerClass]; + } + + return $this->designTimeProviders[$providerClass] = new $providerClass(null, []); + } + + protected function generateConfigFiles() + { + if (!$this->sourceModel->behaviors) { + return; + } + + $controllerPath = $this->sourceModel->getControllerFilePath(true); + $behaviorLibrary = ControllerBehaviorLibrary::instance(); + $dumper = new YamlDumper(); + + foreach ($this->sourceModel->behaviors as $behaviorClass) { + $behaviorInfo = $behaviorLibrary->getBehaviorInfo($behaviorClass); + $configFileName = $behaviorInfo['configFileName']; + + if (!strlen($configFileName)) { + continue; + } + + $provider = $this->getBehaviorDesignTimeProvider($behaviorInfo['designTimeProvider']); + + $destFilePath = $controllerPath.'/'.$configFileName; + + try { + $configArray = $provider->getDefaultConfiguration($behaviorClass, $this->sourceModel, $this); + } + catch (Exception $ex) { + throw new ValidationException(['baseModelClassName' => $ex->getMessage()]); + } + + $code = $dumper->dump($configArray, 20, 0, false, true); + + $this->writeFile($destFilePath, $code); + } + } + + protected function generateViews() + { + foreach ($this->templateFiles as $templatePath=>$destPath) { + $code = $this->parseTemplate($templatePath); + + $this->writeFile($destPath, $code); + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ControllerModel.php b/server/plugins/rainlab/builder/classes/ControllerModel.php new file mode 100644 index 0000000..186886f --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ControllerModel.php @@ -0,0 +1,394 @@ + ['regex:/^[A-Z]+[a-zA-Z0-9_]+$/'] + ]; + + public function load($controller) + { + if (!$this->validateFileName($controller)) { + throw new SystemException('Invalid controller file name: '.$language); + } + + $this->controller = $this->trimExtension($controller); + $this->loadControllerBehaviors(); + $this->exists = true; + } + + public function save() + { + if ($this->isNewModel()) { + $this->generateController(); + } + else { + $this->saveController(); + } + } + + public function fill(array $attributes) + { + parent::fill($attributes); + + if (!$this->isNewModel() && is_array($this->behaviors)) { + foreach ($this->behaviors as $class=>&$configuration) { + if (is_scalar($configuration)) { + $configuration = json_decode($configuration, true); + } + } + } + } + + public static function listPluginControllers($pluginCodeObj) + { + $controllersDirectoryPath = $pluginCodeObj->toPluginDirectoryPath().'/controllers'; + + $controllersDirectoryPath = File::symbolizePath($controllersDirectoryPath); + + if (!File::isDirectory($controllersDirectoryPath)) { + return []; + } + + $result = []; + foreach (new DirectoryIterator($controllersDirectoryPath) as $fileInfo) { + if ($fileInfo->isDir()) { + continue; + } + + if ($fileInfo->getExtension() !== 'php') { + continue; + } + + $result[] = $fileInfo->getBasename('.php'); + } + + return $result; + } + + public function getBaseModelClassNameOptions() + { + $models = ModelModel::listPluginModels($this->getPluginCodeObj()); + + $result = []; + foreach ($models as $model) { + $result[$model->className] = $model->className; + } + + return $result; + } + + public function getBehaviorsOptions() + { + $library = ControllerBehaviorLibrary::instance(); + $behaviors = $library->listBehaviors(); + + $result = []; + foreach ($behaviors as $behaviorClass=>$behaviorInfo) { + $result[$behaviorClass] = [ + $behaviorInfo['name'], + $behaviorInfo['description'] + ]; + } + + return $result; + } + + public function getPermissionsOptions() + { + $model = new PermissionsModel(); + + $model->loadPlugin($this->getPluginCodeObj()->toCode()); + + $result = []; + + foreach ($model->permissions as $permissionInfo) { + if (!isset($permissionInfo['label']) || !isset($permissionInfo['permission'])) { + continue; + } + + $result[$permissionInfo['permission']] = Lang::get($permissionInfo['label']); + } + + return $result; + } + + public function getMenuItemOptions() + { + $model = new MenusModel(); + + $model->loadPlugin($this->getPluginCodeObj()->toCode()); + + $result = []; + + foreach ($model->menus as $itemInfo) { + if (!isset($itemInfo['label']) || !isset($itemInfo['code'])) { + continue; + } + + $itemCode = $itemInfo['code']; + $result[$itemCode] = Lang::get($itemInfo['label']); + + if (!isset($itemInfo['sideMenu'])) { + continue; + } + + foreach ($itemInfo['sideMenu'] as $itemInfo) { + if (!isset($itemInfo['label']) || !isset($itemInfo['code'])) { + continue; + } + + $subItemCode = $itemInfo['code']; + + $result[$itemCode.'||'.$subItemCode] = str_repeat(' ', 4).Lang::get($itemInfo['label']); + } + } + + return $result; + } + + public function getControllerFilePath($controllerFilesDirectory = false) + { + $pluginCodeObj = $this->getPluginCodeObj(); + $controllersDirectoryPath = File::symbolizePath($pluginCodeObj->toPluginDirectoryPath().'/controllers'); + + if (!$controllerFilesDirectory) { + return $controllersDirectoryPath.'/'.$this->controller.'.php'; + } + + return $controllersDirectoryPath.'/'.strtolower($this->controller); + } + + public static function getPluginRegistryData($pluginCode, $subtype) + { + $pluginCodeObj = new PluginCode($pluginCode); + $urlBase = $pluginCodeObj->toUrl().'/'; + + $controllers = self::listPluginControllers($pluginCodeObj); + $result = []; + + foreach ($controllers as $controler) { + $controllerPath = strtolower(basename($controler)); + + $url = $urlBase.$controllerPath; + + $result[$url] = $url; + } + + return $result; + } + + protected function saveController() + { + $this->validate(); + + $controllerPath = $this->getControllerFilePath(); + if (!File::isFile($controllerPath)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_controller_not_found')); + } + + if (!is_array($this->behaviors)) { + throw new SystemException('The behaviors data should be an array.'); + } + + $fileContents = File::get($controllerPath); + + $parser = new ControllerFileParser($fileContents); + + $behaviors = $parser->listBehaviors(); + if (!$behaviors) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_controller_has_no_behaviors')); + } + + $library = ControllerBehaviorLibrary::instance(); + foreach ($behaviors as $behaviorClass) { + $behaviorInfo = $library->getBehaviorInfo($behaviorClass); + + if (!$behaviorInfo) { + continue; + } + + $propertyName = $behaviorInfo['configPropertyName']; + $propertyValue = $parser->getStringPropertyValue($propertyName); + if (!strlen($propertyValue)) { + continue; + } + + if (array_key_exists($behaviorClass, $this->behaviors)) { + $this->saveBehaviorConfiguration($propertyValue, $this->behaviors[$behaviorClass], $behaviorClass); + } + } + } + + protected function generateController() + { + $this->validationMessages = [ + 'controller.regex' => Lang::get('rainlab.builder::lang.controller.error_controller_name_invalid') + ]; + + $this->validationRules['controller'][] = 'required'; + + $this->validate(); + + $generator = new ControllerGenerator($this); + $generator->generate(); + } + + protected function loadControllerBehaviors() + { + $filePath = $this->getControllerFilePath(); + if (!File::isFile($filePath)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_controller_not_found')); + } + + $fileContents = File::get($filePath); + + $parser = new ControllerFileParser($fileContents); + + $behaviors = $parser->listBehaviors(); + if (!$behaviors) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_controller_has_no_behaviors')); + } + + $library = ControllerBehaviorLibrary::instance(); + $this->behaviors = []; + foreach ($behaviors as $behaviorClass) { + $behaviorInfo = $library->getBehaviorInfo($behaviorClass); + + if (!$behaviorInfo) { + continue; + } + + $propertyName = $behaviorInfo['configPropertyName']; + $propertyValue = $parser->getStringPropertyValue($propertyName); + if (!strlen($propertyValue)) { + continue; + } + + $configuration = $this->loadBehaviorConfiguration($propertyValue, $behaviorClass); + if ($configuration === false) { + continue; + } + + $this->behaviors[$behaviorClass] = $configuration; + } + } + + protected function loadBehaviorConfiguration($fileName, $behaviorClass) + { + if (!preg_match('/^[a-z0-9\.\-_]+$/i', $fileName)) { + return false; + } + + $extension = pathinfo($fileName, PATHINFO_EXTENSION); + if (strlen($extension) && $extension != 'yaml') { + return false; + } + + $controllerPath = $this->getControllerFilePath(true); + $filePath = $controllerPath.'/'.$fileName; + + if (!File::isFile($filePath)) { + return false; + } + + try { + return Yaml::parse(File::get($filePath)); + } + catch (Exception $ex) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_invalid_yaml_configuration', ['file'=>$fileName])); + } + } + + protected function saveBehaviorConfiguration($fileName, $configuration, $behaviorClass) + { + if (!preg_match('/^[a-z0-9\.\-_]+$/i', $fileName)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_invalid_config_file_name', ['file'=>$fileName, 'class'=>$behaviorClass])); + } + + $extension = pathinfo($fileName, PATHINFO_EXTENSION); + if (strlen($extension) && $extension != 'yaml') { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_file_not_yaml', ['file'=>$fileName, 'class'=>$behaviorClass])); + } + + $controllerPath = $this->getControllerFilePath(true); + $filePath = $controllerPath.'/'.$fileName; + + $fileDirectory = dirname($filePath); + if (!File::isDirectory($fileDirectory)) { + if (!File::makeDirectory($fileDirectory, 0777, true, true)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.common.error_make_dir', ['name'=>$fileDirectory])); + } + } + + $dumper = new YamlDumper(); + if ($configuration !== null) { + $yamlData = $dumper->dump($configuration, 20, 0, false, true); + } + else { + $yamlData = ''; + } + + if (@File::put($filePath, $yamlData) === false) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.yaml.save_error', ['name'=>$filePath])); + } + + @File::chmod($filePath); + } + + protected function trimExtension($fileName) + { + if (substr($fileName, -4) == '.php') { + return substr($fileName, 0, -4); + } + + return $fileName; + } + + protected function validateFileName($fileName) + { + if (!preg_match('/^[a-z0-9\.\-_]+$/i', $fileName)) { + return false; + } + + $extension = pathinfo($fileName, PATHINFO_EXTENSION); + if (strlen($extension) && $extension != 'php') { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/DatabaseTableModel.php b/server/plugins/rainlab/builder/classes/DatabaseTableModel.php new file mode 100644 index 0000000..1701807 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/DatabaseTableModel.php @@ -0,0 +1,401 @@ + ['required', 'regex:/^[a-z]+[a-z0-9_]+$/', 'tablePrefix', 'uniqueTableName', 'max:64'] + ]; + + /** + * @var \Doctrine\DBAL\Schema\Table Table details loaded from the database. + */ + protected $tableInfo; + + /** + * @var \Doctrine\DBAL\Schema\AbstractSchemaManager Contains the database schema + */ + protected static $schemaManager = null; + + /** + * @var \Doctrine\DBAL\Schema\Schema Contains the database schema + */ + protected static $schema = null; + + public static function listPluginTables($pluginCode) + { + $pluginCodeObj = new PluginCode($pluginCode); + $prefix = $pluginCodeObj->toDatabasePrefix(); + + $tables = self::getSchemaManager()->listTableNames(); + + return array_filter($tables, function($item) use($prefix) { + return Str::startsWith($item, $prefix); + }); + } + + public static function tableExists($name) + { + return self::getSchema()->hasTable($name); + } + + /** + * Loads the table from the database. + * @param string $name Specifies the table name. + */ + public function load($name) + { + if (!self::tableExists($name)) { + throw new SystemException(sprintf('The table with name %s doesn\'t exist', $name)); + } + + $schema = self::getSchemaManager()->createSchema(); + + $this->name = $name; + $this->tableInfo = $schema->getTable($this->name); + $this->loadColumnsFromTableInfo(); + $this->exists = true; + } + + public function validate() + { + $pluginDbPrefix = $this->getPluginCodeObj()->toDatabasePrefix(); + + if (!strlen($pluginDbPrefix)) { + throw new SystemException('Error saving the table model - the plugin database prefix is not set for the object.'); + } + + $prefix = $pluginDbPrefix.'_'; + + $this->validationMessages = [ + 'name.table_prefix' => Lang::get('rainlab.builder::lang.database.error_table_name_invalid_prefix', [ + 'prefix' => $prefix + ]), + 'name.regex' => Lang::get('rainlab.builder::lang.database.error_table_name_invalid_characters'), + 'name.unique_table_name' => Lang::get('rainlab.builder::lang.database.error_table_already_exists', ['name'=>$this->name]), + 'name.max' => Lang::get('rainlab.builder::lang.database.error_table_name_too_long') + ]; + + Validator::extend('tablePrefix', function($attribute, $value, $parameters) use ($prefix) { + $value = trim($value); + + if (!Str::startsWith($value, $prefix)) { + return false; + } + + return true; + }); + + Validator::extend('uniqueTableName', function($attribute, $value, $parameters) { + $value = trim($value); + + $schema = $this->getSchema(); + if ($this->isNewModel()) { + return !$schema->hasTable($value); + } + + if ($value != $this->tableInfo->getName()) { + return !$schema->hasTable($value); + } + + return true; + }); + + $this->validateColumns(); + + return parent::validate(); + } + + public function generateCreateOrUpdateMigration() + { + $schemaCreator = new DatabaseTableSchemaCreator(); + $existingSchema = $this->tableInfo; + $newTableName = $this->name; + $tableName = $existingSchema ? $existingSchema->getName() : $this->name; + + $newSchema = $schemaCreator->createTableSchema($tableName, $this->columns); + + $codeGenerator = new TableMigrationCodeGenerator(); + $migrationCode = $codeGenerator->createOrUpdateTable($newSchema, $existingSchema, $newTableName); + if ($migrationCode === false) { + return $migrationCode; + } + + $description = $existingSchema ? 'Updated table %s' : 'Created table %s'; + return $this->createMigrationObject($migrationCode, sprintf($description, $tableName)); + } + + public function generateDropMigration() + { + $existingSchema = $this->tableInfo; + $codeGenerator = new TableMigrationCodeGenerator(); + $migrationCode = $codeGenerator->dropTable($existingSchema); + + return $this->createMigrationObject($migrationCode, sprintf('Drop table %s', $this->name)); + } + + public static function getSchema() + { + if (!self::$schema) { + self::$schema = self::getSchemaManager()->createSchema(); + } + + return self::$schema; + } + + protected function validateColumns() + { + $this->validateColumnNameLengths(); + $this->validateDupicateColumns(); + $this->validateDubplicatePrimaryKeys(); + $this->validateAutoIncrementColumns(); + $this->validateColumnsLengthParameter(); + $this->validateUnsignedColumns(); + $this->validateDefaultValues(); + } + + protected function validateColumnNameLengths() + { + foreach ($this->columns as $column) { + $name = trim($column['name']); + + if (Str::length($name) > 64) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_column_name_too_long', + ['column' => $name] + ) + ]); + } + } + } + + protected function validateDupicateColumns() + { + foreach ($this->columns as $outerIndex=>$outerColumn) { + foreach ($this->columns as $innerIndex=>$innerColumn) { + if ($innerIndex != $outerIndex && $innerColumn['name'] == $outerColumn['name']) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_table_duplicate_column', + ['column' => $outerColumn['name']] + ) + ]); + } + } + } + } + + protected function validateDubplicatePrimaryKeys() + { + $keysFound = 0; + $autoIncrementsFound = 0; + foreach ($this->columns as $column) { + if ($column['primary_key']) { + $keysFound++; + } + + if ($column['auto_increment']) { + $autoIncrementsFound++; + } + } + + if ($keysFound > 1 && $autoIncrementsFound) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_table_auto_increment_in_compound_pk') + ]); + } + } + + protected function validateAutoIncrementColumns() + { + $autoIncrement = null; + foreach ($this->columns as $column) { + if (!$column['auto_increment']) { + continue; + } + + if ($autoIncrement) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_table_mutliple_auto_increment') + ]); + } + + $autoIncrement = $column; + } + + if (!$autoIncrement) { + return; + } + + if (!in_array($autoIncrement['type'], MigrationColumnType::getIntegerTypes())) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_table_auto_increment_non_integer') + ]); + } + } + + protected function validateUnsignedColumns() + { + foreach ($this->columns as $column) { + if (!$column['unsigned']) { + continue; + } + + if (!in_array($column['type'], MigrationColumnType::getIntegerTypes())) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_unsigned_type_not_int', ['column'=>$column['name']]) + ]); + } + } + } + + protected function validateColumnsLengthParameter() + { + foreach ($this->columns as $column) { + try { + MigrationColumnType::validateLength($column['type'], $column['length']); + } + catch (Exception $ex) { + throw new ValidationException([ + 'columns' => $ex->getMessage() + ]); + } + } + } + + protected function validateDefaultValues() + { + foreach ($this->columns as $column) { + if (!strlen($column['default'])) { + continue; + } + + $default = trim($column['default']); + + if (in_array($column['type'], MigrationColumnType::getIntegerTypes())) { + if (!preg_match('/^\-?[0-9]+$/', $default)) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_integer_default_value', ['column'=>$column['name']]) + ]); + } + + if ($column['unsigned'] && $default < 0) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_unsigned_negative_value', ['column'=>$column['name']]) + ]); + } + + continue; + } + + if (in_array($column['type'], MigrationColumnType::getDecimalTypes())) { + if (!preg_match('/^\-?([0-9]+\.[0-9]+|[0-9]+)$/', $default)) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_decimal_default_value', ['column'=>$column['name']]) + ]); + } + + continue; + } + + if ($column['type'] == MigrationColumnType::TYPE_BOOLEAN) { + if (!preg_match('/^0|1$/', $default)) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.database.error_boolean_default_value', ['column'=>$column['name']]) + ]); + } + } + } + } + + protected static function getSchemaManager() + { + if (!self::$schemaManager) { + self::$schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); + + Type::addType('enumdbtype', 'RainLab\Builder\Classes\EnumDbType'); + + // Fixes the problem with enum column type not supported + // by Doctrine (https://github.com/laravel/framework/issues/1346) + $platform = self::$schemaManager->getDatabasePlatform(); + $platform->registerDoctrineTypeMapping('enum', 'enumdbtype'); + $platform->registerDoctrineTypeMapping('json', 'text'); + } + + return self::$schemaManager; + } + + protected function loadColumnsFromTableInfo() + { + $this->columns = []; + $columns = $this->tableInfo->getColumns(); + + $primaryKey = $this->tableInfo->getPrimaryKey(); + $primaryKeyColumns =[]; + if ($primaryKey) { + $primaryKeyColumns = $primaryKey->getColumns(); + } + + foreach ($columns as $column) { + $columnName = $column->getName(); + $typeName = $column->getType()->getName(); + + if ($typeName == EnumDbType::TYPENAME) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_enum_not_supported')); + } + + $item = [ + 'name' => $columnName, + 'type' => MigrationColumnType::toMigrationMethodName($typeName, $columnName), + 'length' => MigrationColumnType::doctrineLengthToMigrationLength($column), + 'unsigned' => $column->getUnsigned(), + 'allow_null' => !$column->getNotnull(), + 'auto_increment' => $column->getAutoincrement(), + 'primary_key' => in_array($columnName, $primaryKeyColumns), + 'default' => $column->getDefault(), + 'id' => $columnName, + ]; + + $this->columns[] = $item; + } + } + + protected function createMigrationObject($code, $description) + { + $migration = new MigrationModel(); + $migration->setPluginCodeObj($this->getPluginCodeObj()); + + $migration->code = $code; + $migration->version = $migration->getNextVersion(); + $migration->description = $description; + + return $migration; + } +} diff --git a/server/plugins/rainlab/builder/classes/DatabaseTableSchemaCreator.php b/server/plugins/rainlab/builder/classes/DatabaseTableSchemaCreator.php new file mode 100644 index 0000000..f2bced1 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/DatabaseTableSchemaCreator.php @@ -0,0 +1,65 @@ +formatOptions($type, $column); + + $schema->addColumn($column['name'], $typeName, $options); + if ($column['primary_key']) { + $primaryKeyColumns[] = $column['name']; + } + } + + if ($primaryKeyColumns) { + $schema->setPrimaryKey($primaryKeyColumns); + } + + return $schema; + } + + /** + * Converts column options to a format supported by Doctrine\DBAL\Schema\Column + */ + protected function formatOptions($type, $options) + { + $result = MigrationColumnType::lengthToPrecisionAndScale($type, $options['length']); + + $result['unsigned'] = !!$options['unsigned']; + $result['notnull'] = !$options['allow_null']; + $result['autoincrement'] = !!$options['auto_increment']; + + $default = trim($options['default']); + + // Note - this code doesn't allow to set empty string as default. + // But converting empty strings to NULLs is required for the further + // work with Doctrine types. As an option - empty strings could be specified + // as '' in the editor UI (table column editor). + $result['default'] = $default === '' ? null : $default; + + return $result; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/EnumDbType.php b/server/plugins/rainlab/builder/classes/EnumDbType.php new file mode 100644 index 0000000..83fcf84 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/EnumDbType.php @@ -0,0 +1,38 @@ + 'plugin.php.tpl' + * ]; + * $generator = new FilesystemGenerator('$', $structure, '$/Author/Plugin/templates/plugin'); + * + * $variables = [ + * 'namespace' => 'Author/Plugin' + * ]; + * $generator->setVariables($variables); + * $generator->generate(); + * + * @package rainlab\builder + * @author Alexey Bobkov, Samuel Georges + */ +class FilesystemGenerator +{ + protected $destinationPath; + + protected $structure; + + protected $variables = []; + + protected $templatesPath; + + /** + * Initializes the object. + * @param string $destinationPath Destination path to create the filesystem objects in. + * The path can contain filesystem symbols. + * @param array $structure Specifies the structure as array. + * @param string $templatesPath Path to the directory that contains file templates. + * The parameter is required only in case any files should be created. The path can + * contain filesystem symbols. + */ + public function __construct($destinationPath, array $structure, $templatesPath = null) + { + $this->destinationPath = File::symbolizePath($destinationPath); + $this->structure = $structure; + + if ($templatesPath) { + $this->templatesPath = File::symbolizePath($templatesPath); + } + } + + public function setVariables($variables) + { + foreach ($variables as $key=>$value) { + $this->setVariable($key, $value); + } + } + + public function setVariable($key, $value) + { + $this->variables[$key] = $value; + } + + public function generate() + { + if (!File::isDirectory($this->destinationPath)) { + throw new SystemException(Lang::get('rainlab.builder::lang.common.destination_dir_not_exists', ['path'=>$this->destinationPath])); + } + + foreach ($this->structure as $key=>$value) { + if (is_numeric($key)) { + $this->makeDirectory($value); + } + else { + $this->makeFile($key, $value); + } + } + } + + public function getTemplateContents($templateName) + { + $templatePath = $this->templatesPath.DIRECTORY_SEPARATOR.$templateName; + if (!File::isFile($templatePath)) { + throw new SystemException(Lang::get('rainlab.builder::lang.common.template_not_found', ['name'=>$templateName])); + } + + $fileContents = File::get($templatePath); + + return TextParser::parse($fileContents, $this->variables); + } + + protected function makeDirectory($dirPath) + { + $path = $this->destinationPath.DIRECTORY_SEPARATOR.$dirPath; + + if (File::isDirectory($path)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.common.error_dir_exists', ['path'=>$path])); + } + + if (!File::makeDirectory($path, 0777, true, true)) { + throw new SystemException(Lang::get('rainlab.builder::lang.common.error_make_dir', ['name'=>$path])); + } + } + + protected function makeFile($filePath, $templateName) + { + $path = $this->destinationPath.DIRECTORY_SEPARATOR.$filePath; + + if (File::isFile($path)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.common.error_file_exists', ['path'=>$path])); + } + + $fileDirectory = dirname($path); + if (!File::isDirectory($fileDirectory)) { + if (!File::makeDirectory($fileDirectory, 0777, true, true)) { + throw new SystemException(Lang::get('rainlab.builder::lang.common.error_make_dir', ['name'=>$fileDirectory])); + } + } + + $fileContents = $this->getTemplateContents($templateName); + if (@File::put($path, $fileContents) === false) { + throw new SystemException(Lang::get('rainlab.builder::lang.common.error_generating_file', ['path'=>$path])); + } + + @File::chmod($path); + } +} diff --git a/server/plugins/rainlab/builder/classes/IconList.php b/server/plugins/rainlab/builder/classes/IconList.php new file mode 100644 index 0000000..16a9722 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/IconList.php @@ -0,0 +1,607 @@ + ['adjust', 'oc-icon-adjust'], + 'oc-icon-adn' => ['adn', 'oc-icon-adn'], + 'oc-icon-align-center' => ['align-center', 'oc-icon-align-center'], + 'oc-icon-align-justify' => ['align-justify', 'oc-icon-align-justify'], + 'oc-icon-align-left' => ['align-left', 'oc-icon-align-left'], + 'oc-icon-align-right' => ['align-right', 'oc-icon-align-right'], + 'oc-icon-ambulance' => ['ambulance', 'oc-icon-ambulance'], + 'oc-icon-anchor' => ['anchor', 'oc-icon-anchor'], + 'oc-icon-android' => ['android', 'oc-icon-android'], + 'oc-icon-angellist' => ['angellist', 'oc-icon-angellist'], + 'oc-icon-angle-double-down' => ['angle-double-down', 'oc-icon-angle-double-down'], + 'oc-icon-angle-double-left' => ['angle-double-left', 'oc-icon-angle-double-left'], + 'oc-icon-angle-double-right' => ['angle-double-right', 'oc-icon-angle-double-right'], + 'oc-icon-angle-double-up' => ['angle-double-up', 'oc-icon-angle-double-up'], + 'oc-icon-angle-down' => ['angle-down', 'oc-icon-angle-down'], + 'oc-icon-angle-left' => ['angle-left', 'oc-icon-angle-left'], + 'oc-icon-angle-right' => ['angle-right', 'oc-icon-angle-right'], + 'oc-icon-angle-up' => ['angle-up', 'oc-icon-angle-up'], + 'oc-icon-apple' => ['apple', 'oc-icon-apple'], + 'oc-icon-archive' => ['archive', 'oc-icon-archive'], + 'oc-icon-area-chart' => ['area-chart', 'oc-icon-area-chart'], + 'oc-icon-arrow-circle-down' => ['arrow-circle-down', 'oc-icon-arrow-circle-down'], + 'oc-icon-arrow-circle-left' => ['arrow-circle-left', 'oc-icon-arrow-circle-left'], + 'oc-icon-arrow-circle-o-down' => ['arrow-circle-o-down', 'oc-icon-arrow-circle-o-down'], + 'oc-icon-arrow-circle-o-left' => ['arrow-circle-o-left', 'oc-icon-arrow-circle-o-left'], + 'oc-icon-arrow-circle-o-right' => ['arrow-circle-o-right', 'oc-icon-arrow-circle-o-right'], + 'oc-icon-arrow-circle-o-up' => ['arrow-circle-o-up', 'oc-icon-arrow-circle-o-up'], + 'oc-icon-arrow-circle-right' => ['arrow-circle-right', 'oc-icon-arrow-circle-right'], + 'oc-icon-arrow-circle-up' => ['arrow-circle-up', 'oc-icon-arrow-circle-up'], + 'oc-icon-arrow-down' => ['arrow-down', 'oc-icon-arrow-down'], + 'oc-icon-arrow-left' => ['arrow-left', 'oc-icon-arrow-left'], + 'oc-icon-arrow-right' => ['arrow-right', 'oc-icon-arrow-right'], + 'oc-icon-arrow-up' => ['arrow-up', 'oc-icon-arrow-up'], + 'oc-icon-arrows' => ['arrows', 'oc-icon-arrows'], + 'oc-icon-arrows-alt' => ['arrows-alt', 'oc-icon-arrows-alt'], + 'oc-icon-arrows-h' => ['arrows-h', 'oc-icon-arrows-h'], + 'oc-icon-arrows-v' => ['arrows-v', 'oc-icon-arrows-v'], + 'oc-icon-asterisk' => ['asterisk', 'oc-icon-asterisk'], + 'oc-icon-at' => ['at', 'oc-icon-at'], + 'oc-icon-automobile' => ['automobile', 'oc-icon-automobile'], + 'oc-icon-backward' => ['backward', 'oc-icon-backward'], + 'oc-icon-ban' => ['ban', 'oc-icon-ban'], + 'oc-icon-bank' => ['bank', 'oc-icon-bank'], + 'oc-icon-bar-chart' => ['bar-chart', 'oc-icon-bar-chart'], + 'oc-icon-bar-chart-o' => ['bar-chart-o', 'oc-icon-bar-chart-o'], + 'oc-icon-barcode' => ['barcode', 'oc-icon-barcode'], + 'oc-icon-bars' => ['bars', 'oc-icon-bars'], + 'oc-icon-bed' => ['bed', 'oc-icon-bed'], + 'oc-icon-beer' => ['beer', 'oc-icon-beer'], + 'oc-icon-behance' => ['behance', 'oc-icon-behance'], + 'oc-icon-behance-square' => ['behance-square', 'oc-icon-behance-square'], + 'oc-icon-bell' => ['bell', 'oc-icon-bell'], + 'oc-icon-bell-o' => ['bell-o', 'oc-icon-bell-o'], + 'oc-icon-bell-slash' => ['bell-slash', 'oc-icon-bell-slash'], + 'oc-icon-bell-slash-o' => ['bell-slash-o', 'oc-icon-bell-slash-o'], + 'oc-icon-bicycle' => ['bicycle', 'oc-icon-bicycle'], + 'oc-icon-binoculars' => ['binoculars', 'oc-icon-binoculars'], + 'oc-icon-birthday-cake' => ['birthday-cake', 'oc-icon-birthday-cake'], + 'oc-icon-bitbucket' => ['bitbucket', 'oc-icon-bitbucket'], + 'oc-icon-bitbucket-square' => ['bitbucket-square', 'oc-icon-bitbucket-square'], + 'oc-icon-bitcoin' => ['bitcoin', 'oc-icon-bitcoin'], + 'oc-icon-bold' => ['bold', 'oc-icon-bold'], + 'oc-icon-bolt' => ['bolt', 'oc-icon-bolt'], + 'oc-icon-bomb' => ['bomb', 'oc-icon-bomb'], + 'oc-icon-book' => ['book', 'oc-icon-book'], + 'oc-icon-bookmark' => ['bookmark', 'oc-icon-bookmark'], + 'oc-icon-bookmark-o' => ['bookmark-o', 'oc-icon-bookmark-o'], + 'oc-icon-briefcase' => ['briefcase', 'oc-icon-briefcase'], + 'oc-icon-btc' => ['btc', 'oc-icon-btc'], + 'oc-icon-bug' => ['bug', 'oc-icon-bug'], + 'oc-icon-building' => ['building', 'oc-icon-building'], + 'oc-icon-building-o' => ['building-o', 'oc-icon-building-o'], + 'oc-icon-bullhorn' => ['bullhorn', 'oc-icon-bullhorn'], + 'oc-icon-bullseye' => ['bullseye', 'oc-icon-bullseye'], + 'oc-icon-bus' => ['bus', 'oc-icon-bus'], + 'oc-icon-buysellads' => ['buysellads', 'oc-icon-buysellads'], + 'oc-icon-cab' => ['cab', 'oc-icon-cab'], + 'oc-icon-calculator' => ['calculator', 'oc-icon-calculator'], + 'oc-icon-calendar' => ['calendar', 'oc-icon-calendar'], + 'oc-icon-calendar-o' => ['calendar-o', 'oc-icon-calendar-o'], + 'oc-icon-camera' => ['camera', 'oc-icon-camera'], + 'oc-icon-camera-retro' => ['camera-retro', 'oc-icon-camera-retro'], + 'oc-icon-car' => ['car', 'oc-icon-car'], + 'oc-icon-caret-down' => ['caret-down', 'oc-icon-caret-down'], + 'oc-icon-caret-left' => ['caret-left', 'oc-icon-caret-left'], + 'oc-icon-caret-right' => ['caret-right', 'oc-icon-caret-right'], + 'oc-icon-caret-square-o-down' => ['caret-square-o-down', 'oc-icon-caret-square-o-down'], + 'oc-icon-caret-square-o-left' => ['caret-square-o-left', 'oc-icon-caret-square-o-left'], + 'oc-icon-caret-square-o-right' => ['caret-square-o-right', 'oc-icon-caret-square-o-right'], + 'oc-icon-caret-square-o-up' => ['caret-square-o-up', 'oc-icon-caret-square-o-up'], + 'oc-icon-caret-up' => ['caret-up', 'oc-icon-caret-up'], + 'oc-icon-cart-arrow-down' => ['cart-arrow-down', 'oc-icon-cart-arrow-down'], + 'oc-icon-cart-plus' => ['cart-plus', 'oc-icon-cart-plus'], + 'oc-icon-cc' => ['cc', 'oc-icon-cc'], + 'oc-icon-cc-amex' => ['cc-amex', 'oc-icon-cc-amex'], + 'oc-icon-cc-discover' => ['cc-discover', 'oc-icon-cc-discover'], + 'oc-icon-cc-mastercard' => ['cc-mastercard', 'oc-icon-cc-mastercard'], + 'oc-icon-cc-paypal' => ['cc-paypal', 'oc-icon-cc-paypal'], + 'oc-icon-cc-stripe' => ['cc-stripe', 'oc-icon-cc-stripe'], + 'oc-icon-cc-visa' => ['cc-visa', 'oc-icon-cc-visa'], + 'oc-icon-certificate' => ['certificate', 'oc-icon-certificate'], + 'oc-icon-chain' => ['chain', 'oc-icon-chain'], + 'oc-icon-chain-broken' => ['chain-broken', 'oc-icon-chain-broken'], + 'oc-icon-check' => ['check', 'oc-icon-check'], + 'oc-icon-check-circle' => ['check-circle', 'oc-icon-check-circle'], + 'oc-icon-check-circle-o' => ['check-circle-o', 'oc-icon-check-circle-o'], + 'oc-icon-check-square' => ['check-square', 'oc-icon-check-square'], + 'oc-icon-check-square-o' => ['check-square-o', 'oc-icon-check-square-o'], + 'oc-icon-chevron-circle-down' => ['chevron-circle-down', 'oc-icon-chevron-circle-down'], + 'oc-icon-chevron-circle-left' => ['chevron-circle-left', 'oc-icon-chevron-circle-left'], + 'oc-icon-chevron-circle-right' => ['chevron-circle-right', 'oc-icon-chevron-circle-right'], + 'oc-icon-chevron-circle-up' => ['chevron-circle-up', 'oc-icon-chevron-circle-up'], + 'oc-icon-chevron-down' => ['chevron-down', 'oc-icon-chevron-down'], + 'oc-icon-chevron-left' => ['chevron-left', 'oc-icon-chevron-left'], + 'oc-icon-chevron-right' => ['chevron-right', 'oc-icon-chevron-right'], + 'oc-icon-chevron-up' => ['chevron-up', 'oc-icon-chevron-up'], + 'oc-icon-child' => ['child', 'oc-icon-child'], + 'oc-icon-circle' => ['circle', 'oc-icon-circle'], + 'oc-icon-circle-o' => ['circle-o', 'oc-icon-circle-o'], + 'oc-icon-circle-o-notch' => ['circle-o-notch', 'oc-icon-circle-o-notch'], + 'oc-icon-circle-thin' => ['circle-thin', 'oc-icon-circle-thin'], + 'oc-icon-clipboard' => ['clipboard', 'oc-icon-clipboard'], + 'oc-icon-clock-o' => ['clock-o', 'oc-icon-clock-o'], + 'oc-icon-close' => ['close', 'oc-icon-close'], + 'oc-icon-cloud' => ['cloud', 'oc-icon-cloud'], + 'oc-icon-cloud-download' => ['cloud-download', 'oc-icon-cloud-download'], + 'oc-icon-cloud-upload' => ['cloud-upload', 'oc-icon-cloud-upload'], + 'oc-icon-cny' => ['cny', 'oc-icon-cny'], + 'oc-icon-code' => ['code', 'oc-icon-code'], + 'oc-icon-code-fork' => ['code-fork', 'oc-icon-code-fork'], + 'oc-icon-codepen' => ['codepen', 'oc-icon-codepen'], + 'oc-icon-coffee' => ['coffee', 'oc-icon-coffee'], + 'oc-icon-cog' => ['cog', 'oc-icon-cog'], + 'oc-icon-cogs' => ['cogs', 'oc-icon-cogs'], + 'oc-icon-columns' => ['columns', 'oc-icon-columns'], + 'oc-icon-comment' => ['comment', 'oc-icon-comment'], + 'oc-icon-comment-o' => ['comment-o', 'oc-icon-comment-o'], + 'oc-icon-comments' => ['comments', 'oc-icon-comments'], + 'oc-icon-comments-o' => ['comments-o', 'oc-icon-comments-o'], + 'oc-icon-compass' => ['compass', 'oc-icon-compass'], + 'oc-icon-compress' => ['compress', 'oc-icon-compress'], + 'oc-icon-connectdevelop' => ['connectdevelop', 'oc-icon-connectdevelop'], + 'oc-icon-copy' => ['copy', 'oc-icon-copy'], + 'oc-icon-copyright' => ['copyright', 'oc-icon-copyright'], + 'oc-icon-credit-card' => ['credit-card', 'oc-icon-credit-card'], + 'oc-icon-crop' => ['crop', 'oc-icon-crop'], + 'oc-icon-crosshairs' => ['crosshairs', 'oc-icon-crosshairs'], + 'oc-icon-css3' => ['css3', '|'], + 'oc-icon-cube' => ['cube', 'oc-icon-cube'], + 'oc-icon-cubes' => ['cubes', 'oc-icon-cubes'], + 'oc-icon-cut' => ['cut', 'oc-icon-cut'], + 'oc-icon-cutlery' => ['cutlery', 'oc-icon-cutlery'], + 'oc-icon-dashboard' => ['dashboard', 'oc-icon-dashboard'], + 'oc-icon-dashcube' => ['dashcube', 'oc-icon-dashcube'], + 'oc-icon-database' => ['database', 'oc-icon-database'], + 'oc-icon-dedent' => ['dedent', 'oc-icon-dedent'], + 'oc-icon-delicious' => ['delicious', 'oc-icon-delicious'], + 'oc-icon-desktop' => ['desktop', 'oc-icon-desktop'], + 'oc-icon-deviantart' => ['deviantart', 'oc-icon-deviantart'], + 'oc-icon-diamond' => ['diamond', 'oc-icon-diamond'], + 'oc-icon-digg' => ['digg', 'oc-icon-digg'], + 'oc-icon-dollar' => ['dollar', 'oc-icon-dollar'], + 'oc-icon-dot-circle-o' => ['dot-circle-o', 'oc-icon-dot-circle-o'], + 'oc-icon-download' => ['download', 'oc-icon-download'], + 'oc-icon-dribbble' => ['dribbble', 'oc-icon-dribbble'], + 'oc-icon-dropbox' => ['dropbox', 'oc-icon-dropbox'], + 'oc-icon-drupal' => ['drupal', 'oc-icon-drupal'], + 'oc-icon-edit' => ['edit', 'oc-icon-edit'], + 'oc-icon-eject' => ['eject', 'oc-icon-eject'], + 'oc-icon-ellipsis-h' => ['ellipsis-h', 'oc-icon-ellipsis-h'], + 'oc-icon-ellipsis-v' => ['ellipsis-v', 'oc-icon-ellipsis-v'], + 'oc-icon-empire' => ['empire', 'oc-icon-empire'], + 'oc-icon-envelope' => ['envelope', 'oc-icon-envelope'], + 'oc-icon-envelope-o' => ['envelope-o', 'oc-icon-envelope-o'], + 'oc-icon-envelope-square' => ['envelope-square', 'oc-icon-envelope-square'], + 'oc-icon-eraser' => ['eraser', 'oc-icon-eraser'], + 'oc-icon-eur' => ['eur', 'oc-icon-eur'], + 'oc-icon-euro' => ['euro', 'oc-icon-euro'], + 'oc-icon-exchange' => ['exchange', 'oc-icon-exchange'], + 'oc-icon-exclamation' => ['exclamation', 'oc-icon-exclamation'], + 'oc-icon-exclamation-circle' => ['exclamation-circle', 'oc-icon-exclamation-circle'], + 'oc-icon-exclamation-triangle' => ['exclamation-triangle', 'oc-icon-exclamation-triangle'], + 'oc-icon-expand' => ['expand', 'oc-icon-expand'], + 'oc-icon-external-link' => ['external-link', 'oc-icon-external-link'], + 'oc-icon-external-link-square' => ['external-link-square', 'oc-icon-external-link-square'], + 'oc-icon-eye' => ['eye', 'oc-icon-eye'], + 'oc-icon-eye-slash' => ['eye-slash', 'oc-icon-eye-slash'], + 'oc-icon-eyedropper' => ['eyedropper', 'oc-icon-eyedropper'], + 'oc-icon-facebook' => ['facebook', 'oc-icon-facebook'], + 'oc-icon-facebook-f' => ['facebook-f', 'oc-icon-facebook-f'], + 'oc-icon-facebook-official' => ['facebook-official', 'oc-icon-facebook-official'], + 'oc-icon-facebook-square' => ['facebook-square', 'oc-icon-facebook-square'], + 'oc-icon-fast-backward' => ['fast-backward', 'oc-icon-fast-backward'], + 'oc-icon-fast-forward' => ['fast-forward', 'oc-icon-fast-forward'], + 'oc-icon-fax' => ['fax', 'oc-icon-fax'], + 'oc-icon-female' => ['female', 'oc-icon-female'], + 'oc-icon-fighter-jet' => ['fighter-jet', 'oc-icon-fighter-jet'], + 'oc-icon-file' => ['file', 'oc-icon-file'], + 'oc-icon-file-archive-o' => ['file-archive-o', 'oc-icon-file-archive-o'], + 'oc-icon-file-audio-o' => ['file-audio-o', 'oc-icon-file-audio-o'], + 'oc-icon-file-code-o' => ['file-code-o', 'oc-icon-file-code-o'], + 'oc-icon-file-excel-o' => ['file-excel-o', 'oc-icon-file-excel-o'], + 'oc-icon-file-image-o' => ['file-image-o', 'oc-icon-file-image-o'], + 'oc-icon-file-movie-o' => ['file-movie-o', 'oc-icon-file-movie-o'], + 'oc-icon-file-o' => ['file-o', 'oc-icon-file-o'], + 'oc-icon-file-pdf-o' => ['file-pdf-o', 'oc-icon-file-pdf-o'], + 'oc-icon-file-photo-o' => ['file-photo-o', 'oc-icon-file-photo-o'], + 'oc-icon-file-picture-o' => ['file-picture-o', 'oc-icon-file-picture-o'], + 'oc-icon-file-powerpoint-o' => ['file-powerpoint-o', 'oc-icon-file-powerpoint-o'], + 'oc-icon-file-sound-o' => ['file-sound-o', 'oc-icon-file-sound-o'], + 'oc-icon-file-text' => ['file-text', 'oc-icon-file-text'], + 'oc-icon-file-text-o' => ['file-text-o', 'oc-icon-file-text-o'], + 'oc-icon-file-video-o' => ['file-video-o', 'oc-icon-file-video-o'], + 'oc-icon-file-word-o' => ['file-word-o', 'oc-icon-file-word-o'], + 'oc-icon-file-zip-o' => ['file-zip-o', 'oc-icon-file-zip-o'], + 'oc-icon-files-o' => ['files-o', 'oc-icon-files-o'], + 'oc-icon-film' => ['film', 'oc-icon-film'], + 'oc-icon-filter' => ['filter', 'oc-icon-filter'], + 'oc-icon-fire' => ['fire', 'oc-icon-fire'], + 'oc-icon-fire-extinguisher' => ['fire-extinguisher', 'oc-icon-fire-extinguisher'], + 'oc-icon-flag' => ['flag', 'oc-icon-flag'], + 'oc-icon-flag-checkered' => ['flag-checkered', 'oc-icon-flag-checkered'], + 'oc-icon-flag-o' => ['flag-o', 'oc-icon-flag-o'], + 'oc-icon-flash' => ['flash', 'oc-icon-flash'], + 'oc-icon-flask' => ['flask', 'oc-icon-flask'], + 'oc-icon-flickr' => ['flickr', 'oc-icon-flickr'], + 'oc-icon-floppy-o' => ['floppy-o', 'oc-icon-floppy-o'], + 'oc-icon-folder' => ['folder', 'oc-icon-folder'], + 'oc-icon-folder-o' => ['folder-o', 'oc-icon-folder-o'], + 'oc-icon-folder-open' => ['folder-open', 'oc-icon-folder-open'], + 'oc-icon-folder-open-o' => ['folder-open-o', 'oc-icon-folder-open-o'], + 'oc-icon-font' => ['font', 'oc-icon-font'], + 'oc-icon-forumbee' => ['forumbee', 'oc-icon-forumbee'], + 'oc-icon-forward' => ['forward', 'oc-icon-forward'], + 'oc-icon-foursquare' => ['foursquare', 'oc-icon-foursquare'], + 'oc-icon-frown-o' => ['frown-o', 'oc-icon-frown-o'], + 'oc-icon-futbol-o' => ['futbol-o', 'oc-icon-futbol-o'], + 'oc-icon-gamepad' => ['gamepad', 'oc-icon-gamepad'], + 'oc-icon-gavel' => ['gavel', 'oc-icon-gavel'], + 'oc-icon-gbp' => ['gbp', 'oc-icon-gbp'], + 'oc-icon-ge' => ['ge', 'oc-icon-ge'], + 'oc-icon-gear' => ['gear', 'oc-icon-gear'], + 'oc-icon-gears' => ['gears', 'oc-icon-gears'], + 'oc-icon-genderless' => ['genderless', 'oc-icon-genderless'], + 'oc-icon-gift' => ['gift', 'oc-icon-gift'], + 'oc-icon-git' => ['git', 'oc-icon-git'], + 'oc-icon-git-square' => ['git-square', 'oc-icon-git-square'], + 'oc-icon-github' => ['github', 'oc-icon-github'], + 'oc-icon-github-alt' => ['github-alt', 'oc-icon-github-alt'], + 'oc-icon-github-square' => ['github-square', 'oc-icon-github-square'], + 'oc-icon-gittip' => ['gittip', 'oc-icon-gittip'], + 'oc-icon-glass' => ['glass', 'oc-icon-glass'], + 'oc-icon-globe' => ['globe', 'oc-icon-globe'], + 'oc-icon-google' => ['google', 'oc-icon-google'], + 'oc-icon-google-plus' => ['google-plus', 'oc-icon-google-plus'], + 'oc-icon-google-plus-square' => ['google-plus-square', 'oc-icon-google-plus-square'], + 'oc-icon-google-wallet' => ['google-wallet', 'oc-icon-google-wallet'], + 'oc-icon-graduation-cap' => ['graduation-cap', 'oc-icon-graduation-cap'], + 'oc-icon-gratipay' => ['gratipay', 'oc-icon-gratipay'], + 'oc-icon-group' => ['group', 'oc-icon-group'], + 'oc-icon-h-square' => ['h-square', 'oc-icon-h-square'], + 'oc-icon-hacker-news' => ['hacker-news', 'oc-icon-hacker-news'], + 'oc-icon-hand-o-down' => ['hand-o-down', 'oc-icon-hand-o-down'], + 'oc-icon-hand-o-left' => ['hand-o-left', 'oc-icon-hand-o-left'], + 'oc-icon-hand-o-right' => ['hand-o-right', 'oc-icon-hand-o-right'], + 'oc-icon-hand-o-up' => ['hand-o-up', 'oc-icon-hand-o-up'], + 'oc-icon-hdd-o' => ['hdd-o', 'oc-icon-hdd-o'], + 'oc-icon-header' => ['header', 'oc-icon-header'], + 'oc-icon-headphones' => ['headphones', 'oc-icon-headphones'], + 'oc-icon-heart' => ['heart', 'oc-icon-heart'], + 'oc-icon-heart-o' => ['heart-o', 'oc-icon-heart-o'], + 'oc-icon-heartbeat' => ['heartbeat', 'oc-icon-heartbeat'], + 'oc-icon-history' => ['history', 'oc-icon-history'], + 'oc-icon-home' => ['home', 'oc-icon-home'], + 'oc-icon-hospital-o' => ['hospital-o', 'oc-icon-hospital-o'], + 'oc-icon-hotel' => ['hotel', 'oc-icon-hotel'], + 'oc-icon-html5' => ['html5', '|'], + 'oc-icon-ils' => ['ils', 'oc-icon-ils'], + 'oc-icon-image' => ['image', 'oc-icon-image'], + 'oc-icon-inbox' => ['inbox', 'oc-icon-inbox'], + 'oc-icon-indent' => ['indent', 'oc-icon-indent'], + 'oc-icon-info' => ['info', 'oc-icon-info'], + 'oc-icon-info-circle' => ['info-circle', 'oc-icon-info-circle'], + 'oc-icon-inr' => ['inr', 'oc-icon-inr'], + 'oc-icon-instagram' => ['instagram', 'oc-icon-instagram'], + 'oc-icon-institution' => ['institution', 'oc-icon-institution'], + 'oc-icon-ioxhost' => ['ioxhost', 'oc-icon-ioxhost'], + 'oc-icon-italic' => ['italic', 'oc-icon-italic'], + 'oc-icon-joomla' => ['joomla', 'oc-icon-joomla'], + 'oc-icon-jpy' => ['jpy', 'oc-icon-jpy'], + 'oc-icon-jsfiddle' => ['jsfiddle', 'oc-icon-jsfiddle'], + 'oc-icon-key' => ['key', 'oc-icon-key'], + 'oc-icon-keyboard-o' => ['keyboard-o', 'oc-icon-keyboard-o'], + 'oc-icon-krw' => ['krw', 'oc-icon-krw'], + 'oc-icon-language' => ['language', 'oc-icon-language'], + 'oc-icon-laptop' => ['laptop', 'oc-icon-laptop'], + 'oc-icon-lastfm' => ['lastfm', 'oc-icon-lastfm'], + 'oc-icon-lastfm-square' => ['lastfm-square', 'oc-icon-lastfm-square'], + 'oc-icon-leaf' => ['leaf', 'oc-icon-leaf'], + 'oc-icon-leanpub' => ['leanpub', 'oc-icon-leanpub'], + 'oc-icon-legal' => ['legal', 'oc-icon-legal'], + 'oc-icon-lemon-o' => ['lemon-o', 'oc-icon-lemon-o'], + 'oc-icon-level-down' => ['level-down', 'oc-icon-level-down'], + 'oc-icon-level-up' => ['level-up', 'oc-icon-level-up'], + 'oc-icon-life-bouy' => ['life-bouy', 'oc-icon-life-bouy'], + 'oc-icon-lightbulb-o' => ['lightbulb-o', 'oc-icon-lightbulb-o'], + 'oc-icon-line-chart' => ['line-chart', 'oc-icon-line-chart'], + 'oc-icon-link' => ['link', 'oc-icon-link'], + 'oc-icon-linkedin' => ['linkedin', 'oc-icon-linkedin'], + 'oc-icon-linkedin-square' => ['linkedin-square', 'oc-icon-linkedin-square'], + 'oc-icon-linux' => ['linux', 'oc-icon-linux'], + 'oc-icon-list' => ['list', 'oc-icon-list'], + 'oc-icon-list-alt' => ['list-alt', 'oc-icon-list-alt'], + 'oc-icon-list-ol' => ['list-ol', 'oc-icon-list-ol'], + 'oc-icon-list-ul' => ['list-ul', 'oc-icon-list-ul'], + 'oc-icon-location-arrow' => ['location-arrow', 'oc-icon-location-arrow'], + 'oc-icon-lock' => ['lock', 'oc-icon-lock'], + 'oc-icon-long-arrow-down' => ['long-arrow-down', 'oc-icon-long-arrow-down'], + 'oc-icon-long-arrow-left' => ['long-arrow-left', 'oc-icon-long-arrow-left'], + 'oc-icon-long-arrow-right' => ['long-arrow-right', 'oc-icon-long-arrow-right'], + 'oc-icon-long-arrow-up' => ['long-arrow-up', 'oc-icon-long-arrow-up'], + 'oc-icon-magic' => ['magic', 'oc-icon-magic'], + 'oc-icon-magnet' => ['magnet', 'oc-icon-magnet'], + 'oc-icon-mail-forward' => ['mail-forward', 'oc-icon-mail-forward'], + 'oc-icon-mail-reply' => ['mail-reply', 'oc-icon-mail-reply'], + 'oc-icon-mail-reply-all' => ['mail-reply-all', 'oc-icon-mail-reply-all'], + 'oc-icon-male' => ['male', 'oc-icon-male'], + 'oc-icon-map-marker' => ['map-marker', 'oc-icon-map-marker'], + 'oc-icon-mars' => ['mars', 'oc-icon-mars'], + 'oc-icon-mars-double' => ['mars-double', 'oc-icon-mars-double'], + 'oc-icon-mars-stroke' => ['mars-stroke', 'oc-icon-mars-stroke'], + 'oc-icon-mars-stroke-h' => ['mars-stroke-h', 'oc-icon-mars-stroke-h'], + 'oc-icon-mars-stroke-v' => ['mars-stroke-v', 'oc-icon-mars-stroke-v'], + 'oc-icon-maxcdn' => ['maxcdn', 'oc-icon-maxcdn'], + 'oc-icon-meanpath' => ['meanpath', 'oc-icon-meanpath'], + 'oc-icon-medium' => ['medium', 'oc-icon-medium'], + 'oc-icon-medkit' => ['medkit', 'oc-icon-medkit'], + 'oc-icon-meh-o' => ['meh-o', 'oc-icon-meh-o'], + 'oc-icon-mercury' => ['mercury', 'oc-icon-mercury'], + 'oc-icon-microphone' => ['microphone', 'oc-icon-microphone'], + 'oc-icon-microphone-slash' => ['microphone-slash', 'oc-icon-microphone-slash'], + 'oc-icon-minus' => ['minus', 'oc-icon-minus'], + 'oc-icon-minus-circle' => ['minus-circle', 'oc-icon-minus-circle'], + 'oc-icon-minus-square' => ['minus-square', 'oc-icon-minus-square'], + 'oc-icon-minus-square-o' => ['minus-square-o', 'oc-icon-minus-square-o'], + 'oc-icon-mobile' => ['mobile', 'oc-icon-mobile'], + 'oc-icon-mobile-phone' => ['mobile-phone', 'oc-icon-mobile-phone'], + 'oc-icon-money' => ['money', 'oc-icon-money'], + 'oc-icon-moon-o' => ['moon-o', 'oc-icon-moon-o'], + 'oc-icon-mortar-board' => ['mortar-board', 'oc-icon-mortar-board'], + 'oc-icon-motorcycle' => ['motorcycle', 'oc-icon-motorcycle'], + 'oc-icon-music' => ['music', 'oc-icon-music'], + 'oc-icon-navicon' => ['navicon', 'oc-icon-navicon'], + 'oc-icon-neuter' => ['neuter', 'oc-icon-neuter'], + 'oc-icon-newspaper-o' => ['newspaper-o', 'oc-icon-newspaper-o'], + 'oc-icon-openid' => ['openid', 'oc-icon-openid'], + 'oc-icon-outdent' => ['outdent', 'oc-icon-outdent'], + 'oc-icon-pagelines' => ['pagelines', 'oc-icon-pagelines'], + 'oc-icon-paint-brush' => ['paint-brush', 'oc-icon-paint-brush'], + 'oc-icon-paper-plane' => ['paper-plane', 'oc-icon-paper-plane'], + 'oc-icon-paper-plane-o' => ['paper-plane-o', 'oc-icon-paper-plane-o'], + 'oc-icon-paperclip' => ['paperclip', 'oc-icon-paperclip'], + 'oc-icon-paragraph' => ['paragraph', 'oc-icon-paragraph'], + 'oc-icon-paste' => ['paste', 'oc-icon-paste'], + 'oc-icon-pause' => ['pause', 'oc-icon-pause'], + 'oc-icon-paw' => ['paw', 'oc-icon-paw'], + 'oc-icon-paypal' => ['paypal', 'oc-icon-paypal'], + 'oc-icon-pencil' => ['pencil', 'oc-icon-pencil'], + 'oc-icon-pencil-square' => ['pencil-square', 'oc-icon-pencil-square'], + 'oc-icon-pencil-square-o' => ['pencil-square-o', 'oc-icon-pencil-square-o'], + 'oc-icon-phone' => ['phone', 'oc-icon-phone'], + 'oc-icon-phone-square' => ['phone-square', 'oc-icon-phone-square'], + 'oc-icon-photo' => ['photo', 'oc-icon-photo'], + 'oc-icon-picture-o' => ['picture-o', 'oc-icon-picture-o'], + 'oc-icon-pie-chart' => ['pie-chart', 'oc-icon-pie-chart'], + 'oc-icon-pied-piper' => ['pied-piper', 'oc-icon-pied-piper'], + 'oc-icon-pied-piper-alt' => ['pied-piper-alt', 'oc-icon-pied-piper-alt'], + 'oc-icon-pinterest' => ['pinterest', 'oc-icon-pinterest'], + 'oc-icon-pinterest-p' => ['pinterest-p', 'oc-icon-pinterest-p'], + 'oc-icon-pinterest-square' => ['pinterest-square', 'oc-icon-pinterest-square'], + 'oc-icon-plane' => ['plane', 'oc-icon-plane'], + 'oc-icon-play' => ['play', 'oc-icon-play'], + 'oc-icon-play-circle' => ['play-circle', 'oc-icon-play-circle'], + 'oc-icon-play-circle-o' => ['play-circle-o', 'oc-icon-play-circle-o'], + 'oc-icon-plug' => ['plug', 'oc-icon-plug'], + 'oc-icon-plus' => ['plus', 'oc-icon-plus'], + 'oc-icon-plus-circle' => ['plus-circle', 'oc-icon-plus-circle'], + 'oc-icon-plus-square' => ['plus-square', 'oc-icon-plus-square'], + 'oc-icon-plus-square-o' => ['plus-square-o', 'oc-icon-plus-square-o'], + 'oc-icon-power-off' => ['power-off', 'oc-icon-power-off'], + 'oc-icon-print' => ['print', 'oc-icon-print'], + 'oc-icon-puzzle-piece' => ['puzzle-piece', 'oc-icon-puzzle-piece'], + 'oc-icon-qq' => ['qq', 'oc-icon-qq'], + 'oc-icon-qrcode' => ['qrcode', 'oc-icon-qrcode'], + 'oc-icon-question' => ['question', 'oc-icon-question'], + 'oc-icon-question-circle' => ['question-circle', 'oc-icon-question-circle'], + 'oc-icon-quote-left' => ['quote-left', 'oc-icon-quote-left'], + 'oc-icon-quote-right' => ['quote-right', 'oc-icon-quote-right'], + 'oc-icon-ra' => ['ra', 'oc-icon-ra'], + 'oc-icon-random' => ['random', 'oc-icon-random'], + 'oc-icon-rebel' => ['rebel', 'oc-icon-rebel'], + 'oc-icon-recycle' => ['recycle', 'oc-icon-recycle'], + 'oc-icon-reddit' => ['reddit', 'oc-icon-reddit'], + 'oc-icon-reddit-square' => ['reddit-square', 'oc-icon-reddit-square'], + 'oc-icon-refresh' => ['refresh', 'oc-icon-refresh'], + 'oc-icon-remove' => ['remove', 'oc-icon-remove'], + 'oc-icon-renren' => ['renren', 'oc-icon-renren'], + 'oc-icon-reorder' => ['reorder', 'oc-icon-reorder'], + 'oc-icon-repeat' => ['repeat', 'oc-icon-repeat'], + 'oc-icon-reply' => ['reply', 'oc-icon-reply'], + 'oc-icon-reply-all' => ['reply-all', 'oc-icon-reply-all'], + 'oc-icon-retweet' => ['retweet', 'oc-icon-retweet'], + 'oc-icon-rmb' => ['rmb', 'oc-icon-rmb'], + 'oc-icon-road' => ['road', 'oc-icon-road'], + 'oc-icon-rocket' => ['rocket', 'oc-icon-rocket'], + 'oc-icon-rotate-left' => ['rotate-left', 'oc-icon-rotate-left'], + 'oc-icon-rotate-right' => ['rotate-right', 'oc-icon-rotate-right'], + 'oc-icon-rouble' => ['rouble', 'oc-icon-rouble'], + 'oc-icon-rss' => ['rss', 'oc-icon-rss'], + 'oc-icon-rss-square' => ['rss-square', 'oc-icon-rss-square'], + 'oc-icon-rub' => ['rub', 'oc-icon-rub'], + 'oc-icon-ruble' => ['ruble', 'oc-icon-ruble'], + 'oc-icon-rupee' => ['rupee', 'oc-icon-rupee'], + 'oc-icon-save' => ['save', 'oc-icon-save'], + 'oc-icon-scissors' => ['scissors', 'oc-icon-scissors'], + 'oc-icon-search' => ['search', 'oc-icon-search'], + 'oc-icon-search-minus' => ['search-minus', 'oc-icon-search-minus'], + 'oc-icon-search-plus' => ['search-plus', 'oc-icon-search-plus'], + 'oc-icon-sellsy' => ['sellsy', 'oc-icon-sellsy'], + 'oc-icon-send' => ['send', 'oc-icon-send'], + 'oc-icon-send-o' => ['send-o', 'oc-icon-send-o'], + 'oc-icon-server' => ['server', 'oc-icon-server'], + 'oc-icon-share' => ['share', 'oc-icon-share'], + 'oc-icon-share-alt' => ['share-alt', 'oc-icon-share-alt'], + 'oc-icon-share-alt-square' => ['share-alt-square', 'oc-icon-share-alt-square'], + 'oc-icon-share-square' => ['share-square', 'oc-icon-share-square'], + 'oc-icon-share-square-o' => ['share-square-o', 'oc-icon-share-square-o'], + 'oc-icon-shekel' => ['shekel', 'oc-icon-shekel'], + 'oc-icon-sheqel' => ['sheqel', 'oc-icon-sheqel'], + 'oc-icon-shield' => ['shield', 'oc-icon-shield'], + 'oc-icon-ship' => ['ship', 'oc-icon-ship'], + 'oc-icon-shirtsinbulk' => ['shirtsinbulk', 'oc-icon-shirtsinbulk'], + 'oc-icon-shopping-cart' => ['shopping-cart', 'oc-icon-shopping-cart'], + 'oc-icon-sign-in' => ['sign-in', 'oc-icon-sign-in'], + 'oc-icon-sign-out' => ['sign-out', 'oc-icon-sign-out'], + 'oc-icon-signal' => ['signal', 'oc-icon-signal'], + 'oc-icon-simplybuilt' => ['simplybuilt', 'oc-icon-simplybuilt'], + 'oc-icon-sitemap' => ['sitemap', 'oc-icon-sitemap'], + 'oc-icon-skyatlas' => ['skyatlas', 'oc-icon-skyatlas'], + 'oc-icon-skype' => ['skype', 'oc-icon-skype'], + 'oc-icon-slack' => ['slack', 'oc-icon-slack'], + 'oc-icon-sliders' => ['sliders', 'oc-icon-sliders'], + 'oc-icon-slideshare' => ['slideshare', 'oc-icon-slideshare'], + 'oc-icon-smile-o' => ['smile-o', 'oc-icon-smile-o'], + 'oc-icon-soccer-ball-o' => ['soccer-ball-o', 'oc-icon-soccer-ball-o'], + 'oc-icon-sort' => ['sort', 'oc-icon-sort'], + 'oc-icon-sort-alpha-asc' => ['sort-alpha-asc', 'oc-icon-sort-alpha-asc'], + 'oc-icon-sort-alpha-desc' => ['sort-alpha-desc', 'oc-icon-sort-alpha-desc'], + 'oc-icon-sort-amount-asc' => ['sort-amount-asc', 'oc-icon-sort-amount-asc'], + 'oc-icon-sort-amount-desc' => ['sort-amount-desc', 'oc-icon-sort-amount-desc'], + 'oc-icon-sort-asc' => ['sort-asc', 'oc-icon-sort-asc'], + 'oc-icon-sort-desc' => ['sort-desc', 'oc-icon-sort-desc'], + 'oc-icon-sort-down' => ['sort-down', 'oc-icon-sort-down'], + 'oc-icon-sort-numeric-asc' => ['sort-numeric-asc', 'oc-icon-sort-numeric-asc'], + 'oc-icon-sort-numeric-desc' => ['sort-numeric-desc', 'oc-icon-sort-numeric-desc'], + 'oc-icon-sort-up' => ['sort-up', 'oc-icon-sort-up'], + 'oc-icon-soundcloud' => ['soundcloud', 'oc-icon-soundcloud'], + 'oc-icon-space-shuttle' => ['space-shuttle', 'oc-icon-space-shuttle'], + 'oc-icon-spinner' => ['spinner', 'oc-icon-spinner'], + 'oc-icon-spoon' => ['spoon', 'oc-icon-spoon'], + 'oc-icon-spotify' => ['spotify', 'oc-icon-spotify'], + 'oc-icon-square' => ['square', 'oc-icon-square'], + 'oc-icon-square-o' => ['square-o', 'oc-icon-square-o'], + 'oc-icon-stack-exchange' => ['stack-exchange', 'oc-icon-stack-exchange'], + 'oc-icon-stack-overflow' => ['stack-overflow', 'oc-icon-stack-overflow'], + 'oc-icon-star' => ['star', 'oc-icon-star'], + 'oc-icon-star-half' => ['star-half', 'oc-icon-star-half'], + 'oc-icon-star-half-empty' => ['star-half-empty', 'oc-icon-star-half-empty'], + 'oc-icon-star-half-full' => ['star-half-full', 'oc-icon-star-half-full'], + 'oc-icon-star-half-o' => ['star-half-o', 'oc-icon-star-half-o'], + 'oc-icon-star-o' => ['star-o', 'oc-icon-star-o'], + 'oc-icon-steam' => ['steam', 'oc-icon-steam'], + 'oc-icon-steam-square' => ['steam-square', 'oc-icon-steam-square'], + 'oc-icon-step-backward' => ['step-backward', 'oc-icon-step-backward'], + 'oc-icon-step-forward' => ['step-forward', 'oc-icon-step-forward'], + 'oc-icon-stethoscope' => ['stethoscope', 'oc-icon-stethoscope'], + 'oc-icon-stop' => ['stop', 'oc-icon-stop'], + 'oc-icon-street-view' => ['street-view', 'oc-icon-street-view'], + 'oc-icon-strikethrough' => ['strikethrough', 'oc-icon-strikethrough'], + 'oc-icon-stumbleupon' => ['stumbleupon', 'oc-icon-stumbleupon'], + 'oc-icon-stumbleupon-circle' => ['stumbleupon-circle', 'oc-icon-stumbleupon-circle'], + 'oc-icon-subscript' => ['subscript', 'oc-icon-subscript'], + 'oc-icon-subway' => ['subway', 'oc-icon-subway'], + 'oc-icon-suitcase' => ['suitcase', 'oc-icon-suitcase'], + 'oc-icon-sun-o' => ['sun-o', 'oc-icon-sun-o'], + 'oc-icon-superscript' => ['superscript', 'oc-icon-superscript'], + 'oc-icon-support' => ['support', 'oc-icon-support'], + 'oc-icon-table' => ['table', 'oc-icon-table'], + 'oc-icon-tablet' => ['tablet', 'oc-icon-tablet'], + 'oc-icon-tachometer' => ['tachometer', 'oc-icon-tachometer'], + 'oc-icon-tag' => ['tag', 'oc-icon-tag'], + 'oc-icon-tags' => ['tags', 'oc-icon-tags'], + 'oc-icon-tasks' => ['tasks', 'oc-icon-tasks'], + 'oc-icon-taxi' => ['taxi', 'oc-icon-taxi'], + 'oc-icon-tencent-weibo' => ['tencent-weibo', 'oc-icon-tencent-weibo'], + 'oc-icon-terminal' => ['terminal', 'oc-icon-terminal'], + 'oc-icon-text-height' => ['text-height', 'oc-icon-text-height'], + 'oc-icon-text-width' => ['text-width', 'oc-icon-text-width'], + 'oc-icon-th' => ['th', 'oc-icon-th'], + 'oc-icon-th-large' => ['th-large', 'oc-icon-th-large'], + 'oc-icon-th-list' => ['th-list', 'oc-icon-th-list'], + 'oc-icon-thumb-tack' => ['thumb-tack', 'oc-icon-thumb-tack'], + 'oc-icon-thumbs-down' => ['thumbs-down', 'oc-icon-thumbs-down'], + 'oc-icon-thumbs-o-down' => ['thumbs-o-down', 'oc-icon-thumbs-o-down'], + 'oc-icon-thumbs-o-up' => ['thumbs-o-up', 'oc-icon-thumbs-o-up'], + 'oc-icon-thumbs-up' => ['thumbs-up', 'oc-icon-thumbs-up'], + 'oc-icon-ticket' => ['ticket', 'oc-icon-ticket'], + 'oc-icon-times' => ['times', 'oc-icon-times'], + 'oc-icon-times-circle' => ['times-circle', 'oc-icon-times-circle'], + 'oc-icon-times-circle-o' => ['times-circle-o', 'oc-icon-times-circle-o'], + 'oc-icon-tint' => ['tint', 'oc-icon-tint'], + 'oc-icon-toggle-down' => ['toggle-down', 'oc-icon-toggle-down'], + 'oc-icon-toggle-left' => ['toggle-left', 'oc-icon-toggle-left'], + 'oc-icon-toggle-off' => ['toggle-off', 'oc-icon-toggle-off'], + 'oc-icon-toggle-on' => ['toggle-on', 'oc-icon-toggle-on'], + 'oc-icon-toggle-right' => ['toggle-right', 'oc-icon-toggle-right'], + 'oc-icon-toggle-up' => ['toggle-up', 'oc-icon-toggle-up'], + 'oc-icon-train' => ['train', 'oc-icon-train'], + 'oc-icon-transgender' => ['transgender', 'oc-icon-transgender'], + 'oc-icon-transgender-alt' => ['transgender-alt', 'oc-icon-transgender-alt'], + 'oc-icon-trash' => ['trash', 'oc-icon-trash'], + 'oc-icon-trash-o' => ['trash-o', 'oc-icon-trash-o'], + 'oc-icon-tree' => ['tree', 'oc-icon-tree'], + 'oc-icon-trello' => ['trello', 'oc-icon-trello'], + 'oc-icon-trophy' => ['trophy', 'oc-icon-trophy'], + 'oc-icon-truck' => ['truck', 'oc-icon-truck'], + 'oc-icon-try' => ['try', 'oc-icon-try'], + 'oc-icon-tty' => ['tty', 'oc-icon-tty'], + 'oc-icon-tumblr' => ['tumblr', 'oc-icon-tumblr'], + 'oc-icon-tumblr-square' => ['tumblr-square', 'oc-icon-tumblr-square'], + 'oc-icon-turkish-lira' => ['turkish-lira', 'oc-icon-turkish-lira'], + 'oc-icon-twitch' => ['twitch', 'oc-icon-twitch'], + 'oc-icon-twitter' => ['twitter', 'oc-icon-twitter'], + 'oc-icon-twitter-square' => ['twitter-square', 'oc-icon-twitter-square'], + 'oc-icon-umbrella' => ['umbrella', 'oc-icon-umbrella'], + 'oc-icon-underline' => ['underline', 'oc-icon-underline'], + 'oc-icon-undo' => ['undo', 'oc-icon-undo'], + 'oc-icon-university' => ['university', 'oc-icon-university'], + 'oc-icon-unlink' => ['unlink', 'oc-icon-unlink'], + 'oc-icon-unlock' => ['unlock', 'oc-icon-unlock'], + 'oc-icon-unlock-alt' => ['unlock-alt', 'oc-icon-unlock-alt'], + 'oc-icon-unsorted' => ['unsorted', 'oc-icon-unsorted'], + 'oc-icon-upload' => ['upload', 'oc-icon-upload'], + 'oc-icon-usd' => ['usd', 'oc-icon-usd'], + 'oc-icon-user' => ['user', 'oc-icon-user'], + 'oc-icon-user-md' => ['user-md', 'oc-icon-user-md'], + 'oc-icon-user-plus' => ['user-plus', 'oc-icon-user-plus'], + 'oc-icon-user-secret' => ['user-secret', 'oc-icon-user-secret'], + 'oc-icon-user-times' => ['user-times', 'oc-icon-user-times'], + 'oc-icon-users' => ['users', 'oc-icon-users'], + 'oc-icon-venus' => ['venus', 'oc-icon-venus'], + 'oc-icon-venus-double' => ['venus-double', 'oc-icon-venus-double'], + 'oc-icon-venus-mars' => ['venus-mars', 'oc-icon-venus-mars'], + 'oc-icon-viacoin' => ['viacoin', 'oc-icon-viacoin'], + 'oc-icon-video-camera' => ['video-camera', 'oc-icon-video-camera'], + 'oc-icon-vimeo-square' => ['vimeo-square', 'oc-icon-vimeo-square'], + 'oc-icon-vine' => ['vine', 'oc-icon-vine'], + 'oc-icon-vk' => ['vk', 'oc-icon-vk'], + 'oc-icon-volume-down' => ['volume-down', 'oc-icon-volume-down'], + 'oc-icon-volume-off' => ['volume-off', 'oc-icon-volume-off'], + 'oc-icon-volume-up' => ['volume-up', 'oc-icon-volume-up'], + 'oc-icon-warning' => ['warning', 'oc-icon-warning'], + 'oc-icon-wechat' => ['wechat', 'oc-icon-wechat'], + 'oc-icon-weibo' => ['weibo', 'oc-icon-weibo'], + 'oc-icon-weixin' => ['weixin', 'oc-icon-weixin'], + 'oc-icon-whatsapp' => ['whatsapp', 'oc-icon-whatsapp'], + 'oc-icon-wheelchair' => ['wheelchair', 'oc-icon-wheelchair'], + 'oc-icon-wifi' => ['wifi', 'oc-icon-wifi'], + 'oc-icon-windows' => ['windows', 'oc-icon-windows'], + 'oc-icon-won' => ['won', 'oc-icon-won'], + 'oc-icon-wordpress' => ['wordpress', 'oc-icon-wordpress'], + 'oc-icon-wrench' => ['wrench', 'oc-icon-wrench'], + 'oc-icon-xing' => ['xing', 'oc-icon-xing'], + 'oc-icon-xing-square' => ['xing-square', 'oc-icon-xing-square'], + 'oc-icon-yahoo' => ['yahoo', 'oc-icon-yahoo'], + 'oc-icon-yelp' => ['yelp', 'oc-icon-yelp'], + 'oc-icon-yen' => ['yen', 'oc-icon-yen'], + 'oc-icon-youtube' => ['youtube', 'oc-icon-youtube'], + 'oc-icon-youtube-play' => ['youtube-play', 'oc-icon-youtube-play'], + 'oc-icon-youtube-square' => ['youtube-square', 'oc-icon-youtube-square'] + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/IndexOperationsBehaviorBase.php b/server/plugins/rainlab/builder/classes/IndexOperationsBehaviorBase.php new file mode 100644 index 0000000..9ae6c2d --- /dev/null +++ b/server/plugins/rainlab/builder/classes/IndexOperationsBehaviorBase.php @@ -0,0 +1,46 @@ +baseFormConfigFile)) { + throw new ApplicationException(sprintf('Base form configuration file is not specified for %s behavior', get_class($this))); + } + + $widgetConfig = $this->makeConfig($this->baseFormConfigFile); + + $widgetConfig->model = $this->loadOrCreateBaseModel($modelCode, $options); + $widgetConfig->alias = 'form_'.md5(get_class($this)).uniqid(); + + $form = $this->makeWidget('Backend\Widgets\Form', $widgetConfig); + $form->context = strlen($modelCode) ? FormController::CONTEXT_UPDATE : FormController::CONTEXT_CREATE; + + return $form; + } + + protected function getPluginCode() + { + $vector = $this->controller->getBuilderActivePluginVector(); + + if (!$vector) { + throw new ApplicationException('Cannot determine the currently active plugin.'); + } + + return $vector->pluginCodeObj; + } + + abstract protected function loadOrCreateBaseModel($modelCode, $options = []); +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/LanguageMixer.php b/server/plugins/rainlab/builder/classes/LanguageMixer.php new file mode 100644 index 0000000..59f9540 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/LanguageMixer.php @@ -0,0 +1,201 @@ + '', + 'mismatch' => false, + 'updatedLines' => [], + ]; + + try + { + $destArray = Yaml::parse($destContents); + } + catch (Exception $ex) { + throw new ApplicationException(sprintf('Cannot parse the YAML content: %s', $ex->getMessage())); + } + + if (!$destArray) { + $result['strings'] = $this->arrayToYaml($srcArray); + return $result; + } + + $mismatch = false; + $missingPaths = $this->findMissingPaths($destArray, $srcArray, $mismatch); + $mergedArray = self::arrayMergeRecursive($srcArray, $destArray); + + $destStrings = $this->arrayToYaml($mergedArray); + $addedLines = $this->getAddedLines($destStrings, $missingPaths); + + $result['strings'] = $destStrings; + $result['updatedLines'] = $addedLines['lines']; + $result['mismatch'] = $mismatch || $addedLines['mismatch']; + + return $result; + } + + public static function arrayMergeRecursive(&$array1, &$array2) + { + // The native PHP implementation of array_merge_recursive + // generates unexpected results when two scalar elements with a + // same key is found, so we use a custom one. + + $result = $array1; + + foreach ($array2 as $key=>&$value) + { + if (is_array ($value) && isset($result[$key]) && is_array($result[$key])) + { + $result[$key] = self::arrayMergeRecursive($result[$key], $value); + } + else + { + $result[$key] = $value; + } + } + + return $result; + } + + protected function findMissingPaths($destArray, $srcArray, &$mismatch) + { + $result = []; + $mismatch = false; + $this->findMissingPathsRecursive($destArray, $srcArray, $result, [], $mismatch); + + return $result; + } + + protected function findMissingPathsRecursive($destArray, $srcArray, &$result, $currentPath, &$mismatch) + { + foreach ($srcArray as $key=>$value) { + $newPath = array_merge($currentPath, [$key]); + $pathValue = null; + $pathExists = $this->pathExistsInArray($destArray, $newPath, $pathValue); + + if (!$pathExists) { + $result[] = $newPath; + } + + if (is_array($value)) { + $this->findMissingPathsRecursive($destArray, $value, $result, $newPath, $mismatch); + } + else { + // Detect the case when the value in the destination file + // is an array, when the value in the source file a is a string. + if ($pathExists && is_array($pathValue)) { + $mismatch = true; + } + } + } + } + + protected function pathExistsInArray($array, $path, &$value) + { + $currentArray = $array; + + while ($path) { + $currentPath = array_shift($path); + + if (!is_array($currentArray)) { + return false; + } + + if (!array_key_exists($currentPath, $currentArray)) { + return false; + } + + $currentArray = $currentArray[$currentPath]; + } + + $value = $currentArray; + return true; + } + + protected function arrayToYaml($array) + { + $dumper = new YamlDumper(); + return $dumper->dump($array, 20, 0, false, true); + } + + protected function getAddedLines($strings, $paths) + { + $result = [ + 'lines' => [], + 'mismatch' => false + ]; + + foreach ($paths as $path) { + $line = $this->getLineForPath($strings, $path); + + if ($line !== false) { + $result['lines'][] = $line; + } + else { + $result['mismatch'] = true; + } + } + + return $result; + } + + protected function getLineForPath($strings, $path) + { + $strings = str_replace("\n\r", "\n", trim($strings)); + $lines = explode("\n", $strings); + + $lineCount = count($lines); + $currentLineIndex = 0; + foreach ($path as $indentaion=>$key) { + $expectedKeyDefinition = str_repeat(' ', $indentaion).$key.':'; + + $firstLineAfterKey = true; + for ($lineIndex = $currentLineIndex; $lineIndex < $lineCount; $lineIndex++) { + $line = $lines[$lineIndex]; + + if (!$firstLineAfterKey) { + $lineIndentation = 0; + if (preg_match('/^\s+/', $line, $matches)) { + $lineIndentation = strlen($matches[0])/4; + } + + if ($lineIndentation < $indentaion) { + continue; // Don't allow entering wrong branches + } + } + + $firstLineAfterKey = false; + + if (strpos($line, $expectedKeyDefinition) === 0) { + $currentLineIndex = $lineIndex; + continue 2; + } + } + + // If the key wasn't found in the text, there is + // a structure difference between the source an destination + // languages - for example when a string key was replaced + // with an array of strings. + return false; + } + + return $currentLineIndex; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/LocalizationModel.php b/server/plugins/rainlab/builder/classes/LocalizationModel.php new file mode 100644 index 0000000..3f44368 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/LocalizationModel.php @@ -0,0 +1,436 @@ + ['required', 'regex:/^[a-z0-9\.\-]+$/i'] + ]; + + protected $originalStringArray = []; + + public function load($language) + { + $this->language = $language; + + $this->originalLanguage = $language; + + $filePath = $this->getFilePath(); + + if (!File::isFile($filePath)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.localization.error_cant_load_file')); + } + + if (!$this->validateFileContents($filePath)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.localization.error_bad_localization_file_contents')); + } + + $strings = include($filePath); + if (!is_array($strings)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.localization.error_file_not_array')); + } + + $this->originalStringArray = $strings; + + if (count($strings) > 0) { + $dumper = new YamlDumper(); + $this->strings = $dumper->dump($strings, 20, 0, false, true); + } + else { + $this->strings = ''; + } + + $this->exists = true; + } + + public static function initModel($pluginCode, $language) + { + $model = new self(); + $model->setPluginCode($pluginCode); + $model->language = $language; + + return $model; + } + + public function save() + { + $data = $this->modelToLanguageFile(); + $this->validate(); + + $filePath = File::symbolizePath($this->getFilePath()); + $isNew = $this->isNewModel(); + + if (File::isFile($filePath)) { + if ($isNew || $this->originalLanguage != $this->language) { + throw new ValidationException(['fileName' => Lang::get('rainlab.builder::lang.common.error_file_exists', ['path'=>$this->language.'/'.basename($filePath)])]); + } + } + + $fileDirectory = dirname($filePath); + if (!File::isDirectory($fileDirectory)) { + if (!File::makeDirectory($fileDirectory, 0777, true, true)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.common.error_make_dir', ['name'=>$fileDirectory])); + } + } + + if (@File::put($filePath, $data) === false) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.localization.save_error', ['name'=>$filePath])); + } + + @File::chmod($filePath); + + if (!$this->isNewModel() && strlen($this->originalLanguage) > 0 && $this->originalLanguage != $this->language) { + $this->originalFilePath = $this->getFilePath($this->originalLanguage); + @File::delete($this->originalFilePath); + } + + $this->originalLanguage = $this->language; + $this->exists = true; + } + + public function deleteModel() + { + if ($this->isNewModel()) { + throw new ApplicationException('Cannot delete language file which is not saved yet.'); + } + + $filePath = File::symbolizePath($this->getFilePath()); + if (File::isFile($filePath)) { + if (!@unlink($filePath)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.localization.error_delete_file')); + } + } + } + + public function initContent() + { + $templatePath = '$/rainlab/builder/classes/localizationmodel/templates/lang.php'; + $templatePath = File::symbolizePath($templatePath); + + $strings = include($templatePath); + $dumper = new YamlDumper(); + $this->strings = $dumper->dump($strings, 20, 0, false, true); + } + + public static function listPluginLanguages($pluginCodeObj) + { + $languagesDirectoryPath = $pluginCodeObj->toPluginDirectoryPath().'/lang'; + + $languagesDirectoryPath = File::symbolizePath($languagesDirectoryPath); + + if (!File::isDirectory($languagesDirectoryPath)) { + return []; + } + + $result = []; + foreach (new DirectoryIterator($languagesDirectoryPath) as $fileInfo) { + if (!$fileInfo->isDir() || $fileInfo->isDot()) { + continue; + } + + $langFilePath = $fileInfo->getPathname().'/lang.php'; + + if (File::isFile($langFilePath)) { + $result[] = $fileInfo->getFilename(); + } + } + + return $result; + } + + public function copyStringsFrom($destinationText, $sourceLanguageCode) + { + $sourceLanguageModel = new self(); + $sourceLanguageModel->setPluginCodeObj($this->getPluginCodeObj()); + $sourceLanguageModel->load($sourceLanguageCode); + + $srcArray = $sourceLanguageModel->getOriginalStringsArray(); + + $languageMixer = new LanguageMixer(); + + return $languageMixer->addStringsFromAnotherLanguage($destinationText, $srcArray); + } + + public function getOriginalStringsArray() + { + return $this->originalStringArray; + } + + public function createStringAndSave($stringKey, $stringValue) + { + $stringKey = trim($stringKey, '.'); + + if (!strlen($stringKey)) { + throw new ValidationException(['key' => Lang::get('rainlab.builder::lang.localization.string_key_is_empty')]); + } + + if (!strlen($stringValue)) { + throw new ValidationException(['value' => Lang::get('rainlab.builder::lang.localization.string_value_is_empty')]); + } + + $originalStringArray = $this->getOriginalStringsArray(); + $languagePrefix = strtolower($this->getPluginCodeObj()->toCode()).'::lang.'; + + $existingStrings = self::convertToStringsArray($originalStringArray, $languagePrefix); + if (array_key_exists($languagePrefix.$stringKey, $existingStrings)) { + throw new ValidationException(['key' => Lang::get('rainlab.builder::lang.localization.string_key_exists')]); + } + + $existingSections = self::convertToSectionsArray($originalStringArray); + if (array_key_exists($stringKey.'.', $existingSections)) { + throw new ValidationException(['key' => Lang::get('rainlab.builder::lang.localization.string_key_exists')]); + } + + $sectionArray = []; + self::createStringSections($sectionArray, $stringKey, $stringValue) ; + + $this->checkKeyWritable($stringKey, $existingStrings, $languagePrefix); + $newStrings = LanguageMixer::arrayMergeRecursive($originalStringArray, $sectionArray); + + $dumper = new YamlDumper(); + $this->strings = $dumper->dump($newStrings, 20, 0, false, true); + + $this->save(); + + return $languagePrefix.$stringKey; + } + + public static function getDefaultLanguage() + { + $language = Config::get('app.locale'); + + if (!$language) { + throw new ApplicationException('The default language is not defined in the application configuration (app.locale).'); + } + + return $language; + } + + public static function getPluginRegistryData($pluginCode, $subtype) + { + $defaultLanguage = self::getDefaultLanguage(); + + $model = new self(); + $model->setPluginCode($pluginCode); + $model->language = $defaultLanguage; + + $filePath = $model->getFilePath(); + if (!File::isFile($filePath)) { + return []; + } + + $model->load($defaultLanguage); + + $array = $model->getOriginalStringsArray(); + $languagePrefix = strtolower($model->getPluginCodeObj()->toCode()).'::lang.'; + + if ($subtype !== 'sections') { + return self::convertToStringsArray($array, $languagePrefix); + } + + return self::convertToSectionsArray($array); + } + + public static function languageFileExists($pluginCode, $language) + { + $model = new self(); + $model->setPluginCode($pluginCode); + $model->language = $language; + + $filePath = $model->getFilePath(); + return File::isFile($filePath); + } + + protected static function createStringSections(&$arr, $path, $value) { + $keys = explode('.', $path); + + while ($key = array_shift($keys)) { + $arr = &$arr[$key]; + } + + $arr = $value; + } + + protected static function convertToStringsArray($stringsArray, $prefix, $currentKey = '') + { + $result = []; + + foreach ($stringsArray as $key=>$value) { + $newKey = strlen($currentKey) ? $currentKey.'.'.$key : $key; + + if (is_scalar($value)) { + $result[$prefix.$newKey] = $value; + } + else { + $result = array_merge($result, self::convertToStringsArray($value, $prefix, $newKey)); + } + } + + return $result; + } + + protected static function convertToSectionsArray($stringsArray, $currentKey = '') + { + $result = []; + + foreach ($stringsArray as $key=>$value) { + $newKey = strlen($currentKey) ? $currentKey.'.'.$key : $key; + + if (is_scalar($value)) { + $result[$currentKey.'.'] = $currentKey.'.'; + } + else { + $result = array_merge($result, self::convertToSectionsArray($value, $newKey)); + } + } + + return $result; + } + + protected function validateLanguage($language) + { + return preg_match('/^[a-z0-9\.\-]+$/i', $language); + } + + protected function getFilePath($language = null) + { + if ($language === null) { + $language = $this->language; + } + + $language = trim($language); + + if (!strlen($language)) { + throw new SystemException('The form model language is not set.'); + } + + if (!$this->validateLanguage($language)) { + throw new SystemException('Invalid language file name: '.$language); + } + + $path = $this->getPluginCodeObj()->toPluginDirectoryPath().'/lang/'.$language.'/lang.php'; + return File::symbolizePath($path); + } + + protected function modelToLanguageFile() + { + $this->strings = trim($this->strings); + + if (!strlen($this->strings)) { + return "getSanitizedPHPStrings(Yaml::parse($this->strings)); + + $phpData = var_export($data, true); + $phpData = preg_replace('/^(\s+)\),/m', '$1],', $phpData); + $phpData = preg_replace('/^(\s+)array\s+\(/m', '$1[', $phpData); + $phpData = preg_replace_callback('/^(\s+)/m', function($matches) { + return str_repeat($matches[1], 2); // Increase indentation + }, $phpData); + $phpData = preg_replace('/\n\s+\[/m', '[', $phpData); + $phpData = preg_replace('/^array\s\(/', '[', $phpData); + $phpData = preg_replace('/^\)\Z/m', ']', $phpData); + + return "getMessage())); + } + } + + protected function validateFileContents($path) + { + $fileContents = File::get($path); + + $stream = new PhpSourceStream($fileContents); + + $invalidTokens = [ + T_CLASS, + T_FUNCTION, + T_INCLUDE, + T_INCLUDE_ONCE, + T_REQUIRE, + T_REQUIRE_ONCE, + T_EVAL, + T_ECHO, + T_GOTO, + T_HALT_COMPILER, + T_STRING // Unescaped strings - function names, etc. + ]; + + while ($stream->forward()) { + $tokenCode = $stream->getCurrentCode(); + + if (in_array($tokenCode, $invalidTokens)) { + return false; + } + } + + return true; + } + + protected function getSanitizedPHPStrings($strings) + { + array_walk_recursive($strings, function(&$item, $key){ + if (!is_scalar($item)) { + return; + } + + // In YAML single quotes are escaped with two single quotes + // http://yaml.org/spec/current.html#id2534365 + $item = str_replace("''", "'", $item); + }); + + return $strings; + } + + protected function checkKeyWritable($stringKey, $existingStrings, $languagePrefix) + { + $sectionList = explode('.', $stringKey); + + $lastElement = array_pop($sectionList); + while (strlen($lastElement)) { + if (count($sectionList) > 0) { + $fullKey = implode('.', $sectionList).'.'.$lastElement; + } + else { + $fullKey = $lastElement; + } + + if (array_key_exists($languagePrefix.$fullKey, $existingStrings)) { + throw new ValidationException(['key' => Lang::get('rainlab.builder::lang.localization.string_key_is_a_string', ['key'=>$fullKey])]); + } + + $lastElement = array_pop($sectionList); + } + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/MenusModel.php b/server/plugins/rainlab/builder/classes/MenusModel.php new file mode 100644 index 0000000..fed89b5 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/MenusModel.php @@ -0,0 +1,205 @@ +menus as $mainMenuItem) { + $mainMenuItem = $this->trimMenuProperties($mainMenuItem); + + if (!isset($mainMenuItem['code'])) { + throw new ApplicationException('Cannot save menus - the main menu item code should not be empty.'); + } + + if (isset($mainMenuItem['sideMenu'])) { + $sideMenuItems = []; + + foreach ($mainMenuItem['sideMenu'] as $sideMenuItem) { + $sideMenuItem = $this->trimMenuProperties($sideMenuItem); + + if (!isset($sideMenuItem['code'])) { + throw new ApplicationException('Cannot save menus - the side menu item code should not be empty.'); + } + + $code = $sideMenuItem['code']; + unset($sideMenuItem['code']); + + $sideMenuItems[$code] = $sideMenuItem; + } + + $mainMenuItem['sideMenu'] = $sideMenuItems; + } + + $code = $mainMenuItem['code']; + unset($mainMenuItem['code']); + + $fileMenus[$code] = $mainMenuItem; + } + + return $fileMenus; + } + + public function validate() + { + parent::validate(); + + $this->validateDupicateMenus(); + } + + public function fill(array $attributes) + { + if (!is_array($attributes['menus'])) { + $attributes['menus'] = json_decode($attributes['menus'], true); + + if ($attributes['menus'] === null) { + throw new SystemException('Cannot decode menus JSON string.'); + } + } + + return parent::fill($attributes); + } + + public function setPluginCodeObj($pluginCodeObj) + { + $this->pluginCodeObj = $pluginCodeObj; + } + + /** + * Load the model's data from an array. + * @param array $array An array to load the model fields from. + */ + protected function yamlArrayToModel($array) + { + $fileMenus = $array; + $menus = []; + $index = 0; + + foreach ($fileMenus as $code=>$mainMenuItem) { + $mainMenuItem['code'] = $code; + + if (isset($mainMenuItem['sideMenu'])) { + $sideMenuItems = []; + + foreach ($mainMenuItem['sideMenu'] as $code=>$sideMenuItem) { + $sideMenuItem['code'] = $code; + $sideMenuItems[] = $sideMenuItem; + } + + $mainMenuItem['sideMenu'] = $sideMenuItems; + } + + $menus[] = $mainMenuItem; + } + + $this->menus = $menus; + } + + protected function trimMenuProperties($menu) + { + array_walk($menu, function($value, $key){ + if (!is_scalar($value)) { + return $value; + } + + return trim($value); + }); + + return $menu; + } + + /** + * Returns a file path to save the model to. + * @return string Returns a path. + */ + protected function getFilePath() + { + if ($this->pluginCodeObj === null) { + throw new SystemException('Error saving plugin menus model - the plugin code object is not set.'); + } + + return $this->pluginCodeObj->toPluginFilePath(); + } + + protected function validateDupicateMenus() + { + foreach ($this->menus as $outerIndex=>$mainMenuItem) { + $mainMenuItem = $this->trimMenuProperties($mainMenuItem); + + if (!isset($mainMenuItem['code'])) { + continue; + } + + if ($this->codeExistsInList($outerIndex, $mainMenuItem['code'], $this->menus)) { + throw new ValidationException([ + 'permissions' => Lang::get('rainlab.builder::lang.menu.error_duplicate_main_menu_code', + ['code' => $mainMenuItem['code']] + ) + ]); + } + + if (isset($mainMenuItem['sideMenu'])) { + foreach ($mainMenuItem['sideMenu'] as $innerIndex=>$sideMenuItem) { + $sideMenuItem = $this->trimMenuProperties($sideMenuItem); + + if (!isset($sideMenuItem['code'])) { + continue; + } + + if ($this->codeExistsInList($innerIndex, $sideMenuItem['code'], $mainMenuItem['sideMenu'])) { + throw new ValidationException([ + 'permissions' => Lang::get('rainlab.builder::lang.menu.error_duplicate_side_menu_code', + ['code' => $sideMenuItem['code']] + ) + ]); + } + } + } + } + } + + protected function codeExistsInList($codeIndex, $code, $list) + { + foreach ($list as $index=>$item) { + if (!isset($item['code'])) { + continue; + } + + if ($index == $codeIndex) { + continue; + } + + if ($code == $item['code']) { + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/MigrationColumnType.php b/server/plugins/rainlab/builder/classes/MigrationColumnType.php new file mode 100644 index 0000000..da3450d --- /dev/null +++ b/server/plugins/rainlab/builder/classes/MigrationColumnType.php @@ -0,0 +1,224 @@ + DoctrineType::INTEGER, + self::TYPE_SMALLINTEGER => DoctrineType::SMALLINT, + self::TYPE_BIGINTEGER => DoctrineType::BIGINT, + self::TYPE_DATE => DoctrineType::DATE, + self::TYPE_TIME => DoctrineType::TIME, + self::TYPE_DATETIME => DoctrineType::DATETIME, + self::TYPE_TIMESTAMP => DoctrineType::DATETIME, + self::TYPE_STRING => DoctrineType::STRING, + self::TYPE_TEXT => DoctrineType::TEXT, + self::TYPE_BINARY => DoctrineType::BLOB, + self::TYPE_BOOLEAN => DoctrineType::BOOLEAN, + self::TYPE_DECIMAL => DoctrineType::DECIMAL, + self::TYPE_DOUBLE => DoctrineType::FLOAT + ]; + } + + /** + * Converts a migration column type to a corresponding Doctrine mapping type name. + */ + public static function toDoctrineTypeName($type) + { + $typeMap = self::getDoctrineTypeMap(); + + if (!array_key_exists($type, $typeMap)) { + throw new SystemException(sprintf('Unknown column type: %s', $type)); + } + + return $typeMap[$type]; + } + + /** + * Converts Doctrine mapping type name to a migration column method name + */ + public static function toMigrationMethodName($type, $columnName) + { + $typeMap = self::getDoctrineTypeMap(); + + if (!in_array($type, $typeMap)) { + throw new SystemException(sprintf('Unknown column type: %s', $type)); + } + + // Some Doctrine types map to multiple migration types, for example + // Doctrine boolean could be boolean and tinyInteger in migrations. + // Some guessing could be required in this method. The method is not + // 100% reliable. + + if ($type == DoctrineType::DATETIME) { + // The datetime type maps to datetime and timestamp. Use the name + // guessing as the only possible solution. + + if (in_array($columnName, ['created_at', 'updated_at', 'deleted_at', 'published_at', 'deleted_at'])) { + return self::TYPE_TIMESTAMP; + } + + return self::TYPE_DATETIME; + } + + $typeMap = array_flip($typeMap); + return $typeMap[$type]; + } + + /** + * Validates the column length parameter basing on the column type + */ + public static function validateLength($type, $value) + { + $value = trim($value); + + if (!strlen($value)) { + return; + } + + if (in_array($type, self::getDecimalTypes())) { + if (!preg_match(self::REGEX_LENGTH_DOUBLE, $value)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_decimal_length', [ + 'type' => $type + ])); + } + } else { + if (!preg_match(self::REGEX_LENGTH_SINGLE, $value)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [ + 'type' => $type + ])); + } + } + } + + /** + * Returns an array containing a column length, precision and scale, basing on the column type. + */ + public static function lengthToPrecisionAndScale($type, $length) + { + $length = trim($length); + + if (!strlen($length)) { + return []; + } + + $result = [ + 'length' => null, + 'precision' => null, + 'scale' => null + ]; + + if (in_array($type, self::getDecimalTypes())) { + $matches = []; + + if (!preg_match(self::REGEX_LENGTH_DOUBLE, $length, $matches)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [ + 'type' => $type + ])); + } + + $result['precision'] = $matches[1]; + $result['scale'] = $matches[2]; + + return $result; + } + + if (in_array($type, self::getIntegerTypes())) { + if (!preg_match(self::REGEX_LENGTH_SINGLE, $length)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.database.error_table_length', [ + 'type' => $type + ])); + } + + $result['precision'] = $length; + $result['scale'] = 0; + + return $result; + } + + $result['length'] = $length; + return $result; + } + + /** + * Converts Doctrine length, precision and scale to migration-compatible length string + * @return string + */ + public static function doctrineLengthToMigrationLength($column) + { + $typeName = $column->getType()->getName(); + $migrationTypeName = self::toMigrationMethodName($typeName, $column->getName()); + + if (in_array($migrationTypeName, self::getDecimalTypes())) { + return $column->getPrecision().','.$column->getScale(); + } + + if (in_array($migrationTypeName, self::getIntegerTypes())) { + return $column->getPrecision(); + } + + return $column->getLength(); + } +} diff --git a/server/plugins/rainlab/builder/classes/MigrationFileParser.php b/server/plugins/rainlab/builder/classes/MigrationFileParser.php new file mode 100644 index 0000000..2f57882 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/MigrationFileParser.php @@ -0,0 +1,69 @@ +forward()) { + $tokenCode = $stream->getCurrentCode(); + + if ($tokenCode == T_NAMESPACE) { + $namespace = $this->extractNamespace($stream); + if ($namespace === null) { + return null; + } + + $result['namespace'] = $namespace; + } + + if ($tokenCode == T_CLASS) { + $className = $this->extractClassName($stream); + if ($className === null) { + return null; + } + + $result['class'] = $className; + } + } + + if (!$result) { + return null; + } + + return $result; + } + + protected function extractClassName($stream) + { + if ($stream->getNextExpected(T_WHITESPACE) === null) { + return null; + } + + return $stream->getNextExpectedTerminated([T_STRING], [T_WHITESPACE, ';']); + } + + protected function extractNamespace($stream) + { + if ($stream->getNextExpected(T_WHITESPACE) === null) { + return null; + } + + return $stream->getNextExpectedTerminated([T_STRING, T_NS_SEPARATOR], [T_WHITESPACE, ';']); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/MigrationModel.php b/server/plugins/rainlab/builder/classes/MigrationModel.php new file mode 100644 index 0000000..d0e693f --- /dev/null +++ b/server/plugins/rainlab/builder/classes/MigrationModel.php @@ -0,0 +1,500 @@ + ['required', 'regex:/^[0-9]+\.[0-9]+\.[0-9]+$/', 'uniqueVersion'], + 'description' => ['required'], + 'scriptFileName' => ['regex:/^[a-z]+[a-z0-9_]+$/'] + ]; + + public function validate() + { + $isNewModel = $this->isNewModel(); + + $this->validationMessages = [ + 'version.regex' => Lang::get('rainlab.builder::lang.migration.error_version_invalid'), + 'version.unique_version' => Lang::get('rainlab.builder::lang.migration.error_version_exists'), + 'scriptFileName.regex' => Lang::get('rainlab.builder::lang.migration.error_script_filename_invalid') + ]; + + $versionInformation = $this->getPluginVersionInformation(); + + Validator::extend('uniqueVersion', function($attribute, $value, $parameters) use ($versionInformation, $isNewModel) { + if ($isNewModel || $this->version != $this->originalVersion) { + return !array_key_exists($value, $versionInformation); + } + return true; + }); + + if (!$isNewModel && $this->version != $this->originalVersion && $this->isApplied()) { + throw new ValidationException([ + 'version' => Lang::get('rainlab.builder::lang.migration.error_cannot_change_version_number') + ]); + } + + return parent::validate(); + } + + public function getNextVersion() + { + $versionInformation = $this->getPluginVersionInformation(); + + if (!count($versionInformation)) { + return '1.0.0'; + } + + $versions = array_keys($versionInformation); + $latestVersion = end($versions); + + $versionNumbers = []; + if (!preg_match('/^([0-9]+)\.([0-9]+)\.([0-9]+)$/', $latestVersion, $versionNumbers)) { + throw new SystemException(sprintf('Cannot parse the latest plugin version number: %s.', $latestVersion)); + } + + return $versionNumbers[1].'.'.$versionNumbers[2].'.'.($versionNumbers[3]+1); + } + + /** + * Saves the migration and applies all outstanding migrations for the plugin. + */ + public function save($executeOnSave = true) + { + $this->validate(); + + if (!strlen($this->scriptFileName) || !$this->isNewModel()) { + $this->assignFileName(); + } + + $originalFileContents = $this->saveScriptFile(); + + try { + $originalVersionData = $this->insertOrUpdateVersion(); + } catch (Exception $ex) { + // Remove the script file, but don't rollback + // the version.yaml. + $this->rollbackSaving(null, $originalFileContents); + + throw $ex; + } + + try { + if ($executeOnSave) { + VersionManager::instance()->updatePlugin($this->getPluginCodeObj()->toCode(), $this->version); + } + } + catch (Exception $ex) { + // Remove the script file, and rollback + // the version.yaml. + $this->rollbackSaving($originalVersionData, $originalFileContents); + + throw $ex; + } + + $this->originalVersion = $this->version; + $this->exists = true; + } + + public function load($versionNumber) + { + $versionNumber = trim($versionNumber); + + if (!strlen($versionNumber)) { + throw new ApplicationException('Cannot load the the version model - the version number should not be empty.'); + } + + $pluginVersions = $this->getPluginVersionInformation(); + if (!array_key_exists($versionNumber, $pluginVersions)) { + throw new ApplicationException('The requested version does not exist in the version information file.'); + } + + $this->version = $versionNumber; + $this->originalVersion = $this->version; + $this->exists = true; + + $versionInformation = $pluginVersions[$versionNumber]; + if (!is_array($versionInformation)) { + $this->description = $versionInformation; + } + else { + $cnt = count($versionInformation); + + if ($cnt > 2) { + throw new ApplicationException('The requested version cannot be edited with Builder as it refers to multiple PHP scripts.'); + } + + if ($cnt > 0) { + $this->description = $versionInformation[0]; + } + + if ($cnt > 1) { + $this->scriptFileName = pathinfo(trim($versionInformation[1]), PATHINFO_FILENAME); + $this->code = $this->loadScriptFile(); + } + } + + $this->originalScriptFileName = $this->scriptFileName; + } + + public function initVersion($versionType) + { + $versionTypes = ['migration', 'seeder', 'custom']; + + if (!in_array($versionType, $versionTypes)) { + throw new SystemException('Unknown version type.'); + } + + $this->version = $this->getNextVersion(); + + if ($versionType == 'custom') { + $this->scriptFileName = null; + return; + } + + $templateFiles = [ + 'migration' => 'migration.php.tpl', + 'seeder' => 'seeder.php.tpl' + ]; + + $templatePath = '$/rainlab/builder/classes/migrationmodel/templates/'.$templateFiles[$versionType]; + $templatePath = File::symbolizePath($templatePath); + + $fileContents = File::get($templatePath); + $scriptFileName = $versionType.str_replace('.', '-', $this->version); + + $pluginCodeObj = $this->getPluginCodeObj(); + $this->code = TextParser::parse($fileContents, [ + 'className' => Str::studly($scriptFileName), + 'namespace' => $pluginCodeObj->toUpdatesNamespace(), + 'tableNamePrefix' => $pluginCodeObj->toDatabasePrefix() + ]); + + $this->scriptFileName = $scriptFileName; + } + + public function makeScriptFileNameUnique() + { + $updatesPath = $this->getPluginUpdatesPath(); + $baseFileName = $fileName = $this->scriptFileName; + + $counter = 2; + while (File::isFile($updatesPath.'/'.$fileName.'.php')) { + $fileName = $baseFileName.'_'.$counter; + $counter++; + } + + return $this->scriptFileName = $fileName; + } + + public function deleteModel() + { + if ($this->isApplied()) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.migration.error_cant_delete_applied')); + } + + $this->deleteVersion(); + $this->removeScriptFile(); + } + + public function isApplied() + { + if ($this->isNewModel()) { + return false; + } + + $versionManager = VersionManager::instance(); + $unappliedVersions = $versionManager->listNewVersions($this->pluginCodeObj->toCode()); + + return !array_key_exists($this->originalVersion, $unappliedVersions); + } + + public function apply() + { + if ($this->isApplied()) { + return; + } + + $versionManager = VersionManager::instance(); + $versionManager->updatePlugin($this->pluginCodeObj->toCode(), $this->version); + } + + public function rollback() + { + if (!$this->isApplied()) { + return; + } + + $versionManager = VersionManager::instance(); + $versionManager->removePlugin($this->pluginCodeObj->toCode(), $this->version); + } + + protected function assignFileName() + { + $code = trim($this->code); + + if (!strlen($code)) { + $this->scriptFileName = null; + return; + } + + /* + * The file name is based on the migration class name. + */ + $parser = new MigrationFileParser(); + $migrationInfo = $parser->extractMigrationInfoFromSource($code); + + if (!$migrationInfo || !array_key_exists('class', $migrationInfo)) { + throw new ValidationException([ + 'code' => Lang::get('rainlab.builder::lang.migration.error_file_must_define_class') + ]); + } + + if (!array_key_exists('namespace', $migrationInfo)) { + throw new ValidationException([ + 'code' => Lang::get('rainlab.builder::lang.migration.error_file_must_define_namespace') + ]); + } + + $pluginCodeObj = $this->getPluginCodeObj(); + $pluginNamespace = $pluginCodeObj->toUpdatesNamespace(); + + if ($migrationInfo['namespace'] != $pluginNamespace) { + throw new ValidationException([ + 'code' => Lang::get('rainlab.builder::lang.migration.error_namespace_mismatch', ['namespace'=>$pluginNamespace]) + ]); + } + + $this->scriptFileName = Str::snake($migrationInfo['class']); + + /* + * Validate that a file with the generated name does not exist yet. + */ + if ($this->scriptFileName != $this->originalScriptFileName) { + $fileName = $this->scriptFileName.'.php'; + $filePath = $this->getPluginUpdatesPath($fileName); + + if (File::isFile($filePath)) { + throw new ValidationException([ + 'code' => Lang::get('rainlab.builder::lang.migration.error_migration_file_exists', ['file'=>$fileName]) + ]); + } + } + } + + protected function saveScriptFile() + { + $originalFileContents = $this->getOriginalFileContents(); + + if (strlen($this->scriptFileName)) { + $scriptFilePath = $this->getPluginUpdatesPath($this->scriptFileName.'.php'); + + if (!File::put($scriptFilePath, $this->code)) { + throw new SystemException(sprintf('Error saving file %s', $scriptFilePath)); + } + + @File::chmod($scriptFilePath); + } + + if (strlen($this->originalScriptFileName) && $this->scriptFileName != $this->originalScriptFileName) { + $originalScriptFilePath = $this->getPluginUpdatesPath($this->originalScriptFileName.'.php'); + if (File::isFile($originalScriptFilePath)) { + @unlink($originalScriptFilePath); + } + } + + return $originalFileContents; + } + + protected function getOriginalFileContents() + { + if (!strlen($this->originalScriptFileName)) { + return null; + } + + $scriptFilePath = $this->getPluginUpdatesPath($this->originalScriptFileName.'.php'); + if (File::isFile($scriptFilePath)) { + return File::get($scriptFilePath); + } + } + + protected function loadScriptFile() + { + $scriptFilePath = $this->getPluginUpdatesPath($this->scriptFileName.'.php'); + + if (!File::isFile($scriptFilePath)) { + throw new ApplicationException(sprintf('Version file %s is not found.', $scriptFilePath)); + } + + return File::get($scriptFilePath); + } + + protected function removeScriptFile() + { + $scriptFilePath = $this->getPluginUpdatesPath($this->scriptFileName.'.php'); + + // Using unlink instead of File::remove() is safer here. + @unlink($scriptFilePath); + } + + protected function rollbackScriptFile($fileContents) + { + $scriptFilePath = $this->getPluginUpdatesPath($this->originalScriptFileName.'.php'); + + @File::put($scriptFilePath, $fileContents); + + if ($this->scriptFileName != $this->originalScriptFileName) { + $scriptFilePath = $this->getPluginUpdatesPath($this->scriptFileName.'.php'); + @unlink($scriptFilePath); + } + } + + protected function rollbackSaving($originalVersionData, $originalScriptFileContents) + { + if ($originalVersionData) { + $this->rollbackVersionFile($originalVersionData); + } + + if ($this->isNewModel()) { + $this->removeScriptFile(); + } + else { + $this->rollbackScriptFile($originalScriptFileContents); + } + } + + protected function insertOrUpdateVersion() + { + $versionFilePath = $this->getPluginUpdatesPath('version.yaml'); + + $versionInformation = $this->getPluginVersionInformation(); + if (!$versionInformation) { + $versionInformation = []; + } + + $originalFileContents = File::get($versionFilePath); + if (!$originalFileContents) { + throw new SystemException(sprintf('Error loading file %s', $versionFilePath)); + } + + $versionInformation[$this->version] = [ + $this->description + ]; + + if (strlen($this->scriptFileName)) { + $versionInformation[$this->version][] = $this->scriptFileName.'.php'; + } + + if (!$this->isNewModel() && $this->version != $this->originalVersion) { + if (array_key_exists($this->originalVersion, $versionInformation)) { + unset($versionInformation[$this->originalVersion]); + } + } + + $yamlData = Yaml::render($versionInformation); + + if (!File::put($versionFilePath, $yamlData)) { + throw new SystemException(sprintf('Error saving file %s', $versionFilePath)); + } + + @File::chmod($versionFilePath); + + return $originalFileContents; + } + + protected function deleteVersion() + { + $versionInformation = $this->getPluginVersionInformation(); + if (!$versionInformation) { + $versionInformation = []; + } + + if (array_key_exists($this->version, $versionInformation)) { + unset($versionInformation[$this->version]); + } + + $versionFilePath = $this->getPluginUpdatesPath('version.yaml'); + $yamlData = Yaml::render($versionInformation); + + if (!File::put($versionFilePath, $yamlData)) { + throw new SystemException(sprintf('Error saving file %s', $versionFilePath)); + } + + @File::chmod($versionFilePath); + } + + protected function rollbackVersionFile($fileData) + { + $versionFilePath = $this->getPluginUpdatesPath('version.yaml'); + File::put($versionFilePath, $fileData); + } + + protected function getPluginUpdatesPath($fileName = null) + { + $pluginCodeObj = $this->getPluginCodeObj(); + + $filePath = '$/'.$pluginCodeObj->toFilesystemPath().'/updates'; + $filePath = File::symbolizePath($filePath); + + if ($fileName !== null) { + return $filePath .= '/'.$fileName; + } + + return $filePath; + } + + protected function getPluginVersionInformation() + { + $versionObj = new PluginVersion; + return $versionObj->getPluginVersionInformation($this->getPluginCodeObj()); + } +} diff --git a/server/plugins/rainlab/builder/classes/ModelFileParser.php b/server/plugins/rainlab/builder/classes/ModelFileParser.php new file mode 100644 index 0000000..f49d279 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ModelFileParser.php @@ -0,0 +1,186 @@ +forward()) { + $tokenCode = $stream->getCurrentCode(); + + if ($tokenCode == T_NAMESPACE) { + $namespace = $this->extractNamespace($stream); + if ($namespace === null) { + return null; + } + + $result['namespace'] = $namespace; + } + + if ($tokenCode == T_CLASS && !isset($result['class'])) { + $className = $this->extractClassName($stream); + if ($className === null) { + return null; + } + + $result['class'] = $className; + } + + if ($tokenCode == T_PUBLIC || $tokenCode == T_PROTECTED) { + $tableName = $this->extractTableName($stream); + if ($tableName === false) { + continue; + } + + if ($tableName === null) { + return null; + } + + $result['table'] = $tableName; + } + } + + if (!$result) { + return null; + } + + return $result; + } + + /** + * Extracts names and types of model relations. + * @param string $fileContents Specifies the file contents. + * @return array|null Returns an array with keys matching the relation types and values containing relation names as array. + * Returns null if the parsing fails. + */ + public function extractModelRelationsFromSource($fileContents) + { + $result = []; + + $stream = new PhpSourceStream($fileContents); + + while ($stream->forward()) { + $tokenCode = $stream->getCurrentCode(); + + if ($tokenCode == T_PUBLIC) { + $relations = $this->extractRelations($stream); + if ($relations === false) { + continue; + } + } + } + + if (!$result) { + return null; + } + + return $result; + } + + protected function extractNamespace($stream) + { + if ($stream->getNextExpected(T_WHITESPACE) === null) { + return null; + } + + return $stream->getNextExpectedTerminated([T_STRING, T_NS_SEPARATOR], [T_WHITESPACE, ';']); + } + + protected function extractClassName($stream) + { + if ($stream->getNextExpected(T_WHITESPACE) === null) { + return null; + } + + return $stream->getNextExpectedTerminated([T_STRING], [T_WHITESPACE, ';']); + } + + /** + * Returns the table name. This method would return null in case if the + * $table variable was found, but it value cannot be read. If the variable + * is not found, the method returns false, allowing the outer loop to go to + * the next token. + */ + protected function extractTableName($stream) + { + if ($stream->getNextExpected(T_WHITESPACE) === null) { + return false; + } + + if ($stream->getNextExpected(T_VARIABLE) === null) { + return false; + } + + if ($stream->getCurrentText() != '$table') { + return false; + } + + if ($stream->getNextExpectedTerminated(['=', T_WHITESPACE], [T_CONSTANT_ENCAPSED_STRING]) === null) { + return null; + } + + $tableName = $stream->getCurrentText(); + $tableName = trim($tableName, '\''); + $tableName = trim($tableName, '"'); + + return $tableName; + } + + protected function extractRelations($stream) + { + if ($stream->getNextExpected(T_WHITESPACE) === null) { + return false; + } + + if ($stream->getNextExpected(T_VARIABLE) === null) { + return false; + } + + $relationTypes = [ + 'belongsTo', + 'belongsToMany', + 'attachMany', + 'hasMany', + 'morphToMany', + 'morphedByMany', + 'morphMany', + 'hasManyThrough' + ]; + + $relationType = null; + $currentText = $stream->getCurrentText(); + + foreach ($relationTypes as $type) { + if ($currentText == '$'.$type) { + $relationType = $type; + break; + } + } + + if (!$relationType) { + return false; + } + + if ($stream->getNextExpectedTerminated(['=', T_WHITESPACE], ['[']) === null) { + return null; + } + + // The implementation is not finished and postponed. Relation definition could + // be quite complex and contain nested arrays. + } +} diff --git a/server/plugins/rainlab/builder/classes/ModelFormModel.php b/server/plugins/rainlab/builder/classes/ModelFormModel.php new file mode 100644 index 0000000..0811b03 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ModelFormModel.php @@ -0,0 +1,93 @@ + ['required', 'regex:/^[a-z0-9\.\-_]+$/i'] + ]; + + public function loadForm($path) + { + $this->fileName = $path; + + return parent::load($this->getFilePath()); + } + + public function fill(array $attributes) + { + if (!is_array($attributes['controls'])) { + $attributes['controls'] = json_decode($attributes['controls'], true); + + if ($attributes['controls'] === null) { + throw new SystemException('Cannot decode controls JSON string.'); + } + } + + return parent::fill($attributes); + } + + public static function validateFileIsModelType($fileContentsArray) + { + $modelRootNodes = [ + 'fields', + 'tabs', + 'secondaryTabs' + ]; + + foreach ($modelRootNodes as $node) { + if (array_key_exists($node, $fileContentsArray)) { + return true; + } + } + + return false; + } + + public function validate() + { + parent::validate(); + + if (!$this->controls) { + throw new ValidationException(['controls' => 'Please create at least one field.']); + } + } + + public function initDefaults() + { + $this->fileName = 'fields.yaml'; + } + + /** + * Converts the model's data to an array before it's saved to a YAML file. + * @return array + */ + protected function modelToYamlArray() + { + return $this->controls; + } + + /** + * Load the model's data from an array. + * @param array $array An array to load the model fields from. + */ + protected function yamlArrayToModel($array) + { + $this->controls = $array; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ModelListModel.php b/server/plugins/rainlab/builder/classes/ModelListModel.php new file mode 100644 index 0000000..c5b0f41 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ModelListModel.php @@ -0,0 +1,185 @@ + ['required', 'regex:/^[a-z0-9\.\-_]+$/i'] + ]; + + public function loadForm($path) + { + $this->fileName = $path; + + return parent::load($this->getFilePath()); + } + + public function fill(array $attributes) + { + if (!is_array($attributes['columns'])) { + $attributes['columns'] = json_decode($attributes['columns'], true); + + if ($attributes['columns'] === null) { + throw new SystemException('Cannot decode columns JSON string.'); + } + } + + return parent::fill($attributes); + } + + public static function validateFileIsModelType($fileContentsArray) + { + $modelRootNodes = [ + 'columns' + ]; + + foreach ($modelRootNodes as $node) { + if (array_key_exists($node, $fileContentsArray)) { + return true; + } + } + + return false; + } + + public function validate() + { + parent::validate(); + + $this->validateDupicateColumns(); + + if (!$this->columns) { + throw new ValidationException(['columns' => 'Please create at least one column.']); + } + } + + public function initDefaults() + { + $this->fileName = 'columns.yaml'; + } + + protected function validateDupicateColumns() + { + foreach ($this->columns as $outerIndex=>$outerColumn) { + foreach ($this->columns as $innerIndex=>$innerColumn) { + if ($innerIndex != $outerIndex && $innerColumn['field'] == $outerColumn['field']) { + throw new ValidationException([ + 'columns' => Lang::get('rainlab.builder::lang.list.error_duplicate_column', + ['column' => $outerColumn['field']] + ) + ]); + } + } + } + } + + /** + * Converts the model's data to an array before it's saved to a YAML file. + * @return array + */ + protected function modelToYamlArray() + { + $fileColumns = []; + + foreach ($this->columns as $column) { + if (!isset($column['field'])) { + throw new ApplicationException('Cannot save the list - the column field name should not be empty.'); + } + + $columnName = $column['field']; + unset($column['field']); + + if (array_key_exists('id', $column)) { + unset($column['id']); + } + + $column = $this->preprocessColumnDataBeforeSave($column); + + $fileColumns[$columnName] = $column; + } + + return [ + 'columns'=>$fileColumns + ]; + } + + /** + * Load the model's data from an array. + * @param array $array An array to load the model fields from. + */ + protected function yamlArrayToModel($array) + { + $fileColumns = $array['columns']; + $columns = []; + $index = 0; + + foreach ($fileColumns as $columnName=>$column) { + if (!is_array($column)) { + // Handle the case when a column is defined as + // column: Title + $column = [ + 'label' => $column + ]; + } + + $column['id'] = $index; + $column['field'] = $columnName; + + $columns[] = $column; + + $index++; + } + + $this->columns = $columns; + } + + protected function preprocessColumnDataBeforeSave($column) + { + $booleanFields = [ + 'searchable', + 'invisible', + 'sortable' + ]; + + $column = array_filter($column, function($value) + { + return strlen($value) > 0; + }); + + foreach ($booleanFields as $booleanField) { + if (!array_key_exists($booleanField, $column)) { + continue; + } + + $value = $column[$booleanField]; + if ($value == '1' || $value == 'true') { + $value = true; + } + else { + $value = false; + } + + + $column[$booleanField] = $value; + } + + return $column; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ModelModel.php b/server/plugins/rainlab/builder/classes/ModelModel.php new file mode 100644 index 0000000..57d9e61 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ModelModel.php @@ -0,0 +1,294 @@ + ['required', 'regex:' . self::UNQUALIFIED_CLASS_NAME_PATTERN, 'uniqModelName'], + 'databaseTable' => ['required'], + 'addTimestamps' => ['timestampColumnsMustExist'], + 'addSoftDeleting' => ['deletedAtColumnMustExist'] + ]; + + public static function listPluginModels($pluginCodeObj) + { + $modelsDirectoryPath = $pluginCodeObj->toPluginDirectoryPath().'/models'; + $pluginNamespace = $pluginCodeObj->toPluginNamespace(); + + $modelsDirectoryPath = File::symbolizePath($modelsDirectoryPath); + if (!File::isDirectory($modelsDirectoryPath)) { + return []; + } + + $parser = new ModelFileParser(); + $result = []; + foreach (new DirectoryIterator($modelsDirectoryPath) as $fileInfo) { + if (!$fileInfo->isFile()) { + continue; + } + + if ($fileInfo->getExtension() != 'php') { + continue; + } + + $filePath = $fileInfo->getPathname(); + $contents = File::get($filePath); + + $modelInfo = $parser->extractModelInfoFromSource($contents); + if (!$modelInfo) { + continue; + } + + if (!Str::startsWith($modelInfo['namespace'], $pluginNamespace.'\\')) { + continue; + } + + $model = new ModelModel(); + $model->className = $modelInfo['class']; + $model->databaseTable = isset($modelInfo['table']) ? $modelInfo['table'] : null; + + $result[] = $model; + } + + return $result; + } + + public function save() + { + $this->validate(); + + $modelFilePath = $this->getFilePath(); + $namespace = $this->getPluginCodeObj()->toPluginNamespace().'\\Models'; + + $structure = [ + $modelFilePath => 'model.php.tpl' + ]; + + $variables = [ + 'namespace' => $namespace, + 'classname' => $this->className, + 'table' => $this->databaseTable + ]; + + $dynamicContents = []; + + $generator = new FilesystemGenerator('$', $structure, '$/rainlab/builder/classes/modelmodel/templates'); + $generator->setVariables($variables); + + if ($this->addSoftDeleting) { + $dynamicContents[] = $generator->getTemplateContents('soft-delete.php.tpl'); + } + + if (!$this->addTimestamps) { + $dynamicContents[] = $generator->getTemplateContents('no-timestamps.php.tpl'); + } + + $generator->setVariable('dynamicContents', implode('', $dynamicContents)); + + $generator->generate(); + } + + public function validate() + { + $path = File::symbolizePath('$/'.$this->getFilePath()); + + $this->validationMessages = [ + 'className.uniq_model_name' => Lang::get('rainlab.builder::lang.model.error_class_name_exists', ['path'=>$path]), + 'addTimestamps.timestamp_columns_must_exist' => Lang::get('rainlab.builder::lang.model.error_timestamp_columns_must_exist'), + 'addSoftDeleting.deleted_at_column_must_exist' => Lang::get('rainlab.builder::lang.model.error_deleted_at_column_must_exist') + ]; + + Validator::extend('uniqModelName', function($attribute, $value, $parameters) use ($path) { + $value = trim($value); + + if (!$this->isNewModel()) { + // Editing models is not supported at the moment, + // so no validation is required. + return true; + } + + return !File::isFile($path); + }); + + $columns = $this->isNewModel() ? Schema::getColumnListing($this->databaseTable) : []; + Validator::extend('timestampColumnsMustExist', function($attribute, $value, $parameters) use ($columns) { + return $this->validateColumnsExist($value, $columns, ['created_at', 'updated_at']); + }); + + Validator::extend('deletedAtColumnMustExist', function($attribute, $value, $parameters) use ($columns) { + return $this->validateColumnsExist($value, $columns, ['deleted_at']); + }); + + parent::validate(); + } + + public function getDatabaseTableOptions() + { + $pluginCode = $this->getPluginCodeObj()->toCode(); + + $tables = DatabaseTableModel::listPluginTables($pluginCode); + return array_combine($tables, $tables); + } + + private static function getTableNameFromModelClass($pluginCodeObj, $modelClassName) + { + if (!self::validateModelClassName($modelClassName)) { + throw new SystemException('Invalid model class name: '.$modelClassName); + } + + $modelsDirectoryPath = File::symbolizePath($pluginCodeObj->toPluginDirectoryPath().'/models'); + if (!File::isDirectory($modelsDirectoryPath)) { + return ''; + } + + $modelFilePath = $modelsDirectoryPath.'/'.$modelClassName.'.php'; + if (!File::isFile($modelFilePath)) { + return ''; + } + + $parser = new ModelFileParser(); + $modelInfo = $parser->extractModelInfoFromSource(File::get($modelFilePath)); + if (!$modelInfo || !isset($modelInfo['table'])) { + return ''; + } + + return $modelInfo['table']; + } + + public static function getModelFields($pluginCodeObj, $modelClassName) + { + $tableName = self::getTableNameFromModelClass($pluginCodeObj, $modelClassName); + + // Currently we return only table columns, + // but eventually we might want to return relations as well. + + return Schema::getColumnListing($tableName); + } + + public static function getModelColumnsAndTypes($pluginCodeObj, $modelClassName) + { + $tableName = self::getTableNameFromModelClass($pluginCodeObj, $modelClassName); + + if (!DatabaseTableModel::tableExists($tableName)) { + throw new ApplicationException('Database table not found: '.$tableName); + } + + $schema = DatabaseTableModel::getSchema(); + $tableInfo = $schema->getTable($tableName); + + $columns = $tableInfo->getColumns(); + $result = []; + foreach ($columns as $column) { + $columnName = $column->getName(); + $typeName = $column->getType()->getName(); + + if ($typeName == EnumDbType::TYPENAME) { + continue; + } + + $item = [ + 'name' => $columnName, + 'type' => MigrationColumnType::toMigrationMethodName($typeName, $columnName) + ]; + + $result[] = $item; + } + + return $result; + } + + public static function getPluginRegistryData($pluginCode, $subtype) + { + $pluginCodeObj = new PluginCode($pluginCode); + + $models = self::listPluginModels($pluginCodeObj); + $result = []; + foreach ($models as $model) { + $fullClassName = $pluginCodeObj->toPluginNamespace().'\\Models\\'.$model->className; + + $result[$fullClassName] = $model->className; + } + + return $result; + } + + public static function getPluginRegistryDataColumns($pluginCode, $modelClassName) + { + $classParts = explode('\\', $modelClassName); + if (!$classParts) { + return []; + } + + $modelClassName = array_pop($classParts); + + if (!self::validateModelClassName($modelClassName)) { + return []; + } + + $pluginCodeObj = new PluginCode($pluginCode); + $columnNames = self::getModelFields($pluginCodeObj, $modelClassName); + + $result = []; + foreach ($columnNames as $columnName) { + $result[$columnName] = $columnName; + } + + return $result; + } + + public static function validateModelClassName($modelClassName) + { + return class_exists($modelClassName) || !!preg_match(self::UNQUALIFIED_CLASS_NAME_PATTERN, $modelClassName); + } + + protected function getFilePath() + { + return $this->getPluginCodeObj()->toFilesystemPath().'/models/'.$this->className.'.php'; + } + + protected function validateColumnsExist($value, $columns, $columnsToCheck) + { + if (!strlen(trim($this->databaseTable))) { + return true; + } + + if (!$this->isNewModel()) { + // Editing models is not supported at the moment, + // so no validation is required. + return true; + } + + if (!$value) { + return true; + } + + return count(array_intersect($columnsToCheck, $columns)) == count($columnsToCheck); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/ModelYamlModel.php b/server/plugins/rainlab/builder/classes/ModelYamlModel.php new file mode 100644 index 0000000..4f48545 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/ModelYamlModel.php @@ -0,0 +1,202 @@ +fileName)) { + $this->fileName = $this->addExtension($this->fileName); + } + } + + public function setModelClassName($className) + { + if (!preg_match('/^[a-zA-Z]+[0-9a-z\_]*$/', $className)) { + throw new SystemException('Invalid class name: '.$className); + } + + $this->modelClassName = $className; + } + + public function validate() + { + $this->validationMessages = [ + 'fileName.required' => Lang::get('rainlab.builder::lang.form.error_file_name_required'), + 'fileName.regex' => Lang::get('rainlab.builder::lang.form.error_file_name_invalid') + ]; + + return parent::validate(); + } + + /** + * Returns a string suitable for displaying in the Builder UI tabs. + */ + public function getDisplayName($nameFallback) + { + $fileName = $this->fileName; + + if (substr($fileName, -5) == '.yaml') { + $fileName = substr($fileName, 0, -5); + } + + if (!strlen($fileName)) { + $fileName = $nameFallback; + } + + return $this->getModelClassName().'/'.$fileName; + } + + public static function listModelFiles($pluginCodeObj, $modelClassName) + { + if (!self::validateModelClassName($modelClassName)) { + throw new SystemException('Invalid model class name: '.$modelClassName); + } + + $modelDirectoryPath = $pluginCodeObj->toPluginDirectoryPath().'/models/'.strtolower($modelClassName); + + $modelDirectoryPath = File::symbolizePath($modelDirectoryPath); + + if (!File::isDirectory($modelDirectoryPath)) { + return []; + } + + $result = []; + foreach (new DirectoryIterator($modelDirectoryPath) as $fileInfo) { + if (!$fileInfo->isFile() || $fileInfo->getExtension() != 'yaml') { + continue; + } + + try { + $fileContents = Yaml::parseFile($fileInfo->getPathname()); + } + catch (Exception $ex) { + continue; + } + + if (!is_array($fileContents)) { + $fileContents = []; + } + + if (!static::validateFileIsModelType($fileContents)) { + continue; + } + + $result[] = $fileInfo->getBasename(); + } + + return $result; + } + + public static function getPluginRegistryData($pluginCode, $modelClassName) + { + $pluginCodeObj = new PluginCode($pluginCode); + + $classParts = explode('\\', $modelClassName); + if (!$classParts) { + return []; + } + + $modelClassName = array_pop($classParts); + + if (!self::validateModelClassName($modelClassName)) { + return []; + } + + $models = self::listModelFiles($pluginCodeObj, $modelClassName); + $modelDirectoryPath = $pluginCodeObj->toPluginDirectoryPath().'/models/'.strtolower($modelClassName).'/'; + + $result = []; + foreach ($models as $fileName) { + $fullFilePath = $modelDirectoryPath.$fileName; + + $result[$fullFilePath] = $fileName; + } + + return $result; + } + + public static function getPluginRegistryDataAllRecords($pluginCode) + { + $pluginCodeObj = new PluginCode($pluginCode); + $pluginDirectoryPath = $pluginCodeObj->toPluginDirectoryPath(); + + $models = ModelModel::listPluginModels($pluginCodeObj); + $result = []; + foreach ($models as $model) { + $modelRecords = self::listModelFiles($pluginCodeObj, $model->className); + $modelDirectoryPath = $pluginDirectoryPath.'/models/'.strtolower($model->className).'/'; + + foreach ($modelRecords as $fileName) { + $label = $model->className.'/'.$fileName; + $key = $modelDirectoryPath.$fileName; + + $result[$key] = $label; + } + } + + return $result; + } + + public static function validateFileIsModelType($fileContentsArray) + { + return false; + } + + protected static function validateModelClassName($modelClassName) + { + return preg_match('/^[A-Z]+[a-zA-Z0-9_]+$/i', $modelClassName); + } + + protected function getModelClassName() + { + if ($this->modelClassName === null) { + throw new SystemException('The model class name is not set.'); + } + + return $this->modelClassName; + } + + + /** + * Returns a file path to save the model to. + * @return string Returns a path. + */ + protected function getFilePath() + { + $fileName = trim($this->fileName); + if (!strlen($fileName)) { + throw new SystemException('The form model file name is not set.'); + } + + $fileName = $this->addExtension($fileName); + + return $this->getPluginCodeObj()->toPluginDirectoryPath().'/models/'.strtolower($this->getModelClassName()).'/'.$fileName; + } + + protected function addExtension($fileName) { + if (substr($fileName, -5) !== '.yaml') { + $fileName .= '.yaml'; + } + + return $fileName; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/PermissionsModel.php b/server/plugins/rainlab/builder/classes/PermissionsModel.php new file mode 100644 index 0000000..603ea82 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PermissionsModel.php @@ -0,0 +1,195 @@ +pluginCodeObj = $pluginCodeObj; + } + + /** + * Converts the model's data to an array before it's saved to a YAML file. + * @return array + */ + protected function modelToYamlArray() + { + $filePermissions = []; + + foreach ($this->permissions as $permission) { + if (array_key_exists('id', $permission)) { + unset($permission['id']); + } + + $permission = $this->trimPermissionProperties($permission); + + if ($this->isEmptyRow($permission)) { + continue; + } + + if (!isset($permission['permission'])) { + throw new ApplicationException('Cannot save permissions - the permission code should not be empty.'); + } + + $code = $permission['permission']; + unset($permission['permission']); + + $filePermissions[$code] = $permission; + } + + return $filePermissions; + } + + public function validate() + { + parent::validate(); + + $this->validateDupicatePermissions(); + $this->validateRequiredProperties(); + } + + public static function getPluginRegistryData($pluginCode) + { + $model = new PermissionsModel(); + + $model->loadPlugin($pluginCode); + + $result = []; + + foreach ($model->permissions as $permissionInfo) { + if (!isset($permissionInfo['permission']) || !isset($permissionInfo['label'])) { + continue; + } + + $key = $permissionInfo['permission']; + $result[$key] = $key.' - '.Lang::get($permissionInfo['label']); + } + + return $result; + } + + protected function validateDupicatePermissions() + { + foreach ($this->permissions as $outerIndex=>$outerPermission) { + if (!isset($outerPermission['permission'])) { + continue; + } + + foreach ($this->permissions as $innerIndex=>$innerPermission) { + if (!isset($innerPermission['permission'])) { + continue; + } + + $outerCode = trim($outerPermission['permission']); + $innerCode = trim($innerPermission['permission']); + + if ($innerIndex != $outerIndex && $outerCode == $innerCode && strlen($outerCode)) { + throw new ValidationException([ + 'permissions' => Lang::get('rainlab.builder::lang.permission.error_duplicate_code', + ['code' => $outerCode] + ) + ]); + } + } + } + } + + protected function validateRequiredProperties() + { + foreach ($this->permissions as $permission) { + if (array_key_exists('id', $permission)) { + unset($permission['id']); + } + + $permission = $this->trimPermissionProperties($permission); + + if ($this->isEmptyRow($permission)) { + continue; + } + + if (!strlen($permission['permission'])) { + throw new ValidationException([ + 'permissions' => Lang::get('rainlab.builder::lang.permission.column_permission_required') + ]); + } + + if (!strlen($permission['label'])) { + throw new ValidationException([ + 'permissions' => Lang::get('rainlab.builder::lang.permission.column_label_required') + ]); + } + + if (!strlen($permission['tab'])) { + throw new ValidationException([ + 'permissions' => Lang::get('rainlab.builder::lang.permission.column_tab_required') + ]); + } + } + } + + protected function trimPermissionProperties($permission) + { + array_walk($permission, function($value, $key){ + return trim($value); + }); + + return $permission; + } + + protected function isEmptyRow($permission) + { + return !isset($permission['tab']) || !isset($permission['permission']) || !isset($permission['label']); + } + + /** + * Load the model's data from an array. + * @param array $array An array to load the model fields from. + */ + protected function yamlArrayToModel($array) + { + $filePermissions = $array; + $permissions = []; + $index = 0; + + foreach ($filePermissions as $code=>$permission) { + $permission['permission'] = $code; + + $permissions[] = $permission; + } + + $this->permissions = $permissions; + } + + /** + * Returns a file path to save the model to. + * @return string Returns a path. + */ + protected function getFilePath() + { + if ($this->pluginCodeObj === null) { + throw new SystemException('Error saving plugin permission model - the plugin code object is not set.'); + } + + return $this->pluginCodeObj->toPluginFilePath(); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/PhpSourceStream.php b/server/plugins/rainlab/builder/classes/PhpSourceStream.php new file mode 100644 index 0000000..a9f62db --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PhpSourceStream.php @@ -0,0 +1,242 @@ +tokens = token_get_all($fileContents); + } + + /** + * Moves head to the beginning and cleans the internal bookmarks. + */ + public function reset() + { + $this->head = 0; + $this->headBookmarks = []; + } + + public function getHead() + { + return $this->head; + } + + /** + * Updates the head position. + * @return boolean Returns true if the head was successfully updated. Returns false otherwise. + */ + public function setHead($head) + { + if ($head < 0) { + return false; + } + + if ($head > (count($this->tokens) - 1)) { + return false; + } + + $this->head = $head; + return true; + } + + /** + * Bookmarks the head position in the internal bookmark stack. + */ + public function bookmarkHead() + { + array_push($this->headBookmarks, $this->head); + } + + /** + * Restores the head position from the last stored bookmark. + */ + public function restoreBookmark() + { + $head = array_pop($this->headBookmarks); + if ($head === null) { + throw new SystemException("Can't restore PHP token stream bookmark - the bookmark doesn't exist"); + } + + return $this->setHead($head); + } + + /** + * Discards the last stored bookmark without changing the head position. + */ + public function discardBookmark() + { + $head = array_pop($this->headBookmarks); + if ($head === null) { + throw new SystemException("Can't discard PHP token stream bookmark - the bookmark doesn't exist"); + } + } + + /** + * Returns the current token and doesn't move the head. + */ + public function getCurrent() + { + return $this->tokens[$this->head]; + } + + /** + * Returns the current token's text and doesn't move the head. + */ + public function getCurrentText() + { + $token = $this->getCurrent(); + if (!is_array($token)) { + return $token; + } + + return $token[1]; + } + + /** + * Returns the current token's code and doesn't move the head. + */ + public function getCurrentCode() + { + $token = $this->getCurrent(); + if (!is_array($token)) { + return null; + } + + return $token[0]; + } + + /** + * Returns the next token and moves the head forward. + */ + public function getNext() + { + $nextIndex = $this->head + 1; + if (!array_key_exists($nextIndex, $this->tokens)) { + return null; + } + + $this->head = $nextIndex; + return $this->tokens[$nextIndex]; + } + + /** + * Reads the next token, updates the head and and returns the token if it has the expected code. + * @param integer $expectedCode Specifies the code to expect. + * @return mixed Returns the token or null if the token code was not expected. + */ + public function getNextExpected($expectedCode) + { + $token = $this->getNext(); + if ($this->getCurrentCode() != $expectedCode) { + return null; + } + + return $token; + } + + /** + * Reads expected tokens, until the termination token is found. + * If any unexpected token is found before the termination token, returns null. + * If the method succeeds, the head is positioned on the termination token. + * @param array $expectedCodesOrValues Specifies the expected codes or token values. + * @param integer|string|array $terminationToken Specifies the termination token text or code. + * The termination tokens could be specified as array. + * @return string|null Returns the tokens text or null + */ + public function getNextExpectedTerminated($expectedCodesOrValues, $terminationToken) + { + $buffer = null; + + if (!is_array($terminationToken)) { + $terminationToken = [$terminationToken]; + } + + while (($nextToken = $this->getNext()) !== null) { + $code = $this->getCurrentCode(); + $text = $this->getCurrentText(); + + if (in_array($code, $expectedCodesOrValues) || in_array($text, $expectedCodesOrValues)) { + $buffer .= $text; + continue; + } + + if (in_array($code, $terminationToken)) { + return $buffer; + } + + if (in_array($text, $terminationToken)) { + return $buffer; + } + + // The token should be either expected or termination. + // If something else is found, return null. + return null; + } + + return $buffer; + } + + /** + * Moves the head forward. + * @return boolean Returns true if the head was successfully moved. + * Returns false if the head can't be moved because it has reached the end of the steam. + */ + public function forward() + { + return $this->setHead($this->getHead()+1); + } + + /** + * Moves the head backward. + * @return boolean Returns true if the head was successfully moved. + * Returns false if the head can't be moved because it has reached the beginning of the steam. + */ + public function back() + { + return $this->setHead($this->getHead()-1); + } + + + /** + * Returns the stream text from the head position to the next semicolon and updates the head. + * If the method succeeds, the head is positioned on the semicolon. + */ + public function getTextToSemicolon() + { + $buffer = null; + + while (($nextToken = $this->getNext()) !== null) { + if ($nextToken == ';') { + return $buffer; + } + + $buffer .= $this->getCurrentText(); + } + + // The semicolon wasn't found. + return null; + } + + public function unquotePhpString($string) + { + if ((substr($string, 0, 1) === '\'' && substr($string, -1) === '\'') || + (substr($string, 0, 1) === '"' && substr($string, -1) === '"')) { + return substr($string, 1, -1); + } + + return false; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/PluginBaseModel.php b/server/plugins/rainlab/builder/classes/PluginBaseModel.php new file mode 100644 index 0000000..0361e76 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PluginBaseModel.php @@ -0,0 +1,217 @@ + 'required', + 'author' => ['required'], + 'namespace' => ['required', 'regex:/^[a-z]+[a-z0-9]+$/i', 'reserved'], + 'author_namespace' => ['required', 'regex:/^[a-z]+[a-z0-9]+$/i', 'reserved'], + 'homepage' => 'url' + ]; + + public function getIconOptions() + { + return IconList::getList(); + } + + public function initDefaults() + { + $settings = PluginSettings::instance(); + $this->author = $settings->author_name; + $this->author_namespace = $settings->author_namespace; + } + + public function getPluginCode() + { + return $this->author_namespace.'.'.$this->namespace; + } + + public static function listAllPluginCodes() + { + $plugins = PluginManager::instance()->getPlugins(); + + return array_keys($plugins); + } + + protected function initPropertiesFromPluginCodeObject($pluginCodeObj) + { + $this->author_namespace = $pluginCodeObj->getAuthorCode(); + $this->namespace = $pluginCodeObj->getPluginCode(); + } + + /** + * Converts the model's data to an array before it's saved to a YAML file. + * @return array + */ + protected function modelToYamlArray() + { + return [ + 'name' => $this->name, + 'description' => $this->description, + 'author' => $this->author, + 'icon' => $this->icon, + 'homepage' => $this->homepage + ]; + } + + /** + * Load the model's data from an array. + * @param array $array An array to load the model fields from. + */ + protected function yamlArrayToModel($array) + { + $this->name = $this->getArrayKeySafe($array, 'name'); + $this->description = $this->getArrayKeySafe($array, 'description'); + $this->author = $this->getArrayKeySafe($array, 'author'); + $this->icon = $this->getArrayKeySafe($array, 'icon'); + $this->homepage = $this->getArrayKeySafe($array, 'homepage'); + } + + protected function beforeCreate() + { + $this->localizedName = $this->name; + $this->localizedDescription = $this->description; + + $pluginCode = strtolower($this->author_namespace.'.'.$this->namespace); + + $this->name = $pluginCode.'::lang.plugin.name'; + $this->description = $pluginCode.'::lang.plugin.description'; + } + + protected function afterCreate() + { + try { + $this->initPluginStructure(); + $this->forcePluginRegistration(); + $this->initBuilderSettings(); + } + catch (Exception $ex) { + $this->rollbackPluginCreation(); + throw $ex; + } + } + + protected function initPluginStructure() + { + $basePath = $this->getPluginPath(); + + $defaultLanguage = LocalizationModel::getDefaultLanguage(); + + $structure = [ + $basePath.'/Plugin.php' => 'plugin.php.tpl', + $basePath.'/updates/version.yaml' => 'version.yaml.tpl', + $basePath.'/classes', + $basePath.'/lang/'.$defaultLanguage.'/lang.php' => 'lang.php.tpl' + ]; + + $variables = [ + 'authorNamespace' => $this->author_namespace, + 'pluginNamespace' => $this->namespace, + 'pluginNameSanitized' => $this->sanitizePHPString($this->localizedName), + 'pluginDescriptionSanitized' => $this->sanitizePHPString($this->localizedDescription), + ]; + + $generator = new FilesystemGenerator('$', $structure, '$/rainlab/builder/classes/pluginbasemodel/templates'); + $generator->setVariables($variables); + $generator->generate(); + } + + protected function forcePluginRegistration() + { + PluginManager::instance()->loadPlugins(); + UpdateManager::instance()->update(); + } + + protected function rollbackPluginCreation() + { + $basePath = '$/'.$this->getPluginPath(); + $basePath = File::symbolizePath($basePath); + + if (basename($basePath) == strtolower($this->namespace)) { + File::deleteDirectory($basePath); + } + } + + protected function sanitizePHPString($str) + { + return str_replace("'", "\'", $str); + } + + /** + * Returns a file path to save the model to. + * @return string Returns a path. + */ + protected function getFilePath() + { + return $this->getPluginPathObj()->toPluginFilePath(); + } + + protected function getPluginPath() + { + return $this->getPluginPathObj()->toFilesystemPath(); + } + + protected function getPluginPathObj() + { + return new PluginCode($this->getPluginCode()); + } + + protected function initBuilderSettings() + { + // Initialize Builder configuration - author name and namespace + // if it was not set yet. + + $settings = PluginSettings::instance(); + if (strlen($settings->author_name) || strlen($settings->author_namespace)) { + return; + } + + $settings->author_name = $this->author; + $settings->author_namespace = $this->author_namespace; + + $settings->save(); + } +} diff --git a/server/plugins/rainlab/builder/classes/PluginCode.php b/server/plugins/rainlab/builder/classes/PluginCode.php new file mode 100644 index 0000000..0b56416 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PluginCode.php @@ -0,0 +1,107 @@ +validateCodeWord($authorCode) || !$this->validateCodeWord($pluginCode)) { + throw new ApplicationException(sprintf('Invalid plugin code: %s', $pluginCodeStr)); + } + + $this->authorCode = trim($authorCode); + $this->pluginCode = trim($pluginCode); + } + + public static function createFromNamespace($namespace) + { + $namespaceParts = explode('\\', $namespace); + if (count($namespaceParts) < 2) { + throw new ApplicationException('Invalid plugin namespace value.'); + } + + $authorCode = $namespaceParts[0]; + $pluginCode = $namespaceParts[1]; + + return new self($authorCode.'.'.$pluginCode); + } + + public function toPluginNamespace() + { + return $this->authorCode.'\\'.$this->pluginCode; + } + + public function toUrl() + { + return strtolower($this->authorCode).'/'.strtolower($this->pluginCode); + } + + public function toUpdatesNamespace() + { + return $this->toPluginNamespace().'\\Updates'; + } + + public function toFilesystemPath() + { + return strtolower($this->authorCode.'/'.$this->pluginCode); + } + + public function toCode() + { + return $this->authorCode.'.'.$this->pluginCode; + } + + public function toPluginFilePath() + { + return '$/'.$this->toFilesystemPath().'/plugin.yaml'; + } + + public function toPluginInformationFilePath() + { + return '$/'.$this->toFilesystemPath().'/Plugin.php'; + } + + public function toPluginDirectoryPath() + { + return '$/'.$this->toFilesystemPath(); + } + + public function toDatabasePrefix() + { + return strtolower($this->authorCode.'_'.$this->pluginCode); + } + + public function getAuthorCode() + { + return $this->authorCode; + } + + public function getPluginCode() + { + return $this->pluginCode; + } + + private function validateCodeWord($str) + { + $str = trim($str); + return strlen($str) && preg_match('/^[a-z]+[a-z0-9]+$/i', $str); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/PluginVector.php b/server/plugins/rainlab/builder/classes/PluginVector.php new file mode 100644 index 0000000..652dc99 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PluginVector.php @@ -0,0 +1,58 @@ +plugin = $plugin; + $this->pluginCodeObj = $pluginCodeObj; + } + + public static function createFromPluginCode($pluginCode) + { + $pluginCodeObj = new PluginCode($pluginCode); + + $plugins = PluginManager::instance()->getPlugins(); + + foreach ($plugins as $code=>$plugin) { + if ($code == $pluginCode) { + return new PluginVector($plugin, $pluginCodeObj); + } + } + + return null; + } + + public function getPluginName() + { + if (!$this->plugin) { + return null; + } + + $pluginInfo = $this->plugin->pluginDetails(); + if (!isset($pluginInfo['name'])) { + return null; + } + + return $pluginInfo['name']; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/PluginVersion.php b/server/plugins/rainlab/builder/classes/PluginVersion.php new file mode 100644 index 0000000..ad57e46 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PluginVersion.php @@ -0,0 +1,49 @@ +getPluginUpdatesPath($pluginCodeObj, 'version.yaml'); + + if (!File::isFile($filePath)) { + throw new SystemException('Plugin version.yaml file is not found.'); + } + + $versionInfo = Yaml::parseFile($filePath); + + if (!is_array($versionInfo)) { + $versionInfo = []; + } + + if ($versionInfo) { + uksort($versionInfo, function ($a, $b) { + return version_compare($a, $b); + }); + } + + return $versionInfo; + } + + protected function getPluginUpdatesPath($pluginCodeObj, $fileName = null) + { + $filePath = '$/'.$pluginCodeObj->toFilesystemPath().'/updates'; + $filePath = File::symbolizePath($filePath); + + if ($fileName !== null) { + return $filePath .= '/'.$fileName; + } + + return $filePath; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/PluginYamlModel.php b/server/plugins/rainlab/builder/classes/PluginYamlModel.php new file mode 100644 index 0000000..1cfd43c --- /dev/null +++ b/server/plugins/rainlab/builder/classes/PluginYamlModel.php @@ -0,0 +1,66 @@ +initPropertiesFromPluginCodeObject($pluginCodeObj); + + $result = parent::load($filePath); + + $this->loadCommonProperties(); + + return $result; + } + + public function getPluginName() + { + return Lang::get($this->pluginName); + } + + protected function loadCommonProperties() + { + if (!array_key_exists('plugin', $this->originalFileData)) { + return; + } + + $pluginData = $this->originalFileData['plugin']; + + if (array_key_exists('name', $pluginData)) { + $this->pluginName = $pluginData['name']; + } + } + + protected function initPropertiesFromPluginCodeObject($pluginCodeObj) + { + } + + protected static function pluginSettingsFileExists($pluginCodeObj) + { + $filePath = File::symbolizePath($pluginCodeObj->toPluginFilePath()); + if (File::isFile($filePath)) { + return $filePath; + } + + return false; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/StandardBehaviorsRegistry.php b/server/plugins/rainlab/builder/classes/StandardBehaviorsRegistry.php new file mode 100644 index 0000000..cf9e142 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/StandardBehaviorsRegistry.php @@ -0,0 +1,429 @@ +behaviorLibrary = $behaviorLibrary; + + $this->registerBehaviors(); + } + + protected function registerBehaviors() + { + $this->registerListBehavior(); + $this->registerFormBehavior(); + $this->registerReorderBehavior(); + } + + protected function registerFormBehavior() + { + $properties = [ + 'name' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_name'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_name_description'), + 'type' => 'string', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_name_required') + ] + ], + ], + 'modelClass' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_model_class'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_model_class_description'), + 'placeholder' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_model_class_placeholder'), + 'type' => 'dropdown', + 'fillFrom' => 'model-classes', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_model_class_required') + ] + ], + ], + 'form' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_file'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_file_description'), + 'placeholder' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_placeholder'), + 'type' => 'autocomplete', + 'fillFrom' => 'model-forms', + 'subtypeFrom' => 'modelClass', + 'depends' => ['modelClass'], + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_file_required') + ] + ], + ], + 'defaultRedirect' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_default_redirect'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_default_redirect_description'), + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + 'ignoreIfEmpty' => true + ], + 'create' => [ + 'type' => 'object', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_create'), + 'ignoreIfEmpty' => true, + 'properties' => [ + [ + 'property' => 'title', + 'type' => 'builderLocalization', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_page_title'), + 'ignoreIfEmpty' => true + ], + [ + 'property' => 'redirect', + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect_description'), + 'ignoreIfEmpty' => true + ], + [ + 'property' => 'redirectClose', + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect_close'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect_close_description'), + 'ignoreIfEmpty' => true + ], + [ + 'property' => 'flashSave', + 'type' => 'builderLocalization', + 'ignoreIfEmpty' => true, + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_flash_save'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_flash_save_description'), + ] + ] + ], + 'update' => [ + 'type' => 'object', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_update'), + 'ignoreIfEmpty' => true, + 'properties' => [ + [ + 'property' => 'title', + 'type' => 'builderLocalization', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_page_title'), + 'ignoreIfEmpty' => true + ], + [ + 'property' => 'redirect', + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect_description'), + 'ignoreIfEmpty' => true + ], + [ + 'property' => 'redirectClose', + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect_close'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_redirect_close_description'), + 'ignoreIfEmpty' => true + ], + [ + 'property' => 'flashSave', + 'type' => 'builderLocalization', + 'ignoreIfEmpty' => true, + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_flash_save'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_flash_save_description'), + ], + [ + 'property' => 'flashDelete', + 'type' => 'builderLocalization', + 'ignoreIfEmpty' => true, + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_flash_delete'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_flash_delete_description'), + ] + ] + ], + 'preview' => [ + 'type' => 'object', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_preview'), + 'ignoreIfEmpty' => true, + 'properties' => [ + [ + 'property' => 'title', + 'type' => 'builderLocalization', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_page_title'), + 'ignoreIfEmpty' => true + ] + ] + ] + ]; + + $templates = [ + '$/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/create.htm.tpl', + '$/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/update.htm.tpl', + '$/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/preview.htm.tpl' + ]; + + $this->behaviorLibrary->registerBehavior( + 'Backend\Behaviors\FormController', + 'rainlab.builder::lang.controller.behavior_form_controller', + 'rainlab.builder::lang.controller.behavior_form_controller_description', + $properties, + 'formConfig', + null, + 'config_form.yaml', + $templates + ); + } + + protected function registerListBehavior() + { + $properties = [ + 'title' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_title'), + 'type' => 'builderLocalization', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_title_required') + ] + ], + ], + 'modelClass' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_model_class'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_model_class_description'), + 'placeholder' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_model_placeholder'), + 'type' => 'dropdown', + 'fillFrom' => 'model-classes', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_model_class_required') + ] + ], + ], + 'list' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_file'), + 'placeholder' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_placeholder'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_file_description'), + 'type' => 'autocomplete', + 'fillFrom' => 'model-lists', + 'subtypeFrom' => 'modelClass', + 'depends' => ['modelClass'], + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_file_required') + ] + ], + ], + 'recordUrl' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_record_url'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_record_url_description'), + 'ignoreIfEmpty' => true, + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + ], + 'noRecordsMessage' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_no_records_message'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_no_records_message_description'), + 'ignoreIfEmpty' => true, + 'type' => 'builderLocalization', + ], + 'recordsPerPage' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_recs_per_page'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_recs_per_page_description'), + 'ignoreIfEmpty' => true, + 'type' => 'string', + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]+$', + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_recs_per_page_regex') + ] + ], + ], + 'showSetup' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_show_setup'), + 'type' => 'checkbox', + 'ignoreIfEmpty' => true, + ], + 'showCheckboxes' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_show_checkboxes'), + 'type' => 'checkbox', + 'ignoreIfEmpty' => true, + ], + 'showSorting' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_show_sorting'), + 'type' => 'checkbox', + 'ignoreIfEmpty' => false, + 'default' => true, + 'ignoreIfDefault' => true, + ], + 'defaultSort' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_default_sort'), + 'ignoreIfEmpty' => true, + 'type' => 'object', + 'ignoreIfPropertyEmpty' => 'column', + 'properties' => [ + [ + 'property' => 'column', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_ds_column'), + 'type' => 'autocomplete', + 'fillFrom' => 'model-columns', + 'subtypeFrom' => 'modelClass', + 'depends' => ['modelClass'] + ], + [ + 'property' => 'direction', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_ds_direction'), + 'type' => 'dropdown', + 'options' => [ + 'asc' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_ds_asc'), + 'desc' => Lang::get('rainlab.builder::lang.controller.property_behavior_form_ds_desc'), + ], + ] + ] + ], + 'toolbar' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_toolbar'), + 'type' => 'object', + 'ignoreIfEmpty' => true, + 'properties' => [ + [ + 'property' => 'buttons', + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_toolbar_buttons'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_toolbar_buttons_description'), + ], + [ + 'property' => 'search', + 'type' => 'object', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_search'), + 'properties' => [ + [ + 'property' => 'prompt', + 'type' => 'builderLocalization', + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_search_prompt'), + ] + ] + ] + ] + ], + 'recordOnClick' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_onclick'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_onclick_description'), + 'ignoreIfEmpty' => true, + 'type' => 'string' + ], + 'showTree' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_show_tree'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_show_tree_description'), + 'type' => 'checkbox', + 'ignoreIfEmpty' => true + ], + 'treeExpanded' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_tree_expanded'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_tree_expanded_description'), + 'type' => 'checkbox', + 'ignoreIfEmpty' => true + ], + 'filter' => [ + 'type' => 'string', // Should be configurable in place later + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_list_filter'), + 'ignoreIfEmpty' => true + ] + ]; + + $templates = [ + '$/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/index.htm.tpl', + '$/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/_list_toolbar.htm.tpl' + ]; + + $this->behaviorLibrary->registerBehavior( + 'Backend\Behaviors\ListController', + 'rainlab.builder::lang.controller.behavior_list_controller', + 'rainlab.builder::lang.controller.behavior_list_controller_description', + $properties, + 'listConfig', + null, + 'config_list.yaml', + $templates + ); + } + + protected function registerReorderBehavior() + { + $properties = [ + 'title' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_title'), + 'type' => 'builderLocalization', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_title_required') + ] + ], + ], + 'modelClass' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_model_class'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_model_class_description'), + 'placeholder' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_model_placeholder'), + 'type' => 'dropdown', + 'fillFrom' => 'model-classes', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_model_class_required') + ] + ], + ], + 'nameFrom' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_name_from'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_name_from_description'), + 'type' => 'autocomplete', + 'fillFrom' => 'model-columns', + 'subtypeFrom' => 'modelClass', + 'depends' => ['modelClass'], + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_name_from_required') + ] + ], + ], + 'toolbar' => [ + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_toolbar'), + 'type' => 'object', + 'ignoreIfEmpty' => true, + 'properties' => [ + [ + 'property' => 'buttons', + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'title' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_toolbar_buttons'), + 'description' => Lang::get('rainlab.builder::lang.controller.property_behavior_reorder_toolbar_buttons_description'), + ] + ] + ], + ]; + + $templates = [ + '$/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/reorder.htm.tpl', + '$/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/_reorder_toolbar.htm.tpl' + ]; + + $this->behaviorLibrary->registerBehavior( + 'Backend\Behaviors\ReorderController', + 'rainlab.builder::lang.controller.behavior_reorder_controller', + 'rainlab.builder::lang.controller.behavior_reorder_controller_description', + $properties, + 'reorderConfig', + null, + 'config_reorder.yaml', + $templates + ); + } +} diff --git a/server/plugins/rainlab/builder/classes/StandardControlsRegistry.php b/server/plugins/rainlab/builder/classes/StandardControlsRegistry.php new file mode 100644 index 0000000..21929d5 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/StandardControlsRegistry.php @@ -0,0 +1,1073 @@ +controlLibrary = $controlLibrary; + + $this->registerControls(); + } + + protected function registerControls() + { + // Controls + // + $this->registerTextControl(); + $this->registerPasswordControl(); + $this->registerNumberControl(); + $this->registerCheckboxControl(); + $this->registerSwitchControl(); + $this->registerTextareaControl(); + $this->registerDropdownControl(); + $this->registerBalloonSelectorControl(); + $this->registerHintControl(); + $this->registerPartialControl(); + $this->registerSectionControl(); + $this->registerRadioListControl(); + $this->registerCheckboxListControl(); + + // Widgets + // + $this->registerCodeEditorWidget(); + $this->registerColorPickerWidget(); + $this->registerDatepickerWidget(); + $this->registerRichEditorWidget(); + $this->registerMarkdownWidget(); + $this->registerFileUploadWidget(); + $this->registerRecordFinderWidget(); + $this->registerMediaFinderWidget(); + $this->registerRelationWidget(); + $this->registerRepeaterWidget(); + } + + protected function registerTextControl() + { + $this->controlLibrary->registerControl('text', + 'rainlab.builder::lang.form.control_text', + 'rainlab.builder::lang.form.control_text_description', + ControlLibrary::GROUP_STANDARD, + 'icon-terminal', + $this->controlLibrary->getStandardProperties(['stretch']), + null + ); + } + + protected function registerPasswordControl() + { + $this->controlLibrary->registerControl('password', + 'rainlab.builder::lang.form.control_password', + 'rainlab.builder::lang.form.control_password_description', + ControlLibrary::GROUP_STANDARD, + 'icon-lock', + $this->controlLibrary->getStandardProperties(['stretch']), + null + ); + } + + protected function registerNumberControl() + { + $this->controlLibrary->registerControl('number', + 'rainlab.builder::lang.form.control_number', + 'rainlab.builder::lang.form.control_number_description', + ControlLibrary::GROUP_STANDARD, + 'icon-superscript', + $this->controlLibrary->getStandardProperties(['stretch']), + null + ); + } + + protected function registerCheckboxControl() + { + $this->controlLibrary->registerControl('checkbox', + 'rainlab.builder::lang.form.control_checkbox', + 'rainlab.builder::lang.form.control_checkbox_description', + ControlLibrary::GROUP_STANDARD, + 'icon-check-square-o', + $this->controlLibrary->getStandardProperties(['oc.commentPosition', 'stretch'], $this->getCheckboxTypeProperties()), + null + ); + } + + protected function registerSwitchControl() + { + $this->controlLibrary->registerControl('switch', + 'rainlab.builder::lang.form.control_switch', + 'rainlab.builder::lang.form.control_switch_description', + ControlLibrary::GROUP_STANDARD, + 'icon-toggle-on', + $this->controlLibrary->getStandardProperties(['oc.commentPosition', 'stretch'], $this->getCheckboxTypeProperties()), + null + ); + } + + protected function registerTextareaControl() + { + $properties = $this->getFieldSizeProperties(); + + $this->controlLibrary->registerControl('textarea', + 'rainlab.builder::lang.form.control_textarea', + 'rainlab.builder::lang.form.control_textarea_description', + ControlLibrary::GROUP_STANDARD, + 'icon-pencil-square-o', + $this->controlLibrary->getStandardProperties(['stretch'], $properties), + null + ); + } + + protected function registerDropdownControl() + { + $properties = [ + 'emptyOption' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_empty_option'), + 'description' => Lang::get('rainlab.builder::lang.form.property_empty_option_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 82 + ], + 'options' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_options'), + 'type' => 'dictionary', + 'ignoreIfEmpty' => true, + 'sortOrder' => 81 + ] + ]; + + $this->controlLibrary->registerControl('dropdown', + 'rainlab.builder::lang.form.control_dropdown', + 'rainlab.builder::lang.form.control_dropdown_description', + ControlLibrary::GROUP_STANDARD, + 'icon-angle-double-down', + $this->controlLibrary->getStandardProperties(['stretch'], $properties), + null + ); + } + + protected function registerBalloonSelectorControl() + { + $properties = [ + 'options' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_options'), + 'type' => 'dictionary', + 'ignoreIfEmpty' => true, + 'sortOrder' => 81 + ] + ]; + + $this->controlLibrary->registerControl('balloon-selector', + 'rainlab.builder::lang.form.control_balloon-selector', + 'rainlab.builder::lang.form.control_balloon-selector_description', + ControlLibrary::GROUP_STANDARD, + 'icon-ellipsis-h', + $this->controlLibrary->getStandardProperties(['stretch'], $properties), + null + ); + } + + protected function registerHintControl() + { + $properties = [ + 'path' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_hint_path'), + 'description' => Lang::get('rainlab.builder::lang.form.property_hint_path_description'), + 'type' => 'string', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_hint_path_required') + ] + ], + 'sortOrder' => 81 + ] + ]; + + $this->controlLibrary->registerControl('hint', + 'rainlab.builder::lang.form.control_hint', + 'rainlab.builder::lang.form.control_hint_description', + ControlLibrary::GROUP_STANDARD, + 'icon-question-circle', + $this->controlLibrary->getStandardProperties($this->getPartialIgnoreProperties(), $properties), + null + ); + } + + protected function registerPartialControl() + { + $properties = [ + 'path' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_partial_path'), + 'description' => Lang::get('rainlab.builder::lang.form.property_partial_path_description'), + 'type' => 'string', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_partial_path_required') + ] + ], + 'sortOrder' => 81 + ] + ]; + + $this->controlLibrary->registerControl('partial', + 'rainlab.builder::lang.form.control_partial', + 'rainlab.builder::lang.form.control_partial_description', + ControlLibrary::GROUP_STANDARD, + 'icon-file-text-o', + $this->controlLibrary->getStandardProperties($this->getPartialIgnoreProperties(), $properties), + null + ); + } + + protected function registerSectionControl() + { + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'required', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes', + 'oc.commentPosition', + 'disabled' + ]; + + $this->controlLibrary->registerControl('section', + 'rainlab.builder::lang.form.control_section', + 'rainlab.builder::lang.form.control_section_description', + ControlLibrary::GROUP_STANDARD, + 'icon-minus', + $this->controlLibrary->getStandardProperties($ignoreProperties), + null + ); + } + + protected function registerRadioListControl() + { + $properties = [ + 'options' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_options'), + 'type' => 'dictionary', + 'ignoreIfEmpty' => true, + 'sortOrder' => 81 + ] + ]; + + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'defaultFrom', + 'preset' + ]; + + $this->controlLibrary->registerControl('radio', + 'rainlab.builder::lang.form.control_radio', + 'rainlab.builder::lang.form.control_radio_description', + ControlLibrary::GROUP_STANDARD, + 'icon-dot-circle-o', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerCheckboxListControl() + { + $properties = [ + 'options' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_options'), + 'type' => 'dictionary', + 'ignoreIfEmpty' => true, + 'sortOrder' => 81 + ] + ]; + + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'defaultFrom', + 'preset' + ]; + + $this->controlLibrary->registerControl('checkboxlist', + 'rainlab.builder::lang.form.control_checkboxlist', + 'rainlab.builder::lang.form.control_checkboxlist_description', + ControlLibrary::GROUP_STANDARD, + 'icon-list', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function getCheckboxTypeProperties() + { + return [ + 'default' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_checked_default_title'), + 'type' => 'checkbox' + ] + ]; + } + + protected function getPartialIgnoreProperties() + { + return [ + 'stretch', + 'default', + 'placeholder', + 'required', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes', + 'label', + 'oc.commentPosition', + 'oc.comment', + 'disabled' + ]; + } + + protected function registerRepeaterWidget() + { + $properties = [ + 'prompt' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_prompt'), + 'description' => Lang::get('rainlab.builder::lang.form.property_prompt_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'default' => Lang::get('rainlab.builder::lang.form.property_prompt_default'), + 'sortOrder' => 81 + ], + 'form' => [ + 'type' => 'control-container' + ], + 'maxItems' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_max_items'), + 'description' => Lang::get('rainlab.builder::lang.form.property_max_items_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 82 + ], + ]; + + $ignoreProperties = [ + 'stretch', + 'placeholder', + 'default', + 'required', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes' + ]; + + $this->controlLibrary->registerControl('repeater', + 'rainlab.builder::lang.form.control_repeater', + 'rainlab.builder::lang.form.control_repeater_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-server', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerCodeEditorWidget() + { + $ignoreProperties = [ + 'placeholder', + 'default', + 'defaultFrom', + 'dependsOn', + 'trigger', + 'preset', + 'attributes' + ]; + + $properties = $this->getFieldSizeProperties(); + + $properties = array_merge($properties, [ + 'size' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_attributes_size'), + 'type' => 'dropdown', + 'options' => [ + 'tiny' => Lang::get('rainlab.builder::lang.form.property_attributes_size_tiny'), + 'small' => Lang::get('rainlab.builder::lang.form.property_attributes_size_small'), + 'large' => Lang::get('rainlab.builder::lang.form.property_attributes_size_large'), + 'huge' => Lang::get('rainlab.builder::lang.form.property_attributes_size_huge'), + 'giant' => Lang::get('rainlab.builder::lang.form.property_attributes_size_giant') + ], + 'sortOrder' => 81 + ], + 'language' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_code_language'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => 'php', + 'options' => [ + 'css' => 'CSS', + 'html' => 'HTML', + 'javascript' => 'JavaScript', + 'less' => 'LESS', + 'markdown' => 'Markdown', + 'php' => 'PHP', + 'plain_text' => 'Plain text', + 'sass' => 'SASS', + 'scss' => 'SCSS', + 'twig' => 'Twig' + ], + 'sortOrder' => 82 + ], + 'theme' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_code_theme'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_theme_use_default'), + 'ambiance' => 'Ambiance', + 'chaos' => 'Chaos', + 'chrome' => 'Chrome', + 'clouds' => 'Clouds', + 'clouds_midnight' => 'Clouds midnight', + 'cobalt' => 'Cobalt', + 'crimson_editor' => 'Crimson editor', + 'dawn' => 'Dawn', + 'dreamweaver' => 'Dreamweaver', + 'eclipse' => 'Eclipse', + 'github' => 'Github', + 'idle_fingers' => 'Idle fingers', + 'iplastic' => 'IPlastic', + 'katzenmilch' => 'Katzenmilch', + 'kr_theme' => 'krTheme', + 'kuroir' => 'Kuroir', + 'merbivore' => 'Merbivore', + 'merbivore_soft' => 'Merbivore soft', + 'mono_industrial' => 'Mono industrial', + 'monokai' => 'Monokai', + 'pastel_on_dark' => 'Pastel on dark', + 'solarized_dark' => 'Solarized dark', + 'solarized_light' => 'Solarized light', + 'sqlserver' => 'SQL server', + 'terminal' => 'Terminal', + 'textmate' => 'Textmate', + 'tomorrow' => 'Tomorrow', + 'tomorrow_night' => 'Tomorrow night', + 'tomorrow_night_blue' => 'Tomorrow night blue', + 'tomorrow_night_bright' => 'Tomorrow night bright', + 'tomorrow_night_eighties' => 'Tomorrow night eighties', + 'twilight' => 'Twilight', + 'vibrant_ink' => 'Vibrant ink', + 'xcode' => 'XCode' + ], + 'sortOrder' => 83 + ], + 'showGutter' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_gutter'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'booleanValues' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + 'true' => Lang::get('rainlab.builder::lang.form.property_gutter_show'), + 'false' => Lang::get('rainlab.builder::lang.form.property_gutter_hide'), + ], + 'sortOrder' => 84 + ], + 'wordWrap' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_wordwrap'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'booleanValues' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + 'true' => Lang::get('rainlab.builder::lang.form.property_wordwrap_wrap'), + 'false' => Lang::get('rainlab.builder::lang.form.property_wordwrap_nowrap'), + ], + 'sortOrder' => 85 + ], + 'fontSize' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fontsize'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + '10' => '10px', + '11' => '11px', + '12' => '11px', + '13' => '13px', + '14' => '14px', + '16' => '16px', + '18' => '18px', + '20' => '20px', + '24' => '24px' + ], + 'sortOrder' => 86 + ], + 'codeFolding' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_codefolding'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + 'manual' => Lang::get('rainlab.builder::lang.form.property_codefolding_manual'), + 'markbegin' => Lang::get('rainlab.builder::lang.form.property_codefolding_markbegin'), + 'markbeginend' => Lang::get('rainlab.builder::lang.form.property_codefolding_markbeginend'), + ], + 'sortOrder' => 87 + ], + 'autoClosing' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_autoclosing'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'booleanValues' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + 'true' => Lang::get('rainlab.builder::lang.form.property_enabled'), + 'false' => Lang::get('rainlab.builder::lang.form.property_disabled') + ], + 'sortOrder' => 88 + ], + 'useSoftTabs' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_soft_tabs'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'booleanValues' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + 'true' => Lang::get('rainlab.builder::lang.form.property_enabled'), + 'false' => Lang::get('rainlab.builder::lang.form.property_disabled') + ], + 'sortOrder' => 89 + ], + 'tabSize' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_tab_size'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'type' => 'dropdown', + 'default' => '', + 'ignoreIfEmpty' => true, + 'options' => [ + '' => Lang::get('rainlab.builder::lang.form.property_use_default'), + 2 => 2, + 4 => 4, + 8 => 8 + ], + 'sortOrder' => 90 + ], + 'readOnly' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_readonly'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_code_editor'), + 'default' => 0, + 'ignoreIfEmpty' => true, + 'type' => 'checkbox' + ] + ]); + + $this->controlLibrary->registerControl('codeeditor', + 'rainlab.builder::lang.form.control_codeeditor', + 'rainlab.builder::lang.form.control_codeeditor_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-code', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerColorPickerWidget() + { + $ignoreProperties = [ + 'stretch' + ]; + + $properties = [ + 'availableColors' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_available_colors'), + 'description' => Lang::get('rainlab.builder::lang.form.property_available_colors_description'), + 'type' => 'stringList', + 'ignoreIfEmpty' => true, + 'sortOrder' => 81 + ] + ]; + + $this->controlLibrary->registerControl('colorpicker', + 'rainlab.builder::lang.form.control_colorpicker', + 'rainlab.builder::lang.form.control_colorpicker_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-eyedropper', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerDatepickerWidget() + { + $ignoreProperties = [ + 'stretch' + ]; + + $properties = [ + 'mode' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_datepicker_mode'), + 'type' => 'dropdown', + 'default' => 'datetime', + 'options' => [ + 'date' => Lang::get('rainlab.builder::lang.form.property_datepicker_mode_date'), + 'datetime' => Lang::get('rainlab.builder::lang.form.property_datepicker_mode_datetime'), + 'time' => Lang::get('rainlab.builder::lang.form.property_datepicker_mode_time') + ], + 'sortOrder' => 81 + ], + 'minDate' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_datepicker_min_date'), + 'description' => Lang::get('rainlab.builder::lang.form.property_datepicker_min_date_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', + 'message' => Lang::get('rainlab.builder::lang.form.property_datepicker_date_invalid_format') + ] + ], + 'sortOrder' => 82 + ], + 'maxDate' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_datepicker_max_date'), + 'description' => Lang::get('rainlab.builder::lang.form.property_datepicker_max_date_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', + 'message' => Lang::get('rainlab.builder::lang.form.property_datepicker_date_invalid_format') + ] + ], + 'sortOrder' => 83 + ], + 'yearRange' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_datepicker_year_range'), + 'description' => Lang::get('rainlab.builder::lang.form.property_datepicker_year_range_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^([0-9]+|\[[0-9]{4},[0-9]{4}\])$', + 'message' => Lang::get('rainlab.builder::lang.form.property_datepicker_year_range_invalid_format') + ] + ], + 'sortOrder' => 84 + ] + ]; + + $this->controlLibrary->registerControl('datepicker', + 'rainlab.builder::lang.form.control_datepicker', + 'rainlab.builder::lang.form.control_datepicker_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-calendar', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerRichEditorWidget() + { + $properties = $this->getFieldSizeProperties(); + + $this->controlLibrary->registerControl('richeditor', + 'rainlab.builder::lang.form.control_richeditor', + 'rainlab.builder::lang.form.control_richeditor_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-indent', + $this->controlLibrary->getStandardProperties([], $properties), + null + ); + } + + protected function getFieldSizeProperties() + { + return [ + 'size' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_attributes_size'), + 'type' => 'dropdown', + 'options' => [ + 'tiny' => Lang::get('rainlab.builder::lang.form.property_attributes_size_tiny'), + 'small' => Lang::get('rainlab.builder::lang.form.property_attributes_size_small'), + 'large' => Lang::get('rainlab.builder::lang.form.property_attributes_size_large'), + 'huge' => Lang::get('rainlab.builder::lang.form.property_attributes_size_huge'), + 'giant' => Lang::get('rainlab.builder::lang.form.property_attributes_size_giant') + ], + 'sortOrder' => 51 + ] + ]; + } + + protected function registerMarkdownWidget() + { + $properties = $this->getFieldSizeProperties(); + + $properties = array_merge($properties, [ + 'mode' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_markdown_mode'), + 'type' => 'dropdown', + 'default' => 'tab', + 'options' => [ + 'split' => Lang::get('rainlab.builder::lang.form.property_markdown_mode_split'), + 'tab' => Lang::get('rainlab.builder::lang.form.property_markdown_mode_tab') + ], + 'sortOrder' => 81 + ] + ]); + + $this->controlLibrary->registerControl('markdown', + 'rainlab.builder::lang.form.control_markdown', + 'rainlab.builder::lang.form.control_markdown_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-columns', + $this->controlLibrary->getStandardProperties([], $properties), + null + ); + } + + protected function registerFileUploadWidget() + { + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes' + ]; + + $properties = [ + 'mode' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_mode'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'dropdown', + 'default' => 'file', + 'options' => [ + 'file' => Lang::get('rainlab.builder::lang.form.property_fileupload_mode_file'), + 'image' => Lang::get('rainlab.builder::lang.form.property_fileupload_mode_image') + ], + 'sortOrder' => 81 + ], + 'prompt' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_prompt'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_prompt_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 82 + ], + 'imageWidth' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_image_width'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_image_width_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]+$', + 'message' => Lang::get('rainlab.builder::lang.form.property_fileupload_invalid_dimension') + ] + ], + 'sortOrder' => 83 + ], + 'imageHeight' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_image_height'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_image_height_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]+$', + 'message' => Lang::get('rainlab.builder::lang.form.property_fileupload_invalid_dimension') + ] + ], + 'sortOrder' => 84 + ], + 'fileTypes' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_file_types'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_file_types_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 85 + ], + 'mimeTypes' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_mime_types'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_mime_types_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 86 + ], + 'useCaption' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_use_caption'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_use_caption_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'checkbox', + 'default' => true, + 'sortOrder' => 87 + ], + 'thumbOptions' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_options'), + 'description' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_options_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_fileupload'), + 'type' => 'object', + 'properties' => [ + [ + 'property' => 'mode', + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_mode'), + 'type' => 'dropdown', + 'default' => 'crop', + 'options' => [ + 'auto' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_auto'), + 'exact' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_exact'), + 'portrait' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_portrait'), + 'landscape' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_landscape'), + 'crop' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_crop') + ] + ], + [ + 'property' => 'extension', + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_extension'), + 'type' => 'dropdown', + 'default' => 'auto', + 'options' => [ + 'auto' => Lang::get('rainlab.builder::lang.form.property_fileupload_thumb_auto'), + 'jpg' => 'jpg', + 'gif' => 'gif', + 'png' => 'png' + ] + ] + ], + 'sortOrder' => 88 + ] + ]; + + $this->controlLibrary->registerControl('fileupload', + 'rainlab.builder::lang.form.control_fileupload', + 'rainlab.builder::lang.form.control_fileupload_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-upload', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerRecordFinderWidget() + { + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes', + 'disabled' + ]; + + $properties = [ + 'nameFrom' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_name_from'), + 'description' => Lang::get('rainlab.builder::lang.form.property_name_from_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_recordfinder'), + 'type' => 'string', + 'default' => 'name', + 'sortOrder' => 81 + ], + 'descriptionFrom' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_description_from'), + 'description' => Lang::get('rainlab.builder::lang.form.property_description_from_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_recordfinder'), + 'type' => 'string', + 'default' => 'description', + 'sortOrder' => 82 + ], + 'prompt' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_recordfinder_prompt'), + 'description' => Lang::get('rainlab.builder::lang.form.property_recordfinder_prompt_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_recordfinder'), + 'type' => 'builderLocalization', + 'ignoreIfEmpty' => true, + 'sortOrder' => 83 + ], + 'list' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_recordfinder_list'), + 'description' => Lang::get('rainlab.builder::lang.form.property_recordfinder_list_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_recordfinder'), + 'type' => 'autocomplete', + 'fillFrom' => 'plugin-lists', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_recordfinder_list_required'), + ] + ], + 'sortOrder' => 83 + ] + ]; + + $this->controlLibrary->registerControl('recordfinder', + 'rainlab.builder::lang.form.control_recordfinder', + 'rainlab.builder::lang.form.control_recordfinder_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-search', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerMediaFinderWidget() + { + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes', + 'disabled' + ]; + + $properties = [ + 'mode' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_mediafinder_mode'), + 'type' => 'dropdown', + 'default' => 'file', + 'options' => [ + 'file' => Lang::get('rainlab.builder::lang.form.property_mediafinder_mode_file'), + 'image' => Lang::get('rainlab.builder::lang.form.property_mediafinder_mode_image') + ], + 'sortOrder' => 81 + ], + 'prompt' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_mediafinder_prompt'), + 'description' => Lang::get('rainlab.builder::lang.form.property_mediafinder_prompt_description'), + 'ignoreIfEmpty' => true, + 'type' => 'string', + 'sortOrder' => 82 + ], + 'imageWidth' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_image_width'), + 'description' => Lang::get('rainlab.builder::lang.form.property_mediafinder_image_width_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]+$', + 'message' => Lang::get('rainlab.builder::lang.form.property_fileupload_invalid_dimension') + ] + ], + 'sortOrder' => 83 + ], + 'imageHeight' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_fileupload_image_height'), + 'description' => Lang::get('rainlab.builder::lang.form.property_mediafinder_image_height_description'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]+$', + 'message' => Lang::get('rainlab.builder::lang.form.property_fileupload_invalid_dimension') + ] + ], + 'sortOrder' => 84 + ], + ]; + + $this->controlLibrary->registerControl('mediafinder', + 'rainlab.builder::lang.form.control_mediafinder', + 'rainlab.builder::lang.form.control_mediafinder_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-picture-o', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } + + protected function registerRelationWidget() + { + $ignoreProperties = [ + 'stretch', + 'default', + 'placeholder', + 'defaultFrom', + 'dependsOn', + 'preset', + 'attributes', + 'trigger', + 'disabled' + ]; + + $properties = [ + 'nameFrom' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_name_from'), + 'description' => Lang::get('rainlab.builder::lang.form.property_name_from_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_relation'), + 'type' => 'string', + 'default' => 'name', + 'sortOrder' => 81 + ], + 'descriptionFrom' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_description_from'), + 'description' => Lang::get('rainlab.builder::lang.form.property_description_from_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_relation'), + 'type' => 'string', + 'default' => 'description', + 'ignoreIfEmpty' => true, + 'sortOrder' => 82 + ], + 'emptyOption' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_relation_prompt'), + 'description' => Lang::get('rainlab.builder::lang.form.property_relation_prompt_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_relation'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 83 + ], + 'select' => [ + 'title' => Lang::get('rainlab.builder::lang.form.property_relation_select'), + 'description' => Lang::get('rainlab.builder::lang.form.property_relation_select_description'), + 'group' => Lang::get('rainlab.builder::lang.form.property_group_relation'), + 'type' => 'string', + 'ignoreIfEmpty' => true, + 'sortOrder' => 84 + ] + ]; + + $this->controlLibrary->registerControl('relation', + 'rainlab.builder::lang.form.control_relation', + 'rainlab.builder::lang.form.control_relation_description', + ControlLibrary::GROUP_WIDGETS, + 'icon-code-fork', + $this->controlLibrary->getStandardProperties($ignoreProperties, $properties), + null + ); + } +} diff --git a/server/plugins/rainlab/builder/classes/TableMigrationCodeGenerator.php b/server/plugins/rainlab/builder/classes/TableMigrationCodeGenerator.php new file mode 100644 index 0000000..7f41a5d --- /dev/null +++ b/server/plugins/rainlab/builder/classes/TableMigrationCodeGenerator.php @@ -0,0 +1,626 @@ +diffTable($existingTable, $updatedTable); + + if ($newTableName !== $existingTable->getName()) { + if (!$tableDiff) { + $tableDiff = new TableDiff($existingTable->getName()); + } + + $tableDiff->newName = $newTableName; + } + } + else { + /* + * The table doesn't exist + */ + $tableDiff = new TableDiff( + $updatedTable->getName(), + $updatedTable->getColumns(), + [], // Changed columns + [], // Removed columns + $updatedTable->getIndexes() // Added indexes + ); + + $tableDiff->fromTable = $updatedTable; + } + + if (!$tableDiff) { + return false; + } + + if (!$this->tableHasNameOrColumnChanges($tableDiff) && !$this->tableHasPrimaryKeyChanges($tableDiff)) { + return false; + } + + return $this->generateCreateOrUpdateCode($tableDiff, !$existingTable, $updatedTable); + } + + /** + * Wrap migration's up() and down() functions into a complete migration class declaration + * @param string $scriptFilename Specifies the migration script file name + * @param string $code Specifies the migration code + * @param PluginCode $pluginCodeObj The plugin code object + * @return TextParser + */ + public function wrapMigrationCode($scriptFilename, $code, $pluginCodeObj) + { + $templatePath = '$/rainlab/builder/classes/databasetablemodel/templates/full-migration-code.php.tpl'; + $templatePath = File::symbolizePath($templatePath); + + $fileContents = File::get($templatePath); + + return TextParser::parse($fileContents, [ + 'className' => Str::studly($scriptFilename), + 'migrationCode' => $this->indent($code), + 'namespace' => $pluginCodeObj->toUpdatesNamespace() + ]); + } + + /** + * Generates code for dropping a database table. + * @param \Doctrine\DBAL\Schema\Table $existingTable Specifies the existing table schema. + * @return string Returns the migration up() and down() methods code. + */ + public function dropTable($existingTable) + { + return $this->generateMigrationCode( + $this->generateDropUpCode($existingTable), + $this->generateDropDownCode($existingTable) + ); + } + + protected function generateCreateOrUpdateCode($tableDiff, $isNewTable, $newOrUpdatedTable) + { + /* + * Although it might seem that a reverse diff could be used + * for the down() method, that's not so. The up and down operations + * are not fully symmetrical. + */ + + return $this->generateMigrationCode( + $this->generateCreateOrUpdateUpCode($tableDiff, $isNewTable, $newOrUpdatedTable), + $this->generateCreateOrUpdateDownCode($tableDiff, $isNewTable, $newOrUpdatedTable) + ); + } + + protected function generateMigrationCode($upCode, $downCode) + { + $templatePath = '$/rainlab/builder/classes/databasetablemodel/templates/migration-code.php.tpl'; + $templatePath = File::symbolizePath($templatePath); + + $fileContents = File::get($templatePath); + + return TextParser::parse($fileContents, [ + 'upCode' => $upCode, + 'downCode' => $downCode + ]); + } + + protected function generateCreateOrUpdateUpCode($tableDiff, $isNewTable, $newOrUpdatedTable) + { + $result = null; + + $hasColumnChanges = $this->tableHasNameOrColumnChanges($tableDiff, true); + $changedPrimaryKey = $this->getChangedOrRemovedPrimaryKey($tableDiff); + $addedPrimaryKey = $this->findPrimaryKeyIndex($tableDiff->addedIndexes, $newOrUpdatedTable); + + if ($tableDiff->getNewName()) { + $result .= $this->generateTableRenameCode($tableDiff->name, $tableDiff->newName); + + if ($hasColumnChanges || $changedPrimaryKey) { + $result .= $this->eol; + } + } + + if (!$hasColumnChanges && !$changedPrimaryKey && !$addedPrimaryKey) { + return $this->makeTabs($result); + } + + $tableName = $tableDiff->getNewName() ? $tableDiff->newName : $tableDiff->name; + $result .= $this->generateSchemaTableMethodStart($tableName, $isNewTable); + + if ($changedPrimaryKey) { + $result .= $this->generatePrimaryKeyDrop($tableDiff->fromTable); + } + + foreach ($tableDiff->addedColumns as $column) { + $result .= $this->generateColumnCode($column, self::COLUMN_MODE_CREATE); + } + + foreach ($tableDiff->changedColumns as $columnDiff) { + $result .= $this->generateColumnCode($columnDiff, self::COLUMN_MODE_CHANGE); + } + + foreach ($tableDiff->renamedColumns as $oldName=>$column) { + $result .= $this->generateColumnRenameCode($oldName, $column->getName()); + } + + foreach ($tableDiff->removedColumns as $name=>$column) { + $result .= $this->generateColumnRemoveCode($name); + } + + $primaryKey = $changedPrimaryKey ? + $this->findPrimaryKeyIndex($tableDiff->changedIndexes, $newOrUpdatedTable) : + $this->findPrimaryKeyIndex($tableDiff->addedIndexes, $newOrUpdatedTable); + + if ($primaryKey) { + $result .= $this->generatePrimaryKeyCode($primaryKey, self::COLUMN_MODE_CREATE); + } + + $result .= $this->generateSchemaTableMethodEnd(); + + return $this->makeTabs($result); + } + + protected function generateCreateOrUpdateDownCode($tableDiff, $isNewTable, $newOrUpdatedTable) + { + $result = ''; + + if ($isNewTable) { + $result = $this->generateTableDropCode($tableDiff->name); + } + else { + $changedPrimaryKey = $this->getChangedOrRemovedPrimaryKey($tableDiff); + $addedPrimaryKey = $this->findPrimaryKeyIndex($tableDiff->addedIndexes, $newOrUpdatedTable); + + if ($this->tableHasNameOrColumnChanges($tableDiff) || $changedPrimaryKey || $addedPrimaryKey) { + $hasColumnChanges = $this->tableHasNameOrColumnChanges($tableDiff, true); + + if ($tableDiff->getNewName()) { + $result .= $this->generateTableRenameCode($tableDiff->newName, $tableDiff->name); + + if ($hasColumnChanges || $changedPrimaryKey || $addedPrimaryKey) { + $result .= $this->eol; + } + } + + if (!$hasColumnChanges && !$changedPrimaryKey && !$addedPrimaryKey) { + return $this->makeTabs($result); + } + + $result .= $this->generateSchemaTableMethodStart($tableDiff->name, $isNewTable); + + if ($changedPrimaryKey || $addedPrimaryKey) { + $result .= $this->generatePrimaryKeyDrop($newOrUpdatedTable); + } + + foreach ($tableDiff->addedColumns as $column) { + $result .= $this->generateColumnDrop($column); + } + + foreach ($tableDiff->changedColumns as $columnDiff) { + $result .= $this->generateColumnCode($columnDiff, self::COLUMN_MODE_REVERT); + } + + foreach ($tableDiff->renamedColumns as $oldName=>$column) { + $result .= $this->generateColumnRenameCode($column->getName(), $oldName); + } + + foreach ($tableDiff->removedColumns as $name=>$column) { + $result .= $this->generateColumnCode($column, self::COLUMN_MODE_CREATE); + } + + if ($changedPrimaryKey || $addedPrimaryKey) { + $primaryKey = $this->findPrimaryKeyIndex($tableDiff->fromTable->getIndexes(), $tableDiff->fromTable); + if ($primaryKey) { + $result .= $this->generatePrimaryKeyCode($primaryKey, self::COLUMN_MODE_CREATE); + } + } + + $result .= $this->generateSchemaTableMethodEnd(); + } + } + + return $this->makeTabs($result); + } + + protected function generateDropUpCode($table) + { + $result = $this->generateTableDropCode($table->getName()); + return $this->makeTabs($result); + } + + protected function generateDropDownCode($table) + { + $tableDiff = new TableDiff( + $table->getName(), + $table->getColumns(), + [], // Changed columns + [], // Removed columns + $table->getIndexes() // Added indexes + ); + + return $this->generateCreateOrUpdateUpCode($tableDiff, true, $table); + } + + protected function formatLengthParameters($column, $method) + { + $length = $column->getLength(); + $precision = $column->getPrecision(); + $scale = $column->getScale(); + + if (!strlen($length) && !strlen($precision)) { + return null; + } + + if ($method == MigrationColumnType::TYPE_STRING) { + if (!strlen($length)) { + return null; + } + + return ', '.$length; + } + + if ($method == MigrationColumnType::TYPE_DECIMAL || $method == MigrationColumnType::TYPE_DOUBLE) { + if (!strlen($precision)) { + return null; + } + + if (strlen($scale)) { + return ', '.$precision.', '.$scale; + } + + return ', '.$precision; + } + } + + protected function applyMethodIncrements($method, $column) + { + if (!$column->getAutoincrement()) { + return $method; + } + + if ($method == MigrationColumnType::TYPE_BIGINTEGER) { + return 'bigIncrements'; + } + + return 'increments'; + } + + protected function generateSchemaTableMethodStart($tableName, $isNewTable) + { + $tableFunction = $isNewTable ? 'create' : 'table'; + $result = sprintf('\tSchema::%s(\'%s\', function($table)', $tableFunction, $tableName).$this->eol; + $result .= '\t{'.$this->eol; + + if ($isNewTable) { + $result .= '\t\t$table->engine = \'InnoDB\';'.$this->eol; + } + + return $result; + } + + protected function generateSchemaTableMethodEnd() + { + return '\t});'; + } + + protected function generateColumnDrop($column) + { + return sprintf('\t\t$table->dropColumn(\'%s\');', $column->getName()).$this->eol; + } + + protected function generateIndexDrop($index) + { + return sprintf('\t\t$table->dropIndex(\'%s\');', $index->getName()).$this->eol; + } + + protected function generatePrimaryKeyDrop($table) + { + $index = $this->findPrimaryKeyIndex($table->getIndexes(), $table); + if (!$index) { + return; + } + + $indexColumns = $index->getColumns(); + return sprintf('\t\t$table->dropPrimary([%s]);', $this->implodeColumnList($indexColumns)).$this->eol; + } + + protected function generateColumnCode($columnData, $mode) + { + $forceFlagsChange = false; + + switch ($mode) { + case self::COLUMN_MODE_CREATE: + $column = $columnData; + $changeMode = false; + break; + case self::COLUMN_MODE_CHANGE: + $column = $columnData->column; + $changeMode = true; + + $forceFlagsChange = in_array('type', $columnData->changedProperties); + break; + case self::COLUMN_MODE_REVERT: + $column = $columnData->fromColumn; + $changeMode = true; + + $forceFlagsChange = in_array('type', $columnData->changedProperties); + break; + } + + $result = $this->generateColumnMethodCall($column); + $result .= $this->generateNullable($column, $changeMode, $columnData, $forceFlagsChange); + $result .= $this->generateUnsigned($column, $changeMode, $columnData, $forceFlagsChange); + $result .= $this->generateDefault($column, $changeMode, $columnData, $forceFlagsChange); + + if ($changeMode) { + $result .= '->change()'; + } + + $result .= ';'.$this->eol; + + return $result; + } + + protected function generateColumnRenameCode($fromName, $toName) + { + return sprintf('\t\t$table->renameColumn(\'%s\', \'%s\');', $fromName, $toName).$this->eol; + } + + protected function generateTableRenameCode($fromName, $toName) + { + return sprintf('\tSchema::rename(\'%s\', \'%s\');', $fromName, $toName); + } + + protected function generateTableDropCode($name) + { + return sprintf('\tSchema::dropIfExists(\'%s\');', $name); + } + + protected function generateColumnRemoveCode($name) + { + return sprintf('\t\t$table->dropColumn(\'%s\');', $name).$this->eol; + } + + protected function generateColumnMethodCall($column) + { + $columnName = $column->getName(); + $typeName = $column->getType()->getName(); + + $method = MigrationColumnType::toMigrationMethodName($typeName, $columnName); + $method = $this->applyMethodIncrements($method, $column); + + $lengthStr = $this->formatLengthParameters($column, $method); + return sprintf('\t\t$table->%s(\'%s\'%s)', $method, $columnName, $lengthStr); + } + + protected function generateNullable($column, $changeMode, $columnData, $forceFlagsChange) + { + $result = null; + + if (!$changeMode) { + if (!$column->getNotnull()) { + $result = $this->generateBooleanMethod('nullable', true); + } + } + elseif (in_array('notnull', $columnData->changedProperties) || $forceFlagsChange) { + $result = $this->generateBooleanMethod('nullable', !$column->getNotnull()); + } + + return $result; + } + + protected function generateUnsigned($column, $changeMode, $columnData, $forceFlagsChange) + { + $result = null; + + if (!$changeMode) { + if ($column->getUnsigned()) { + $result = $this->generateBooleanMethod('unsigned', true); + } + } + elseif (in_array('unsigned', $columnData->changedProperties) || $forceFlagsChange) { + $result = $this->generateBooleanMethod('unsigned', $column->getUnsigned()); + } + + return $result; + } + + protected function generateDefault($column, $changeMode, $columnData, $forceFlagsChange) + { + /* + * See a note about empty strings as default values in + * DatabaseTableSchemaCreator::formatOptions() method. + */ + $result = null; + $default = $column->getDefault(); + + if (!$changeMode) { + if (strlen($default)) { + $result = $this->generateDefaultMethodCall($default, $column); + } + } + elseif (in_array('default', $columnData->changedProperties) || $forceFlagsChange) { + if (strlen($default)) { + $result = $this->generateDefaultMethodCall($default, $column); + } + elseif ($changeMode) { + $result = sprintf('->default(null)'); + } + } + + return $result; + } + + protected function generateDefaultMethodCall($default, $column) + { + $columnName = $column->getName(); + $typeName = $column->getType()->getName(); + + $type = MigrationColumnType::toMigrationMethodName($typeName, $columnName); + + if (in_array($type, MigrationColumnType::getIntegerTypes()) || + in_array($type, MigrationColumnType::getDecimalTypes()) || + $type == MigrationColumnType::TYPE_BOOLEAN) { + return sprintf('->default(%s)', $default); + } + + return sprintf('->default(\'%s\')', $this->quoteParameter($default)); + } + + protected function generatePrimaryKeyCode($index) + { + $columns = $index->getColumns(); + + return sprintf('\t\t$table->primary([%s]);', $this->implodeColumnList($columns)).$this->eol; + } + + protected function generateBooleanString($value) + { + $result = $value ? 'true' : 'false'; + + return$result; + } + + protected function generateBooleanMethod($methodName, $value) + { + if ($value) { + return '->'.$methodName.'()'; + } + + return '->'.$methodName.'('.$this->generateBooleanString($value).')'; + } + + protected function quoteParameter($str) + { + return str_replace("'", "\'", $str); + } + + protected function makeTabs($str) + { + return str_replace('\t', ' ', $str); + } + + protected function indent($str) + { + return $this->indent . str_replace($this->eol, $this->eol . $this->indent, $str); + } + + protected function implodeColumnList($columnNames) + { + foreach ($columnNames as &$columnName) { + $columnName = '\''.$columnName.'\''; + } + + return implode(',', $columnNames); + } + + protected function tableHasNameOrColumnChanges($tableDiff, $columnChangesOnly = false) + { + $result = $tableDiff->addedColumns + || $tableDiff->changedColumns + || $tableDiff->removedColumns + || $tableDiff->renamedColumns; + + if ($columnChangesOnly) { + return $result; + } + + return $result || $tableDiff->getNewName(); + } + + protected function tableHasPrimaryKeyChanges($tableDiff) + { + return $this->findPrimaryKeyIndex($tableDiff->addedIndexes, $tableDiff->fromTable) || + $this->findPrimaryKeyIndex($tableDiff->changedIndexes, $tableDiff->fromTable) || + $this->findPrimaryKeyIndex($tableDiff->removedIndexes, $tableDiff->fromTable); + } + + protected function getChangedOrRemovedPrimaryKey($tableDiff) + { + foreach ($tableDiff->changedIndexes as $index) { + if ($index->isPrimary()) { + return $index; + } + } + + foreach ($tableDiff->removedIndexes as $index) { + if ($index->isPrimary()) { + return $index; + } + } + + return null; + } + + protected function findPrimaryKeyIndex($indexes, $table) + { + /* + * This method ignores auto-increment primary keys + * as they are managed with the increments() method + * instead of the primary(). + */ + foreach ($indexes as $index) { + if (!$index->isPrimary()) { + continue; + } + + if ($this->indexHasAutoincrementColumns($index, $table)) { + continue; + } + + return $index; + } + + return null; + } + + protected function indexHasAutoincrementColumns($index, $table) + { + $indexColumns = $index->getColumns(); + + foreach ($indexColumns as $indexColumn) { + if (!$table->hasColumn($indexColumn)) { + continue; + } + + $tableColumn = $table->getColumn($indexColumn); + if ($tableColumn->getAutoincrement()) { + return true; + } + } + + return false; + } +} diff --git a/server/plugins/rainlab/builder/classes/YamlModel.php b/server/plugins/rainlab/builder/classes/YamlModel.php new file mode 100644 index 0000000..ec7681d --- /dev/null +++ b/server/plugins/rainlab/builder/classes/YamlModel.php @@ -0,0 +1,186 @@ +validate(); + + if ($this->isNewModel()) { + $this->beforeCreate(); + } + + $data = $this->modelToYamlArray(); + + if ($this->yamlSection) { + $fileData = $this->originalFileData; + + if ($data) { + // Save the section data only if the section + // is not empty. + $fileData[$this->yamlSection] = $data; + } else { + if (array_key_exists($this->yamlSection, $fileData)) { + unset($fileData[$this->yamlSection]); + } + } + $data = $fileData; + } + + $dumper = new YamlDumper(); + + if ($data !== null) { + $yamlData = $dumper->dump($data, 20, 0, false, true); + } + else { + $yamlData = ''; + } + + $filePath = File::symbolizePath($this->getFilePath()); + $isNew = $this->isNewModel(); + + if (File::isFile($filePath)) { + if ($isNew || $this->originalFilePath != $filePath) { + throw new ValidationException(['fileName' => Lang::get('rainlab.builder::lang.common.error_file_exists', ['path'=>basename($filePath)])]); + } + } + + $fileDirectory = dirname($filePath); + if (!File::isDirectory($fileDirectory)) { + if (!File::makeDirectory($fileDirectory, 0777, true, true)) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.common.error_make_dir', ['name'=>$fileDirectory])); + } + } + + if (@File::put($filePath, $yamlData) === false) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.yaml.save_error', ['name'=>$filePath])); + } + + @File::chmod($filePath); + + if ($this->isNewModel()) { + $this->afterCreate(); + } + + if ($this->yamlSection) { + $this->originalFileData = $data; + } + + if (strlen($this->originalFilePath) > 0 && $this->originalFilePath != $filePath) { + @File::delete($this->originalFilePath); + } + + $this->originalFilePath = $filePath; + } + + protected function load($filePath) + { + $filePath = File::symbolizePath($filePath); + + if (!File::isFile($filePath)) { + throw new ApplicationException('Cannot load the model - the original file is not found: '.basename($filePath)); + } + + try { + $data = Yaml::parse(File::get($filePath)); + } + catch (Exception $ex) { + throw new ApplicationException(sprintf('Cannot parse the YAML file %s: %s', basename($filePath), $ex->getMessage())); + } + + $this->originalFilePath = $filePath; + + if ($this->yamlSection) { + $this->originalFileData = $data; + if (!is_array($this->originalFileData)) { + $this->originalFileData = []; + } + + if (array_key_exists($this->yamlSection, $data)) { + $data = $data[$this->yamlSection]; + } + else { + $data = []; + } + } + + $this->yamlArrayToModel($data); + } + + public function deleteModel() + { + if (!File::isFile($this->originalFilePath)) { + throw new ApplicationException('Cannot load the model - the original file is not found: '.$filePath); + } + + if (strtolower(substr($this->originalFilePath, -5)) !== '.yaml') { + throw new ApplicationException('Cannot delete the model - the original file should be a YAML document'); + } + + File::delete($this->originalFilePath); + } + + public function initDefaults() + { + } + + public function isNewModel() + { + return !strlen($this->originalFilePath); + } + + protected function beforeCreate() + { + } + + protected function afterCreate() + { + } + + protected function getArrayKeySafe($array, $key, $default = null) + { + return array_key_exists($key, $array) ? $array[$key] : $default; + } + + /** + * Converts the model's data to an array before it's saved to a YAML file. + * @return array + */ + abstract protected function modelToYamlArray(); + + /** + * Load the model's data from an array. + * @param array $array An array to load the model fields from. + */ + abstract protected function yamlArrayToModel($array); + + /** + * Returns a file path to save the model to. + * @return string Returns a path. + */ + abstract protected function getFilePath(); +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-config-vars.php.tpl b/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-config-vars.php.tpl new file mode 100644 index 0000000..62c2600 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-config-vars.php.tpl @@ -0,0 +1,3 @@ +{% for configVar, varValue in behaviorConfigVars %} + public ${{ configVar }} = '{{ varValue }}'; +{% endfor %} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-permissions.php.tpl b/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-permissions.php.tpl new file mode 100644 index 0000000..e1395dd --- /dev/null +++ b/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller-permissions.php.tpl @@ -0,0 +1,7 @@ +{% if permissions %} + public $requiredPermissions = [ +{% for permission in permissions %} + '{{ permission }}'{% if not loop.last %},{% endif %} +{% endfor %} + ]; +{% endif %} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller.php.tpl b/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller.php.tpl new file mode 100644 index 0000000..bea3886 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/controllergenerator/templates/controller.php.tpl @@ -0,0 +1,23 @@ + [ + 'name' => 'Plugin name', + 'description' => 'Plugin description.' + ] +]; \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/menusmodel/fields.yaml b/server/plugins/rainlab/builder/classes/menusmodel/fields.yaml new file mode 100644 index 0000000..01ad3ba --- /dev/null +++ b/server/plugins/rainlab/builder/classes/menusmodel/fields.yaml @@ -0,0 +1,17 @@ +# =================================== +# Form Field Definitions +# =================================== + +fields: + toolbar: + type: partial + path: $/rainlab/builder/behaviors/indexmenusoperations/partials/_toolbar.htm + cssClass: collapse-visible + +secondaryTabs: + stretch: true + fields: + menus: + stretch: true + tab: rainlab.builder::lang.menu.items + type: RainLab\Builder\FormWidgets\MenuEditor \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/migrationmodel/fields.yaml b/server/plugins/rainlab/builder/classes/migrationmodel/fields.yaml new file mode 100644 index 0000000..4218401 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/migrationmodel/fields.yaml @@ -0,0 +1,11 @@ +fields: + version: + label: rainlab.builder::lang.migration.field_version + description: + label: rainlab.builder::lang.migration.field_description + code: + label: rainlab.builder::lang.migration.field_code + commentAbove: rainlab.builder::lang.migration.field_code_comment + type: codeeditor + language: php + readOnly: true \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/migrationmodel/management-fields.yaml b/server/plugins/rainlab/builder/classes/migrationmodel/management-fields.yaml new file mode 100644 index 0000000..5604262 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/migrationmodel/management-fields.yaml @@ -0,0 +1,31 @@ +# =================================== +# Form Field Definitions +# =================================== + +fields: + version: + span: left + label: rainlab.builder::lang.migration.field_version + attributes: + default-focus: 1 + spellcheck: 'false' + cssClass: size-quarter + + description: + span: right + label: rainlab.builder::lang.migration.field_description + cssClass: size-three-quarter + + toolbar: + type: partial + path: $/rainlab/builder/behaviors/indexversionsoperations/partials/_toolbar.htm + cssClass: collapse-visible + +secondaryTabs: + stretch: true + fields: + code: + tab: rainlab.builder::lang.migration.field_code + stretch: true + type: codeeditor + language: php diff --git a/server/plugins/rainlab/builder/classes/migrationmodel/templates/migration.php.tpl b/server/plugins/rainlab/builder/classes/migrationmodel/templates/migration.php.tpl new file mode 100644 index 0000000..c53eb39 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/migrationmodel/templates/migration.php.tpl @@ -0,0 +1,19 @@ + [ + 'name' => '{pluginNameSanitized}', + 'description' => '{pluginDescriptionSanitized}' + ] +]; \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/pluginbasemodel/templates/plugin.php.tpl b/server/plugins/rainlab/builder/classes/pluginbasemodel/templates/plugin.php.tpl new file mode 100644 index 0000000..08ea737 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/pluginbasemodel/templates/plugin.php.tpl @@ -0,0 +1,14 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + +
    +
    + + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/preview.htm.tpl b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/preview.htm.tpl new file mode 100644 index 0000000..46fef44 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/preview.htm.tpl @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
    + formRenderPreview() ?> +
    + + +

    fatalError) ?>

    + + +

    + + + +

    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/update.htm.tpl b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/update.htm.tpl new file mode 100644 index 0000000..77f3a5e --- /dev/null +++ b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/formcontroller/templates/update.htm.tpl @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + + + +
    +
    + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/_list_toolbar.htm.tpl b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/_list_toolbar.htm.tpl new file mode 100644 index 0000000..b2296d6 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/_list_toolbar.htm.tpl @@ -0,0 +1,23 @@ +
    + {% if hasFormBehavior %} + + {% endif %} + {% if hasReorderBehavior %} + + {% endif %} + +
    diff --git a/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/index.htm.tpl b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/index.htm.tpl new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/listcontroller/templates/index.htm.tpl @@ -0,0 +1 @@ +listRender() ?> diff --git a/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/_reorder_toolbar.htm.tpl b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/_reorder_toolbar.htm.tpl new file mode 100644 index 0000000..41f7c6d --- /dev/null +++ b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/_reorder_toolbar.htm.tpl @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/reorder.htm.tpl b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/reorder.htm.tpl new file mode 100644 index 0000000..ef28059 --- /dev/null +++ b/server/plugins/rainlab/builder/classes/standardbehaviorsregistry/reordercontroller/templates/reorder.htm.tpl @@ -0,0 +1,8 @@ + + + + +reorderRender() ?> \ No newline at end of file diff --git a/server/plugins/rainlab/builder/components/RecordDetails.php b/server/plugins/rainlab/builder/components/RecordDetails.php new file mode 100644 index 0000000..7212716 --- /dev/null +++ b/server/plugins/rainlab/builder/components/RecordDetails.php @@ -0,0 +1,161 @@ + 'rainlab.builder::lang.components.details_title', + 'description' => 'rainlab.builder::lang.components.details_description' + ]; + } + + // + // Properties + // + + public function defineProperties() + { + return [ + 'modelClass' => [ + 'title' => 'rainlab.builder::lang.components.details_model', + 'type' => 'dropdown', + 'showExternalParam' => false + ], + 'identifierValue' => [ + 'title' => 'rainlab.builder::lang.components.details_identifier_value', + 'description' => 'rainlab.builder::lang.components.details_identifier_value_description', + 'type' => 'string', + 'default' => '{{ :id }}', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.components.details_identifier_value_required') + ] + ] + ], + 'modelKeyColumn' => [ + 'title' => 'rainlab.builder::lang.components.details_key_column', + 'description' => 'rainlab.builder::lang.components.details_key_column_description', + 'type' => 'autocomplete', + 'default' => 'id', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.components.details_key_column_required') + ] + ], + 'showExternalParam' => false + ], + 'displayColumn' => [ + 'title' => 'rainlab.builder::lang.components.details_display_column', + 'description' => 'rainlab.builder::lang.components.details_display_column_description', + 'type' => 'autocomplete', + 'depends' => ['modelClass'], + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.components.details_display_column_required') + ] + ], + 'showExternalParam' => false + ], + 'notFoundMessage' => [ + 'title' => 'rainlab.builder::lang.components.details_not_found_message', + 'description' => 'rainlab.builder::lang.components.details_not_found_message_description', + 'default' => Lang::get('rainlab.builder::lang.components.details_not_found_message_default'), + 'type' => 'string', + 'showExternalParam' => false + ] + ]; + } + + public function getModelClassOptions() + { + return ComponentHelper::instance()->listGlobalModels(); + } + + public function getDisplayColumnOptions() + { + return ComponentHelper::instance()->listModelColumnNames(); + } + + public function getModelKeyColumnOptions() + { + return ComponentHelper::instance()->listModelColumnNames(); + } + + // + // Rendering and processing + // + + public function onRun() + { + $this->prepareVars(); + + $this->record = $this->page['record'] = $this->loadRecord(); + } + + protected function prepareVars() + { + $this->notFoundMessage = $this->page['notFoundMessage'] = Lang::get($this->property('notFoundMessage')); + $this->displayColumn = $this->page['displayColumn'] = $this->property('displayColumn'); + $this->modelKeyColumn = $this->page['modelKeyColumn'] = $this->property('modelKeyColumn'); + $this->identifierValue = $this->page['identifierValue'] = $this->property('identifierValue'); + + if (!strlen($this->displayColumn)) { + throw new SystemException('The display column name is not set.'); + } + + if (!strlen($this->modelKeyColumn)) { + throw new SystemException('The model key column name is not set.'); + } + } + + protected function loadRecord() + { + if (!strlen($this->identifierValue)) { + return; + } + + $modelClassName = $this->property('modelClass'); + if (!strlen($modelClassName) || !class_exists($modelClassName)) { + throw new SystemException('Invalid model class name'); + } + + $model = new $modelClassName(); + return $model->where($this->modelKeyColumn, '=', $this->identifierValue)->first(); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/components/RecordList.php b/server/plugins/rainlab/builder/components/RecordList.php new file mode 100644 index 0000000..be0ec7a --- /dev/null +++ b/server/plugins/rainlab/builder/components/RecordList.php @@ -0,0 +1,342 @@ + 'rainlab.builder::lang.components.list_title', + 'description' => 'rainlab.builder::lang.components.list_description' + ]; + } + + // + // Properties + // + + public function defineProperties() + { + return [ + 'modelClass' => [ + 'title' => 'rainlab.builder::lang.components.list_model', + 'type' => 'dropdown', + 'showExternalParam' => false + ], + 'scope' => [ + 'title' => 'rainlab.builder::lang.components.list_scope', + 'description' => 'rainlab.builder::lang.components.list_scope_description', + 'type' => 'dropdown', + 'depends' => ['modelClass'], + 'showExternalParam' => false + ], + 'scopeValue' => [ + 'title' => 'rainlab.builder::lang.components.list_scope_value', + 'description' => 'rainlab.builder::lang.components.list_scope_value_description', + 'type' => 'string', + 'default' => '{{ :scope }}', + ], + 'displayColumn' => [ + 'title' => 'rainlab.builder::lang.components.list_display_column', + 'description' => 'rainlab.builder::lang.components.list_display_column_description', + 'type' => 'autocomplete', + 'depends' => ['modelClass'], + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.components.list_display_column_required') + ] + ] + ], + 'noRecordsMessage' => [ + 'title' => 'rainlab.builder::lang.components.list_no_records', + 'description' => 'rainlab.builder::lang.components.list_no_records_description', + 'type' => 'string', + 'default' => Lang::get('rainlab.builder::lang.components.list_no_records_default'), + 'showExternalParam' => false, + ], + 'detailsPage' => [ + 'title' => 'rainlab.builder::lang.components.list_details_page', + 'description' => 'rainlab.builder::lang.components.list_details_page_description', + 'type' => 'dropdown', + 'showExternalParam' => false, + 'group' => 'rainlab.builder::lang.components.list_details_page_link' + ], + 'detailsKeyColumn' => [ + 'title' => 'rainlab.builder::lang.components.list_details_key_column', + 'description' => 'rainlab.builder::lang.components.list_details_key_column_description', + 'type' => 'autocomplete', + 'depends' => ['modelClass'], + 'showExternalParam' => false, + 'group' => 'rainlab.builder::lang.components.list_details_page_link' + ], + 'detailsUrlParameter' => [ + 'title' => 'rainlab.builder::lang.components.list_details_url_parameter', + 'description' => 'rainlab.builder::lang.components.list_details_url_parameter_description', + 'type' => 'string', + 'default' => 'id', + 'showExternalParam' => false, + 'group' => 'rainlab.builder::lang.components.list_details_page_link' + ], + 'recordsPerPage' => [ + 'title' => 'rainlab.builder::lang.components.list_records_per_page', + 'description' => 'rainlab.builder::lang.components.list_records_per_page_description', + 'type' => 'string', + 'validationPattern' => '^[0-9]*$', + 'validationMessage' => 'rainlab.builder::lang.components.list_records_per_page_validation', + 'group' => 'rainlab.builder::lang.components.list_pagination' + ], + 'pageNumber' => [ + 'title' => 'rainlab.builder::lang.components.list_page_number', + 'description' => 'rainlab.builder::lang.components.list_page_number_description', + 'type' => 'string', + 'default' => '{{ :page }}', + 'group' => 'rainlab.builder::lang.components.list_pagination' + ], + 'sortColumn' => [ + 'title' => 'rainlab.builder::lang.components.list_sort_column', + 'description' => 'rainlab.builder::lang.components.list_sort_column_description', + 'type' => 'autocomplete', + 'depends' => ['modelClass'], + 'group' => 'rainlab.builder::lang.components.list_sorting', + 'showExternalParam' => false + ], + 'sortDirection' => [ + 'title' => 'rainlab.builder::lang.components.list_sort_direction', + 'type' => 'dropdown', + 'showExternalParam' => false, + 'group' => 'rainlab.builder::lang.components.list_sorting', + 'options' => [ + 'asc' => 'rainlab.builder::lang.components.list_order_direction_asc', + 'desc' => 'rainlab.builder::lang.components.list_order_direction_desc' + ] + ] + ]; + } + + public function getDetailsPageOptions() + { + $pages = Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); + + $pages = [ + '-' => Lang::get('rainlab.builder::lang.components.list_details_page_no') + ] + $pages; + + return $pages; + } + + public function getModelClassOptions() + { + return ComponentHelper::instance()->listGlobalModels(); + } + + public function getDisplayColumnOptions() + { + return ComponentHelper::instance()->listModelColumnNames(); + } + + public function getDetailsKeyColumnOptions() + { + return ComponentHelper::instance()->listModelColumnNames(); + } + + public function getSortColumnOptions() + { + return ComponentHelper::instance()->listModelColumnNames(); + } + + public function getScopeOptions() + { + $modelClass = ComponentHelper::instance()->getModelClassDesignTime(); + + $result = [ + '-' => Lang::get('rainlab.builder::lang.components.list_scope_default') + ]; + try { + $methods = get_class_methods($modelClass); + + foreach ($methods as $method) { + if (preg_match('/scope[A-Z].*/', $method)) { + $result[$method] = $method; + } + } + } + catch (Exception $ex) { + // Ignore invalid models + } + + return $result; + } + + // + // Rendering and processing + // + + public function onRun() + { + $this->prepareVars(); + + $this->records = $this->page['records'] = $this->listRecords(); + } + + protected function prepareVars() + { + $this->noRecordsMessage = $this->page['noRecordsMessage'] = Lang::get($this->property('noRecordsMessage')); + $this->displayColumn = $this->page['displayColumn'] = $this->property('displayColumn'); + $this->pageParam = $this->page['pageParam'] = $this->paramName('pageNumber'); + + $this->detailsKeyColumn = $this->page['detailsKeyColumn'] = $this->property('detailsKeyColumn'); + $this->detailsUrlParameter = $this->page['detailsUrlParameter'] = $this->property('detailsUrlParameter'); + + $detailsPage = $this->property('detailsPage'); + if ($detailsPage == '-') { + $detailsPage = null; + } + + $this->detailsPage = $this->page['detailsPage'] = $detailsPage; + + if (!strlen($this->displayColumn)) { + throw new SystemException('The display column name is not set.'); + } + + if (strlen($this->detailsPage)) { + if (!strlen($this->detailsKeyColumn)) { + throw new SystemException('The details key column should be set to generate links to the details page.'); + } + + if (!strlen($this->detailsUrlParameter)) { + throw new SystemException('The details page URL parameter name should be set to generate links to the details page.'); + } + } + } + + protected function listRecords() + { + $modelClassName = $this->property('modelClass'); + if (!strlen($modelClassName) || !class_exists($modelClassName)) { + throw new SystemException('Invalid model class name'); + } + + $model = new $modelClassName(); + $scope = $this->getScopeName($model); + $scopeValue = $this->property('scopeValue'); + + if ($scope !== null) { + $model = $model->$scope($scopeValue); + } + + $model = $this->sort($model); + $records = $this->paginate($model); + + return $records; + } + + protected function getScopeName($model) + { + $scopeMethod = trim($this->property('scope')); + if (!strlen($scopeMethod) || $scopeMethod == '-') { + return null; + } + + if (!preg_match('/scope[A-Z].+/', $scopeMethod)) { + throw new SystemException('Invalid scope method name.'); + } + + if (!method_exists($model, $scopeMethod)) { + throw new SystemException('Scope method not found.'); + } + + return lcfirst(substr($scopeMethod, 5)); + } + + protected function paginate($model) + { + $recordsPerPage = trim($this->property('recordsPerPage')); + if (!strlen($recordsPerPage)) { + // Pagination is disabled - return all records + return $model->get(); + } + + if (!preg_match('/^[0-9]+$/', $recordsPerPage)) { + throw new SystemException('Invalid records per page value.'); + } + + $pageNumber = trim($this->property('pageNumber')); + if (!strlen($pageNumber) || !preg_match('/^[0-9]+$/', $pageNumber)) { + $pageNumber = 1; + } + + return $model->paginate($recordsPerPage, $pageNumber); + } + + protected function sort($model) + { + $sortColumn = trim($this->property('sortColumn')); + if (!strlen($sortColumn)) { + return $model; + } + + $sortDirection = trim($this->property('sortDirection')); + + if ($sortDirection !== 'desc') { + $sortDirection = 'asc'; + } + + // Note - no further validation of the sort column + // value is performed here, relying to the ORM sanitizing. + return $model->orderBy($sortColumn, $sortDirection); + } +} diff --git a/server/plugins/rainlab/builder/components/recorddetails/default.htm b/server/plugins/rainlab/builder/components/recorddetails/default.htm new file mode 100644 index 0000000..3d56a45 --- /dev/null +++ b/server/plugins/rainlab/builder/components/recorddetails/default.htm @@ -0,0 +1,9 @@ +{% set record = __SELF__.record %} +{% set displayColumn = __SELF__.displayColumn %} +{% set notFoundMessage = __SELF__.notFoundMessage %} + +{% if record %} + {{ attribute(record, displayColumn) }} +{% else %} + {{ notFoundMessage }} +{% endif %} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/components/recordlist/default.htm b/server/plugins/rainlab/builder/components/recordlist/default.htm new file mode 100644 index 0000000..9bfaeda --- /dev/null +++ b/server/plugins/rainlab/builder/components/recordlist/default.htm @@ -0,0 +1,45 @@ +{% set records = __SELF__.records %} +{% set displayColumn = __SELF__.displayColumn %} +{% set noRecordsMessage = __SELF__.noRecordsMessage %} +{% set detailsPage = __SELF__.detailsPage %} +{% set detailsKeyColumn = __SELF__.detailsKeyColumn %} +{% set detailsUrlParameter = __SELF__.detailsUrlParameter %} + + + +{% if records.lastPage > 1 %} +
      + {% if records.currentPage > 1 %} +
    • ← Prev
    • + {% endif %} + + {% for page in 1..records.lastPage %} +
    • + {{ page }} +
    • + {% endfor %} + + {% if records.lastPage > records.currentPage %} +
    • Next →
    • + {% endif %} +
    +{% endif %} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/controllers/Index.php b/server/plugins/rainlab/builder/controllers/Index.php new file mode 100644 index 0000000..e5160f9 --- /dev/null +++ b/server/plugins/rainlab/builder/controllers/Index.php @@ -0,0 +1,100 @@ +bodyClass = 'compact-container'; + $this->pageTitle = 'rainlab.builder::lang.plugin.name'; + + new PluginList($this, 'pluginList'); + new DatabaseTableList($this, 'databaseTabelList'); + new ModelList($this, 'modelList'); + new VersionList($this, 'versionList'); + new LanguageList($this, 'languageList'); + new ControllerList($this, 'controllerList'); + } + + public function index() + { + $this->addCss('/plugins/rainlab/builder/assets/css/builder.css', 'RainLab.Builder'); + + // The table widget scripts should be preloaded + $this->addJs('/modules/backend/widgets/table/assets/js/build-min.js', 'core'); + $this->addJs('/plugins/rainlab/builder/assets/js/build-min.js', 'RainLab.Builder'); + + $this->pageTitleTemplate = '%s Builder'; + } + + public function setBuilderActivePlugin($pluginCode, $refreshPluginList = false) + { + $this->widget->pluginList->setActivePlugin($pluginCode); + + $result = []; + if ($refreshPluginList) { + $result = $this->widget->pluginList->updateList(); + } + + $result = array_merge( + $result, + $this->widget->databaseTabelList->refreshActivePlugin(), + $this->widget->modelList->refreshActivePlugin(), + $this->widget->versionList->refreshActivePlugin(), + $this->widget->languageList->refreshActivePlugin(), + $this->widget->controllerList->refreshActivePlugin() + ); + + return $result; + } + + public function getBuilderActivePluginVector() + { + return $this->widget->pluginList->getActivePluginVector(); + } + + public function updatePluginList() + { + return $this->widget->pluginList->updateList(); + } +} diff --git a/server/plugins/rainlab/builder/controllers/index/_plugin-selector.htm b/server/plugins/rainlab/builder/controllers/index/_plugin-selector.htm new file mode 100644 index 0000000..a3fdda0 --- /dev/null +++ b/server/plugins/rainlab/builder/controllers/index/_plugin-selector.htm @@ -0,0 +1,9 @@ +
    +
    +
    +
    + widget->pluginList->render() ?> +
    +
    +
    +
    diff --git a/server/plugins/rainlab/builder/controllers/index/_sidepanel.htm b/server/plugins/rainlab/builder/controllers/index/_sidepanel.htm new file mode 100644 index 0000000..f5f696c --- /dev/null +++ b/server/plugins/rainlab/builder/controllers/index/_sidepanel.htm @@ -0,0 +1,55 @@ +
    +
    +
    + +
    + widget->databaseTabelList->render() ?> +
    + + +
    + widget->modelList->render() ?> +
    + + +
    + widget->controllerList->render() ?> +
    + + +
    + widget->versionList->render() ?> +
    + + +
    + widget->languageList->render() ?> +
    +
    +
    +
    diff --git a/server/plugins/rainlab/builder/controllers/index/index.htm b/server/plugins/rainlab/builder/controllers/index/index.htm new file mode 100644 index 0000000..f1e3bd7 --- /dev/null +++ b/server/plugins/rainlab/builder/controllers/index/index.htm @@ -0,0 +1,38 @@ + + + + fatalError): ?> + makePartial('sidepanel') ?> + + + + + makePartial('plugin-selector') ?> + + + + fatalError): ?> +
    + +
    +
    + +
    +
    +
    +
    + +
    + + +

    fatalError)) ?>

    + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/ControllerBuilder.php b/server/plugins/rainlab/builder/formwidgets/ControllerBuilder.php new file mode 100644 index 0000000..1811881 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/ControllerBuilder.php @@ -0,0 +1,117 @@ +prepareVars(); + return $this->makePartial('body'); + } + + /** + * Prepares the list data + */ + public function prepareVars() + { + $this->vars['model'] = $this->model; + } + + /** + * {@inheritDoc} + */ + public function loadAssets() + { + $this->addJs('js/controllerbuilder.js', 'builder'); + } + + /* + * Event handlers + */ + + // + // Methods for the internal use + // + + protected function getBehaviorDesignTimeProvider($providerClass) + { + if (array_key_exists($providerClass, $this->designTimeProviders)) { + return $this->designTimeProviders[$providerClass]; + } + + return $this->designTimeProviders[$providerClass] = new $providerClass($this->controller); + } + + protected function getPropertyValue($properties, $property) + { + if (array_key_exists($property, $properties)) { + return $properties[$property]; + } + + return null; + } + + protected function propertiesToInspectorSchema($propertyConfiguration) + { + $result = []; + + foreach ($propertyConfiguration as $property=>$propertyData) { + $propertyData['property'] = $property; + + $result[] = $propertyData; + } + + return $result; + } + + protected function getBehaviorInfo($class) + { + if (array_key_exists($class, $this->behaviorInfoCache)) { + return $this->behaviorInfoCache[$class]; + } + + $library = ControllerBehaviorLibrary::instance(); + $behaviorInfo = $library->getBehaviorInfo($class); + + if (!$behaviorInfo) { + throw new ApplicationException('The requested behavior class information is not found.'); + } + + return $this->behaviorInfoCache[$class] = $behaviorInfo; + } + + protected function renderBehaviorBody($behaviorClass, $behaviorInfo, $behaviorConfig) + { + $provider = $this->getBehaviorDesignTimeProvider($behaviorInfo['designTimeProvider']); + + return $provider->renderBehaviorBody($behaviorClass, $behaviorConfig, $this); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/FormBuilder.php b/server/plugins/rainlab/builder/formwidgets/FormBuilder.php new file mode 100644 index 0000000..7683bd4 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/FormBuilder.php @@ -0,0 +1,411 @@ +prepareVars(); + return $this->makePartial('body'); + } + + /** + * Prepares the list data + */ + public function prepareVars() + { + $this->vars['model'] = $this->model; + } + + /** + * {@inheritDoc} + */ + public function loadAssets() + { + $this->addJs('js/formbuilder.js', 'builder'); + $this->addJs('js/formbuilder.domtopropertyjson.js', 'builder'); + $this->addJs('js/formbuilder.tabs.js', 'builder'); + $this->addJs('js/formbuilder.controlpalette.js', 'builder'); + } + + public function renderControlList($controls, $listName = '') + { + return $this->makePartial('controllist', [ + 'controls' => $controls, + 'listName' => $listName + ]); + } + + /* + * Event handlers + */ + + public function onModelFormRenderControlWrapper() + { + $type = Input::get('controlType'); + $controlId = Input::get('controlId'); + $properties = Input::get('properties'); + + $controlInfo = $this->getControlInfo($type); + + return [ + 'markup' => $this->renderControlWrapper($type, $properties), + 'controlId' => $controlId, + 'controlTitle' => Lang::get($controlInfo['name']), + 'description' => Lang::get($controlInfo['description']), + 'type' => $type + ]; + } + + public function onModelFormRenderControlBody() + { + $type = Input::get('controlType'); + $controlId = Input::get('controlId'); + $properties = Input::get('properties'); + + return [ + 'markup' => $this->renderControlBody($type, $properties, $this), + 'controlId' => $controlId + ]; + } + + public function onModelFormLoadControlPalette() + { + $controlId = Input::get('controlId'); + + $library = ControlLibrary::instance(); + $controls = $library->listControls(); + $this->vars['registeredControls'] = $controls; + $this->vars['controlGroups'] = array_keys($controls); + + return [ + 'markup' => $this->makePartial('controlpalette'), + 'controlId' => $controlId + ]; + } + + public function getPluginCode() + { + $pluginCode = Input::get('plugin_code'); + if (strlen($pluginCode)) { + return $pluginCode; + } + + return $this->model->getPluginCodeObj()->toCode(); + } + + // + // Methods for the internal use + // + + protected function getControlDesignTimeProvider($providerClass) + { + if (array_key_exists($providerClass, $this->designTimeProviders)) { + return $this->designTimeProviders[$providerClass]; + } + + return $this->designTimeProviders[$providerClass] = new $providerClass($this->controller); + } + + protected function getPropertyValue($properties, $property) + { + if (array_key_exists($property, $properties)) { + return $properties[$property]; + } + + return null; + } + + protected function propertiesToInspectorSchema($propertyConfiguration) + { + $result = []; + + $fieldNameProperty = [ + 'title' => Lang::get('rainlab.builder::lang.form.property_field_name_title'), + 'property' => 'oc.fieldName', + 'type' => 'autocomplete', + 'fillFrom' => 'model-fields', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_field_name_required') + ], + 'regex' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_field_name_regex'), + 'pattern' => '^[a-zA-Z\_]+[0-9a-z\_\[\]]*$' + ] + ] + ]; + + $result[] = $fieldNameProperty; + + foreach ($propertyConfiguration as $property=>$propertyData) { + $propertyData['property'] = $property; + + if ($propertyData['type'] === 'control-container') { + // Control container type properties are handled with the form builder UI and + // should not be available in Inspector. + // + continue; + } + + $result[] = $propertyData; + } + + return $result; + } + + protected function getControlInfo($type) + { + if (array_key_exists($type, $this->controlInfoCache)) { + return $this->controlInfoCache[$type]; + } + + $library = ControlLibrary::instance(); + $controlInfo = $library->getControlInfo($type); + + if (!$controlInfo) { + throw new ApplicationException('The requested control type is not found.'); + } + + return $this->controlInfoCache[$type] = $controlInfo; + } + + protected function renderControlBody($type, $properties) + { + $controlInfo = $this->getControlInfo($type); + $provider = $this->getControlDesignTimeProvider($controlInfo['designTimeProvider']); + + return $this->makePartial('controlbody', [ + 'hasLabels' => $provider->controlHasLabels($type), + 'body' => $provider->renderControlBody($type, $properties, $this), + 'properties' => $properties + ]); + } + + protected function renderControlStaticBody($type, $properties, $controlConfiguration) + { + // The control body footer is never updated with AJAX and currently + // used only by the Repeater widget to display its controls. + + $controlInfo = $this->getControlInfo($type); + $provider = $this->getControlDesignTimeProvider($controlInfo['designTimeProvider']); + + return $provider->renderControlStaticBody($type, $properties, $controlConfiguration, $this); + } + + protected function renderControlWrapper($type, $properties = [], $controlConfiguration = []) + { + // This method renders the entire control, including + // the wrapping element. + + $controlInfo = $this->getControlInfo($type); + + // Builder UI displays Comment and Comment Above properties + // as Comment and Comment Position properties. + + if (array_key_exists('comment', $properties) && strlen($properties['comment'])) { + $properties['oc.comment'] = $properties['comment']; + $properties['oc.commentPosition'] = 'below'; + } + + if (array_key_exists('commentAbove', $properties) && strlen($properties['commentAbove'])) { + $properties['oc.comment'] = $properties['commentAbove']; + $properties['oc.commentPosition'] = 'above'; + } + + $provider = $this->getControlDesignTimeProvider($controlInfo['designTimeProvider']); + return $this->makePartial('controlwrapper', [ + 'fieldsConfiguration' => $this->propertiesToInspectorSchema($controlInfo['properties']), + 'controlConfiguration' => $controlConfiguration, + 'type' => $type, + 'properties' => $properties + ]); + } + + protected function getSpan($currentSpan, $prevSpan, $isPlaceholder = false) + { + if ($currentSpan == 'auto' || !strlen($currentSpan)) { + if ($prevSpan == 'left') { + return 'right'; + } + else { + return $isPlaceholder ? 'full' : 'left'; + } + } + + return $currentSpan; + } + + protected function preprocessPropertyValues($controlName, $properties, $controlInfo) + { + $properties['oc.fieldName'] = $controlName; + + // Remove the control container type property values. + // + if (isset($controlInfo['properties'])) { + foreach ($controlInfo['properties'] as $property=>$propertyConfig) { + if (isset($propertyConfig['type']) && $propertyConfig['type'] === 'control-container' && isset($properties[$property])) { + unset($properties[$property]); + } + } + } + + return $properties; + } + + protected function getControlRenderingInfo($controlName, $properties, $prevProperties) + { + $type = isset($properties['type']) ? $properties['type'] : 'text'; + $spanFixed = isset($properties['span']) ? $properties['span'] : 'auto'; + $prevSpan = isset($prevProperties['span']) ? $prevProperties['span'] : 'auto'; + + $span = $this->getSpan($spanFixed, $prevSpan); + $spanClass = 'span-'.$span; + + $controlInfo = $this->getControlInfo($type); + + $properties = $this->preprocessPropertyValues($controlName, $properties, $controlInfo); + + return [ + 'title' => Lang::get($controlInfo['name']), + 'description' => Lang::get($controlInfo['description']), + 'type' => $type, + 'span' => $span, + 'spanFixed' => $spanFixed, + 'spanClass' => $spanClass, + 'properties' => $properties, + 'unknownControl' => isset($controlInfo['unknownControl']) && $controlInfo['unknownControl'] + ]; + } + + protected function getTabConfigurationSchema() + { + if ($this->tabConfigurationSchema !== null) { + return $this->tabConfigurationSchema; + } + + $result = [ + [ + 'title' => Lang::get('rainlab.builder::lang.form.tab_title'), + 'property' => 'title', + 'type' => 'builderLocalization', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.form.property_tab_title_required') + ] + ] + ] + ]; + + return $this->tabConfigurationSchema = json_encode($result); + } + + protected function getTabsConfigurationSchema() + { + if ($this->tabsConfigurationSchema !== null) { + return $this->tabsConfigurationSchema; + } + + $result = [ + [ + 'title' => Lang::get('rainlab.builder::lang.form.tab_stretch'), + 'description' => Lang::get('rainlab.builder::lang.form.tab_stretch_description'), + 'property' => 'stretch', + 'type' => 'checkbox' + ], + [ + 'title' => Lang::get('rainlab.builder::lang.form.tab_css_class'), + 'description' => Lang::get('rainlab.builder::lang.form.tab_css_class_description'), + 'property' => 'cssClass', + 'type' => 'string' + ] + ]; + + return $this->tabsConfigurationSchema = json_encode($result); + } + + protected function getTabConfigurationValues($values) + { + if (!count($values)) { + return '{}'; + } + + return json_encode($values); + } + + protected function getTabsConfigurationValues($values) + { + if (!count($values)) { + return '{}'; + } + + return json_encode($values); + } + + protected function getTabsFields($tabsName, $fields) + { + $result = []; + + if (!is_array($fields)) { + return $result; + } + + if (!array_key_exists($tabsName, $fields) || !array_key_exists('fields', $fields[$tabsName])) { + return $result; + } + + $defaultTab = Lang::get('backend::lang.form.undefined_tab'); + if (array_key_exists('defaultTab', $fields[$tabsName])) { + $defaultTab = Lang::get($fields[$tabsName]['defaultTab']); + } + + foreach ($fields[$tabsName]['fields'] as $fieldName=>$fieldConfiguration) { + if (!isset($fieldConfiguration['tab'])) { + $fieldConfiguration['tab'] = $defaultTab; + } + + $tab = $fieldConfiguration['tab']; + if (!array_key_exists($tab, $result)) { + $result[$tab] = []; + } + + $result[$tab][$fieldName] = $fieldConfiguration; + } + + return $result; + } +} diff --git a/server/plugins/rainlab/builder/formwidgets/MenuEditor.php b/server/plugins/rainlab/builder/formwidgets/MenuEditor.php new file mode 100644 index 0000000..e0f3756 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/MenuEditor.php @@ -0,0 +1,222 @@ +prepareVars(); + return $this->makePartial('body'); + } + + /** + * Prepares the list data + */ + public function prepareVars() + { + $this->vars['model'] = $this->model; + $this->vars['items'] = $this->model->menus; + + $this->vars['emptyItem'] = [ + 'label' => Lang::get('rainlab.builder::lang.menu.new_menu_item'), + 'icon' => 'icon-life-ring', + 'code' => 'newitemcode', + 'url' => '/' + ]; + + $this->vars['emptySubItem'] = [ + 'label' => Lang::get('rainlab.builder::lang.menu.new_menu_item'), + 'icon' => 'icon-sitemap', + 'code' => 'newitemcode', + 'url' => '/' + ]; + } + + /** + * {@inheritDoc} + */ + public function loadAssets() + { + $this->addJs('js/menubuilder.js', 'builder'); + } + + public function getPluginCode() + { + $pluginCode = Input::get('plugin_code'); + if (strlen($pluginCode)) { + return $pluginCode; + } + + $pluginVector = $this->controller->getBuilderActivePluginVector(); + + return $pluginVector->pluginCodeObj->toCode(); + } + + // + // Event handlers + // + + // + // Methods for the internal use + // + + protected function getItemArrayProperty($item, $property) + { + if (array_key_exists($property, $item)) { + return $item[$property]; + } + + return null; + } + + protected function getIconList() + { + if ($this->iconList !== null) { + return $this->iconList; + } + + $icons = IconList::getList(); + $this->iconList = []; + + foreach ($icons as $iconCode=>$iconInfo) { + $iconCode = preg_replace('/^oc\-/', '', $iconCode); + + $this->iconList[$iconCode] = $iconInfo; + } + + return $this->iconList; + } + + protected function getCommonMenuItemConfigurationSchema() + { + $result = [ + [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_code'), + 'property' => 'code', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.menu.property_code_required') + ] + ] + ], + [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_label'), + 'type' => 'builderLocalization', + 'property' => 'label', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.menu.property_label_required') + ] + ] + ], + [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_url'), + 'property' => 'url', + 'type' => 'autocomplete', + 'fillFrom' => 'controller-urls', + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.menu.property_url_required') + ] + ] + ], + [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_icon'), + 'property' => 'icon', + 'type' => 'dropdown', + 'options' => $this->getIconList(), + 'validation' => [ + 'required' => [ + 'message' => Lang::get('rainlab.builder::lang.menu.property_icon_required') + ] + ], + ], + [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_permissions'), + 'property' => 'permissions', + 'type' => 'stringListAutocomplete', + 'fillFrom' => 'permissions' + ] + ]; + + return $result; + } + + protected function getSideMenuConfigurationSchema() + { + $result = $this->getCommonMenuItemConfigurationSchema(); + + $result[] = [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_attributes'), + 'property' => 'attributes', + 'type' => 'stringList' + ]; + + return json_encode($result); + } + + protected function getSideMenuConfiguration($item) + { + if (!count($item)) { + return '{}'; + } + + return json_encode($item); + } + + + protected function getMainMenuConfigurationSchema() + { + $result = $this->getCommonMenuItemConfigurationSchema(); + + $result[] = [ + 'title' => Lang::get('rainlab.builder::lang.menu.property_order'), + 'description' => Lang::get('rainlab.builder::lang.menu.property_order_description'), + 'property' => 'order', + 'validation' => [ + 'regex' => [ + 'pattern' => '^[0-9]+$', + 'message' => Lang::get('rainlab.builder::lang.menu.property_order_invalid') + ] + ] + ]; + + return json_encode($result); + } + + protected function getMainMenuConfiguration($item) + { + if (!count($item)) { + return '{}'; + } + + return json_encode($item); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/controllerbuilder/assets/js/controllerbuilder.js b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/assets/js/controllerbuilder.js new file mode 100644 index 0000000..e69de29 diff --git a/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_behavior.htm b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_behavior.htm new file mode 100644 index 0000000..e5839b0 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_behavior.htm @@ -0,0 +1,16 @@ +getBehaviorInfo($behaviorClass); + + $fieldsConfiguration = $this->propertiesToInspectorSchema($behaviorInfo['properties']); +?> + +
  • +

    + +
    + renderBehaviorBody($behaviorClass, $behaviorInfo, $behaviorConfig) ?> + + + +
    +
  • diff --git a/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_body.htm b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_body.htm new file mode 100644 index 0000000..ad34004 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_body.htm @@ -0,0 +1,10 @@ +
    +
    +
    + makePartial('buildingarea') ?> +
    + + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_buildingarea.htm b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_buildingarea.htm new file mode 100644 index 0000000..5fae3d5 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/controllerbuilder/partials/_buildingarea.htm @@ -0,0 +1,11 @@ +
    +
    +
    +
      + behaviors as $behaviorClass=>$behaviorConfig): ?> + makePartial('behavior', ['behaviorClass'=>$behaviorClass, 'behaviorConfig'=>$behaviorConfig]) ?> + +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.controlpalette.js b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.controlpalette.js new file mode 100644 index 0000000..f5c9ec6 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.controlpalette.js @@ -0,0 +1,263 @@ +/* + * Manages the control palette loading and displaying + */ ++function ($) { "use strict"; + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var ControlPalette = function() { + Base.call(this) + + this.controlPaletteMarkup = null + this.popoverMarkup = null + this.containerMarkup = null + this.$popoverContainer = null + } + + ControlPalette.prototype = Object.create(BaseProto) + ControlPalette.prototype.constructor = ControlPalette + + // INTERNAL METHODS + // ============================ + + ControlPalette.prototype.loadControlPalette = function(element, controlId) { + if (this.controlPaletteMarkup === null) { + var data = { + controlId: controlId + } + + $.oc.stripeLoadIndicator.show() + $(element).request('onModelFormLoadControlPalette', { + data: data + }).done( + this.proxy(this.controlPaletteMarkupLoaded) + ).always(function(){ + $.oc.stripeLoadIndicator.hide() + }) + } + else { + this.showControlPalette(controlId, true) + } + } + + ControlPalette.prototype.controlPaletteMarkupLoaded = function(responseData) { + this.controlPaletteMarkup = responseData.markup + + this.showControlPalette(responseData.controlId) + } + + ControlPalette.prototype.getControlById = function(controlId) { + return document.body.querySelector('li[data-builder-control-id="'+controlId+'"]') + } + + ControlPalette.prototype.showControlPalette = function(controlId, initControls) { + if (this.getContainerPreference()) { + this.showControlPalletteInContainer(controlId, initControls) + } + else { + this.showControlPalletteInPopup(controlId, initControls) + } + } + + ControlPalette.prototype.assignControlIdToTemplate = function(template, controlId) { + return template.replace('%c', controlId) + } + + ControlPalette.prototype.markPlaceholderPaletteOpen = function(control) { + $(control).addClass('control-palette-open') + } + + ControlPalette.prototype.markPlaceholderPaletteNotOpen = function(control) { + $(control).removeClass('control-palette-open') + } + + ControlPalette.prototype.getContainerPreference = function() { + return $.oc.inspector.manager.getContainerPreference() + } + + ControlPalette.prototype.setContainerPreference = function(value) { + return $.oc.inspector.manager.setContainerPreference(value) + } + + ControlPalette.prototype.addControl = function(ev) { + var $target = $(ev.currentTarget), + controlId = $target.closest('[data-control-palette-controlid]').attr('data-control-palette-controlid') + + ev.preventDefault() + ev.stopPropagation() + + if (!controlId) { + return false; + } + + var control = this.getControlById(controlId) + if (!control) { + return false + } + + if ($(control).hasClass('loading-control')) { + return false + } + + $target.trigger('close.oc.popover') + + var promise = $.oc.builder.formbuilder.controller.addControlFromControlPalette(controlId, + $target.data('builderControlType'), + $target.data('builderControlName')) + + promise.done(function() { + $.oc.inspector.manager.createInspector(control) + $(control).trigger('change') // Set modified state for the form + }) + + return false + } + + // + // Popover wrapper + // + + ControlPalette.prototype.showControlPalletteInPopup = function(controlId, initControls) { + var control = this.getControlById(controlId) + + if (!control) { + return + } + + var $control = $(control) + + $control.ocPopover({ + content: this.assignControlIdToTemplate(this.getPopoverMarkup(), controlId), + highlightModalTarget: true, + modal: true, + placement: 'below', + containerClass: 'control-inspector', + offset: 15, + width: 400 + }) + + var $popoverContainer = $control.data('oc.popover').$container + + if (initControls) { + // Initialize the scrollpad control in the popup only when the + // popup is created from the cached markup string + $popoverContainer.trigger('render') + } + } + + ControlPalette.prototype.getPopoverMarkup = function() { + if (this.popoverMarkup !== null) { + return this.popoverMarkup + } + + var outerMarkup = $('script[data-template=control-palette-popover]').html() + + this.popoverMarkup = outerMarkup.replace('%s', this.controlPaletteMarkup) + + return this.popoverMarkup + } + + ControlPalette.prototype.dockToContainer = function(ev) { + var $popoverBody = $(ev.target).closest('.control-popover'), + $controlIdContainer = $popoverBody.find('[data-control-palette-controlid]'), + controlId = $controlIdContainer.attr('data-control-palette-controlid'), + control = this.getControlById(controlId) + + $popoverBody.trigger('close.oc.popover') + + this.setContainerPreference(true) + + if (control) { + this.loadControlPalette($(control), controlId) + } + } + + // + // Container wrapper + // + + ControlPalette.prototype.showControlPalletteInContainer = function(controlId, initControls) { + var control = this.getControlById(controlId) + + if (!control) { + return + } + + var inspectorManager = $.oc.inspector.manager, + $container = inspectorManager.getContainerElement($(control)) + + // If the container is already in use, apply values to the inspectable elements + if (!inspectorManager.applyValuesFromContainer($container) || !inspectorManager.containerHidingAllowed($container)) { + return + } + + // Dispose existing Inspector + $.oc.foundation.controlUtils.disposeControls($container.get(0)) + + this.markPlaceholderPaletteOpen(control) + + var template = this.assignControlIdToTemplate(this.getContainerMarkup(), controlId) + $container.append(template) + + $container.find('[data-control-palette-controlid]').one('dispose-control', this.proxy(this.onRemovePaletteFromContainer)) + + if (initControls) { + // Initialize the scrollpad control in the container only when the + // palette is created from the cached markup string + $container.trigger('render') + } + } + + ControlPalette.prototype.onRemovePaletteFromContainer = function(ev) { + this.removePaletteFromContainer($(ev.target)) + } + + ControlPalette.prototype.removePaletteFromContainer = function($container) { + var controlId = $container.attr('data-control-palette-controlid'), + control = this.getControlById(controlId) + + if (control) { + this.markPlaceholderPaletteNotOpen(control) + } + + var $parent = $container.parent() + $container.remove() + $parent.html('') + } + + ControlPalette.prototype.getContainerMarkup = function() { + if (this.containerMarkup !== null) { + return this.containerMarkup + } + + var outerMarkup = $('script[data-template=control-palette-container]').html() + + this.containerMarkup = outerMarkup.replace('%s', this.controlPaletteMarkup) + + return this.containerMarkup + } + + ControlPalette.prototype.closeInContainer = function(ev) { + this.removePaletteFromContainer($(ev.target).closest('[data-control-palette-controlid]')) + } + + ControlPalette.prototype.undockFromContainer = function(ev) { + var $container = $(ev.target).closest('[data-control-palette-controlid]'), + controlId = $container.attr('data-control-palette-controlid'), + control = this.getControlById(controlId) + + this.removePaletteFromContainer($container) + this.setContainerPreference(false) + + if (control) { + this.loadControlPalette($(control), controlId) + } + } + + $(document).ready(function(){ + // There is a single instance of the control palette manager. + $.oc.builder.formbuilder.controlPalette = new ControlPalette() + }) + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.domtopropertyjson.js b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.domtopropertyjson.js new file mode 100644 index 0000000..21998d3 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.domtopropertyjson.js @@ -0,0 +1,330 @@ +/* + * Converts control properties from DOM elements to JSON format. + */ ++function ($) { "use strict"; + + if ($.oc.builder === undefined) + $.oc.builder = {} + + if ($.oc.builder.formbuilder === undefined) + $.oc.builder.formbuilder = {} + + function getControlPropertyValues(item) { + for (var i=0, len=item.children.length; i 0 && properties['oc.commentPosition'] == 'above') { + properties['commentAbove'] = properties['oc.comment'] + + if (properties['comment'] !== undefined) { + delete properties['comment'] + } + + delete properties['oc.comment'] + delete properties['oc.commentPosition'] + } + + if (String(properties['oc.comment']).length > 0 && properties['oc.commentPosition'] == 'below') { + properties['comment'] = properties['oc.comment'] + + if (properties['comentAbove'] !== undefined) { + delete properties['comentAbove'] + } + + delete properties['oc.comment'] + delete properties['oc.commentPosition'] + } + + if (properties['oc.comment'] !== undefined) { + if (String(properties['oc.comment']).length > 0) { + properties['comment'] = properties['oc.comment'] + } + + delete properties['oc.comment'] + } + } + + function parseControlControlContainer(control) { + var children = control.children, + result = {} + + for (var i=0, len=children.length; i 0) { + if (objectHasProperties(controls)) { + if (result[listName].fields === undefined) { + result[listName].fields = {} + } + + result[listName].fields = $.extend(result[listName].fields, controls) + } + } + else { + if (objectHasProperties(controls)) { + if (result.fields === undefined) { + result.fields = {} + } + + result.fields = $.extend(result.fields, controls) + } + } + } + + function containerToJson(container) { + var containerElements = container.children, + result = {} + + for (var i=0, len=containerElements.length; i li.control'), + result = [] + + for (var i=controls.length-1; i>=0; i--) { + var properties = getControlPropertyValues(controls[i]) + + if (typeof properties !== 'object') { + continue + } + + if (properties['oc.fieldName'] === undefined) { + continue + } + + var name = properties['oc.fieldName'] + + if (result.indexOf(name) === -1) { + result.push(name) + } + } + + result.sort() + + return result + } + + + $.oc.builder.formbuilder.domToPropertyJson = DomToJson + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.js b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.js new file mode 100644 index 0000000..229a087 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.js @@ -0,0 +1,801 @@ +/* + * Form Builder widget class. + * + * There is only a single instance of the Form Builder class and it handles + * as many form builder user interfaces as needed. + * + */ ++function ($) { "use strict"; + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var FormBuilder = function() { + Base.call(this) + + this.placeholderIdIndex = 0 + this.updateControlBodyTimer = null + + this.init() + } + + FormBuilder.prototype = Object.create(BaseProto) + FormBuilder.prototype.constructor = FormBuilder + + // INTERNAL METHODS + // ============================ + + FormBuilder.prototype.init = function() { + this.registerHandlers() + } + + FormBuilder.prototype.registerHandlers = function() { + document.addEventListener('dragstart', this.proxy(this.onDragStart)) + document.addEventListener('dragover', this.proxy(this.onDragOver)) + document.addEventListener('dragenter', this.proxy(this.onDragEnter)) + document.addEventListener('dragleave', this.proxy(this.onDragLeave)) + document.addEventListener('drop', this.proxy(this.onDragDrop), false); + + $(document).on('change', '.builder-control-list > li.control', this.proxy(this.onControlChange)) + $(document).on('click', '.builder-control-list > li.control div[data-builder-remove-control]', this.proxy(this.onRemoveControl)) + $(document).on('click', '.builder-control-list > li.placeholder', this.proxy(this.onPlaceholderClick)) + $(document).on('showing.oc.inspector', '.builder-control-list > li.control', this.proxy(this.onInspectorShowing)) + $(document).on('livechange', '.builder-control-list > li.control', this.proxy(this.onControlLiveChange)) + $(document).on('autocompleteitems.oc.inspector', '.builder-control-list > li.control', this.proxy(this.onAutocompleteItems)) + $(document).on('dropdownoptions.oc.inspector', '.builder-control-list > li.control', this.proxy(this.onDropdownOptions)) + } + + FormBuilder.prototype.getControlId = function(li) { + if (li.hasAttribute('data-builder-control-id')) { + return li.getAttribute('data-builder-control-id') + } + + this.placeholderIdIndex++ + li.setAttribute('data-builder-control-id', this.placeholderIdIndex) + + return this.placeholderIdIndex + } + + // PROPERTY HELPERS + // ============================ + + FormBuilder.prototype.getControlProperties = function(li) { + var children = li.children + + for (var i=children.length-1; i>=0; i--) { + var element = children[i] + + if (element.tagName === 'INPUT' && element.hasAttribute('data-inspector-values')) { + return $.parseJSON(element.value) + } + } + + throw new Error('Inspector values element is not found in control.') + } + + FormBuilder.prototype.setControlProperties = function(li, propertiesObj) { + var propertiesStr = JSON.stringify(propertiesObj), + valuesInput = li.querySelector('[data-inspector-values]') + + valuesInput.value = propertiesStr + } + + FormBuilder.prototype.loadModelFields = function(control, callback) { + var $form = $(this.findForm(control)), + pluginCode = $.oc.builder.indexController.getFormPluginCode($form), + modelClass = $form.find('input[name=model_class]').val() + + $.oc.builder.dataRegistry.get($form, pluginCode, 'model-columns', modelClass, function(response){ + callback({ + options: $.oc.builder.indexController.dataToInspectorArray(response) + }) + }) + } + + FormBuilder.prototype.getContainerFieldNames = function(control, callback) { + var controlWrapper = this.findRootControlWrapper(control), + fieldNames = $.oc.builder.formbuilder.domToPropertyJson.getAllControlNames(controlWrapper), + options = [] + + options.push({ + title: '---', + value: '' + }) + + for (var i=0, len=fieldNames.length; i=0; i--) { + var value = String(valueInputs[i].value) + + if (value.length === 0) { + continue + } + + var properties = $.parseJSON(value) + + if (properties['oc.fieldName'] == fieldName) { + return true + } + } + + return false + } + + // FLOW MANAGEMENT + // ============================ + + FormBuilder.prototype.reflow = function(li, listElement) { + if (!li && !listElement) { + throw new Error('Invalid call of the reflow method. Either li or list parameter should be not empty.') + } + + var list = listElement ? listElement : li.parentNode, + items = list.children, + prevSpan = null + + for (var i=0, len = items.length; i < len; i++) { + var item = items[i], + itemSpan = item.getAttribute('data-builder-span') + + if ($.oc.foundation.element.hasClass(item, 'clear-row')) { + continue + } + + if (itemSpan == 'auto') { + $.oc.foundation.element.removeClass(item, 'span-left') + $.oc.foundation.element.removeClass(item, 'span-full') + $.oc.foundation.element.removeClass(item, 'span-right') + + if (prevSpan == 'left') { + $.oc.foundation.element.addClass(item, 'span-right') + prevSpan = 'right' + } + else { + if (!$.oc.foundation.element.hasClass(item, 'placeholder')) { + $.oc.foundation.element.addClass(item, 'span-left') + } + else { + $.oc.foundation.element.addClass(item, 'span-full') + } + + prevSpan = 'left' + } + } + else { + $.oc.foundation.element.removeClass(item, 'span-left') + $.oc.foundation.element.removeClass(item, 'span-full') + $.oc.foundation.element.removeClass(item, 'span-right') + $.oc.foundation.element.addClass(item, 'span-' + itemSpan) + + prevSpan = itemSpan + } + } + } + + FormBuilder.prototype.setControlSpanFromProperties = function(li, properties) { + if (properties.span === undefined) { + return + } + + li.setAttribute('data-builder-span', properties.span) + this.reflow(li) + } + + FormBuilder.prototype.appendClearRowElement = function(li) { + li.insertAdjacentHTML('afterend', '
  • '); + } + + FormBuilder.prototype.patchControlSpan = function(li, span) { + li.setAttribute('data-builder-span', span) + + var properties = this.getControlProperties(li) + properties.span = span + this.setControlProperties(li, properties) + } + + // DRAG AND DROP + // ============================ + + FormBuilder.prototype.targetIsPlaceholder = function(ev) { + if (!ev.target.getAttribute) { + return false // In Gecko ev.target could be a text node + } + + return ev.target.getAttribute('data-builder-placeholder') + } + + FormBuilder.prototype.dataTransferContains = function(ev, element) { + if (ev.dataTransfer.types.indexOf !== undefined){ + return ev.dataTransfer.types.indexOf(element) >= 0 + } + + return ev.dataTransfer.types.contains(element) + } + + FormBuilder.prototype.sourceIsContainer = function(ev) { + return this.dataTransferContains(ev, 'builder/source/container') + } + + FormBuilder.prototype.startDragFromContainer = function(ev) { + ev.dataTransfer.effectAllowed = 'move' + + var controlId = this.getControlId(ev.target) + ev.dataTransfer.setData('builder/source/container', 'true') + ev.dataTransfer.setData('builder/control/id', controlId) + ev.dataTransfer.setData(controlId, controlId) + } + + FormBuilder.prototype.dropTargetIsChildOf = function(target, ev) { + var current = target + + while (current) { + if (this.elementIsControl(current) && this.dataTransferContains(ev, this.getControlId(current))) { + return true + } + + current = current.parentNode + } + + return false + } + + FormBuilder.prototype.dropFromContainerToPlaceholderOrControl = function(ev, targetControl) { + var targetElement = targetControl ? targetControl : ev.target + + $.oc.foundation.event.stop(ev) + this.stopHighlightingTargets(targetElement) + + var controlId = ev.dataTransfer.getData('builder/control/id'), + originalControl = document.body.querySelector('li[data-builder-control-id="'+controlId+'"]') + + if (!originalControl) { + return + } + + var isSameList = originalControl.parentNode === targetElement.parentNode, + originalList = originalControl.parentNode, + $originalClearRow = $(originalControl).next() + + targetElement.parentNode.insertBefore(originalControl, targetElement) + + this.appendClearRowElement(originalControl) + if ($originalClearRow.hasClass('clear-row')) { + $originalClearRow.remove() + } + + if (!$.oc.foundation.element.hasClass(originalControl, 'inspector-open')) { + this.patchControlSpan(originalControl, 'auto') + } + + this.reflow(targetElement) + + if (!isSameList) { + this.reflow(null, originalList) + } + + $(targetElement).closest('form').trigger('change') + } + + FormBuilder.prototype.elementContainsPoint = function(point, element) { + var elementPosition = $.oc.foundation.element.absolutePosition(element), + elementRight = elementPosition.left + element.offsetWidth, + elementBottom = elementPosition.top + element.offsetHeight + + return point.x >= elementPosition.left && point.x <= elementRight + && point.y >= elementPosition.top && point.y <= elementBottom + } + + FormBuilder.prototype.stopHighlightingTargets = function(target, excludeTarget) { + var rootWrapper = this.findRootControlWrapper(target), + controls = rootWrapper.querySelectorAll('li.control.drag-over') + + for (var i=controls.length-1; i>= 0; i--) { + if (!excludeTarget || target !== controls[i]) { + $.oc.foundation.element.removeClass(controls[i], 'drag-over') + } + } + } + + // UPDATING CONTROLS + // ============================ + + FormBuilder.prototype.startUpdateControlBody = function(controlId) { + this.clearUpdateControlBodyTimer() + + var self = this + this.updateControlBodyTimer = window.setTimeout(function(){ + self.updateControlBody(controlId) + }, 300) + } + + FormBuilder.prototype.clearUpdateControlBodyTimer = function() { + if (this.updateControlBodyTimer === null) { + return + } + + clearTimeout(this.updateControlBodyTimer) + this.updateControlBodyTimer = null + } + + FormBuilder.prototype.updateControlBody = function(controlId) { + var control = document.body.querySelector('li[data-builder-control-id="'+controlId+'"]') + if (!control) { + return + } + + this.clearUpdateControlBodyTimer() + + var rootWrapper = this.findRootControlWrapper(control), + controls = rootWrapper.querySelectorAll('li.control.updating-control') + + for (var i=controls.length-1; i>=0; i--) { + $.oc.foundation.element.removeClass(controls[i], 'updating-control') + } + + $.oc.foundation.element.addClass(control, 'updating-control') + + var controlType = control.getAttribute('data-control-type'), + properties = this.getControlProperties(control), + data = { + controlType: controlType, + controlId: controlId, + properties: properties + } + + $(control).request('onModelFormRenderControlBody', { + data: data + }).done( + this.proxy(this.controlBodyMarkupLoaded) + ).always(function(){ + $.oc.foundation.element.removeClass(control, 'updating-control') + }) + } + + FormBuilder.prototype.controlBodyMarkupLoaded = function(responseData) { + var li = document.body.querySelector('li[data-builder-control-id="'+responseData.controlId+'"]') + if (!li) { + return + } + + var wrapper = li.querySelector('.control-wrapper') + + wrapper.innerHTML = responseData.markup + } + + // ADDING CONTROLS + // ============================ + + FormBuilder.prototype.generateFieldName = function(controlType, placeholder) { + var controlContainer = this.findControlContainer(placeholder) + + if (!controlContainer) { + throw new Error('Cannot find control container for a placeholder.') + } + + // Replace any banned characters + controlType = controlType.replace(/[^a-zA-Z0-9_\[\]]/g, '') + + var counter = 1, + fieldName = controlType + counter + + while (this.fieldNameExistsInContainer(controlContainer, fieldName)) { + counter ++ + fieldName = controlType + counter + } + + return fieldName + } + + FormBuilder.prototype.addControlToPlaceholder = function(placeholder, controlType, controlName, noNewPlaceholder) { + // Duplicate the placeholder and place it after + // the existing one + if (!noNewPlaceholder) { + var newPlaceholder = $(placeholder.outerHTML) + + newPlaceholder.removeAttr('data-builder-control-id') + newPlaceholder.removeClass('control-palette-open') + + placeholder.insertAdjacentHTML('afterend', newPlaceholder.get(0).outerHTML) + } + + // Create the clear-row element after the current placeholder + this.appendClearRowElement(placeholder) + + // Replace the placeholder class with control + // loading indicator + $.oc.foundation.element.removeClass(placeholder, 'placeholder') + $.oc.foundation.element.addClass(placeholder, 'loading-control') + $.oc.foundation.element.removeClass(placeholder, 'control-palette-open') + placeholder.innerHTML = '' + placeholder.removeAttribute('data-builder-placeholder') + + var fieldName = this.generateFieldName(controlType, placeholder) + + // Send request to the server to load the + // control markup, Inspector data schema, inspector title, etc. + var data = { + controlType: controlType, + controlId: this.getControlId(placeholder), + properties: { + 'label': controlName, + 'span': 'auto', + 'oc.fieldName': fieldName + } + } + this.reflow(placeholder) + + return $(placeholder).request('onModelFormRenderControlWrapper', { + data: data + }).done(this.proxy(this.controlWrapperMarkupLoaded)) + } + + FormBuilder.prototype.controlWrapperMarkupLoaded = function(responseData) { + var placeholder = document.body.querySelector('li[data-builder-control-id="'+responseData.controlId+'"]') + if (!placeholder) { + return + } + + placeholder.setAttribute('draggable', true) + placeholder.setAttribute('data-inspectable', true) + placeholder.setAttribute('data-control-type', responseData.type) + + placeholder.setAttribute('data-inspector-title', responseData.controlTitle) + placeholder.setAttribute('data-inspector-description', responseData.description) + + placeholder.innerHTML = responseData.markup + $.oc.foundation.element.removeClass(placeholder, 'loading-control') + } + + FormBuilder.prototype.displayControlPaletteForPlaceholder = function(element) { + $.oc.builder.formbuilder.controlPalette.loadControlPalette(element, this.getControlId(element)) + } + + FormBuilder.prototype.addControlFromControlPalette = function(placeholderId, controlType, controlName) { + var placeholder = document.body.querySelector('li[data-builder-control-id="'+placeholderId+'"]') + if (!placeholder) { + return + } + + return this.addControlToPlaceholder(placeholder, controlType, controlName) + } + + // REMOVING CONTROLS + // ============================ + + FormBuilder.prototype.removeControl = function($control) { + if ($control.hasClass('inspector-open')) { + var $inspectorContainer = this.findInspectorContainer($control) + $.oc.foundation.controlUtils.disposeControls($inspectorContainer.get(0)) + } + + var $nextControl = $control.next() // Even if the removed element was alone, there's always a placeholder element + $control.remove() + + this.reflow($nextControl.get(0)) + $nextControl.trigger('change') + } + + // DOM HELPERS + // ============================ + + FormBuilder.prototype.findControlContainer = function(element) { + var current = element + + while (current) { + if (current.hasAttribute && current.hasAttribute('data-control-container') ) { + return current + } + + current = current.parentNode + } + + return null + } + + FormBuilder.prototype.findForm = function(element) { + var current = element + + while (current) { + if (current.tagName === 'FORM') { + return current + } + + current = current.parentNode + } + + return null + } + + FormBuilder.prototype.findControlList = function(element) { + var current = element + + while (current) { + if (current.hasAttribute('data-control-list')) { + return current + } + + current = current.parentNode + } + + throw new Error('Cannot find control list for an element.') + } + + FormBuilder.prototype.findPlaceholder = function(controlList) { + var children = controlList.children + + for (var i=children.length-1; i>=0; i--) { + var element = children[i] + + if (element.tagName === 'LI' && $.oc.foundation.element.hasClass(element, 'placeholder')) { + return element + } + } + + throw new Error('Cannot find placeholder in a control list.') + } + + FormBuilder.prototype.findRootControlWrapper = function(control) { + var current = control + + while (current) { + if (current.hasAttribute('data-root-control-wrapper')) { + return current + } + + current = current.parentNode + } + + throw new Error('Cannot find root control wrapper.') + } + + FormBuilder.prototype.findInspectorContainer = function($element) { + var $containerRoot = $element.closest('[data-inspector-container]') + + return $containerRoot.find('.inspector-container') + } + + FormBuilder.prototype.elementIsControl = function(element) { + return element.tagName === 'LI' && element.hasAttribute('data-control-type') && $.oc.foundation.element.hasClass(element, 'control') + } + + FormBuilder.prototype.getClosestControl = function(element) { + var current = element + + while (current) { + if (this.elementIsControl(current)) { + return current + } + + current = current.parentNode + } + + return null + } + + // EVENT HANDLERS + // ============================ + + FormBuilder.prototype.onDragStart = function(ev) { + if (this.elementIsControl(ev.target)) { + this.startDragFromContainer(ev) + + return + } + } + + FormBuilder.prototype.onDragOver = function(ev) { + var targetLi = ev.target + + if (ev.target.tagName !== 'LI') { + targetLi = this.getClosestControl(ev.target) + } + + if (!targetLi || targetLi.tagName != 'LI') { + return + } + + var sourceIsContainer = this.sourceIsContainer(ev), + elementIsControl = this.elementIsControl(targetLi) + + if ((this.targetIsPlaceholder(ev) || elementIsControl) && sourceIsContainer) { + // Do not allow dropping controls to themselves or their + // children controls. + if (sourceIsContainer && elementIsControl && this.dropTargetIsChildOf(targetLi, ev)) { + return false + } + + // Dragging from container over a placeholder or another control. + // Allow the drop. + $.oc.foundation.event.stop(ev) + ev.dataTransfer.dropEffect = 'move' + return + } + } + + FormBuilder.prototype.onDragEnter = function(ev) { + var targetLi = ev.target + + if (ev.target.tagName !== 'LI') { + targetLi = this.getClosestControl(ev.target) + } + + if (!targetLi || targetLi.tagName != 'LI') { + return + } + + var sourceIsContainer = this.sourceIsContainer(ev) + + if (this.targetIsPlaceholder(ev) && sourceIsContainer) { + // Do not allow dropping controls to themselves or their + // children controls. + if (sourceIsContainer && this.dropTargetIsChildOf(ev.target, ev)) { + this.stopHighlightingTargets(ev.target, true) + return + } + + // Dragging from a container over a placeholder. + // Highlight the placeholder. + $.oc.foundation.element.addClass(ev.target, 'drag-over') + return + } + + var elementIsControl = this.elementIsControl(targetLi) + + if (elementIsControl && sourceIsContainer) { + // Do not allow dropping controls to themselves or their + // children controls. + if (sourceIsContainer && elementIsControl && this.dropTargetIsChildOf(targetLi, ev)) { + this.stopHighlightingTargets(targetLi, true) + return + } + + // Dragging from a container over another control. + // Highlight the other control. + $.oc.foundation.element.addClass(targetLi, 'drag-over') + + this.stopHighlightingTargets(targetLi, true) + + return + } + } + + FormBuilder.prototype.onDragLeave = function(ev) { + var targetLi = ev.target + + if (ev.target.tagName !== 'LI') { + targetLi = this.getClosestControl(ev.target) + } + + if (!targetLi || targetLi.tagName != 'LI') { + return + } + + if (this.targetIsPlaceholder(ev) && this.sourceIsContainer(ev)) { + // Dragging from a container over a placeholder. + // Stop highlighting the placeholder. + this.stopHighlightingTargets(ev.target) + + return + } + + if (this.elementIsControl(targetLi) && this.sourceIsContainer(ev)) { + // Dragging from a container over another control. + // Stop highlighting the other control. + var mousePosition = $.oc.foundation.event.pageCoordinates(ev) + + if (!this.elementContainsPoint(mousePosition, targetLi)) { + this.stopHighlightingTargets(targetLi) + } + } + } + + FormBuilder.prototype.onDragDrop = function(ev) { + var targetLi = ev.target + + if (ev.target.tagName !== 'LI') { + targetLi = this.getClosestControl(ev.target) + } + + if (!targetLi || targetLi.tagName != 'LI') { + return + } + + var elementIsControl = this.elementIsControl(targetLi), + sourceIsContainer = this.sourceIsContainer(ev) + + if ((elementIsControl || this.targetIsPlaceholder(ev)) && sourceIsContainer) { + this.stopHighlightingTargets(targetLi) + + if (this.dropTargetIsChildOf(targetLi, ev)) { + return + } + + // Dropped from a container to a placeholder or another control. + // Stop highlighting the placeholder, move the control. + this.dropFromContainerToPlaceholderOrControl(ev, targetLi) + return + } + } + + FormBuilder.prototype.onControlChange = function(ev) { + // Control has changed (with Inspector) - + // update the control markup with AJAX + + var li = ev.currentTarget, + properties = this.getControlProperties(li) + + this.setControlSpanFromProperties(li, properties) + this.updateControlBody(this.getControlId(li)) + + ev.stopPropagation() + return false + } + + FormBuilder.prototype.onControlLiveChange = function(ev) { + $(this.findForm(ev.currentTarget)).trigger('change') // Set modified state for the form + + var li = ev.currentTarget, + propertiesParsed = this.getControlProperties(li) + + this.setControlSpanFromProperties(li, propertiesParsed) + this.startUpdateControlBody(this.getControlId(li)) + + ev.stopPropagation() + return false + } + + FormBuilder.prototype.onAutocompleteItems = function(ev, data) { + if (data.propertyDefinition.fillFrom === 'model-fields') { + ev.preventDefault() + this.loadModelFields(ev.target, data.callback) + } + } + + FormBuilder.prototype.onDropdownOptions = function(ev, data) { + if (data.propertyDefinition.fillFrom === 'form-controls') { + this.getContainerFieldNames(ev.target, data.callback) + ev.preventDefault() + } + } + + FormBuilder.prototype.onRemoveControl = function(ev) { + this.removeControl($(ev.target).closest('li.control')) + + ev.preventDefault() + ev.stopPropagation() + + return false + } + + FormBuilder.prototype.onInspectorShowing = function(ev) { + if ($(ev.target).find('input[data-non-inspectable-control]').length > 0) { + ev.preventDefault() + return false + } + } + + FormBuilder.prototype.onPlaceholderClick = function(ev) { + this.displayControlPaletteForPlaceholder(ev.target) + ev.stopPropagation() + ev.preventDefault() + return false; + } + + $(document).ready(function(){ + // There is a single instance of the form builder. All operations + // are stateless, so instance properties or DOM references are not needed. + $.oc.builder.formbuilder.controller = new FormBuilder() + }) + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.tabs.js b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.tabs.js new file mode 100644 index 0000000..cb498b8 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/assets/js/formbuilder.tabs.js @@ -0,0 +1,286 @@ +/* + * Manages tabs in the form builder area. + */ ++function ($) { "use strict"; + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var TabManager = function() { + Base.call(this) + + this.init() + } + + TabManager.prototype = Object.create(BaseProto) + TabManager.prototype.constructor = TabManager + + // INTERNAL METHODS + // ============================ + + TabManager.prototype.init = function() { + this.registerHandlers() + } + + TabManager.prototype.registerHandlers = function() { + var $layoutBody = $('#layout-body') + + $layoutBody.on('click', 'li[data-builder-new-tab]', this.proxy(this.onNewTabClick)) + $layoutBody.on('click', 'div[data-builder-tab]', this.proxy(this.onTabClick)) + $layoutBody.on('click', 'div[data-builder-close-tab]', this.proxy(this.onTabCloseClick)) + $layoutBody.on('change livechange', 'ul.tabs > li div.inspector-trigger.tab-control', this.proxy(this.onTabChange)) + $layoutBody.on('hiding.oc.inspector', 'ul.tabs > li div.inspector-trigger.tab-control', this.proxy(this.onTabInspectorHiding)) + } + + TabManager.prototype.getTabList = function($tabControl) { + return $tabControl.find('> ul.tabs') + } + + TabManager.prototype.getPanelList = function($tabControl) { + return $tabControl.find('> ul.panels') + } + + TabManager.prototype.findTabControl = function($tab) { + return $tab.closest('div.tabs') + } + + TabManager.prototype.findTabPanel = function($tab) { + var $tabControl = this.findTabControl($tab), + tabIndex = $tab.index() + + return this.getPanelList($tabControl).find(' > li').eq(tabIndex) + } + + TabManager.prototype.findPanelTab = function($panel) { + var $tabControl = this.findTabControl($panel), + tabIndex = $panel.index() + + return this.getTabList($tabControl).find(' > li').eq(tabIndex) + } + + TabManager.prototype.findTabPanel = function($tab) { + var $tabControl = this.findTabControl($tab), + tabIndex = $tab.index() + + return this.getPanelList($tabControl).find(' > li').eq(tabIndex) + } + + TabManager.prototype.findTabForm = function(tab) { + return $(tab).closest('form') + } + + TabManager.prototype.getGlobalTabsProperties = function(tabsContainer) { + var properties = $(tabsContainer).find('.inspector-trigger.tab-control.global [data-inspector-values]').val() + + if (properties.length == 0) { + properties = '{}' + } + + return $.parseJSON(properties) + } + + /* + * Returns tab title an element belongs to + */ + TabManager.prototype.getElementTabTitle = function(element) { + var $panel = $(element).closest('li.tab-panel'), + $tab = this.findPanelTab($panel), + properties = $tab.find('[data-inspector-values]').val(), + propertiesParsed = $.parseJSON(properties) + + return propertiesParsed.title + } + + TabManager.prototype.tabHasControls = function($tab) { + return this.findTabPanel($tab).find('ul[data-control-list] li.control:not(.placeholder)').length > 0 + } + + TabManager.prototype.tabNameExists = function($tabList, name, $ignoreTab) { + var tabs = $tabList.get(0).children + + for (var i=0, len = tabs.length; i li[data-builder-new-tab]') + + $('[data-tab-title]', $newTab).text(tabName) + + $newTab.insertBefore($newTabControl) + this.getPanelList($tabControl).append(panelTemplate) + + this.gotoTab($newTab) + } + + TabManager.prototype.gotoTab = function($tab) { + var tabIndex = $tab.index(), + $tabControl = this.findTabControl($tab), + $tabList = this.getTabList($tabControl), + $panelList = this.getPanelList($tabControl) + + $('> li', $tabList).removeClass('active') + $tab.addClass('active') + + $('> li', $panelList).removeClass('active') + $('> li', $panelList).eq(tabIndex).addClass('active') + } + + TabManager.prototype.findInspectorContainer = function($element) { + var $containerRoot = $element.closest('[data-inspector-container]') + + return $containerRoot.find('.inspector-container') + } + + TabManager.prototype.closeTabInspectors = function($tab, $tabPanel) { + if ($tab.find('.inspector-open').length === 0 && $tabPanel.find('.inspector-open').length === 0) { + return + } + + var $inspectorContainer = this.findInspectorContainer($tab) + + $.oc.foundation.controlUtils.disposeControls($inspectorContainer.get(0)) + } + + TabManager.prototype.closeTabControlPalette = function($tab, $tabPanel) { + if ($tabPanel.find('.control-palette-open').length === 0) { + return + } + + var $inspectorContainer = this.findInspectorContainer($tab) + + $.oc.foundation.controlUtils.disposeControls($inspectorContainer.get(0)) + } + + TabManager.prototype.closeTab = function($tab) { + var $tabControl = this.findTabControl($tab) + + if (this.tabHasControls($tab)) { + if (!confirm($tabControl.data('tabCloseConfirmation'))) { + return + } + + $tab.trigger('change') + } + + var $prevTab = $tab.prev(), + $nextTab = $tab.next(), + $tabPanel = this.findTabPanel($tab) + + this.closeTabInspectors($tab, $tabPanel) + this.closeTabControlPalette($tab, $tabPanel) + + $tab.remove() + $tabPanel.remove() + + if ($prevTab.length > 0) { + this.gotoTab($prevTab) + } + else { + if ($nextTab.length > 0 && !$nextTab.hasClass('new-tab')) { + this.gotoTab($nextTab) + } + else { + this.createNewTab($tabControl) + } + } + } + + TabManager.prototype.updateTabProperties = function($tab) { + var properties = $tab.find('[data-inspector-values]').val(), + propertiesParsed = $.parseJSON(properties), + $form = this.findTabForm($tab), + pluginCode = $form.find('input[name=plugin_code]').val() + + $tab.find('[data-tab-title]').attr('data-localization-key', propertiesParsed.title) + + $.oc.builder.dataRegistry.getLocalizationString($form, pluginCode, propertiesParsed.title, function(title){ + $tab.find('[data-tab-title]').text(title) + }) + } + + // EVENT HANDLERS + // ============================ + + TabManager.prototype.onNewTabClick = function(ev) { + this.createNewTab($(ev.currentTarget).closest('div.tabs')) + + ev.stopPropagation() + ev.preventDefault() + + return false + } + + TabManager.prototype.onTabClick = function(ev) { + this.gotoTab($(ev.currentTarget).closest('li')) + + ev.stopPropagation() + ev.preventDefault() + + return false + } + + TabManager.prototype.onTabCloseClick = function(ev) { + this.closeTab($(ev.currentTarget).closest('li')) + + ev.stopPropagation() + ev.preventDefault() + + return false + } + + TabManager.prototype.onTabChange = function(ev) { + this.updateTabProperties($(ev.currentTarget).closest('li')) + } + + TabManager.prototype.onTabInspectorHiding = function(ev, data) { + var $tab = $(ev.currentTarget).closest('li'), + $tabControl = this.findTabControl($tab), + $tabList = this.getTabList($tabControl) + + if (this.tabNameExists($tabList, data.values.title, $tab)) { + alert($tabControl.data('tabAlreadyExists')) + + ev.preventDefault() + } + } + + $(document).ready(function(){ + // There is a single instance of the tabs manager. + $.oc.builder.formbuilder.tabManager = new TabManager() + }) + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_body.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_body.htm new file mode 100644 index 0000000..c6bd2b8 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_body.htm @@ -0,0 +1,34 @@ +
    +
    +
    + makePartial('buildingarea') ?> +
    + + +
    +
    +
    + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_buildingarea.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_buildingarea.htm new file mode 100644 index 0000000..a15e7a0 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_buildingarea.htm @@ -0,0 +1,9 @@ +
    +
    +
    +
    + makePartial('controlcontainer', ['fieldsConfiguration'=>$model->controls]) ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlbody.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlbody.htm new file mode 100644 index 0000000..1dfe6c9 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlbody.htm @@ -0,0 +1,26 @@ +
    + getPropertyValue($properties, 'label'); + $comment = $this->getPropertyValue($properties, 'oc.comment'); + + // Note - the label and comment elements should not have whitespace in the markup. + ?> +
    + +
    getPropertyValue($properties, 'oc.commentPosition') == 'above'): ?>
    + + + + + +
    getPropertyValue($properties, 'oc.commentPosition') == 'below'): ?>
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlcontainer.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlcontainer.htm new file mode 100644 index 0000000..eca3d0a --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlcontainer.htm @@ -0,0 +1,26 @@ +
    + + makePartial('controllist', [ + 'controls' => isset($fieldsConfiguration['fields']) ? $fieldsConfiguration['fields'] : [], + 'listName' => '' + ]) ?> + + makePartial('tabs', [ + 'type' => 'primary', + 'controls' => $this->getTabsFields('tabs', $fieldsConfiguration), + 'listName' => 'tabs', + 'tabsTitle' => trans('rainlab.builder::lang.form.tabs_primary'), + 'configuration' => [], + 'tabNameTemplate' => trans('rainlab.builder::lang.form.tab_name_template'), + ]) ?> + + makePartial('tabs', [ + 'type' => 'secondary', + 'controls' => $this->getTabsFields('secondaryTabs', $fieldsConfiguration), + 'listName' => 'secondaryTabs', + 'tabsTitle' => trans('rainlab.builder::lang.form.tabs_secondary'), + 'configuration' => [], + 'tabNameTemplate' => trans('rainlab.builder::lang.form.tab_name_template'), + ]) ?> + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controllist.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controllist.htm new file mode 100644 index 0000000..97d3b6a --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controllist.htm @@ -0,0 +1,40 @@ +
      + $controlConfig): + $controlRenderingInfo = $this->getControlRenderingInfo($controlName, $controlConfig, $prevConfig); + + $prevSpan = $controlConfig['span'] = $controlRenderingInfo['span']; + $prevConfig = $controlConfig; + ?> +
    • + data-inspectable="true" + + data-unknown + + draggable="true" + data-control-type="" + data-inspector-title="" + data-inspector-description=""> + + renderControlWrapper($controlRenderingInfo['type'], $controlRenderingInfo['properties'], $controlConfig) ?> + +
    • + +
    • + + +
    • + +
    • +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlpalette.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlpalette.htm new file mode 100644 index 0000000..05559ab --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlpalette.htm @@ -0,0 +1,33 @@ +
    +
    + +
    + +
    + +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlwrapper.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlwrapper.htm new file mode 100644 index 0000000..9256feb --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_controlwrapper.htm @@ -0,0 +1,14 @@ + + +
    + renderControlBody($type, $properties) ?> +
    + +renderControlStaticBody($type, $properties, $controlConfiguration) ?> + + + + +
    ×
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tab.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tab.htm new file mode 100644 index 0000000..140ed71 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tab.htm @@ -0,0 +1,22 @@ +
  • +
    +
    + +
    +
    + +
    + + + + + +
    + +
    ×
    +
  • \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabpanel.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabpanel.htm new file mode 100644 index 0000000..7c2d65c --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabpanel.htm @@ -0,0 +1,6 @@ +
  • + makePartial('controllist', [ + 'controls' => $controls, + 'listName' => $listName + ]) ?> +
  • \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabs.htm b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabs.htm new file mode 100644 index 0000000..016b28a --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/formbuilder/partials/_tabs.htm @@ -0,0 +1,66 @@ +
    +
    +
      + + + makePartial('tab', ['active'=>true, 'title'=>sprintf($tabNameTemplate, '1') ]) ?> + + + $tabControls): + $tabIndex++; + ?> + makePartial('tab', ['active'=>$tabIndex == 1, 'title'=>$tabName]) ?> + + + + +
    • +
    + +
      + + makePartial('tabpanel', ['controls' => [], 'listName'=>$listName, 'active'=>true]); ?> + + + $tabControls): + $tabIndex++; + ?> + makePartial('tabpanel', ['controls' => $tabControls, 'listName'=>$listName, 'active'=>$tabIndex == 1]); ?> + + + +
    + +
    +
    + + + +
    + + +
    + + + + +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/menueditor/assets/js/menubuilder.js b/server/plugins/rainlab/builder/formwidgets/menueditor/assets/js/menubuilder.js new file mode 100644 index 0000000..7a76446 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/menueditor/assets/js/menubuilder.js @@ -0,0 +1,230 @@ +/* + * Menu Builder widget class. + * + * There is only a single instance of the Menu Builder class and it handles + * as many menu builder user interfaces as needed. + * + */ ++function ($) { "use strict"; + + if ($.oc.builder.menubuilder === undefined) + $.oc.builder.menubuilder = {} + + var Base = $.oc.foundation.base, + BaseProto = Base.prototype + + var MenuBulder = function() { + Base.call(this) + + this.init() + } + + MenuBulder.prototype = Object.create(BaseProto) + MenuBulder.prototype.constructor = MenuBulder + + // INTERNAL METHODS + // ============================ + + MenuBulder.prototype.init = function() { + this.registerHandlers() + } + + MenuBulder.prototype.registerHandlers = function() { + $(document).on('change', '.builder-menu-editor li.item', this.proxy(this.onItemChange)) + $(document).on('dragged.list.sortable', '.builder-menu-editor li.item', this.proxy(this.onItemDragged)) + $(document).on('livechange', '.builder-menu-editor li.item', this.proxy(this.onItemLiveChange)) + } + + MenuBulder.prototype.getParentList = function(element) { + return $(element).closest('ul') + } + + MenuBulder.prototype.findForm = function(item) { + return $(item).closest('form') + } + + MenuBulder.prototype.getElementListItem = function(element) { + return $(element).closest('li') + } + + MenuBulder.prototype.getMenuBuilderControlElement = function(element) { + return $(element).closest('[data-control=builder-menu-editor]') + } + + MenuBulder.prototype.getTemplateMarkup = function(element, templateAttribute) { + var $builderControl = this.getMenuBuilderControlElement(element) + + return $builderControl.find('script['+templateAttribute+']').html() + } + + MenuBulder.prototype.getItemProperties = function(item) { + return $.parseJSON($(item).find('> input[data-inspector-values]').val()) + } + + MenuBulder.prototype.itemCodeExistsInList = function($list, code) { + var valueInputs = $list.find('> li.item > input[data-inspector-values]') + + for (var i=valueInputs.length-1; i>=0; i--) { + var value = String(valueInputs[i].value) + + if (value.length === 0) { + continue + } + + var properties = $.parseJSON(value) + + if (properties['code'] == code) { + return true + } + } + + return false + } + + MenuBulder.prototype.replacePropertyValue = function($item, property, value) { + var input = $item.find(' > input[data-inspector-values]'), + properties = $.parseJSON(input.val()) + + properties[property] = value + input.val(JSON.stringify(properties)) + } + + MenuBulder.prototype.generateItemCode = function($parentList, baseCode) { + var counter = 1, + code = baseCode + + while (this.itemCodeExistsInList($parentList, code)) { + counter ++ + code = baseCode + counter + } + + return code + } + + MenuBulder.prototype.updateItemVisualProperties = function(item) { + var properties = this.getItemProperties(item), + $item = $(item), + $form = this.findForm(item), + pluginCode = $form.find('input[name=plugin_code]').val() + + $item.find('> .item-container > span.title').attr('data-localization-key', properties.label) + + $.oc.builder.dataRegistry.getLocalizationString($item, pluginCode, properties.label, function(label){ + $item.find('> .item-container > span.title').text(label) + }) + + $item.find('> .item-container > i').attr('class', properties.icon) + } + + MenuBulder.prototype.findInspectorContainer = function($element) { + var $containerRoot = $element.closest('[data-inspector-container]') + + return $containerRoot.find('.inspector-container') + } + + // BUILDER API METHODS + // ============================ + + MenuBulder.prototype.addMainMenuItem = function(ev) { + var newItemMarkup = this.getTemplateMarkup(ev.currentTarget, 'data-main-menu-template'), + $item = $(newItemMarkup), + $list = this.getParentList(ev.currentTarget), + newCode = this.generateItemCode($list, 'main-menu-item') + + this.replacePropertyValue($item, 'code', newCode) + + this.getElementListItem(ev.currentTarget).before($item) + $(this.findForm(ev.currentTarget)).trigger('change') + } + + MenuBulder.prototype.addSideMenuItem = function(ev) { + var newItemMarkup = this.getTemplateMarkup(ev.currentTarget, 'data-side-menu-template'), + $item = $(newItemMarkup), + $list = this.getParentList(ev.currentTarget), + newCode = this.generateItemCode($list, 'side-menu-item') + + this.replacePropertyValue($item, 'code', newCode) + + this.getElementListItem(ev.currentTarget).before($item) + $(this.findForm(ev.currentTarget)).trigger('change') + } + + MenuBulder.prototype.getJson = function(form) { + var mainMenuItems = form.querySelectorAll('ul.builder-main-menu > li.item'), + result = [] + + for (var i=0,lenOuter=mainMenuItems.length; i < lenOuter; i++) { + var mainMenuItem = mainMenuItems[i], + mainMenuItemConfig = this.getItemProperties(mainMenuItem) + + if (mainMenuItemConfig['sideMenu'] !== undefined) { + delete mainMenuItemConfig['sideMenu'] + } + + var sideMenuItems = mainMenuItem.querySelectorAll('ul.builder-submenu > li.item') + for (var j=0,lenInner=sideMenuItems.length; j < lenInner; j++) { + var sideMenuItem = sideMenuItems[j], + sideMenuItemConfig = this.getItemProperties(sideMenuItem) + + if (mainMenuItemConfig['sideMenu'] === undefined) { + mainMenuItemConfig['sideMenu'] = [] + } + + mainMenuItemConfig['sideMenu'].push(sideMenuItemConfig) + } + + result.push(mainMenuItemConfig) + } + + return JSON.stringify(result) + } + + MenuBulder.prototype.deleteMenuItem = function(ev) { + var item = this.getElementListItem(ev.currentTarget) + + if ($(item).hasClass('inspector-open')) { + var $inspectorContainer = this.findInspectorContainer($(item)) + $.oc.foundation.controlUtils.disposeControls($inspectorContainer.get(0)) + } + + var subitems = item.get(0).querySelectorAll('li.inspector-open') + for (var i=subitems.length-1; i>=0; i--) { + var $inspectorContainer = this.findInspectorContainer($(subitems[i])) + $.oc.foundation.controlUtils.disposeControls($inspectorContainer.get(0)) + } + + $(this.findForm(ev.currentTarget)).trigger('change') + + $(item).remove() + } + + // EVENT HANDLERS + // ============================ + + MenuBulder.prototype.onItemLiveChange = function(ev) { + this.updateItemVisualProperties(ev.currentTarget) + + $(this.findForm(ev.currentTarget)).trigger('change') // Set modified state for the form + + ev.stopPropagation() + return false + } + + MenuBulder.prototype.onItemChange = function(ev) { + this.updateItemVisualProperties(ev.currentTarget) + + ev.stopPropagation() + return false + } + + MenuBulder.prototype.onItemDragged = function(ev) { + $(this.findForm(ev.target)).trigger('change') + } + + $(document).ready(function(){ + // There is a single instance of the form builder. All operations + // are stateless, so instance properties or DOM references are not needed. + $.oc.builder.menubuilder.controller = new MenuBulder() + }) + +}(window.jQuery); \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_body.htm b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_body.htm new file mode 100644 index 0000000..f5bbcfb --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_body.htm @@ -0,0 +1,28 @@ +
    +
    +
    + +
    +
    +
    +
    + makePartial('mainmenuitems', ['items' => $items]) ?> +
    +
    +
    + + + + +
    + +
    + + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitem.htm b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitem.htm new file mode 100644 index 0000000..529d122 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitem.htm @@ -0,0 +1,17 @@ +
  • +
    + + getItemArrayProperty($item, 'label'))) ?> + + × +
    + + + + + makePartial('submenuitems', ['items' => $this->getItemArrayProperty($item, 'sideMenu')]) ?> +
  • \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitems.htm b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitems.htm new file mode 100644 index 0000000..5661380 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_mainmenuitems.htm @@ -0,0 +1,15 @@ +
      + + makePartial('mainmenuitem', ['item' => $item]) ?> + + +
    • + + + + +
    • +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitem.htm b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitem.htm new file mode 100644 index 0000000..673b4d4 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitem.htm @@ -0,0 +1,15 @@ +
  • +
    + + getItemArrayProperty($item, 'label'))) ?> + × +
    + + + +
  • \ No newline at end of file diff --git a/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitems.htm b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitems.htm new file mode 100644 index 0000000..24ee8b5 --- /dev/null +++ b/server/plugins/rainlab/builder/formwidgets/menueditor/partials/_submenuitems.htm @@ -0,0 +1,17 @@ +
      + + + makePartial('submenuitem', ['item' => $item]) ?> + + + +
    • + + + + +
    • +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/lang/cs/lang.php b/server/plugins/rainlab/builder/lang/cs/lang.php new file mode 100644 index 0000000..ef74158 --- /dev/null +++ b/server/plugins/rainlab/builder/lang/cs/lang.php @@ -0,0 +1,637 @@ + [ + 'name' => 'Builder', + 'description' => 'Poskytuje vizuální nástroj pro tvorbu October pluginů.', + 'add' => 'Vytvořit plugin', + 'no_records' => 'Žádný plugin nenalezen', + 'no_description' => 'Bez popisu', + 'no_name' => 'Bez jména', + 'search' => 'Vyhledávání...', + 'filter_description' => 'Zobrazit všechny pluginy, nebo pouze vaše.', + 'settings' => 'Nastavení', + 'entity_name' => 'Plugin', + 'field_name' => 'Název', + 'field_author' => 'Autor', + 'field_description' => 'Popis', + 'field_icon' => 'Ikona pluginu', + 'field_plugin_namespace' => 'Jmenný prostor pluginu', + 'field_author_namespace' => 'Jmenný prostor autora', + 'field_namespace_description' => 'Jmenný prostor může obsahovat pouze znaky, číslice a měl by začínat písmenem. Například Blog.', + 'field_author_namespace_description' => 'Zadaný jmenný prostor nebude možno přes Builder poté změnit. Příklad jmenného prostoru: JohnSmith.', + 'tab_general' => 'Základní parametry', + 'tab_description' => 'Popis', + 'field_homepage' => 'Domovská URL pluginu', + 'no_description' => 'Tento plugin nemá žádný popisek', + 'error_settings_not_editable' => 'Nastavení tohoto pluginu nelze přes Builder měnit, protože nemá soubor plugin.yaml.', + 'update_hint' => 'Překlad názvu a popisku můžete měnit v menu Lokalizace.', + 'manage_plugins' => 'Tvorba a úprava pluginů.', + ], + 'author_name' => [ + 'title' => 'Jméno autora', + 'description' => 'Výchozí jméno autora pro nově vytvořené pluginy. Toto jméno však můžete změnit při vytváření nového pluginu, nebo poté v editaci.', + ], + 'author_namespace' => [ + 'title' => 'Jmenný prostor autora', + 'description' => 'Pokud budete chtít plugin umístit na stránkách OctoberCMS, jmenný prostor by se měl být pro všechny vaše pluginy shodný. Více detailů najdete v dokumentaci publikace pluginů.', + ], + 'database' => [ + 'menu_label' => 'Databáze', + 'no_records' => 'Žádné tabulky nebyly nalezeny', + 'search' => 'Vyhledávání...', + 'confirmation_delete_multiple' => 'Opravdu chcete odstranit vybrané tabulky?', + 'field_name' => 'Název databázové tabulky', + 'tab_columns' => 'Sloupce', + 'column_name_name' => 'Sloupec', + 'column_name_required' => 'Zadejte prosím název sloupce', + 'column_name_type' => 'Typ', + 'column_type_required' => 'Vyberte prosím typ sloupce', + 'column_name_length' => 'Délka', + 'column_validation_length' => "Délka by měla být zadaná číselně, nebo zadaná jako číslo a přesnost (10,2) pro desetinná čísla. Mezery nejsou povolené.", + 'column_validation_title' => 'V názvu sloupce mohou být pouze čísla, malá písmena a podtržítko.', + 'column_name_unsigned' => 'Bez znaménka', + 'column_name_nullable' => 'Nulový', + 'column_auto_increment' => 'AUTOINCR', + 'column_default' => 'Výchozí', + 'column_auto_primary_key' => 'PK', + 'tab_new_table' => 'Nová tabulka', + 'btn_add_column' => 'Přidat sloupec', + 'btn_delete_column' => 'Smazat sloupec', + 'confirm_delete' => 'Opravdu chcete smazat tuto tabulku?', + 'error_enum_not_supported' => 'Tabulka obsahuje sloupce s typem "enum" které Builder aktuálně nepodporuje.', + 'error_table_name_invalid_prefix' => "Název tabulky by měl začínat prefixem pluginu: ':prefix'.", + 'error_table_name_invalid_characters' => 'Formát názvu tabulky není správný, měl by obsahovat pouze písmena, číslice a nebo podtržítka. Název by měl začínat písmenem a neměl by obsahovat mezery.', + 'error_table_duplicate_column' => "Takový název sloupce již existuje: ':column'.", + 'error_table_auto_increment_in_compound_pk' => 'An auto-increment column cannot be a part of a compound primary key.', + 'error_table_mutliple_auto_increment' => 'Tabulka nemůže obsahovat více sloupců s auto-increment vlastností.', + 'error_table_auto_increment_non_integer' => 'Auto-increment sloupec by měl mít číselný typ.', + 'error_table_decimal_length' => "Zápis délky pro typ :type by měl být ve formátu '10,2', bez mezer.", + 'error_table_length' => 'Zápis délky pro typ :type by měl být zadaný jako číslo.', + 'error_unsigned_type_not_int' => "Chyba ve sloupci ':column'. Přiznak 'bez znaménka' můžete použít pouze pro číselné typy.", + 'error_integer_default_value' => "Chybná výchozí hodnota pro číselný sloupec ':column'. Povolené formáty jsou '10', '-10'.", + 'error_decimal_default_value' => "Chybná výchozí hodnota pro desetinný sloupec ':column'. Povolené formáty jsou '1.00', '-1.00'.", + 'error_boolean_default_value' => "Chybná výchozí hodnota pro pravdivostní sloupec ':column'. Povolené hodnoty jsou '0' and '1'.", + 'error_unsigned_negative_value' => "Výchozí hodnota pro sloupec bez znaménka ':column' nemůže být záporná.", + 'error_table_already_exists' => "Tabulka ':name' již v databázi existuje.", + ], + 'model' => [ + 'menu_label' => 'Modely', + 'entity_name' => 'Model', + 'no_records' => 'Žádný model nebyl nalezen', + 'search' => 'Vyhledávání...', + 'add' => 'Přidat...', + 'forms' => 'Formuláře', + 'lists' => 'Listování', + 'field_class_name' => 'Název třídy', + 'field_database_table' => 'Databazová tabulka', + 'error_class_name_exists' => 'Soubor modelu pro tuto třídu již existuje: :path', + 'add_form' => 'Přidat formulář', + 'add_list' => 'Přidat listování', + ], + 'form' => [ + 'saved'=> 'Formulář byl úspěšně uložen.', + 'confirm_delete' => 'Opravdu chcete smazat tento formulář?', + 'tab_new_form' => 'Nový formulář', + 'property_label_title' => 'Popisek', + 'property_label_required' => 'Zadejte prosím popisek pole.', + 'property_span_title' => 'Zarovnání', + 'property_comment_title' => 'Komentář', + 'property_comment_above_title' => 'Komentář nad', + 'property_default_title' => 'Výchozí', + 'property_checked_default_title' => 'Ve výchozím stavu zaškrtnuto', + 'property_css_class_title' => 'CSS třída', + 'property_css_class_description' => 'Volitelná CSS třída která se přiřadí ke kontejneru pole.', + 'property_disabled_title' => 'Neaktivní', + 'property_hidden_title' => 'Skrytý', + 'property_required_title' => 'Povinný', + 'property_field_name_title' => 'Název pole', + 'property_placeholder_title' => 'Zástupný text', + 'property_default_from_title' => 'Default from', + 'property_stretch_title' => 'Stretch', + 'property_stretch_description' => 'Definuje jestli se toto pole zmenší tak, aby se vešlo to rodičovského prvku na výšku.', + 'property_context_title' => 'Kontext', + 'property_context_description' => 'Definuje jaký kontext bude zobrazen při zobrazení tohoto pole.', + 'property_context_create' => 'Vytvořit', + 'property_context_update' => 'Upravit', + 'property_context_preview' => 'Náhled', + 'property_dependson_title' => 'Závisí na', + 'property_trigger_action' => 'Akce', + 'property_trigger_show' => 'Zobrazit', + 'property_trigger_hide' => 'Schovat', + 'property_trigger_enable' => 'Aktivní', + 'property_trigger_disable' => 'Neaktivní', + 'property_trigger_empty' => 'Prázdný', + 'property_trigger_field' => 'Pole', + 'property_trigger_field_description' => 'Defines the other field name that will trigger the action.', + 'property_trigger_condition' => 'Podmínka', + 'property_trigger_condition_description' => 'Determines the condition the specified field should satisfy for the condition to be considered "true". Supported values: checked, unchecked, value[somevalue].', + 'property_trigger_condition_checked' => 'Zaškrtnuté', + 'property_trigger_condition_unchecked' => 'Nezaškrtnuté', + 'property_trigger_condition_somevalue' => 'value[enter-the-value-here]', + 'property_preset_title' => 'Preset', + 'property_preset_description' => 'Allows the field value to be initially set by the value of another field, converted using the input preset converter.', + 'property_preset_field' => 'Pole', + 'property_preset_field_description' => 'Defines the other field name to source the value from.', + 'property_preset_type' => 'Typ', + 'property_preset_type_description' => 'Specifies the conversion type', + 'property_attributes_title' => 'Atributy', + 'property_attributes_description' => 'Custom HTML attributes to add to the form field element.', + 'property_container_attributes_title' => 'Kontejnér atributů', + 'property_container_attributes_description' => 'Custom HTML attributes to add to the form field container element.', + 'property_group_advanced' => 'Pokročilé', + 'property_dependson_description' => 'A list of other field names this field depends on, when the other fields are modified, this field will update. One field per line.', + 'property_trigger_title' => 'Trigger', + 'property_trigger_description' => 'Allows to change elements attributes such as visibility or value, based on another elements\' state.', + 'property_default_from_description' => 'Takes the default value from the value of another field.', + 'property_field_name_required' => 'Název pole je povinný', + 'property_field_name_regex' => 'Název pole může obsahovat pouze písmena, číslice, podtržítka, pomlčky a hranaté závorky.', + 'property_attributes_size' => 'Velikost', + 'property_attributes_size_tiny' => 'Nejmenší', + 'property_attributes_size_small' => 'Malý', + 'property_attributes_size_large' => 'Normální', + 'property_attributes_size_huge' => 'Veliký', + 'property_attributes_size_giant' => 'Obrovský', + 'property_comment_position' => 'Zobrazit komentář', + 'property_comment_position_above' => 'Nad prvkem', + 'property_comment_position_below' => 'Pod prvkem', + 'property_hint_path' => 'Hint partial path', + 'property_hint_path_description' => 'Path to a partial file that contains the hint text. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/partials/_hint.htm', + 'property_hint_path_required' => 'Please enter the hint partial path', + 'property_partial_path' => 'Cesta k dílčímu souboru', + 'property_partial_path_description' => 'Path to a partial file. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/partials/_partial.htm', + 'property_partial_path_required' => 'Prosím zadejte cestu k dílčímu souboru', + 'property_code_language' => 'Jazyk', + 'property_code_theme' => 'Téma', + 'property_theme_use_default' => 'Použít výchozí téma', + 'property_group_code_editor' => 'Editor kódu', + 'property_gutter' => 'Výplň', + 'property_gutter_show' => 'Viditelný', + 'property_gutter_hide' => 'Skrytý', + 'property_wordwrap' => 'Word wrap', + 'property_wordwrap_wrap' => 'Wrap', + 'property_wordwrap_nowrap' => 'Don\'t wrap', + 'property_fontsize' => 'Velikost písma', + 'property_codefolding' => 'Code folding', + 'property_codefolding_manual' => 'Manual', + 'property_codefolding_markbegin' => 'Mark begin', + 'property_codefolding_markbeginend' => 'Mark begin and end', + 'property_autoclosing' => 'Automatické zavírání', + 'property_enabled' => 'Aktivní', + 'property_disabled' => 'Neaktivní', + 'property_soft_tabs' => 'Soft tabs', + 'property_tab_size' => 'Velikost záložky', + 'property_readonly' => 'Pouze pro čtení', + 'property_use_default' => 'Use default settings', + 'property_options' => 'Volby', + 'property_prompt' => 'Prompt', + 'property_prompt_description' => 'Text to display for the create button.', + 'property_prompt_default' => 'Přidat nový prvek', + 'property_available_colors' => 'Dostupné barvy', + 'property_available_colors_description' => 'List of available colors in hex format (#FF0000). Leave empty for the default color set. Enter one value per line.', + 'property_datepicker_mode' => 'Mód', + 'property_datepicker_mode_date' => 'Datum', + 'property_datepicker_mode_datetime' => 'Datum a čas', + 'property_datepicker_mode_time' => 'Čas', + 'property_datepicker_min_date' => 'Min datum', + 'property_datepicker_min_date_description' => 'The minimum/earliest date that can be selected. Leave empty for the default value (2000-01-01).', + 'property_datepicker_max_date' => 'Max datum', + 'property_datepicker_max_date_description' => 'The maximum/latest date that can be selected. Leave empty for the default value (2020-12-31).', + 'property_datepicker_date_invalid_format' => 'Invalid date format. Use format YYYY-MM-DD.', + 'property_markdown_mode' => 'Mód', + 'property_markdown_mode_split' => 'Rozdělit', + 'property_markdown_mode_tab' => 'Záložka', + 'property_fileupload_mode' => 'Mód', + 'property_fileupload_mode_file' => 'Soubor', + 'property_fileupload_mode_image' => 'Obrázek', + 'property_group_fileupload' => 'Nahrávání obrázků', + 'property_fileupload_prompt' => 'Prompt', + 'property_fileupload_prompt_description' => 'Text to display for the upload button, applies to File mode only, optional.', + 'property_fileupload_image_width' => 'Šířka obrázku', + 'property_fileupload_image_width_description' => 'Optional parameter - images will be resized to this width. Applies to Image mode only.', + 'property_fileupload_invalid_dimension' => 'Invalid dimension value - please enter a number.', + 'property_fileupload_image_height' => 'Výška obrázku', + 'property_fileupload_image_height_description' => 'Optional parameter - images will be resized to this height. Applies to Image mode only.', + 'property_fileupload_file_types' => 'Typy souborů', + 'property_fileupload_file_types_description' => 'Optional comma separated list of file extensions that are accepted by the uploader. Eg: zip,txt', + 'property_fileupload_mime_types' => 'MIME typy', + 'property_fileupload_mime_types_description' => 'Optional comma separated list of MIME types that are accepted by the uploader, either as file extensions or fully qualified names. Eg: bin,txt', + 'property_fileupload_use_caption' => 'Použít popisek', + 'property_fileupload_use_caption_description' => 'Allows a title and description to be set for the file.', + 'property_fileupload_thumb_options' => 'Volby náhledu', + 'property_fileupload_thumb_options_description' => 'Manages options for the automatically generated thumbnails. Applies only for the Image mode.', + 'property_fileupload_thumb_mode' => 'Mód', + 'property_fileupload_thumb_auto' => 'Auto', + 'property_fileupload_thumb_exact' => 'Přesně', + 'property_fileupload_thumb_portrait' => 'Portrét', + 'property_fileupload_thumb_landscape' => 'Krajina', + 'property_fileupload_thumb_crop' => 'Crop', + 'property_fileupload_thumb_extension' => 'Přípona souboru', + 'property_name_from' => 'Name column', + 'property_name_from_description' => 'Relation column name to use for displaying a name.', + 'property_description_from' => 'Description column', + 'property_description_from_description' => 'Relation column name to use for displaying a description.', + 'property_recordfinder_prompt' => 'Prompt', + 'property_recordfinder_prompt_description' => 'Text to display when there is no record selected. The %s character represents the search icon. Leave empty for the default prompt.', + 'property_recordfinder_list' => 'List configuration', + 'property_recordfinder_list_description' => 'A reference to a list column definition file. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/lists/_list.yaml', + 'property_recordfinder_list_required' => 'Please provide a path to the list YAML file', + 'property_group_recordfinder' => 'Record finder', + 'property_mediafinder_mode' => 'Mód', + 'property_mediafinder_mode_file' => 'Soubor', + 'property_mediafinder_mode_image' => 'Obrázek', + 'property_mediafinder_prompt' => 'Prompt', + 'property_mediafinder_prompt_description' => 'Text to display when there is no item selected. The %s character represents the media manager icon. Leave empty for the default prompt.', + 'property_group_relation' => 'Relace', + 'property_relation_prompt' => 'Prompt', + 'property_relation_prompt_description' => 'Text to display when there is no available selections.', + 'control_group_standard' => 'Standardní', + 'control_group_widgets' => 'Widgets', + 'click_to_add_control' => 'Přidat prvek', + 'loading' => 'Načítám...', + 'control_text' => 'Text', + 'control_text_description' => 'Single line text box', + 'control_password' => 'Heslo', + 'control_password_description' => 'Single line password text field', + 'control_checkbox' => 'Checkbox', + 'control_checkbox_description' => 'Single checkbox', + 'control_switch' => 'Přepínač', + 'control_switch_description' => 'Single switchbox, an alternative for checkbox', + 'control_textarea' => 'Víceřádkové textové pole', + 'control_textarea_description' => 'Multiline text box with controllable height', + 'control_dropdown' => 'Dropdown', + 'control_dropdown_description' => 'Dropdown list with static or dynamic options', + 'control_unknown' => 'Unknown control type: :type', + 'control_repeater' => 'Repeater', + 'control_repeater_description' => 'Outputs a repeating set of form controls', + 'control_number' => 'Číslo', + 'control_number_description' => 'Single line text box that takes numbers only', + 'control_hint' => 'Hint', + 'control_hint_description' => 'Outputs a partial contents in a box that can be hidden by the user', + 'control_partial' => 'Partial', + 'control_partial_description' => 'Outputs a partial contents', + 'control_section' => 'Sekce', + 'control_section_description' => 'Displays a form section with heading and subheading', + 'control_radio' => 'Radio list', + 'control_radio_description' => 'A list of radio options, where only one item can be selected at a time', + 'control_radio_option_1' => 'Volba 1', + 'control_radio_option_2' => 'Volba 2', + 'control_checkboxlist' => 'Checkbox list', + 'control_checkboxlist_description' => 'A list of checkboxes, where multiple items can be selected', + 'control_codeeditor' => 'Editor kódu', + 'control_codeeditor_description' => 'Plaintext editor for formatted code or markup', + 'control_colorpicker' => 'Výběr barvy', + 'control_colorpicker_description' => 'A field for selecting a hexadecimal color value', + 'control_datepicker' => 'Výběr data', + 'control_datepicker_description' => 'Text field used for selecting date and times', + 'control_richeditor' => 'Rich editor', + 'control_richeditor_description' => 'Visual editor for rich formatted text, also known as a WYSIWYG editor', + 'control_markdown' => 'Markdown editor', + 'control_markdown_description' => 'Basic editor for Markdown formatted text', + 'control_fileupload' => 'Nahrávání souborů', + 'control_fileupload_description' => 'File uploader for images or regular files', + 'control_recordfinder' => 'Record finder', + 'control_recordfinder_description' => 'Field with details of a related record with the record search feature', + 'control_mediafinder' => 'Media finder', + 'control_mediafinder_description' => 'Field for selecting an item from the Media Manager library', + 'control_relation' => 'Relace', + 'control_relation_description' => 'Displays either a dropdown or checkbox list for selecting a related record', + 'error_file_name_required' => 'Please enter the form file name.', + 'error_file_name_invalid' => 'The file name can contain only Latin letters, digits, underscores, dots and hashes.', + 'span_left' => 'Doleva', + 'span_right' => 'Doprava', + 'span_full' => 'Plná šířka', + 'span_auto' => 'Automaticky', + 'empty_tab' => 'Prázdná záložka', + 'confirm_close_tab' => 'The tab contains controls which will be deleted. Continue?', + 'tab' => 'Form tab', + 'tab_title' => 'Název', + 'controls' => 'Prvky formuláře', + 'property_tab_title_required' => 'Název záložky je povinný.', + 'tabs_primary' => 'Primární záložka', + 'tabs_secondary' => 'Vedlejší záložka', + 'tab_stretch' => 'Stretch', + 'tab_stretch_description' => 'Specifies if this tabs container stretches to fit the parent height.', + 'tab_css_class' => 'CSS třída', + 'tab_css_class_description' => 'Přiřadí CSS třídu kontejneru záložky.', + 'tab_name_template' => 'Záložka %s', + 'tab_already_exists' => 'Záložka s tímto názvem již existuje.' + ], + 'list' => [ + 'tab_new_list' => 'Nový list', + 'saved'=> 'List byl úspěšně uložen.', + 'confirm_delete' => 'Opravdu chcete smazat tento list?', + 'tab_columns' => 'Sloupce', + 'btn_add_column' => 'Přidat sloupec', + 'btn_delete_column' => 'Smazat sloupec', + 'column_dbfield_label' => 'Field', + 'column_dbfield_required' => 'Please enter the model field', + 'column_name_label' => 'Popisek', + 'column_label_required' => 'Zadejte prosím popisek sloupce', + 'column_type_label' => 'Type', + 'column_type_required' => 'Zadejte prosím typ sloupce', + 'column_type_text' => 'Text', + 'column_type_number' => 'Číslo', + 'column_type_switch' => 'Switch', + 'column_type_datetime' => 'Datum a čas', + 'column_type_date' => 'Datum', + 'column_type_time' => 'Čas', + 'column_type_timesince' => 'Čas od', + 'column_type_timetense' => 'Čas do', + 'column_type_select' => 'Select', + 'column_type_partial' => 'Partial', + 'column_label_default' => 'Výchozí', + 'column_label_searchable' => 'Vyhledávání', + 'column_label_sortable' => 'Řazení', + 'column_label_invisible' => 'Neviditelný', + 'column_label_select' => 'Výběr', + 'column_label_relation' => 'Relace', + 'column_label_css_class' => 'CSS class', + 'column_label_width' => 'Šířka', + 'column_label_path' => 'Cesta', + 'column_label_format' => 'Formát', + 'column_label_value_from' => 'Hodnota od', + 'error_duplicate_column' => "Duplicitní pole sloupce: ':column'." + ], + 'controller' => [ + 'menu_label' => 'Kontroléry', + 'no_records' => 'Žádné kontrolery nebyly nalezeny', + 'controller' => 'Kontrolér', + 'behaviors' => 'Chování', + 'new_controller' => 'Nový kontrolér', + 'error_controller_has_no_behaviors' => 'The controller doesn\'t have configurable behaviors.', + 'error_invalid_yaml_configuration' => 'Error loading behavior configuration file: :file', + 'behavior_form_controller' => 'Možnost vytvářet a měnit záznamy', + 'behavior_form_controller_description' => 'Přidá možnost vytvářet a měnit záznamy pomocí formulářů. Toto chování vytvoří tři pohledy pro tvorbu položky, úpravu a náhled.', + 'property_behavior_form_placeholder' => '--vyberte formulář--', + 'property_behavior_form_name' => 'Název', + 'property_behavior_form_name_description' => 'The name of the object being managed by this form', + 'property_behavior_form_name_required' => 'Please enter the form name', + 'property_behavior_form_file' => 'Form configuration', + 'property_behavior_form_file_description' => 'Reference to a form field definition file', + 'property_behavior_form_file_required' => 'Please enter a path to the form configuration file', + 'property_behavior_form_model_class' => 'Modelová třída', + 'property_behavior_form_model_class_description' => 'A model class name, the form data is loaded and saved against this model.', + 'property_behavior_form_model_class_required' => 'Please select a model class', + 'property_behavior_form_default_redirect' => 'Výchozí přesměrování', + 'property_behavior_form_default_redirect_description' => 'A page to redirect to by default when the form is saved or cancelled.', + 'property_behavior_form_create' => 'Create record page', + 'property_behavior_form_redirect' => 'Přesměrování', + 'property_behavior_form_redirect_description' => 'A page to redirect to when a record is created.', + 'property_behavior_form_redirect_close' => 'Close redirect', + 'property_behavior_form_redirect_close_description' => 'A page to redirect to when a record is created and the close post variable is sent with the request.', + 'property_behavior_form_flash_save' => 'Save flash message', + 'property_behavior_form_flash_save_description' => 'Flash message to display when record is saved.', + 'property_behavior_form_page_title' => 'Page title', + 'property_behavior_form_update' => 'Update record page', + 'property_behavior_form_update_redirect' => 'Přesměrování', + 'property_behavior_form_create_redirect_description' => 'A page to redirect to when a record is saved.', + 'property_behavior_form_flash_delete' => 'Delete flash message', + 'property_behavior_form_flash_delete_description' => 'Flash message to display when record is deleted.', + 'property_behavior_form_preview' => 'Preview record page', + 'behavior_list_controller' => 'Možnost listování záznamy', + 'behavior_list_controller_description' => 'Vytvoří tabulku s řazením a vyhledávání s možností definovat odkaz na detail jednotlivého záznamu. Chování automaticky vytvoří akci kontroléru "index".', + 'property_behavior_list_title' => 'List title', + 'property_behavior_list_title_required' => 'Please enter the list title', + 'property_behavior_list_placeholder' => '--select list--', + 'property_behavior_list_model_class' => 'Modelová třída', + 'property_behavior_list_model_class_description' => 'A model class name, the list data is loaded from this model.', + 'property_behavior_form_model_class_placeholder' => '--select model--', + 'property_behavior_list_model_class_required' => 'Please select a model class', + 'property_behavior_list_model_placeholder' => '--select model--', + 'property_behavior_list_file' => 'List configuration file', + 'property_behavior_list_file_description' => 'Reference to a list definition file', + 'property_behavior_list_file_required' => 'Please enter a path to the list configuration file', + 'property_behavior_list_record_url' => 'Record URL', + 'property_behavior_list_record_url_description' => 'Link each list record to another page. Eg: users/update:id. The :id part is replaced with the record identifier.', + 'property_behavior_list_no_records_message' => 'No records message', + 'property_behavior_list_no_records_message_description' => 'A message to display when no records are found', + 'property_behavior_list_recs_per_page' => 'Records per page', + 'property_behavior_list_recs_per_page_description' => 'Records to display per page, use 0 for no pages. Default: 0', + 'property_behavior_list_recs_per_page_regex' => 'Records per page should be an integer value', + 'property_behavior_list_show_setup' => 'Show setup button', + 'property_behavior_list_show_sorting' => 'Show sorting', + 'property_behavior_list_default_sort' => 'Default sorting', + 'property_behavior_form_ds_column' => 'Column', + 'property_behavior_form_ds_direction' => 'Direction', + 'property_behavior_form_ds_asc' => 'Ascending', + 'property_behavior_form_ds_desc' => 'Descending', + 'property_behavior_list_show_checkboxes' => 'Show checkboxes', + 'property_behavior_list_onclick' => 'On click handler', + 'property_behavior_list_onclick_description' => 'Custom JavaScript code to execute when clicking on a record.', + 'property_behavior_list_show_tree' => 'Show tree', + 'property_behavior_list_show_tree_description' => 'Displays a tree hierarchy for parent/child records.', + 'property_behavior_list_tree_expanded' => 'Tree expanded', + 'property_behavior_list_tree_expanded_description' => 'Determines if tree nodes should be expanded by default.', + 'property_behavior_list_toolbar' => 'Toolbar', + 'property_behavior_list_toolbar_buttons' => 'Buttons partial', + 'property_behavior_list_toolbar_buttons_description' => 'Reference to a controller partial file with the toolbar buttons. Eg: list_toolbar', + 'property_behavior_list_search' => 'Search', + 'property_behavior_list_search_prompt' => 'Search prompt', + 'property_behavior_list_filter' => 'Filter configuration', + 'error_controller_not_found' => 'Original controller file is not found.', + 'error_invalid_config_file_name' => 'The behavior :class configuration file name (:file) contains invalid characters and cannot be loaded.', + 'error_file_not_yaml' => 'The behavior :class configuration file (:file) is not a YAML file. Only YAML configuration files are supported.', + 'saved' => 'Kontrolér byl úspěšně uložen.', + 'controller_name' => 'Název kontroléru', + 'controller_name_description' => 'Název kontroléru definuje název třídy a URL kontroléru v administraci. Použijte prosím standardní pojmenování PHP tříd - první symbol je velkým písmenem a zbytek normálně, například: Categories, Posts, Products.', + 'base_model_class' => 'Rodičovská třída', + 'base_model_class_description' => 'Vyberte třídu modelu ze které bude tento kontrolér dědit. Chování kontroléru můžete nastavit později.', + 'base_model_class_placeholder' => '--vyberte model--', + 'controller_behaviors' => 'Chování', + 'controller_behaviors_description' => 'Vyberte chování, které má kontrolér implementovat. Builder automaticky vytvoří požadované soubory.', + 'controller_permissions' => 'Oprávnění', + 'controller_permissions_description' => 'Vyberte uživatelská práva potřebná pro tento kontrolér. Práva můžete nastavit v sekci Oprávnění v levém menu. Toto nastavení můžete později změnit v PHP skriptu.', + 'controller_permissions_no_permissions' => 'Plugin nemá vytvořena žádná oprávnění.', + 'menu_item' => 'Aktivní položka menu', + 'menu_item_description' => 'Vyberte položku menu, která bude aktivní pro tento kontrolér. Toto nastavení můžete kdykoli změnit v PHP skriptu.', + 'menu_item_placeholder' => '--vyberte položku menu--', + 'error_unknown_behavior' => 'Třída chování :class není registrovaná v knihovně všech chování.', + 'error_behavior_view_conflict' => 'The selected behaviors provide conflicting views (:view) and cannot be used together in a controller.', + 'error_behavior_config_conflict' => 'The selected behaviors provide conflicting configuration files (:file) and cannot be used together in a controller.', + 'error_behavior_view_file_not_found' => 'View template :view of the behavior :class cannot be found.', + 'error_behavior_config_file_not_found' => 'Configuration template :file of the behavior :class cannot be found.', + 'error_controller_exists' => 'Controller file already exists: :file.', + 'error_controller_name_invalid' => 'Invalid controller name format. The name can only contain digits and Latin letters. The first symbol should be a capital Latin letter.', + 'error_behavior_view_file_exists' => 'Controller view file already exists: :view.', + 'error_behavior_config_file_exists' => 'Behavior configuration file already exists: :file.', + 'error_save_file' => 'Error saving conroller file: :file', + 'error_behavior_requires_base_model' => 'Behavior :behavior requires a base model class to be selected.', + 'error_model_doesnt_have_lists' => 'The selected model doesn\'t have any lists. Please create a list first.', + 'error_model_doesnt_have_forms' => 'The selected model doesn\'t have any forms. Please create a form first.' + ], + 'version' => [ + 'menu_label' => 'Verze', + 'no_records' => 'Žádné verze pluginu', + 'search' => 'Vyhledávání...', + 'tab' => 'Verze', + 'saved' => 'Verze byla úspěšně uložena.', + 'confirm_delete' => 'Opravdu chcete smazat vybranou verzi?', + 'tab_new_version' => 'Nová verze', + 'migration' => 'Migraci', + 'seeder' => 'Seeder', + 'custom' => 'Novou verzi', + 'apply_version' => 'Aplikovat tuto verzi', + 'applying' => 'Aplikování verze...', + 'rollback_version' => 'Vrátit na tuto verzi', + 'rolling_back' => 'Vracení zpět...', + 'applied' => 'Verze byla úspěšně aplikována.', + 'rolled_back' => 'Verze byla úspěšně vrácena zpět.', + 'hint_save_unapplied' => 'Byla uložena neaplikovaná verze. Neaplikované verze mohou být automaticky aplikovány po přihlášení do administrace jakýmkoli uživatelem a nebo pokud je databázová tabulka uložena v sekci Databáze.', + 'hint_rollback' => 'Vracení verze zpět rovněž vrátí zpět všechny novější verze. Neaplikované verze mohou být automaticky aplikovány po přihlášení do administrace jakýmkoli uživatelem a nebo pokud je databázová tabulka uložena v sekci Databáze.', + 'hint_apply' => 'Vracení verze zpět rovněž vrátí zpět všechny starší neaplikované verze.', + 'dont_show_again' => 'Znovu nezobrazovat', + 'save_unapplied_version' => 'Uložit neaplikovanou verzi' + ], + 'menu' => [ + 'menu_label' => 'Menu administrace', + 'tab' => 'Menu', + 'items' => 'Položky menu', + 'saved' => 'Menu byla úspěšně uložena.', + 'add_main_menu_item' => 'Přidat položku menu', + 'new_menu_item' => 'Položka menu', + 'add_side_menu_item' => 'Přidat pod-položku', + 'side_menu_item' => 'Side menu item', + 'property_label' => 'Popisek', + 'property_label_required' => 'Zadejte prosím popisek položky menu.', + 'property_url_required' => 'Zadejte prosím URL položky menu.', + 'property_url' => 'URL', + 'property_icon' => 'Ikona', + 'property_icon_required' => 'Vyberte prosím ikonu', + 'property_permissions' => 'Oprávnění', + 'property_order' => 'Pořadí', + 'property_order_invalid' => 'Zadejte prosím pořadí položky menu jako číslo.', + 'property_order_description' => 'Pořadí položek určuje jejich posloupnost v menu. Pokud není pořadí zadáno, automaticky se umístí položka nakonec. Výchozí hodnoty pořadí jsou násobky 100.', + 'property_attributes' => 'HTML attributy', + 'property_code' => 'Kód', + 'property_code_invalid' => 'Kód položky může obsahovat pouze písmena a číslice', + 'property_code_required' => 'Zadejte prosím kód položky menu.', + 'error_duplicate_main_menu_code' => "Kód položky hlavního menu je duplicitní: ':code'.", + 'error_duplicate_side_menu_code' => "Kód položky postranního menu je duplicitní: ':code'.", + ], + 'localization' => [ + 'menu_label' => 'Lokalizace', + 'language' => 'Zkratka jazyka', + 'strings' => 'Řetězce', + 'confirm_delete' => 'Opravdu chcete smazat soubor s překladem?', + 'tab_new_language' => 'Nový jazyk', + 'no_records' => 'Žádné jazyky nenalezeny', + 'saved' => 'Soubor s překladem byl úspěšně uložen.', + 'error_cant_load_file' => 'Nepodařilo se načíst požadovaný soubor protože neexistuje.', + 'error_bad_localization_file_contents' => 'Nepodařilo se načíst požadovaný soubor. Soubory s překladem mohou obsahovat pouze pole definující překlady řetězců.', + 'error_file_not_array' => 'Nepodařilo se načíst požadovaný soubor. Překladový soubor musí vrátit pole.', + 'save_error' => "Chyba ukládání souboru ':name'. Zkontrolujte prosím práva k zápisu.", + 'error_delete_file' => 'Chyba mazání překladového souboru.', + 'add_missing_strings' => 'Přidat chybějící řetězce', + 'copy' => 'Kopírovat', + 'add_missing_strings_label' => 'Vyberte jazyk ze kterého se zkopírují chybějící řetězce', + 'no_languages_to_copy_from' => 'Nejsou definovány žádné jazyky ze kterých bychom mohli zkopírovat řetězce.', + 'new_string_warning' => 'Nový řetězec nebo sekce', + 'structure_mismatch' => 'Struktura zdrojového jazykového souboru neodpovídá struktuře editovaného souboru. Některé nezávislé řetězce v editovaném souboru odpovídají sekcím ve zdrojovém souboru (nebo naopak) a nemohou být automaticky sloučeny.', + 'create_string' => 'Vytvořit nový řetězec', + 'string_key_label' => 'Klíč řetězce', + 'string_key_comment' => 'Zadejte klíč řetězce s použitím tečky jako oddělovače, například: plugin.search. Řetězec bude vytvořen ve výchozím jazykovém souboru pluginu.', + 'string_value' => 'Hodnota řetězce', + 'string_key_is_empty' => 'Musíte vyplnit klíč řetězce', + 'string_value_is_empty' => 'Musíte vyplnit hodnotu řetězce', + 'string_key_exists' => 'Takový klíč řetězce již existuje', + ], + 'permission' => [ + 'menu_label' => 'Oprávnění', + 'tab' => 'Oprávnění', + 'form_tab_permissions' => 'Oprávnění', + 'btn_add_permission' => 'Přidat oprávnění', + 'btn_delete_permission' => 'Smazat oprávnění', + 'column_permission_label' => 'Kód oprávnění', + 'column_permission_required' => 'Zadejte prosím kód oprávnění', + 'column_tab_label' => 'Název záložky', + 'column_tab_required' => 'Zadejte prosím název záložky oprávnění', + 'column_label_label' => 'Popisek', + 'column_label_required' => 'Zadejte prosím popisek oprávnění', + 'saved' => 'Oprávnění bylo úspěšně uloženo.', + 'error_duplicate_code' => "Kód oprávnění je duplicitní: ':code'.", + ], + 'yaml' => [ + 'save_error' => "Chyba ukládání souboru ':name'. Zkontrolujte prosím práva k zápisu.", + ], + 'common' => [ + 'error_file_exists' => "Soubor již existuje: ':path'.", + 'field_icon_description' => 'October používá ikony Font Autumn: http://octobercms.com/docs/ui/icon', + 'destination_dir_not_exists' => "Cílový adresář neexistuje: ':path'.", + 'error_make_dir' => "Chyba vytváření adresáře: ':name'.", + 'error_dir_exists' => "Adresář již existuje: ':path'.", + 'template_not_found' => "Soubor šablony nebyl nalezen: ':name'.", + 'error_generating_file' => "Chyba vytváření souboru: ':path'.", + 'error_loading_template' => "Chyba načtení souboru šablony: ':name'.", + 'select_plugin_first' => 'Nejdříve vyberte plugin. Pro zobrazení všech pluginů klikněte na symbol > na vrchu levého menu.', + 'plugin_not_selected' => 'Není vybrán žádný plugin', + 'add' => 'Přidat', + ], + 'migration' => [ + 'entity_name' => 'Migrace', + 'error_version_invalid' => 'The version should be specified in format 1.0.1', + 'field_version' => 'Verze', + 'field_description' => 'Popis migrace', + 'field_code' => 'Kód migrace', + 'field_code_comment' => 'Kód migrace je pouze pro čtení a slouží pouze pro náhled. Vlastní migraci můžete vytvořit v sekci Verze v levém menu.', + 'save_and_apply' => 'Uložit a aplikovat', + 'error_version_exists' => 'Tato verze migrace již existuje.', + 'error_script_filename_invalid' => 'The migration script file name can contain only Latin letters, digits and underscores. The name should start with a Latin letter and could not contain spaces.', + 'error_cannot_change_version_number' => 'Cannot change version number for an applied version.', + 'error_file_must_define_class' => 'Migration code should define a migration or seeder class. Leave the code field blank if you only want to update the version number.', + 'error_file_must_define_namespace' => 'Migration code should define a namespace. Leave the code field blank if you only want to update the version number.', + 'no_changes_to_save' => 'Žádné změny k uložení.', + 'error_namespace_mismatch' => "Migrační kód by měl používat jmenný prostor pluginu: :namespace", + 'error_migration_file_exists' => "Migrační soubor :file již existuje. Zadejte prosím jiný název třídy.", + 'error_cant_delete_applied' => 'This version has already been applied and cannot be deleted. Please rollback the version first.', + ], + 'components' => [ + 'list_title' => 'Record list', + 'list_description' => 'Displays a list of records for a selected model', + 'list_page_number' => 'Číslo stránky', + 'list_page_number_description' => 'This value is used to determine what page the user is on.', + 'list_records_per_page' => 'Records per page', + 'list_records_per_page_description' => 'Number of records to display on a single page. Leave empty to disable pagination.', + 'list_records_per_page_validation' => 'Invalid format of the records per page value. The value should be a number.', + 'list_no_records' => 'No records message', + 'list_no_records_description' => 'Message to display in the list in case if there are no records. Used in the default component\'s partial.', + 'list_no_records_default' => 'Žádné záznamy nebyly nalezeny', + 'list_sort_column' => 'Sort by column', + 'list_sort_column_description' => 'Model column the records should be ordered by', + 'list_sort_direction' => 'Směr', + 'list_display_column' => 'Display column', + 'list_display_column_description' => 'Column to display in the list. Used in the default component\'s partial.', + 'list_display_column_required' => 'Please select a display column.', + 'list_details_page' => 'Details page', + 'list_details_page_description' => 'Page to display record details.', + 'list_details_page_no' => '--no details page--', + 'list_sorting' => 'Řazení', + 'list_pagination' => 'Stránkování', + 'list_order_direction_asc' => 'Vzestupně', + 'list_order_direction_desc' => 'Sestupně', + 'list_model' => 'Modelová třída', + 'list_scope' => 'Scope', + 'list_scope_description' => 'Optional model scope to fetch the records', + 'list_scope_default' => '--select a scope, optional--', + 'list_details_page_link' => 'Link to the details page', + 'list_details_key_column' => 'Details key column', + 'list_details_key_column_description' => 'Model column to use as a record identifier in the details page links.', + 'list_details_url_parameter' => 'URL parameter name', + 'list_details_url_parameter_description' => 'Name of the details page URL parameter which takes the record identifier.', + 'details_title' => 'Record details', + 'details_description' => 'Displays record details for a selected model', + 'details_model' => 'Modelová třída', + 'details_identifier_value' => 'Identifier value', + 'details_identifier_value_description' => 'Identifier value to load the record from the database. Specify a fixed value or URL parameter name.', + 'details_identifier_value_required' => 'The identifier value is required', + 'details_key_column' => 'Key column', + 'details_key_column_description' => 'Model column to use as a record identifier for fetching the record from the database.', + 'details_key_column_required' => 'The key column name is required', + 'details_display_column' => 'Display column', + 'details_display_column_description' => 'Model column to display on the details page. Used in the default component\'s partial.', + 'details_display_column_required' => 'Please select a display column.', + 'details_not_found_message' => 'Not found message', + 'details_not_found_message_description' => 'Message to display if the record is not found. Used in the default component\'s partial.', + 'details_not_found_message_default' => 'Záznam nebyl nalezen', + ] +]; diff --git a/server/plugins/rainlab/builder/lang/en/lang.php b/server/plugins/rainlab/builder/lang/en/lang.php new file mode 100644 index 0000000..6512294 --- /dev/null +++ b/server/plugins/rainlab/builder/lang/en/lang.php @@ -0,0 +1,684 @@ + [ + 'name' => 'Builder', + 'description' => 'Provides visual tools for building October plugins.', + 'add' => 'Create plugin', + 'no_records' => 'No plugins found', + 'no_name' => 'No name', + 'search' => 'Search...', + 'filter_description' => 'Display all plugins or only your plugins.', + 'settings' => 'Settings', + 'entity_name' => 'Plugin', + 'field_name' => 'Name', + 'field_author' => 'Author', + 'field_description' => 'Description', + 'field_icon' => 'Plugin icon', + 'field_plugin_namespace' => 'Plugin namespace', + 'field_author_namespace' => 'Author namespace', + 'field_namespace_description' => 'Namespace can contain only Latin letters and digits and should start with a Latin letter. Example plugin namespace: Blog', + 'field_author_namespace_description' => 'You cannot change the namespaces with Builder after you create the plugin. Example author namespace: JohnSmith', + 'tab_general' => 'General parameters', + 'tab_description' => 'Description', + 'field_homepage' => 'Plugin homepage URL', + 'no_description' => 'No description provided for this plugin', + 'error_settings_not_editable' => 'Settings of this plugin cannot be edited with Builder.', + 'update_hint' => 'You can edit localized plugin\'s name and description on the Localization tab.', + 'manage_plugins' => 'Create and edit plugins', + ], + 'author_name' => [ + 'title' => 'Author name', + 'description' => 'Default author name to use for your new plugins. The author name is not fixed - you can change it in the plugins configuration at any time.', + ], + 'author_namespace' => [ + 'title' => 'Author namespace', + 'description' => 'If you develop for the Marketplace, the namespace should match the author code and cannot be changed. Refer to the documentation for details.', + ], + 'database' => [ + 'menu_label' => 'Database', + 'no_records' => 'No tables found', + 'search' => 'Search...', + 'confirmation_delete_multiple' => 'Delete the selected tables?', + 'field_name' => 'Table name', + 'tab_columns' => 'Columns', + 'column_name_name' => 'Column', + 'column_name_required' => 'Please provide the column name', + 'column_name_type' => 'Type', + 'column_type_required' => 'Please select the column type', + 'column_name_length' => 'Length', + 'column_validation_length' => 'The Length value should be integer or specified as precision and scale (10,2) for decimal columns. Spaces are not allowed in the length column.', + 'column_validation_title' => 'Only digits, lower-case Latin letters and underscores are allowed in column names', + 'column_name_unsigned' => 'Unsigned', + 'column_name_nullable' => 'Nullable', + 'column_auto_increment' => 'AUTOINCR', + 'column_default' => 'Default', + 'column_auto_primary_key' => 'PK', + 'tab_new_table' => 'New table', + 'btn_add_column' => 'Add column', + 'btn_delete_column' => 'Delete column', + 'btn_add_timestamps' => 'Add timestamps', + 'btn_add_soft_deleting' => 'Add soft deleting support', + 'timestamps_exist' => 'created_at and deleted_at columns already exist in the table.', + 'soft_deleting_exist' => 'deleted_at column already exists in the table.', + 'confirm_delete' => 'Delete the table?', + 'error_enum_not_supported' => 'The table contains column(s) with type "enum" which is not currently supported by the Builder.', + 'error_table_name_invalid_prefix' => "Table name should start with the plugin prefix: ':prefix'.", + 'error_table_name_invalid_characters' => 'Invalid table name. Table names should contain only Latin letters, digits and underscores. Names should start with a Latin letter and could not contain spaces.', + 'error_table_duplicate_column' => "Duplicate column name: ':column'.", + 'error_table_auto_increment_in_compound_pk' => 'An auto-increment column cannot be a part of a compound primary key.', + 'error_table_mutliple_auto_increment' => 'The table cannot contain multiple auto-increment columns.', + 'error_table_auto_increment_non_integer' => 'Auto-increment columns should have integer type.', + 'error_table_decimal_length' => "The Length parameter for :type type should be in format '10,2', without spaces.", + 'error_table_length' => 'The Length parameter for :type type should be specified as integer.', + 'error_unsigned_type_not_int' => "Error in the ':column' column. The Unsigned flag can be applied only to integer type columns.", + 'error_integer_default_value' => "Invalid default value for the integer column ':column'. The allowed formats are '10', '-10'.", + 'error_decimal_default_value' => "Invalid default value for the decimal or double column ':column'. The allowed formats are '1.00', '-1.00'.", + 'error_boolean_default_value' => "Invalid default value for the boolean column ':column'. The allowed values are '0' and '1'.", + 'error_unsigned_negative_value' => "The default value for the unsigned column ':column' can't be negative.", + 'error_table_already_exists' => "The table ':name' already exists in the database.", + 'error_table_name_too_long' => "The table name should not be longer than 64 characters.", + 'error_column_name_too_long' => "The column name ':column' is too long. Column names should not be longer than 64 characters." + ], + 'model' => [ + 'menu_label' => 'Models', + 'entity_name' => 'Model', + 'no_records' => 'No models found', + 'search' => 'Search...', + 'add' => 'Add...', + 'forms' => 'Forms', + 'lists' => 'Lists', + 'field_class_name' => 'Class name', + 'field_database_table' => 'Database table', + 'field_add_timestamps' => 'Add timestamp support', + 'field_add_timestamps_description' => 'The database table must have created_at and updated_at columns.', + 'field_add_soft_deleting' => 'Add soft deleting support', + 'field_add_soft_deleting_description' => 'The database table must have deleted_at column.', + 'error_class_name_exists' => 'Model file already exists for the specified class name: :path', + 'error_timestamp_columns_must_exist' => 'The database table must have created_at and updated_at columns.', + 'error_deleted_at_column_must_exist' => 'The database table must have deleted_at column.', + 'add_form' => 'Add form', + 'add_list' => 'Add list', + ], + 'form' => [ + 'saved' => 'Form saved', + 'confirm_delete' => 'Delete the form?', + 'tab_new_form' => 'New form', + 'property_label_title' => 'Label', + 'property_label_required' => 'Please specify the control label.', + 'property_span_title' => 'Span', + 'property_comment_title' => 'Comment', + 'property_comment_above_title' => 'Comment above', + 'property_default_title' => 'Default', + 'property_checked_default_title' => 'Checked by default', + 'property_css_class_title' => 'CSS class', + 'property_css_class_description' => 'Optional CSS class to assign to the field container.', + 'property_disabled_title' => 'Disabled', + 'property_hidden_title' => 'Hidden', + 'property_required_title' => 'Required', + 'property_field_name_title' => 'Field name', + 'property_placeholder_title' => 'Placeholder', + 'property_default_from_title' => 'Default from', + 'property_stretch_title' => 'Stretch', + 'property_stretch_description' => 'Specifies if this field stretches to fit the parent height.', + 'property_context_title' => 'Context', + 'property_context_description' => 'Specifies what form context should be used when displaying the field.', + 'property_context_create' => 'Create', + 'property_context_update' => 'Update', + 'property_context_preview' => 'Preview', + 'property_dependson_title' => 'Depends on', + 'property_trigger_action' => 'Action', + 'property_trigger_show' => 'Show', + 'property_trigger_hide' => 'Hide', + 'property_trigger_enable' => 'Enable', + 'property_trigger_disable' => 'Disable', + 'property_trigger_empty' => 'Empty', + 'property_trigger_field' => 'Field', + 'property_trigger_field_description' => 'Defines the other field name that will trigger the action.', + 'property_trigger_condition' => 'Condition', + 'property_trigger_condition_description' => 'Determines the condition the specified field should satisfy for the condition to be considered "true". Supported values: checked, unchecked, value[somevalue].', + 'property_trigger_condition_checked' => 'Checked', + 'property_trigger_condition_unchecked' => 'Unchecked', + 'property_trigger_condition_somevalue' => 'value[enter-the-value-here]', + 'property_preset_title' => 'Preset', + 'property_preset_description' => 'Allows the field value to be initially set by the value of another field, converted using the input preset converter.', + 'property_preset_field' => 'Field', + 'property_preset_field_description' => 'Defines the other field name to source the value from.', + 'property_preset_type' => 'Type', + 'property_preset_type_description' => 'Specifies the conversion type', + 'property_attributes_title' => 'Attributes', + 'property_attributes_description' => 'Custom HTML attributes to add to the form field element.', + 'property_container_attributes_title' => 'Container attributes', + 'property_container_attributes_description' => 'Custom HTML attributes to add to the form field container element.', + 'property_group_advanced' => 'Advanced', + 'property_dependson_description' => 'A list of other field names this field depends on, when the other fields are modified, this field will update. One field per line.', + 'property_trigger_title' => 'Trigger', + 'property_trigger_description' => 'Allows to change elements attributes such as visibility or value, based on another elements\' state.', + 'property_default_from_description' => 'Takes the default value from the value of another field.', + 'property_field_name_required' => 'The field name is required', + 'property_field_name_regex' => 'The field name can contain only Latin letters, digits, underscores, dashes and square brackets.', + 'property_attributes_size' => 'Size', + 'property_attributes_size_tiny' => 'Tiny', + 'property_attributes_size_small' => 'Small', + 'property_attributes_size_large' => 'Large', + 'property_attributes_size_huge' => 'Huge', + 'property_attributes_size_giant' => 'Giant', + 'property_comment_position' => 'Comment position', + 'property_comment_position_above' => 'Above', + 'property_comment_position_below' => 'Below', + 'property_hint_path' => 'Hint partial path', + 'property_hint_path_description' => 'Path to a partial file that contains the hint text. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/partials/_hint.htm', + 'property_hint_path_required' => 'Please enter the hint partial path', + 'property_partial_path' => 'Partial path', + 'property_partial_path_description' => 'Path to a partial file. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/partials/_partial.htm', + 'property_partial_path_required' => 'Please enter the partial path', + 'property_code_language' => 'Language', + 'property_code_theme' => 'Theme', + 'property_theme_use_default' => 'Use default theme', + 'property_group_code_editor' => 'Code editor', + 'property_gutter' => 'Gutter', + 'property_gutter_show' => 'Visible', + 'property_gutter_hide' => 'Hidden', + 'property_wordwrap' => 'Word wrap', + 'property_wordwrap_wrap' => 'Wrap', + 'property_wordwrap_nowrap' => 'Don\'t wrap', + 'property_fontsize' => 'Font size', + 'property_codefolding' => 'Code folding', + 'property_codefolding_manual' => 'Manual', + 'property_codefolding_markbegin' => 'Mark begin', + 'property_codefolding_markbeginend' => 'Mark begin and end', + 'property_autoclosing' => 'Auto closing', + 'property_enabled' => 'Enabled', + 'property_disabled' => 'Disabled', + 'property_soft_tabs' => 'Soft tabs', + 'property_tab_size' => 'Tab size', + 'property_readonly' => 'Read only', + 'property_use_default' => 'Use default settings', + 'property_options' => 'Options', + 'property_prompt' => 'Prompt', + 'property_prompt_description' => 'Text to display for the create button.', + 'property_prompt_default' => 'Add new item', + 'property_available_colors' => 'Available colors', + 'property_available_colors_description' => 'List of available colors in hex format (#FF0000). Leave empty for the default color set. Enter one value per line.', + 'property_datepicker_mode' => 'Mode', + 'property_datepicker_mode_date' => 'Date', + 'property_datepicker_mode_datetime' => 'Date and time', + 'property_datepicker_mode_time' => 'Time', + 'property_datepicker_min_date' => 'Min date', + 'property_datepicker_min_date_description' => 'The minimum/earliest date that can be selected. Leave empty for the default value (2000-01-01).', + 'property_datepicker_max_date' => 'Max date', + 'property_datepicker_max_date_description' => 'The maximum/latest date that can be selected. Leave empty for the default value (2020-12-31).', + 'property_datepicker_date_invalid_format' => 'Invalid date format. Use format YYYY-MM-DD.', + 'property_datepicker_year_range' => 'Year range', + 'property_datepicker_year_range_description' => 'Number of years either side (eg 10) or array of upper/lower range (eg [1900,2015]). Leave empty for the default value (10).', + 'property_datepicker_year_range_invalid_format' => 'Invalid year range format. Use number (eg "10") or array of upper/lower range (eg "[1900,2015]")', + 'property_markdown_mode' => 'Mode', + 'property_markdown_mode_split' => 'Split', + 'property_markdown_mode_tab' => 'Tab', + 'property_fileupload_mode' => 'Mode', + 'property_fileupload_mode_file' => 'File', + 'property_fileupload_mode_image' => 'Image', + 'property_group_fileupload' => 'File upload', + 'property_fileupload_prompt' => 'Prompt', + 'property_fileupload_prompt_description' => 'Text to display for the upload button, applies to File mode only, optional.', + 'property_fileupload_image_width' => 'Image width', + 'property_fileupload_image_width_description' => 'Optional parameter - images will be resized to this width. Applies to Image mode only.', + 'property_fileupload_invalid_dimension' => 'Invalid dimension value - please enter a number.', + 'property_fileupload_image_height' => 'Image height', + 'property_fileupload_image_height_description' => 'Optional parameter - images will be resized to this height. Applies to Image mode only.', + 'property_fileupload_file_types' => 'File types', + 'property_fileupload_file_types_description' => 'Optional comma separated list of file extensions that are accepted by the uploader. Eg: zip,txt', + 'property_fileupload_mime_types' => 'MIME types', + 'property_fileupload_mime_types_description' => 'Optional comma separated list of MIME types that are accepted by the uploader, either as file extensions or fully qualified names. Eg: bin,txt', + 'property_fileupload_use_caption' => 'Use caption', + 'property_fileupload_use_caption_description' => 'Allows a title and description to be set for the file.', + 'property_fileupload_thumb_options' => 'Thumbnail options', + 'property_fileupload_thumb_options_description' => 'Manages options for the automatically generated thumbnails. Applies only for the Image mode.', + 'property_fileupload_thumb_mode' => 'Mode', + 'property_fileupload_thumb_auto' => 'Auto', + 'property_fileupload_thumb_exact' => 'Exact', + 'property_fileupload_thumb_portrait' => 'Portrait', + 'property_fileupload_thumb_landscape' => 'Landscape', + 'property_fileupload_thumb_crop' => 'Crop', + 'property_fileupload_thumb_extension' => 'File extension', + 'property_name_from' => 'Name column', + 'property_name_from_description' => 'Relation column name to use for displaying a name.', + 'property_relation_select' => 'Select', + 'property_relation_select_description' => 'CONCAT multiple columns together for displaying a name', + 'property_description_from' => 'Description column', + 'property_description_from_description' => 'Relation column name to use for displaying a description.', + 'property_recordfinder_prompt' => 'Prompt', + 'property_recordfinder_prompt_description' => 'Text to display when there is no record selected. The %s character represents the search icon. Leave empty for the default prompt.', + 'property_recordfinder_list' => 'List configuration', + 'property_recordfinder_list_description' => 'A reference to a list column definition file. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/lists/_list.yaml', + 'property_recordfinder_list_required' => 'Please provide a path to the list YAML file', + 'property_group_recordfinder' => 'Record finder', + 'property_mediafinder_mode' => 'Mode', + 'property_mediafinder_mode_file' => 'File', + 'property_mediafinder_mode_image' => 'Image', + 'property_mediafinder_prompt' => 'Prompt', + 'property_mediafinder_prompt_description' => 'Text to display when there is no item selected. The %s character represents the media manager icon. Leave empty for the default prompt.', + 'property_mediafinder_image_width_description' => 'If using image type, the preview image will be displayed to this width, optional.', + 'property_mediafinder_image_height_description' => 'If using image type, the preview image will be displayed to this height, optional.', + 'property_group_relation' => 'Relation', + 'property_relation_prompt' => 'Prompt', + 'property_relation_prompt_description' => 'Text to display when there is no available selections.', + 'property_empty_option' => 'Empty option', + 'property_empty_option_description' => 'The empty option corresponds to the empty selection, but unlike the placeholder it can be reselected.', + 'property_max_items' => 'Max items', + 'property_max_items_description' => 'Maximum number of items to allow within the repeater.', + 'control_group_standard' => 'Standard', + 'control_group_widgets' => 'Widgets', + 'click_to_add_control' => 'Add control', + 'loading' => 'Loading...', + 'control_text' => 'Text', + 'control_text_description' => 'Single line text box', + 'control_password' => 'Password', + 'control_password_description' => 'Single line password text field', + 'control_checkbox' => 'Checkbox', + 'control_checkbox_description' => 'Single checkbox', + 'control_switch' => 'Switch', + 'control_switch_description' => 'Single switchbox, an alternative for checkbox', + 'control_textarea' => 'Text area', + 'control_textarea_description' => 'Multiline text box with controllable height', + 'control_dropdown' => 'Dropdown', + 'control_dropdown_description' => 'Dropdown list with static or dynamic options', + 'control_balloon-selector' => 'Balloon Selector', + 'control_balloon-selector_description' => 'List where only one item can be selected at a time with static or dynamic options', + 'control_unknown' => 'Unknown control type: :type', + 'control_repeater' => 'Repeater', + 'control_repeater_description' => 'Outputs a repeating set of form controls', + 'control_number' => 'Number', + 'control_number_description' => 'Single line text box that takes numbers only', + 'control_hint' => 'Hint', + 'control_hint_description' => 'Outputs a partial contents in a box that can be hidden by the user', + 'control_partial' => 'Partial', + 'control_partial_description' => 'Outputs a partial contents', + 'control_section' => 'Section', + 'control_section_description' => 'Displays a form section with heading and subheading', + 'control_radio' => 'Radio list', + 'control_radio_description' => 'A list of radio options, where only one item can be selected at a time', + 'control_radio_option_1' => 'Option 1', + 'control_radio_option_2' => 'Option 2', + 'control_checkboxlist' => 'Checkbox list', + 'control_checkboxlist_description' => 'A list of checkboxes, where multiple items can be selected', + 'control_codeeditor' => 'Code editor', + 'control_codeeditor_description' => 'Plaintext editor for formatted code or markup', + 'control_colorpicker' => 'Color picker', + 'control_colorpicker_description' => 'A field for selecting a hexadecimal color value', + 'control_datepicker' => 'Date picker', + 'control_datepicker_description' => 'Text field used for selecting date and times', + 'control_richeditor' => 'Rich editor', + 'control_richeditor_description' => 'Visual editor for rich formatted text, also known as a WYSIWYG editor', + 'control_markdown' => 'Markdown editor', + 'control_markdown_description' => 'Basic editor for Markdown formatted text', + 'control_fileupload' => 'File upload', + 'control_fileupload_description' => 'File uploader for images or regular files', + 'control_recordfinder' => 'Record finder', + 'control_recordfinder_description' => 'Field with details of a related record with the record search feature', + 'control_mediafinder' => 'Media finder', + 'control_mediafinder_description' => 'Field for selecting an item from the Media Manager library', + 'control_relation' => 'Relation', + 'control_relation_description' => 'Displays either a dropdown or checkbox list for selecting a related record', + 'error_file_name_required' => 'Please enter the form file name.', + 'error_file_name_invalid' => 'The file name can contain only Latin letters, digits, underscores, dots and hashes.', + 'span_left' => 'Left', + 'span_right' => 'Right', + 'span_full' => 'Full', + 'span_auto' => 'Auto', + 'empty_tab' => 'Empty tab', + 'confirm_close_tab' => 'The tab contains controls which will be deleted. Continue?', + 'tab' => 'Form tab', + 'tab_title' => 'Title', + 'controls' => 'Controls', + 'property_tab_title_required' => 'The tab title is required.', + 'tabs_primary' => 'Primary tabs', + 'tabs_secondary' => 'Secondary tabs', + 'tab_stretch' => 'Stretch', + 'tab_stretch_description' => 'Specifies if this tabs container stretches to fit the parent height.', + 'tab_css_class' => 'CSS class', + 'tab_css_class_description' => 'Assigns a CSS class to the tabs container.', + 'tab_name_template' => 'Tab %s', + 'tab_already_exists' => 'Tab with the specified title already exists.', + ], + 'list' => [ + 'tab_new_list' => 'New list', + 'saved' => 'List saved', + 'confirm_delete' => 'Delete the list?', + 'tab_columns' => 'Columns', + 'btn_add_column' => 'Add column', + 'btn_delete_column' => 'Delete column', + 'column_dbfield_label' => 'Field', + 'column_dbfield_required' => 'Please enter the model field', + 'column_name_label' => 'Label', + 'column_label_required' => 'Please provide the column label', + 'column_type_label' => 'Type', + 'column_type_required' => 'Please provide the column type', + 'column_type_text' => 'Text', + 'column_type_number' => 'Number', + 'column_type_switch' => 'Switch', + 'column_type_datetime' => 'Datetime', + 'column_type_date' => 'Date', + 'column_type_time' => 'Time', + 'column_type_timesince' => 'Time since', + 'column_type_timetense' => 'Time tense', + 'column_type_select' => 'Select', + 'column_type_partial' => 'Partial', + 'column_label_default' => 'Default', + 'column_label_searchable' => 'Search', + 'column_label_sortable' => 'Sort', + 'column_label_invisible' => 'Invisible', + 'column_label_select' => 'Select', + 'column_label_relation' => 'Relation', + 'column_label_css_class' => 'CSS class', + 'column_label_width' => 'Width', + 'column_label_path' => 'Path', + 'column_label_format' => 'Format', + 'column_label_value_from' => 'Value from', + 'error_duplicate_column' => "Duplicate column field name: ':column'.", + 'btn_add_database_columns' => 'Add database columns', + 'all_database_columns_exist' => 'All database columns are already defined in the list' + ], + 'controller' => [ + 'menu_label' => 'Controllers', + 'no_records' => 'No plugin controllers found', + 'controller' => 'Controller', + 'behaviors' => 'Behaviors', + 'new_controller' => 'New controller', + 'error_controller_has_no_behaviors' => 'The controller doesn\'t have configurable behaviors.', + 'error_invalid_yaml_configuration' => 'Error loading behavior configuration file: :file', + 'behavior_form_controller' => 'Form controller behavior', + 'behavior_form_controller_description' => 'Adds form functionality to a back-end page. The behavior provides three pages called Create, Update and Preview.', + 'property_behavior_form_placeholder' => '--select form--', + 'property_behavior_form_name' => 'Name', + 'property_behavior_form_name_description' => 'The name of the object being managed by this form', + 'property_behavior_form_name_required' => 'Please enter the form name', + 'property_behavior_form_file' => 'Form configuration', + 'property_behavior_form_file_description' => 'Reference to a form field definition file', + 'property_behavior_form_file_required' => 'Please enter a path to the form configuration file', + 'property_behavior_form_model_class' => 'Model class', + 'property_behavior_form_model_class_description' => 'A model class name, the form data is loaded and saved against this model.', + 'property_behavior_form_model_class_required' => 'Please select a model class', + 'property_behavior_form_default_redirect' => 'Default redirect', + 'property_behavior_form_default_redirect_description' => 'A page to redirect to by default when the form is saved or cancelled.', + 'property_behavior_form_create' => 'Create record page', + 'property_behavior_form_redirect' => 'Redirect', + 'property_behavior_form_redirect_description' => 'A page to redirect to when a record is created.', + 'property_behavior_form_redirect_close' => 'Close redirect', + 'property_behavior_form_redirect_close_description' => 'A page to redirect to when a record is created and the close post variable is sent with the request.', + 'property_behavior_form_flash_save' => 'Save flash message', + 'property_behavior_form_flash_save_description' => 'Flash message to display when record is saved.', + 'property_behavior_form_page_title' => 'Page title', + 'property_behavior_form_update' => 'Update record page', + 'property_behavior_form_update_redirect' => 'Redirect', + 'property_behavior_form_create_redirect_description' => 'A page to redirect to when a record is saved.', + 'property_behavior_form_flash_delete' => 'Delete flash message', + 'property_behavior_form_flash_delete_description' => 'Flash message to display when record is deleted.', + 'property_behavior_form_preview' => 'Preview record page', + 'behavior_list_controller' => 'List controller behavior', + 'behavior_list_controller_description' => 'Provides the sortable and searchable list with optional links on its records. The behavior automatically creates the controller action "index".', + 'property_behavior_list_title' => 'List title', + 'property_behavior_list_title_required' => 'Please enter the list title', + 'property_behavior_list_placeholder' => '--select list--', + 'property_behavior_list_model_class' => 'Model class', + 'property_behavior_list_model_class_description' => 'A model class name, the list data is loaded from this model.', + 'property_behavior_form_model_class_placeholder' => '--select model--', + 'property_behavior_list_model_class_required' => 'Please select a model class', + 'property_behavior_list_model_placeholder' => '--select model--', + 'property_behavior_list_file' => 'List configuration file', + 'property_behavior_list_file_description' => 'Reference to a list definition file', + 'property_behavior_list_file_required' => 'Please enter a path to the list configuration file', + 'property_behavior_list_record_url' => 'Record URL', + 'property_behavior_list_record_url_description' => 'Link each list record to another page. Eg: users/update:id. The :id part is replaced with the record identifier.', + 'property_behavior_list_no_records_message' => 'No records message', + 'property_behavior_list_no_records_message_description' => 'A message to display when no records are found', + 'property_behavior_list_recs_per_page' => 'Records per page', + 'property_behavior_list_recs_per_page_description' => 'Records to display per page, use 0 for no pages. Default: 0', + 'property_behavior_list_recs_per_page_regex' => 'Records per page should be an integer value', + 'property_behavior_list_show_setup' => 'Show setup button', + 'property_behavior_list_show_sorting' => 'Show sorting', + 'property_behavior_list_default_sort' => 'Default sorting', + 'property_behavior_form_ds_column' => 'Column', + 'property_behavior_form_ds_direction' => 'Direction', + 'property_behavior_form_ds_asc' => 'Ascending', + 'property_behavior_form_ds_desc' => 'Descending', + 'property_behavior_list_show_checkboxes' => 'Show checkboxes', + 'property_behavior_list_onclick' => 'On click handler', + 'property_behavior_list_onclick_description' => 'Custom JavaScript code to execute when clicking on a record.', + 'property_behavior_list_show_tree' => 'Show tree', + 'property_behavior_list_show_tree_description' => 'Displays a tree hierarchy for parent/child records.', + 'property_behavior_list_tree_expanded' => 'Tree expanded', + 'property_behavior_list_tree_expanded_description' => 'Determines if tree nodes should be expanded by default.', + 'property_behavior_list_toolbar' => 'Toolbar', + 'property_behavior_list_toolbar_buttons' => 'Buttons partial', + 'property_behavior_list_toolbar_buttons_description' => 'Reference to a controller partial file with the toolbar buttons. Eg: list_toolbar', + 'property_behavior_list_search' => 'Search', + 'property_behavior_list_search_prompt' => 'Search prompt', + 'property_behavior_list_filter' => 'Filter configuration', + 'behavior_reorder_controller' => 'Reorder controller behavior', + 'behavior_reorder_controller_description' => 'Provides features for sorting and reordering on its records. The behavior automatically creates the controller action "reorder".', + 'property_behavior_reorder_title' => 'Reorder title', + 'property_behavior_reorder_title_required' => 'Please enter the reorder title', + 'property_behavior_reorder_name_from' => 'Attribute name', + 'property_behavior_reorder_name_from_description' => 'Model\'s attribute that should be used as a label for each record.', + 'property_behavior_reorder_name_from_required' => 'Please enter the attribute name', + 'property_behavior_reorder_model_class' => 'Model class', + 'property_behavior_reorder_model_class_description' => 'A model class name, the reorder data is loaded from this model.', + 'property_behavior_reorder_model_class_placeholder' => '--select model--', + 'property_behavior_reorder_model_class_required' => 'Please select a model class', + 'property_behavior_reorder_model_placeholder' => '--select model--', + 'property_behavior_reorder_toolbar' => 'Toolbar', + 'property_behavior_reorder_toolbar_buttons' => 'Buttons partial', + 'property_behavior_reorder_toolbar_buttons_description' => 'Reference to a controller partial file with the toolbar buttons. Eg: reorder_toolbar', + 'error_controller_not_found' => 'Original controller file is not found.', + 'error_invalid_config_file_name' => 'The behavior :class configuration file name (:file) contains invalid characters and cannot be loaded.', + 'error_file_not_yaml' => 'The behavior :class configuration file (:file) is not a YAML file. Only YAML configuration files are supported.', + 'saved' => 'Controller saved', + 'controller_name' => 'Controller name', + 'controller_name_description' => 'Controller name defines the class name and URL of the controller\'s back-end pages. Standard PHP variable naming conventions apply. The first symbol should be a capital Latin letter. Examples: Categories, Posts, Products.', + 'base_model_class' => 'Base model class', + 'base_model_class_description' => 'Select a model class to use as a base model in behaviors that require or support models. You can configure the behaviors later.', + 'base_model_class_placeholder' => '--select model--', + 'controller_behaviors' => 'Behaviors', + 'controller_behaviors_description' => 'Select behaviors the controller should implement. Builder will create view files required for the behaviors automatically.', + 'controller_permissions' => 'Permissions', + 'controller_permissions_description' => 'Select user permissions that can access the controller views. Permissions can be defined on the Permissions tab of the Builder. You can change this option in the controller PHP script later.', + 'controller_permissions_no_permissions' => 'The plugin doesn\'t define any permissions.', + 'menu_item' => 'Active menu item', + 'menu_item_description' => 'Select a menu item to make active for the controller pages. You can change this option in the controller PHP script later.', + 'menu_item_placeholder' => '--select menu item--', + 'error_unknown_behavior' => 'The behavior class :class is not registered in the behavior library.', + 'error_behavior_view_conflict' => 'The selected behaviors provide conflicting views (:view) and cannot be used together in a controller.', + 'error_behavior_config_conflict' => 'The selected behaviors provide conflicting configuration files (:file) and cannot be used together in a controller.', + 'error_behavior_view_file_not_found' => 'View template :view of the behavior :class cannot be found.', + 'error_behavior_config_file_not_found' => 'Configuration template :file of the behavior :class cannot be found.', + 'error_controller_exists' => 'Controller file already exists: :file.', + 'error_controller_name_invalid' => 'Invalid controller name format. The name can only contain digits and Latin letters. The first symbol should be a capital Latin letter.', + 'error_behavior_view_file_exists' => 'Controller view file already exists: :view.', + 'error_behavior_config_file_exists' => 'Behavior configuration file already exists: :file.', + 'error_save_file' => 'Error saving conroller file: :file', + 'error_behavior_requires_base_model' => 'Behavior :behavior requires a base model class to be selected.', + 'error_model_doesnt_have_lists' => 'The selected model doesn\'t have any lists. Please create a list first.', + 'error_model_doesnt_have_forms' => 'The selected model doesn\'t have any forms. Please create a form first.', + ], + 'version' => [ + 'menu_label' => 'Versions', + 'no_records' => 'No plugin versions found', + 'search' => 'Search...', + 'tab' => 'Versions', + 'saved' => 'Version saved', + 'confirm_delete' => 'Delete the version?', + 'tab_new_version' => 'New version', + 'migration' => 'Migration', + 'seeder' => 'Seeder', + 'custom' => 'Increase the version number', + 'apply_version' => 'Apply version', + 'applying' => 'Applying...', + 'rollback_version' => 'Rollback version', + 'rolling_back' => 'Rolling back...', + 'applied' => 'Version applied', + 'rolled_back' => 'Version rolled back', + 'hint_save_unapplied' => 'You saved an unapplied version. Unapplied versions could be automatically applied when you or another user logs into the back-end or when a database table is saved in the Database section of the Builder.', + 'hint_rollback' => 'Rolling back a version will also roll back all versions newer than this version. Please note that unapplied versions could be automatically applied by the system when you or another user logs into the back-end or when a database table is saved in the Database section of the Builder.', + 'hint_apply' => 'Applying a version will also apply all older unapplied versions of the plugin.', + 'dont_show_again' => 'Don\'t show again', + 'save_unapplied_version' => 'Save unapplied version', + ], + 'menu' => [ + 'menu_label' => 'Backend Menu', + 'tab' => 'Menus', + 'items' => 'Menu items', + 'saved' => 'Menus saved', + 'add_main_menu_item' => 'Add main menu item', + 'new_menu_item' => 'Menu Item', + 'add_side_menu_item' => 'Add sub-item', + 'side_menu_item' => 'Side menu item', + 'property_label' => 'Label', + 'property_label_required' => 'Please enter the menu item labels.', + 'property_url_required' => 'Please enter the menu item URL', + 'property_url' => 'URL', + 'property_icon' => 'Icon', + 'property_icon_required' => 'Please select an icon', + 'property_permissions' => 'Permissions', + 'property_order' => 'Order', + 'property_order_invalid' => 'Please enter the menu item order as integer value.', + 'property_order_description' => 'Menu item order manages its position in the menu. If the order is not provided, the item will be placed to the end of the menu. The default order values have the increment of 100.', + 'property_attributes' => 'HTML attributes', + 'property_code' => 'Code', + 'property_code_invalid' => 'The code should contain only Latin letter and digits', + 'property_code_required' => 'Please enter the menu item code.', + 'error_duplicate_main_menu_code' => "Duplicate main menu item code: ':code'.", + 'error_duplicate_side_menu_code' => "Duplicate side menu item code: ':code'.", + ], + 'localization' => [ + 'menu_label' => 'Localization', + 'language' => 'Language', + 'strings' => 'Strings', + 'confirm_delete' => 'Delete the language?', + 'tab_new_language' => 'New language', + 'no_records' => 'No languages found', + 'saved' => 'Language file saved', + 'error_cant_load_file' => 'Cannot load the requested language file - file not found.', + 'error_bad_localization_file_contents' => 'Cannot load the requested language file. Language files can only contain array definitions and strings.', + 'error_file_not_array' => 'Cannot load the requested language file. Language files should return an array.', + 'save_error' => "Error saving file ':name'. Please check write permissions.", + 'error_delete_file' => 'Error deleting localization file.', + 'add_missing_strings' => 'Add missing strings', + 'copy' => 'Copy', + 'add_missing_strings_label' => 'Select language to copy missing strings from', + 'no_languages_to_copy_from' => 'There are no other languages to copy strings from.', + 'new_string_warning' => 'New string or section', + 'structure_mismatch' => 'The structure of the source language file doesn\'t match the structure of the file being edited. Some individual strings in the edited file correspond to sections in the source file (or vice versa) and cannot be merged automatically.', + 'create_string' => 'Create new string', + 'string_key_label' => 'String key', + 'string_key_comment' => 'Enter the string key using period as a section separator. For example: plugin.search. The string will be created in the plugin\'s default language localization file.', + 'string_value' => 'String value', + 'string_key_is_empty' => 'String key should not be empty', + 'string_key_is_a_string' => ':key is a string and cannot contain other strings.', + 'string_value_is_empty' => 'String value should not be empty', + 'string_key_exists' => 'The string key already exists', + ], + 'permission' => [ + 'menu_label' => 'Permissions', + 'tab' => 'Permissions', + 'form_tab_permissions' => 'Permissions', + 'btn_add_permission' => 'Add permission', + 'btn_delete_permission' => 'Delete permission', + 'column_permission_label' => 'Permission code', + 'column_permission_required' => 'Please enter the permission code', + 'column_tab_label' => 'Tab title', + 'column_tab_required' => 'Please enter the permission tab title', + 'column_label_label' => 'Label', + 'column_label_required' => 'Please enter the permission label', + 'saved' => 'Permissions saved', + 'error_duplicate_code' => "Duplicate permission code: ':code'.", + ], + 'yaml' => [ + 'save_error' => "Error saving file ':name'. Please check write permissions.", + ], + 'common' => [ + 'error_file_exists' => "File already exists: ':path'.", + 'field_icon_description' => 'October uses Font Autumn icons: http://octobercms.com/docs/ui/icon', + 'destination_dir_not_exists' => "The destination directory doesn't exist: ':path'.", + 'error_make_dir' => "Error creating directory: ':name'.", + 'error_dir_exists' => "Directory already exists: ':path'.", + 'template_not_found' => "Template file is not found: ':name'.", + 'error_generating_file' => "Error generating file: ':path'.", + 'error_loading_template' => "Error loading template file: ':name'.", + 'select_plugin_first' => 'Please select a plugin first. To see the plugin list click the > icon on the left sidebar.', + 'plugin_not_selected' => 'Plugin is not selected', + 'add' => 'Add', + ], + 'migration' => [ + 'entity_name' => 'Migration', + 'error_version_invalid' => 'The version should be specified in format 1.0.1', + 'field_version' => 'Version', + 'field_description' => 'Description', + 'field_code' => 'Code', + 'field_code_comment' => 'The migration code is read-only and for the preview purpose only. You can create custom migrations manually in the Versions section of the Builder.', + 'save_and_apply' => 'Save & Apply', + 'error_version_exists' => 'The migration version already exists.', + 'error_script_filename_invalid' => 'The migration script file name can contain only Latin letters, digits and underscores. The name should start with a Latin letter and could not contain spaces.', + 'error_cannot_change_version_number' => 'Cannot change version number for an applied version.', + 'error_file_must_define_class' => 'Migration code should define a migration or seeder class. Leave the code field blank if you only want to update the version number.', + 'error_file_must_define_namespace' => 'Migration code should define a namespace. Leave the code field blank if you only want to update the version number.', + 'no_changes_to_save' => 'There are no changes to save.', + 'error_namespace_mismatch' => "The migration code should use the plugin namespace: :namespace", + 'error_migration_file_exists' => "Migration file :file already exists. Please use another class name.", + 'error_cant_delete_applied' => 'This version has already been applied and cannot be deleted. Please rollback the version first.', + ], + 'components' => [ + 'list_title' => 'Record list', + 'list_description' => 'Displays a list of records for a selected model', + 'list_page_number' => 'Page number', + 'list_page_number_description' => 'This value is used to determine what page the user is on.', + 'list_records_per_page' => 'Records per page', + 'list_records_per_page_description' => 'Number of records to display on a single page. Leave empty to disable pagination.', + 'list_records_per_page_validation' => 'Invalid format of the records per page value. The value should be a number.', + 'list_no_records' => 'No records message', + 'list_no_records_description' => 'Message to display in the list in case if there are no records. Used in the default component\'s partial.', + 'list_no_records_default' => 'No records found', + 'list_sort_column' => 'Sort by column', + 'list_sort_column_description' => 'Model column the records should be ordered by', + 'list_sort_direction' => 'Direction', + 'list_display_column' => 'Display column', + 'list_display_column_description' => 'Column to display in the list. Used in the default component\'s partial.', + 'list_display_column_required' => 'Please select a display column.', + 'list_details_page' => 'Details page', + 'list_details_page_description' => 'Page to display record details.', + 'list_details_page_no' => '--no details page--', + 'list_sorting' => 'Sorting', + 'list_pagination' => 'Pagination', + 'list_order_direction_asc' => 'Ascending', + 'list_order_direction_desc' => 'Descending', + 'list_model' => 'Model class', + 'list_scope' => 'Scope', + 'list_scope_description' => 'Optional model scope to fetch the records', + 'list_scope_default' => '--select a scope, optional--', + 'list_scope_value' => 'Scope value', + 'list_scope_value_description' => 'Optional value to pass to the model scope', + 'list_details_page_link' => 'Link to the details page', + 'list_details_key_column' => 'Details key column', + 'list_details_key_column_description' => 'Model column to use as a record identifier in the details page links.', + 'list_details_url_parameter' => 'URL parameter name', + 'list_details_url_parameter_description' => 'Name of the details page URL parameter which takes the record identifier.', + 'details_title' => 'Record details', + 'details_description' => 'Displays record details for a selected model', + 'details_model' => 'Model class', + 'details_identifier_value' => 'Identifier value', + 'details_identifier_value_description' => 'Identifier value to load the record from the database. Specify a fixed value or URL parameter name.', + 'details_identifier_value_required' => 'The identifier value is required', + 'details_key_column' => 'Key column', + 'details_key_column_description' => 'Model column to use as a record identifier for fetching the record from the database.', + 'details_key_column_required' => 'The key column name is required', + 'details_display_column' => 'Display column', + 'details_display_column_description' => 'Model column to display on the details page. Used in the default component\'s partial.', + 'details_display_column_required' => 'Please select a display column.', + 'details_not_found_message' => 'Not found message', + 'details_not_found_message_description' => 'Message to display if the record is not found. Used in the default component\'s partial.', + 'details_not_found_message_default' => 'Record not found', + ], + 'validation' => [ + 'reserved' => ':attribute cannot be a PHP reserved keyword' + ] +]; diff --git a/server/plugins/rainlab/builder/lang/es/lang.php b/server/plugins/rainlab/builder/lang/es/lang.php new file mode 100644 index 0000000..3cc6b83 --- /dev/null +++ b/server/plugins/rainlab/builder/lang/es/lang.php @@ -0,0 +1,653 @@ + [ + 'name' => 'Builder', + 'description' => 'Proporciona herramientas visuales para la construcción de plugins de October.', + 'add' => 'Crear plugin', + 'no_records' => 'No se encuentran plugins', + 'no_name' => 'Sin nombre', + 'search' => 'Buscar...', + 'filter_description' => 'Mostrar todos los plugins o sólo tus plugins.', + 'settings' => 'Configuración', + 'entity_name' => 'Plugin', + 'field_name' => 'Nombre', + 'field_author' => 'Autor', + 'field_description' => 'Descripción', + 'field_icon' => 'Icono plugin', + 'field_plugin_namespace' => 'Espacio de nombres de plugin', + 'field_author_namespace' => 'Espacio de nombres de autor', + 'field_namespace_description' => 'Namespace can contain only Latin letters and digits and should start with a Latin letter. Example plugin namespace: Blog', + 'field_author_namespace_description' => 'You cannot change the namespaces with Builder after you create the plugin. Example author namespace: JohnSmith', + 'tab_general' => 'Parametros generales', + 'tab_description' => 'Descripción', + 'field_homepage' => 'Plugin homepage URL', + 'no_description' => 'No hay descripción proporcionada para este plugin', + 'error_settings_not_editable' => 'Configuración de este plugin no se pueden editar con el Builder.', + 'update_hint' => 'Puedes editar el nombre de plugins y descripción localizada en la pestaña de localizaciones.', + 'manage_plugins' => 'Crear y editar plugins', + ], + 'author_name' => [ + 'title' => 'Nombre del autor', + 'description' => 'Por defecto el nombre del autor a utilizar para sus nuevos plugins. El nombre del autor no es fijo - se puede cambiar en la configuración de los plugins en cualquier momento.', + ], + 'author_namespace' => [ + 'title' => 'Espacio de nombres', + 'description' => 'Si desarrolla para el Marketplace, el espacio de nombres debe coincidir con el código de autor y no puede ser cambiado. Consulte la documentación para más detalles.', + ], + 'database' => [ + 'menu_label' => 'Base de datos', + 'no_records' => 'Tablas no encontradas', + 'search' => 'Buscar...', + 'confirmation_delete_multiple' => '¿Eliminar las tablas seleccionadas?', + 'field_name' => 'Nombre de la tabla', + 'tab_columns' => 'Columnas', + 'column_name_name' => 'Columna', + 'column_name_required' => 'Please provide the column name', + 'column_name_type' => 'Tipo', + 'column_type_required' => 'Please select the column type', + 'column_name_length' => 'Length', + 'column_validation_length' => 'The Length value should be integer or specified as precision and scale (10,2) for decimal columns. Spaces are not allowed in the length column.', + 'column_validation_title' => 'Only digits, lower-case Latin letters and underscores are allowed in column names', + 'column_name_unsigned' => 'Unsigned', + 'column_name_nullable' => 'Nullable', + 'column_auto_increment' => 'AUTOINCR', + 'column_default' => 'Default', + 'column_auto_primary_key' => 'PK', + 'tab_new_table' => 'Nueva tabla', + 'btn_add_column' => 'Añadir columna', + 'btn_delete_column' => 'Borrar columna', + 'confirm_delete' => '¿Borrar la tabla?', + 'error_enum_not_supported' => 'The table contains column(s) with type "enum" which is not currently supported by the Builder.', + 'error_table_name_invalid_prefix' => "Table name should start with the plugin prefix: ':prefix'.", + 'error_table_name_invalid_characters' => 'Invalid table name. Table names should contain only Latin letters, digits and underscores. Names should start with a Latin letter and could not contain spaces.', + 'error_table_duplicate_column' => "Duplicate column name: ':column'.", + 'error_table_auto_increment_in_compound_pk' => 'An auto-increment column cannot be a part of a compound primary key.', + 'error_table_mutliple_auto_increment' => 'The table cannot contain multiple auto-increment columns.', + 'error_table_auto_increment_non_integer' => 'Auto-increment columns should have integer type.', + 'error_table_decimal_length' => "The Length parameter for :type type should be in format '10,2', without spaces.", + 'error_table_length' => 'The Length parameter for :type type should be specified as integer.', + 'error_unsigned_type_not_int' => "Error in the ':column' column. The Unsigned flag can be applied only to integer type columns.", + 'error_integer_default_value' => "Invalid default value for the integer column ':column'. The allowed formats are '10', '-10'.", + 'error_decimal_default_value' => "Invalid default value for the decimal or double column ':column'. The allowed formats are '1.00', '-1.00'.", + 'error_boolean_default_value' => "Invalid default value for the boolean column ':column'. The allowed values are '0' and '1'.", + 'error_unsigned_negative_value' => "The default value for the unsigned column ':column' can't be negative.", + 'error_table_already_exists' => "La tabla ':name' ya existe en la base de datos.", + ], + 'model' => [ + 'menu_label' => 'Modelos', + 'entity_name' => 'Modelo', + 'no_records' => 'Modelos no encontrados', + 'search' => 'Buscar...', + 'add' => 'Añadir...', + 'forms' => 'Formularios', + 'lists' => 'Listas', + 'field_class_name' => 'Nombre Clase', + 'field_database_table' => 'Tabla de base de datos', + 'error_class_name_exists' => 'Ya existe el archivo modelo para el nombre de clase especificado: :path', + 'add_form' => 'Añadir formulario', + 'add_list' => 'Añadir lista', + ], + 'form' => [ + 'saved' => 'Formulario salvado', + 'confirm_delete' => '¿Borrar el formulario?', + 'tab_new_form' => 'Nuevo formulario', + 'property_label_title' => 'Etiqueta', + 'property_label_required' => 'Please specify the control label.', + 'property_span_title' => 'Span', + 'property_comment_title' => 'Commentario', + 'property_comment_above_title' => 'Comment above', + 'property_default_title' => 'Default', + 'property_checked_default_title' => 'Checked by default', + 'property_css_class_title' => 'CSS class', + 'property_css_class_description' => 'Optional CSS class to assign to the field container.', + 'property_disabled_title' => 'Disabled', + 'property_hidden_title' => 'Hidden', + 'property_required_title' => 'Required', + 'property_field_name_title' => 'Field name', + 'property_placeholder_title' => 'Placeholder', + 'property_default_from_title' => 'Default from', + 'property_stretch_title' => 'Stretch', + 'property_stretch_description' => 'Specifies if this field stretches to fit the parent height.', + 'property_context_title' => 'Context', + 'property_context_description' => 'Specifies what form context should be used when displaying the field.', + 'property_context_create' => 'Create', + 'property_context_update' => 'Update', + 'property_context_preview' => 'Preview', + 'property_dependson_title' => 'Depends on', + 'property_trigger_action' => 'Action', + 'property_trigger_show' => 'Show', + 'property_trigger_hide' => 'Hide', + 'property_trigger_enable' => 'Enable', + 'property_trigger_disable' => 'Disable', + 'property_trigger_empty' => 'Empty', + 'property_trigger_field' => 'Field', + 'property_trigger_field_description' => 'Defines the other field name that will trigger the action.', + 'property_trigger_condition' => 'Condition', + 'property_trigger_condition_description' => 'Determines the condition the specified field should satisfy for the condition to be considered "true". Supported values: checked, unchecked, value[somevalue].', + 'property_trigger_condition_checked' => 'Checked', + 'property_trigger_condition_unchecked' => 'Unchecked', + 'property_trigger_condition_somevalue' => 'value[enter-the-value-here]', + 'property_preset_title' => 'Preset', + 'property_preset_description' => 'Allows the field value to be initially set by the value of another field, converted using the input preset converter.', + 'property_preset_field' => 'Field', + 'property_preset_field_description' => 'Defines the other field name to source the value from.', + 'property_preset_type' => 'Type', + 'property_preset_type_description' => 'Specifies the conversion type', + 'property_attributes_title' => 'Attributes', + 'property_attributes_description' => 'Custom HTML attributes to add to the form field element.', + 'property_container_attributes_title' => 'Container attributes', + 'property_container_attributes_description' => 'Custom HTML attributes to add to the form field container element.', + 'property_group_advanced' => 'Advanced', + 'property_dependson_description' => 'A list of other field names this field depends on, when the other fields are modified, this field will update. One field per line.', + 'property_trigger_title' => 'Trigger', + 'property_trigger_description' => 'Allows to change elements attributes such as visibility or value, based on another elements\' state.', + 'property_default_from_description' => 'Takes the default value from the value of another field.', + 'property_field_name_required' => 'The field name is required', + 'property_field_name_regex' => 'The field name can contain only Latin letters, digits, underscores, dashes and square brackets.', + 'property_attributes_size' => 'Size', + 'property_attributes_size_tiny' => 'Tiny', + 'property_attributes_size_small' => 'Small', + 'property_attributes_size_large' => 'Large', + 'property_attributes_size_huge' => 'Huge', + 'property_attributes_size_giant' => 'Giant', + 'property_comment_position' => 'Comment position', + 'property_comment_position_above' => 'Above', + 'property_comment_position_below' => 'Below', + 'property_hint_path' => 'Hint partial path', + 'property_hint_path_description' => 'Path to a partial file that contains the hint text. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/partials/_hint.htm', + 'property_hint_path_required' => 'Please enter the hint partial path', + 'property_partial_path' => 'Partial path', + 'property_partial_path_description' => 'Path to a partial file. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/partials/_partial.htm', + 'property_partial_path_required' => 'Please enter the partial path', + 'property_code_language' => 'Language', + 'property_code_theme' => 'Theme', + 'property_theme_use_default' => 'Use default theme', + 'property_group_code_editor' => 'Code editor', + 'property_gutter' => 'Gutter', + 'property_gutter_show' => 'Visible', + 'property_gutter_hide' => 'Hidden', + 'property_wordwrap' => 'Word wrap', + 'property_wordwrap_wrap' => 'Wrap', + 'property_wordwrap_nowrap' => 'Don\'t wrap', + 'property_fontsize' => 'Font size', + 'property_codefolding' => 'Code folding', + 'property_codefolding_manual' => 'Manual', + 'property_codefolding_markbegin' => 'Mark begin', + 'property_codefolding_markbeginend' => 'Mark begin and end', + 'property_autoclosing' => 'Auto closing', + 'property_enabled' => 'Enabled', + 'property_disabled' => 'Disabled', + 'property_soft_tabs' => 'Soft tabs', + 'property_tab_size' => 'Tab size', + 'property_readonly' => 'Read only', + 'property_use_default' => 'Use default settings', + 'property_options' => 'Opciones', + 'property_prompt' => 'Prompt', + 'property_prompt_description' => 'Text to display for the create button.', + 'property_prompt_default' => 'Add new item', + 'property_available_colors' => 'Available colors', + 'property_available_colors_description' => 'List of available colors in hex format (#FF0000). Leave empty for the default color set. Enter one value per line.', + 'property_datepicker_mode' => 'Mode', + 'property_datepicker_mode_date' => 'Date', + 'property_datepicker_mode_datetime' => 'Date and time', + 'property_datepicker_mode_time' => 'Time', + 'property_datepicker_min_date' => 'Min date', + 'property_datepicker_min_date_description' => 'The minimum/earliest date that can be selected. Leave empty for the default value (2000-01-01).', + 'property_datepicker_max_date' => 'Max date', + 'property_datepicker_max_date_description' => 'The maximum/latest date that can be selected. Leave empty for the default value (2020-12-31).', + 'property_datepicker_date_invalid_format' => 'Invalid date format. Use format YYYY-MM-DD.', + 'property_markdown_mode' => 'Mode', + 'property_markdown_mode_split' => 'Split', + 'property_markdown_mode_tab' => 'Tab', + 'property_fileupload_mode' => 'Mode', + 'property_fileupload_mode_file' => 'File', + 'property_fileupload_mode_image' => 'Imagen', + 'property_group_fileupload' => 'File upload', + 'property_fileupload_prompt' => 'Prompt', + 'property_fileupload_prompt_description' => 'Text to display for the upload button, applies to File mode only, optional.', + 'property_fileupload_image_width' => 'Image width', + 'property_fileupload_image_width_description' => 'Optional parameter - images will be resized to this width. Applies to Image mode only.', + 'property_fileupload_invalid_dimension' => 'Invalid dimension value - please enter a number.', + 'property_fileupload_image_height' => 'Image height', + 'property_fileupload_image_height_description' => 'Optional parameter - images will be resized to this height. Applies to Image mode only.', + 'property_fileupload_file_types' => 'File types', + 'property_fileupload_file_types_description' => 'Optional comma separated list of file extensions that are accepted by the uploader. Eg: zip,txt', + 'property_fileupload_mime_types' => 'MIME types', + 'property_fileupload_mime_types_description' => 'Optional comma separated list of MIME types that are accepted by the uploader, either as file extensions or fully qualified names. Eg: bin,txt', + 'property_fileupload_use_caption' => 'Use caption', + 'property_fileupload_use_caption_description' => 'Allows a title and description to be set for the file.', + 'property_fileupload_thumb_options' => 'Thumbnail options', + 'property_fileupload_thumb_options_description' => 'Manages options for the automatically generated thumbnails. Applies only for the Image mode.', + 'property_fileupload_thumb_mode' => 'Mode', + 'property_fileupload_thumb_auto' => 'Auto', + 'property_fileupload_thumb_exact' => 'Exact', + 'property_fileupload_thumb_portrait' => 'Portrait', + 'property_fileupload_thumb_landscape' => 'Landscape', + 'property_fileupload_thumb_crop' => 'Crop', + 'property_fileupload_thumb_extension' => 'File extension', + 'property_name_from' => 'Name column', + 'property_name_from_description' => 'Relation column name to use for displaying a name.', + 'property_relation_select' => 'Select', + 'property_relation_select_description' => 'CONCAT multiple columns together for displaying a name', + 'property_description_from' => 'Description column', + 'property_description_from_description' => 'Relation column name to use for displaying a description.', + 'property_recordfinder_prompt' => 'Prompt', + 'property_recordfinder_prompt_description' => 'Text to display when there is no record selected. The %s character represents the search icon. Leave empty for the default prompt.', + 'property_recordfinder_list' => 'List configuration', + 'property_recordfinder_list_description' => 'A reference to a list column definition file. Use the $ symbol to refer the plugins root directory, for example: $/acme/blog/lists/_list.yaml', + 'property_recordfinder_list_required' => 'Please provide a path to the list YAML file', + 'property_group_recordfinder' => 'Record finder', + 'property_mediafinder_mode' => 'Mode', + 'property_mediafinder_mode_file' => 'File', + 'property_mediafinder_mode_image' => 'Image', + 'property_mediafinder_prompt' => 'Prompt', + 'property_mediafinder_prompt_description' => 'Text to display when there is no item selected. The %s character represents the media manager icon. Leave empty for the default prompt.', + 'property_group_relation' => 'Relation', + 'property_relation_prompt' => 'Prompt', + 'property_relation_prompt_description' => 'Text to display when there is no available selections.', + 'control_group_standard' => 'Standard', + 'control_group_widgets' => 'Widgets', + 'click_to_add_control' => 'Add control', + 'loading' => 'Cargando...', + 'control_text' => 'Texto', + 'control_text_description' => 'Single line text box', + 'control_password' => 'Contraseña', + 'control_password_description' => 'Single line password text field', + 'control_checkbox' => 'Checkbox', + 'control_checkbox_description' => 'Single checkbox', + 'control_switch' => 'Switch', + 'control_switch_description' => 'Single switchbox, an alternative for checkbox', + 'control_textarea' => 'Text area', + 'control_textarea_description' => 'Multiline text box with controllable height', + 'control_dropdown' => 'Dropdown', + 'control_dropdown_description' => 'Dropdown list with static or dynamic options', + 'control_unknown' => 'Unknown control type: :type', + 'control_repeater' => 'Repeater', + 'control_repeater_description' => 'Outputs a repeating set of form controls', + 'control_number' => 'Number', + 'control_number_description' => 'Single line text box that takes numbers only', + 'control_hint' => 'Hint', + 'control_hint_description' => 'Outputs a partial contents in a box that can be hidden by the user', + 'control_partial' => 'Partial', + 'control_partial_description' => 'Outputs a partial contents', + 'control_section' => 'Section', + 'control_section_description' => 'Displays a form section with heading and subheading', + 'control_radio' => 'Radio list', + 'control_radio_description' => 'A list of radio options, where only one item can be selected at a time', + 'control_radio_option_1' => 'Option 1', + 'control_radio_option_2' => 'Option 2', + 'control_checkboxlist' => 'Checkbox list', + 'control_checkboxlist_description' => 'A list of checkboxes, where multiple items can be selected', + 'control_codeeditor' => 'Code editor', + 'control_codeeditor_description' => 'Plaintext editor for formatted code or markup', + 'control_colorpicker' => 'Color picker', + 'control_colorpicker_description' => 'A field for selecting a hexadecimal color value', + 'control_datepicker' => 'Date picker', + 'control_datepicker_description' => 'Text field used for selecting date and times', + 'control_richeditor' => 'Rich editor', + 'control_richeditor_description' => 'Visual editor for rich formatted text, also known as a WYSIWYG editor', + 'control_markdown' => 'Markdown editor', + 'control_markdown_description' => 'Basic editor for Markdown formatted text', + 'control_fileupload' => 'File upload', + 'control_fileupload_description' => 'File uploader for images or regular files', + 'control_recordfinder' => 'Record finder', + 'control_recordfinder_description' => 'Field with details of a related record with the record search feature', + 'control_mediafinder' => 'Media finder', + 'control_mediafinder_description' => 'Field for selecting an item from the Media Manager library', + 'control_relation' => 'Relation', + 'control_relation_description' => 'Displays either a dropdown or checkbox list for selecting a related record', + 'error_file_name_required' => 'Please enter the form file name.', + 'error_file_name_invalid' => 'The file name can contain only Latin letters, digits, underscores, dots and hashes.', + 'span_left' => 'Left', + 'span_right' => 'Right', + 'span_full' => 'Full', + 'span_auto' => 'Auto', + 'empty_tab' => 'Empty tab', + 'confirm_close_tab' => 'The tab contains controls which will be deleted. Continue?', + 'tab' => 'Form tab', + 'tab_title' => 'Title', + 'controls' => 'Controls', + 'property_tab_title_required' => 'The tab title is required.', + 'tabs_primary' => 'Primary tabs', + 'tabs_secondary' => 'Secondary tabs', + 'tab_stretch' => 'Stretch', + 'tab_stretch_description' => 'Specifies if this tabs container stretches to fit the parent height.', + 'tab_css_class' => 'CSS class', + 'tab_css_class_description' => 'Assigns a CSS class to the tabs container.', + 'tab_name_template' => 'Tab %s', + 'tab_already_exists' => 'Tab with the specified title already exists.', + ], + 'list' => [ + 'tab_new_list' => 'Nueva lista', + 'saved' => 'Lista guardada', + 'confirm_delete' => '¿Borrar la lista?', + 'tab_columns' => 'Columnas', + 'btn_add_column' => 'Añadir columna', + 'btn_delete_column' => 'Borrar columna', + 'column_dbfield_label' => 'Campo', + 'column_dbfield_required' => 'Por favor proporcione el campo del modelo', + 'column_name_label' => 'Etiqueta', + 'column_label_required' => 'Por favor proporcione la etiqueta de columna', + 'column_type_label' => 'Tipo', + 'column_type_required' => 'Por favor indique el tipo de columna', + 'column_type_text' => 'Texto', + 'column_type_number' => 'Numero', + 'column_type_switch' => 'Switch', + 'column_type_datetime' => 'Datetime', + 'column_type_date' => 'Fecha', + 'column_type_time' => 'Hora', + 'column_type_timesince' => 'Tine since', + 'column_type_timetense' => 'Tine tense', + 'column_type_select' => 'Select', + 'column_type_partial' => 'Partial', + 'column_label_default' => 'Default', + 'column_label_searchable' => 'Buscable', + 'column_label_sortable' => 'Ordenable', + 'column_label_invisible' => 'Invisible', + 'column_label_select' => 'Select', + 'column_label_relation' => 'Relation', + 'column_label_css_class' => 'CSS class', + 'column_label_width' => 'Width', + 'column_label_path' => 'Path', + 'column_label_format' => 'Format', + 'column_label_value_from' => 'Value from', + 'error_duplicate_column' => "Duplicate column field name: ':column'.", + ], + 'controller' => [ + 'menu_label' => 'Controladores', + 'no_records' => 'No se encuentran controladores del plugin', + 'controller' => 'Controlador', + 'behaviors' => 'Comportamientos', + 'new_controller' => 'Nuevo controlador', + 'error_controller_has_no_behaviors' => 'The controller doesn\'t have configurable behaviors.', + 'error_invalid_yaml_configuration' => 'Error loading behavior configuration file: :file', + 'behavior_form_controller' => 'Form controller behavior', + 'behavior_form_controller_description' => 'Adds form functionality to a back-end page. The behavior provides three pages called Create, Update and Preview.', + 'property_behavior_form_placeholder' => '--select form--', + 'property_behavior_form_name' => 'Nombre', + 'property_behavior_form_name_description' => 'The name of the object being managed by this form', + 'property_behavior_form_name_required' => 'Please enter the form name', + 'property_behavior_form_file' => 'Form configuration', + 'property_behavior_form_file_description' => 'Reference to a form field definition file', + 'property_behavior_form_file_required' => 'Please enter a path to the form configuration file', + 'property_behavior_form_model_class' => 'Model class', + 'property_behavior_form_model_class_description' => 'A model class name, the form data is loaded and saved against this model.', + 'property_behavior_form_model_class_required' => 'Please select a model class', + 'property_behavior_form_default_redirect' => 'Default redirect', + 'property_behavior_form_default_redirect_description' => 'A page to redirect to by default when the form is saved or cancelled.', + 'property_behavior_form_create' => 'Create record page', + 'property_behavior_form_redirect' => 'Redirect', + 'property_behavior_form_redirect_description' => 'A page to redirect to when a record is created.', + 'property_behavior_form_redirect_close' => 'Close redirect', + 'property_behavior_form_redirect_close_description' => 'A page to redirect to when a record is created and the close post variable is sent with the request.', + 'property_behavior_form_flash_save' => 'Save flash message', + 'property_behavior_form_flash_save_description' => 'Flash message to display when record is saved.', + 'property_behavior_form_page_title' => 'Page title', + 'property_behavior_form_update' => 'Update record page', + 'property_behavior_form_update_redirect' => 'Redirect', + 'property_behavior_form_create_redirect_description' => 'A page to redirect to when a record is saved.', + 'property_behavior_form_flash_delete' => 'Delete flash message', + 'property_behavior_form_flash_delete_description' => 'Flash message to display when record is deleted.', + 'property_behavior_form_preview' => 'Preview record page', + 'behavior_list_controller' => 'List controller behavior', + 'behavior_list_controller_description' => 'Provides the sortable and searchable list with optional links on its records. The behavior automatically creates the controller action "index".', + 'property_behavior_list_title' => 'List title', + 'property_behavior_list_title_required' => 'Please enter the list title', + 'property_behavior_list_placeholder' => '--select list--', + 'property_behavior_list_model_class' => 'Model class', + 'property_behavior_list_model_class_description' => 'A model class name, the list data is loaded from this model.', + 'property_behavior_form_model_class_placeholder' => '--select model--', + 'property_behavior_list_model_class_required' => 'Please select a model class', + 'property_behavior_list_model_placeholder' => '--select model--', + 'property_behavior_list_file' => 'List configuration file', + 'property_behavior_list_file_description' => 'Reference to a list definition file', + 'property_behavior_list_file_required' => 'Please enter a path to the list configuration file', + 'property_behavior_list_record_url' => 'Record URL', + 'property_behavior_list_record_url_description' => 'Link each list record to another page. Eg: users/update:id. The :id part is replaced with the record identifier.', + 'property_behavior_list_no_records_message' => 'No records message', + 'property_behavior_list_no_records_message_description' => 'A message to display when no records are found', + 'property_behavior_list_recs_per_page' => 'Records per page', + 'property_behavior_list_recs_per_page_description' => 'Records to display per page, use 0 for no pages. Default: 0', + 'property_behavior_list_recs_per_page_regex' => 'Records per page should be an integer value', + 'property_behavior_list_show_setup' => 'Show setup button', + 'property_behavior_list_show_sorting' => 'Show sorting', + 'property_behavior_list_default_sort' => 'Default sorting', + 'property_behavior_form_ds_column' => 'Columna', + 'property_behavior_form_ds_direction' => 'Direction', + 'property_behavior_form_ds_asc' => 'Ascending', + 'property_behavior_form_ds_desc' => 'Descending', + 'property_behavior_list_show_checkboxes' => 'Show checkboxes', + 'property_behavior_list_onclick' => 'On click handler', + 'property_behavior_list_onclick_description' => 'Custom JavaScript code to execute when clicking on a record.', + 'property_behavior_list_show_tree' => 'Show tree', + 'property_behavior_list_show_tree_description' => 'Displays a tree hierarchy for parent/child records.', + 'property_behavior_list_tree_expanded' => 'Tree expanded', + 'property_behavior_list_tree_expanded_description' => 'Determines if tree nodes should be expanded by default.', + 'property_behavior_list_toolbar' => 'Toolbar', + 'property_behavior_list_toolbar_buttons' => 'Buttons partial', + 'property_behavior_list_toolbar_buttons_description' => 'Reference to a controller partial file with the toolbar buttons. Eg: list_toolbar', + 'property_behavior_list_search' => 'Buscar', + 'property_behavior_list_search_prompt' => 'Search prompt', + 'property_behavior_list_filter' => 'Filter configuration', + 'behavior_reorder_controller' => 'Reorder controller behavior', + 'behavior_reorder_controller_description' => 'Provides features for sorting and reordering on its records. The behavior automatically creates the controller action "reorder".', + 'property_behavior_reorder_title' => 'Reorder title', + 'property_behavior_reorder_title_required' => 'Please enter the reorder title', + 'property_behavior_reorder_name_from' => 'Attribute name', + 'property_behavior_reorder_name_from_description' => 'Model\'s attribute that should be used as a label for each record.', + 'property_behavior_reorder_name_from_required' => 'Please enter the attribute name', + 'property_behavior_reorder_model_class' => 'Model class', + 'property_behavior_reorder_model_class_description' => 'A model class name, the reorder data is loaded from this model.', + 'property_behavior_reorder_model_class_placeholder' => '--select model--', + 'property_behavior_reorder_model_class_required' => 'Please select a model class', + 'property_behavior_reorder_model_placeholder' => '--select model--', + 'property_behavior_reorder_toolbar' => 'Toolbar', + 'property_behavior_reorder_toolbar_buttons' => 'Buttons partial', + 'property_behavior_reorder_toolbar_buttons_description' => 'Reference to a controller partial file with the toolbar buttons. Eg: reorder_toolbar', + 'error_controller_not_found' => 'Original controller file is not found.', + 'error_invalid_config_file_name' => 'The behavior :class configuration file name (:file) contains invalid characters and cannot be loaded.', + 'error_file_not_yaml' => 'The behavior :class configuration file (:file) is not a YAML file. Only YAML configuration files are supported.', + 'saved' => 'Controller saved', + 'controller_name' => 'Controller name', + 'controller_name_description' => 'Controller name defines the class name and URL of the controller\'s back-end pages. Standard PHP variable naming conventions apply. The first symbol should be a capital Latin letter. Examples: Categories, Posts, Products.', + 'base_model_class' => 'Base model class', + 'base_model_class_description' => 'Select a model class to use as a base model in behaviors that require or support models. You can configure the behaviors later.', + 'base_model_class_placeholder' => '--select model--', + 'controller_behaviors' => 'Behaviors', + 'controller_behaviors_description' => 'Select behaviors the controller should implement. Builder will create view files required for the behaviors automatically.', + 'controller_permissions' => 'Permisos', + 'controller_permissions_description' => 'Select user permissions that can access the controller views. Permissions can be defined on the Permissions tab of the Builder. You can change this option in the controller PHP script later.', + 'controller_permissions_no_permissions' => 'The plugin doesn\'t define any permissions.', + 'menu_item' => 'Active menu item', + 'menu_item_description' => 'Select a menu item to make active for the controller pages. You can change this option in the controller PHP script later.', + 'menu_item_placeholder' => '--select menu item--', + 'error_unknown_behavior' => 'The behavior class :class is not registered in the behavior library.', + 'error_behavior_view_conflict' => 'The selected behaviors provide conflicting views (:view) and cannot be used together in a controller.', + 'error_behavior_config_conflict' => 'The selected behaviors provide conflicting configuration files (:file) and cannot be used together in a controller.', + 'error_behavior_view_file_not_found' => 'View template :view of the behavior :class cannot be found.', + 'error_behavior_config_file_not_found' => 'Configuration template :file of the behavior :class cannot be found.', + 'error_controller_exists' => 'Controller file already exists: :file.', + 'error_controller_name_invalid' => 'Invalid controller name format. The name can only contain digits and Latin letters. The first symbol should be a capital Latin letter.', + 'error_behavior_view_file_exists' => 'Controller view file already exists: :view.', + 'error_behavior_config_file_exists' => 'Behavior configuration file already exists: :file.', + 'error_save_file' => 'Error saving conroller file: :file', + 'error_behavior_requires_base_model' => 'Behavior :behavior requires a base model class to be selected.', + 'error_model_doesnt_have_lists' => 'The selected model doesn\'t have any lists. Please create a list first.', + 'error_model_doesnt_have_forms' => 'The selected model doesn\'t have any forms. Please create a form first.', + ], + 'version' => [ + 'menu_label' => 'Versiones', + 'no_records' => 'Versiones del plugin no encontradas', + 'search' => 'Buscar...', + 'tab' => 'Versiones', + 'saved' => 'Versión salvada', + 'confirm_delete' => '¿Borrar esta versión?', + 'tab_new_version' => 'Nueva versión', + 'migration' => 'Migración', + 'seeder' => 'Seeder', + 'custom' => 'Increase the verison number', + 'apply_version' => 'Apply version', + 'applying' => 'Applying...', + 'rollback_version' => 'Rollback versión', + 'rolling_back' => 'Rolling back...', + 'applied' => 'Version applied', + 'rolled_back' => 'Version rolled back', + 'hint_save_unapplied' => 'You saved an unapplied version. Unapplied versions could be automatically applied when you or another user logs into the back-end or when a database table is saved in the Database section of the Builder.', + 'hint_rollback' => 'Rolling back a version will also roll back all versions newer than this version. Please note that unapplied versions could be automatically applied by the system when you or another user logs into the back-end or when a database table is saved in the Database section of the Builder.', + 'hint_apply' => 'Applying a version will also apply all older unapplied versions of the plugin.', + 'dont_show_again' => 'Don\'t show again', + 'save_unapplied_version' => 'Save unapplied version', + ], + 'menu' => [ + 'menu_label' => 'Backend Menu', + 'tab' => 'Menus', + 'items' => 'Menu items', + 'saved' => 'Menus saved', + 'add_main_menu_item' => 'Add main menu item', + 'new_menu_item' => 'Menu Item', + 'add_side_menu_item' => 'Add sub-item', + 'side_menu_item' => 'Side menu item', + 'property_label' => 'Etiqueta', + 'property_label_required' => 'Please enter the menu item labels.', + 'property_url_required' => 'Please enter the menu item URL', + 'property_url' => 'URL', + 'property_icon' => 'Icono', + 'property_icon_required' => 'Please select an icon', + 'property_permissions' => 'Permissions', + 'property_order' => 'Order', + 'property_order_invalid' => 'Please enter the menu item order as integer value.', + 'property_order_description' => 'Menu item order manages its position in the menu. If the order is not provided, the item will be placed to the end of the menu. The default order values have the increment of 100.', + 'property_attributes' => 'HTML attributes', + 'property_code' => 'Code', + 'property_code_invalid' => 'The code should contain only Latin letter and digits', + 'property_code_required' => 'Please enter the menu item code.', + 'error_duplicate_main_menu_code' => "Duplicate main menu item code: ':code'.", + 'error_duplicate_side_menu_code' => "Duplicate side menu item code: ':code'.", + ], + 'localization' => [ + 'menu_label' => 'Localización', + 'language' => 'Lenguaje', + 'strings' => 'Cadenas', + 'confirm_delete' => '¿Borrar el lenguaje?', + 'tab_new_language' => 'Nuevo lenguaje', + 'no_records' => 'Lenguajes no encontrados', + 'saved' => 'Archivo de lenguaje guardado', + 'error_cant_load_file' => 'Cannot load the requested language file - file not found.', + 'error_bad_localization_file_contents' => 'Cannot load the requested language file. Language files can only contain array definitions and strings.', + 'error_file_not_array' => 'Cannot load the requested language file. Language files should return an array.', + 'save_error' => "Error saving file ':name'. Please check write permissions.", + 'error_delete_file' => 'Error deleting localization file.', + 'add_missing_strings' => 'Añadir cadenas que faltan', + 'copy' => 'Copiar', + 'add_missing_strings_label' => 'Select language to copy missing strings from', + 'no_languages_to_copy_from' => 'There are no other languages to copy strings from.', + 'new_string_warning' => 'Nueva cadena o sección', + 'structure_mismatch' => 'The structure of the source language file doesn\'t match the structure of the file being edited. Some individual strings in the edited file correspond to sections in the source file (or vice versa) and cannot be merged automatically.', + 'create_string' => 'Create new string', + 'string_key_label' => 'String key', + 'string_key_comment' => 'Enter the string key using period as a section separator. For example: plugin.search. The string will be created in the plugin\'s default language localization file.', + 'string_value' => 'String value', + 'string_key_is_empty' => 'String key should not be empty', + 'string_value_is_empty' => 'String value should not be empty', + 'string_key_exists' => 'The string key already exists', + ], + 'permission' => [ + 'menu_label' => 'Permisos', + 'tab' => 'Permisos', + 'form_tab_permissions' => 'Permisos', + 'btn_add_permission' => 'Añadir permisos', + 'btn_delete_permission' => 'Borrar permisos', + 'column_permission_label' => 'Permission code', + 'column_permission_required' => 'Please enter the permission code', + 'column_tab_label' => 'Titulo pestaña', + 'column_tab_required' => 'Por favor introduzca el permiso de el título de la pestaña', + 'column_label_label' => 'Etiqueta', + 'column_label_required' => 'Por favor introduzca permiso de etiqueta', + 'saved' => 'Permisos guardados', + 'error_duplicate_code' => "Duplicate permission code: ':code'.", + ], + 'yaml' => [ + 'save_error' => "Error al guardar el archivo ':name'. Consulte permisos de escritura.", + ], + 'common' => [ + 'error_file_exists' => "El archivo ya existe: ':path'.", + 'field_icon_description' => 'October usa Font Autumn icons: http://octobercms.com/docs/ui/icon', + 'destination_dir_not_exists' => "El directorio de destino no existe: ':path'.", + 'error_make_dir' => "Error al crear directorio: ':name'.", + 'error_dir_exists' => "El directorio ya existe!: ':path'.", + 'template_not_found' => "Archivo de plantilla no encuentrado: ':name'.", + 'error_generating_file' => "Error al generar el archivo: ':path'.", + 'error_loading_template' => "Error al cargar el archivo plantilla: ':name'.", + 'select_plugin_first' => 'Seleccione primero un plugin. Para ver la lista de plugin, haga clic en el icono > en la barra lateral izquierda.', + 'plugin_not_selected' => 'Plugin no seleccionado', + 'add' => 'Añadir', + ], + 'migration' => [ + 'entity_name' => 'Migración', + 'error_version_invalid' => 'The version should be specified in format 1.0.1', + 'field_version' => 'Versión', + 'field_description' => 'Descripción', + 'field_code' => 'Code', + 'field_code_comment' => 'The migration code is read-only and for the preview purpose only. You can create custom migrations manually in the Versions section of the Builder.', + 'save_and_apply' => 'Salvar y Aplicar', + 'error_version_exists' => 'The migration version already exists.', + 'error_script_filename_invalid' => 'The migration script file name can contain only Latin letters, digits and underscores. The name should start with a Latin letter and could not contain spaces.', + 'error_cannot_change_version_number' => 'Cannot change version number for an applied version.', + 'error_file_must_define_class' => 'Migration code should define a migration or seeder class. Leave the code field blank if you only want to update the version number.', + 'error_file_must_define_namespace' => 'Migration code should define a namespace. Leave the code field blank if you only want to update the version number.', + 'no_changes_to_save' => 'No hay cambios que salvar.', + 'error_namespace_mismatch' => "The migration code should use the plugin namespace: :namespace", + 'error_migration_file_exists' => "Migration file :file already exists. Please use another class name.", + 'error_cant_delete_applied' => 'This version has already been applied and cannot be deleted. Please rollback the version first.', + ], + 'components' => [ + 'list_title' => 'Record list', + 'list_description' => 'Displays a list of records for a selected model', + 'list_page_number' => 'Page number', + 'list_page_number_description' => 'This value is used to determine what page the user is on.', + 'list_records_per_page' => 'Records per page', + 'list_records_per_page_description' => 'Number of records to display on a single page. Leave empty to disable pagination.', + 'list_records_per_page_validation' => 'Invalid format of the records per page value. The value should be a number.', + 'list_no_records' => 'No records message', + 'list_no_records_description' => 'Message to display in the list in case if there are no records. Used in the default component\'s partial.', + 'list_no_records_default' => 'No records found', + 'list_sort_column' => 'Sort by column', + 'list_sort_column_description' => 'Model column the records should be ordered by', + 'list_sort_direction' => 'Direction', + 'list_display_column' => 'Display column', + 'list_display_column_description' => 'Column to display in the list. Used in the default component\'s partial.', + 'list_display_column_required' => 'Please select a display column.', + 'list_details_page' => 'Details page', + 'list_details_page_description' => 'Page to display record details.', + 'list_details_page_no' => '--no details page--', + 'list_sorting' => 'Sorting', + 'list_pagination' => 'Paginación', + 'list_order_direction_asc' => 'Ascending', + 'list_order_direction_desc' => 'Descending', + 'list_model' => 'Model class', + 'list_scope' => 'Scope', + 'list_scope_description' => 'Optional model scope to fetch the records', + 'list_scope_default' => '--select a scope, optional--', + 'list_details_page_link' => 'Link to the details page', + 'list_details_key_column' => 'Details key column', + 'list_details_key_column_description' => 'Model column to use as a record identifier in the details page links.', + 'list_details_url_parameter' => 'URL parameter name', + 'list_details_url_parameter_description' => 'Name of the details page URL parameter which takes the record identifier.', + 'details_title' => 'Record details', + 'details_description' => 'Displays record details for a selected model', + 'details_model' => 'Model class', + 'details_identifier_value' => 'Identifier value', + 'details_identifier_value_description' => 'Identifier value to load the record from the database. Specify a fixed value or URL parameter name.', + 'details_identifier_value_required' => 'The identifier value is required', + 'details_key_column' => 'Key column', + 'details_key_column_description' => 'Model column to use as a record identifier for fetching the record from the database.', + 'details_key_column_required' => 'The key column name is required', + 'details_display_column' => 'Display column', + 'details_display_column_description' => 'Model column to display on the details page. Used in the default component\'s partial.', + 'details_display_column_required' => 'Please select a display column.', + 'details_not_found_message' => 'Not found message', + 'details_not_found_message_description' => 'Message to display if the record is not found. Used in the default component\'s partial.', + 'details_not_found_message_default' => 'Record not found', + ], +]; diff --git a/server/plugins/rainlab/builder/lang/fa/lang.php b/server/plugins/rainlab/builder/lang/fa/lang.php new file mode 100644 index 0000000..d82ed8d --- /dev/null +++ b/server/plugins/rainlab/builder/lang/fa/lang.php @@ -0,0 +1,638 @@ + [ + 'name' => 'افزونه ساز', + 'description' => 'ساخت افزونه های اکتبر به صورت دیداری', + 'add' => 'ایجاد افزونه', + 'no_records' => 'افزونه ای یافت نشد', + 'no_description' => 'بدون توضیح', + 'no_name' => 'بدون نام', + 'search' => 'جستجو...', + 'filter_description' => 'نمایش تمام افزونه ها و یا افزونه های نوشته شده توسط شما', + 'settings' => 'تنظیمات', + 'entity_name' => 'افزونه', + 'field_name' => 'نام', + 'field_author' => 'صاحب امتیاز', + 'field_description' => 'توضحات', + 'field_icon' => 'آیکن افزونه', + 'field_plugin_namespace' => 'نیم اسپیس افزونه', + 'field_author_namespace' => 'نیم اسپیس صاحب امتیاز', + 'field_namespace_description' => 'نیم اسپیس میتواند شامل حروف لاتین و اعداد باشد و باید با یک حرف لاتین آغاز شود مانند: Blog', + 'field_author_namespace_description' => 'امکان تغییر نیم پس از ایجاد آن توسط افزونه ساز وجود ندارد نمونه ای از نیم اسپیس صاحب امتیاز: OctoberFa', + 'tab_general' => 'پارامتر های عمومی', + 'tab_description' => 'توضیحات', + 'field_homepage' => 'آدرس وب افزونه', + 'no_description' => 'توضیحی برای این افزونه وارد نشده است', + 'error_settings_not_editable' => 'تنظیمات این افزونه توسط افزونه ساز قابل ویرایش نمی باشد.', + 'update_hint' => 'امکان ترجمه نام و توضیحات افزونه در بخش ترجمه وجود دارد' + ], + 'author_name' => [ + 'title' => 'نام صاحب امتیاز', + 'description' => 'نام صاحب امتیاز به هنگام ایجاد افزونه جدید، این نام را همیشه میتوان در تنظیمات افزونه ویرایش کرد.' + ], + 'author_namespace' => [ + 'title' => 'نیم اسپیس صاحب امتیاز', + 'description' => 'اگر شما در فروشگاه افزونه ها حساب کاربری دارید این گزینه باید با نیم اسپیس آن حساب یکی باشد.' + ], + 'database' => [ + 'menu_label' => 'پایگاه داده', + 'no_records' => 'جدولی یافت نشد', + 'search' => 'جستجو...', + 'confirmation_delete_multiple' => 'آیا از حذف جدول های انتخاب شده اطمینان دارید؟', + 'field_name' => 'نام جدول', + 'tab_columns' => 'ستون ها', + 'column_name_name' => 'ستون', + 'column_name_required' => 'لطفا نام ستون را وارد نمایید', + 'column_name_type' => 'نوع', + 'column_type_required' => 'لطفا نوع ستون را وارد نمایید', + 'column_name_length' => 'طول', + 'column_validation_length' => 'مقدار این گزینه باید یک عدد صحیح بوده و برای داده های اعشاری در بازه 2 تا 10 باشد.', + 'column_validation_title' => 'این گزینه باید فقط شامل اعداد، حروف لاتین و خط زیر باشد.', + 'column_name_unsigned' => 'بدون علامت', + 'column_name_nullable' => 'nullable', + 'column_auto_increment' => 'افزایشی خودکار', + 'column_default' => 'پیشفرض', + 'column_auto_primary_key' => 'PK', + 'tab_new_table' => 'جدول جدید', + 'btn_add_column' => 'افزودن ستون', + 'btn_delete_column' => 'حذف ستون', + 'confirm_delete' => 'آیا از حذف ان جدول اطمینان دارید؟', + 'error_enum_not_supported' => 'جدول حاوی ستون(ها) ای با نوع enum می باشد که در حال حاظر توسط افزونه ساز پشتیبانی نمیشود.', + 'error_table_name_invalid_prefix' => 'نام جدول باید با پیشوند افزونه \':prefix\' آغاز شود. ', + 'error_table_name_invalid_characters' => 'نام جدول صحیح نمی باشد. نام جدول میتواند حاوی حروف لاتین، اعداد و خط زیر باشد و باید با حرف لاتین شروع شود. همچنین نام جدول نمیتواند شامل فاصله باشد.', + 'error_table_duplicate_column' => 'نام ستون \':column\' تکراری می باشد.', + 'error_table_auto_increment_in_compound_pk' => 'ستون افزایشی خودکار نمیتواند بخشی از کلید اصلی مرکب باشد', + 'error_table_mutliple_auto_increment' => 'جدول فقط میتواند شامل یک ستون افزایشی باشد.', + 'error_table_auto_increment_non_integer' => 'نوع ستون افزایشی باید عدد صحیح (integer) باشد.', + 'error_table_decimal_length' => "طول نوع :type باید در قالب '10,2' بدون فاصله باشد.", + 'error_table_length' => 'طول نوع :type باید یک عدد صحیح باشد.', + 'error_unsigned_type_not_int' => "خطا در ایجاد ستون ':column'، فقط ستون هایی از نوع عدد صحیح میتوانند نشانه بدون علامت داشته باشند.", + 'error_integer_default_value' => "مقدار پیشفرض وارد شده برای ستون ':column' باید یک مقدار صحیح باشد.", + 'error_decimal_default_value' => "مقدار پیشفرض وارد شده برای ستون ':column' باید یک عدد اعشاری باشد.", + 'error_boolean_default_value' => "مقدار پیشفرض ستون ':column' باید 0 ویا 1 باشد", + 'error_unsigned_negative_value' => "مقدار پیشفرض ستون ':column' باید یک عدد صحیح مثبت باشد.", + 'error_table_already_exists' => "نام جدول ':name' تکراری می باشد." + ], + 'model' => [ + 'menu_label' => 'مدل ها', + 'entity_name' => 'مدل', + 'no_records' => 'مدلی یافت نشد', + 'search' => 'جستجو...', + 'add' => 'افزودن...', + 'forms' => 'فرم ها', + 'lists' => 'لیست ها', + 'field_class_name' => 'نام کلاس', + 'field_database_table' => 'نام پایگاه داده', + 'error_class_name_exists' => 'نام مدل برای کلاس وارد شده :path تکاریست', + 'add_form' => 'فرم جدید', + 'add_list' => 'لیست جدید', + ], + 'form' => [ + 'saved'=> 'فرم با موفقیت ذخیره شد.', + 'confirm_delete' => 'آیا از حذف این فرم اطمینان دارید؟', + 'tab_new_form' => 'فرم جدید', + 'property_label_title' => 'برچسب', + 'property_label_required' => 'لطفا برچسب را وارد نمایید', + 'property_span_title' => 'موقعیت', + 'property_comment_title' => 'توضیح', + 'property_comment_above_title' => 'توضیح بالا', + 'property_default_title' => 'پیشفرض', + 'property_checked_default_title' => 'انتخاب شده (پیشفرض)', + 'property_css_class_title' => 'کلاس CSS', + 'property_css_class_description' => 'کلاس CSS اختیاری جهت والد فیلد', + 'property_disabled_title' => 'غیر فعال', + 'property_hidden_title' => 'مخفی', + 'property_required_title' => 'اجباری', + 'property_field_name_title' => 'نام فیلد', + 'property_placeholder_title' => 'پیش نوشته (Placeholder)', + 'property_default_from_title' => 'فرم پیشفرض', + 'property_stretch_title' => 'کامل', + 'property_stretch_description' => 'اگر میخواهید طول فیلد درون والد خود کامل باشد این گزینه را انتخاب نمایید.', + 'property_context_title' => 'بخش', + 'property_context_description' => 'مشخص کننده نمایش فیلد در حالت های فرم', + 'property_context_create' => 'ایجاد', + 'property_context_update' => 'به روز رسانی', + 'property_context_preview' => 'پیش نمایش', + 'property_dependson_title' => 'وابستگی', + 'property_trigger_action' => 'عمل', + 'property_trigger_show' => 'نمایش', + 'property_trigger_hide' => 'عدم نمایش', + 'property_trigger_enable' => 'فعال', + 'property_trigger_disable' => 'غیر فعال', + 'property_trigger_empty' => 'خالی', + 'property_trigger_field' => 'فیلد', + 'property_trigger_field_description' => 'نام فیلدی را که عمل را اجرا میکند وارد نمایید', + 'property_trigger_condition' => 'شرط', + 'property_trigger_condition_description' => 'شرطی که در صورت درستی عمل انجام میشود. مقادیر پشتیبانی شده این فیلد: checked، unchecked، value[somevalue].', + 'property_trigger_condition_checked' => 'Checked', + 'property_trigger_condition_unchecked' => 'Unchecked', + 'property_trigger_condition_somevalue' => 'value[enter-the-value-here]', + 'property_preset_title' => 'از پیش تایین شده', + 'property_preset_description' => 'این امکان را میدهد که نام فیلد توسط فیلد دیگری مقدار دهی شده و با مبدل از پیش تعریف شده ای تبدیل شود.', + 'property_preset_field' => 'فیلد', + 'property_preset_field_description' => 'فیلد منبعی که مقدار از آن گرفته میشود را وارد نمایید.', + 'property_preset_type' => 'نوع', + 'property_preset_type_description' => 'مشخص کردن نوع تبدیل', + 'property_attributes_title' => 'ویژگی ها', + 'property_attributes_description' => 'ویژگی های HTML ای را که میخواهید به فیلد بدهید را وارد نمایید', + 'property_container_attributes_title' => 'ویژگی های والد', + 'property_container_attributes_description' => 'ویژگی های HTML ای که والد فیلد باید داشته باشد را وارد نمایید.', + 'property_group_advanced' => 'پیشرفته', + 'property_dependson_description' => 'فیلد های دیگری را که این فیلد به آنها وابسته می باشد و به هنگام تغییر آن ها این فیلد نیز تغییر پیدا میکند را وارد نمایید. هر فیلد در یک خط تعریف می شود.', + 'property_trigger_title' => 'عکس العمل', + 'property_trigger_description' => 'به فیلد این اجاره را میدهد که با تغییر فیلد دیگری ویژگی های خود را مانند حالت نمایش و مقدار خود کنترل نماید', + 'property_default_from_description' => 'مقدار پیشفرض را از مقدار فیلد دیگری بگیر.', + 'property_field_name_required' => 'ورود نام فیلد اجباریست', + 'property_field_name_regex' => 'نام فیلد میتواند شامل حروف لاتین، اعداد، خط زیر، خط تیره و کروشه باشد.', + 'property_attributes_size' => 'اندازه', + 'property_attributes_size_tiny' => 'خیلی کوچک', + 'property_attributes_size_small' => 'کوچک', + 'property_attributes_size_large' => 'متوسط', + 'property_attributes_size_huge' => 'بزرک', + 'property_attributes_size_giant' => 'خیلی بزرگ', + 'property_comment_position' => 'محل قرارگیری توضیح', + 'property_comment_position_above' => 'قبل', + 'property_comment_position_below' => 'بعد', + 'property_hint_path' => 'آدرس فایل بخش راهنما', + 'property_hint_path_description' => 'آدرس فایل بخشی که شامل متن راهنما می باشد. علامت $ به پوشه افزونه ها اشاره میکند برای مثال: $/acme/blog/partials/_hint.htm', + 'property_hint_path_required' => 'لطفا مسیر بخش راهنما را وارد نمایید.', + 'property_partial_path' => 'مسیر بخش', + 'property_partial_path_description' => 'مسیر فال مربوط به بخش را وارد نمایید. علامت $ به پوشه پلاگین ها اشاره میکند برای مثال: $/acme/blog/partials/_hint.htm', + 'property_partial_path_required' => 'لطفا مسیر فایل بخش را وارد نمایید.', + 'property_code_language' => 'زبان', + 'property_code_theme' => 'قالب', + 'property_theme_use_default' => 'استفاده از قالب پیشفرض', + 'property_group_code_editor' => 'ویرایشگر کد', + 'property_gutter' => 'شیار', + 'property_gutter_show' => 'قابل مشاهده', + 'property_gutter_hide' => 'مخقی', + 'property_wordwrap' => 'Word wrap', + 'property_wordwrap_wrap' => 'Wrap', + 'property_wordwrap_nowrap' => 'Don\'t wrap', + 'property_fontsize' => 'اندازه فونت', + 'property_codefolding' => 'Code folding', + 'property_codefolding_manual' => 'دستی', + 'property_codefolding_markbegin' => 'علامت گذازی آغاز', + 'property_codefolding_markbeginend' => 'علامت گذاری آغاز و پایان', + 'property_autoclosing' => 'بستن خودکار', + 'property_enabled' => 'فعال', + 'property_disabled' => 'غیر فعال', + 'property_soft_tabs' => 'استفاده از فاصله به جای Tab', + 'property_tab_size' => 'اندازه Tab', + 'property_readonly' => 'فقط خواندنی', + 'property_use_default' => 'استفاده از تنظیمات پیشفرض', + 'property_options' => 'گزینه ها', + 'property_prompt' => 'متن', + 'property_prompt_description' => 'متن نمایش داده شده برای دکمه ایجاد', + 'property_prompt_default' => 'افزودن گزینه جدید', + 'property_available_colors' => 'رنگ های موجود', + 'property_available_colors_description' => 'لیست رنگ های موجود در قالب هگزادسیمال (#FF0000). برای استفاده از رنگ های پیشفرض این گزینه را خالی رها کنید. در هر خط یک رنگ وارد نمایید.', + 'property_datepicker_mode' => 'نحوه نمایش', + 'property_datepicker_mode_date' => 'تاریخ', + 'property_datepicker_mode_datetime' => 'تاریخ و ساعت', + 'property_datepicker_mode_time' => 'ساعت', + 'property_datepicker_min_date' => 'کمترین تاریخ', + 'property_datepicker_min_date_description' => 'کمترین تاریخی که میتوان انتخاب کرد. برای مقدار پیشفرض این گزینه را خالی بگذارید.', + 'property_datepicker_max_date' => 'بیشترین تاریخ', + 'property_datepicker_max_date_description' => 'بیشترین تاریخی که میتوان انتخاب کرد. برای استفاده از مقدار پیشفرض این گزینه را خالی بگذارید.', + 'property_datepicker_date_invalid_format' => 'قالب تاریخ صحیح نمی باشد. مثال: YYYY-MM-DD', + 'property_markdown_mode' => 'نحوه نمایش', + 'property_markdown_mode_split' => 'پنجره کنار هم', + 'property_markdown_mode_tab' => 'Tab', + 'property_fileupload_mode' => 'نحوه نمایش', + 'property_fileupload_mode_file' => 'فایل', + 'property_fileupload_mode_image' => 'تصویر', + 'property_group_fileupload' => 'ارسال فایل', + 'property_fileupload_prompt' => 'متن', + 'property_fileupload_prompt_description' => 'گزینه اختیاری جهت متن دکمه ارسال که در حالت فایل مورد استفاده قرار می گیرد.', + 'property_fileupload_image_width' => 'عرض تصویر', + 'property_fileupload_image_width_description' => 'گزینه اختیاری جهت تغییر اندازه عرض تصویر که فقط در حالت تصویر مورد استفاده قرار میگیرد.', + 'property_fileupload_invalid_dimension' => 'مقدار وارد شده صحیح نیست. لطفا یک عدد وارد نمایید', + 'property_fileupload_image_height' => 'طول تصویر', + 'property_fileupload_image_height_description' => 'گزینه اختیاری جهت تغییر اندازه طول تصویر که فقط در حالت تصویر مورد استفاده قرار میگیرد.', + 'property_fileupload_file_types' => 'نوع فایل ها', + 'property_fileupload_file_types_description' => 'گزینه اختیاری جهت تایین پسوند فایل های ارسالی که با کاما از هم جدا شنده اند برای مثال: zip,txt', + 'property_fileupload_mime_types' => 'MIME types', + 'property_fileupload_mime_types_description' => 'لیست اختیاری از MIME Type های مجاز جهت ارسال فایل که با کاما از هم جدا شده اند برای مثال: bin,txt', + 'property_fileupload_use_caption' => 'از عنوان استفاده شود', + 'property_fileupload_use_caption_description' => 'اجازه ورود عنوان و توضیحات برای فایل ارسالی.', + 'property_fileupload_thumb_options' => 'گزینه های تصویر بند انگشتی', + 'property_fileupload_thumb_options_description' => 'مدیریت گزینه های تولید خودکار تصویر بند انگشتی که فقط در حالت تصویر مورد استفاده قرار میگیرد.', + 'property_fileupload_thumb_mode' => 'حالت نمایش', + 'property_fileupload_thumb_auto' => 'خودکار', + 'property_fileupload_thumb_exact' => 'دقیقا', + 'property_fileupload_thumb_portrait' => 'Portrait', + 'property_fileupload_thumb_landscape' => 'Landscape', + 'property_fileupload_thumb_crop' => 'Crop', + 'property_fileupload_thumb_extension' => 'پسوند فایل', + 'property_name_from' => 'نام ستون', + 'property_name_from_description' => 'نام ستون ارتباطی جهت نمایش نام.', + 'property_description_from' => 'ستون توضیحات', + 'property_description_from_description' => 'نام ستون ارتباطی جهت نمایش توضیحات.', + 'property_recordfinder_prompt' => 'متن', + 'property_recordfinder_prompt_description' => 'متنی که به هنگام نبود هیچ رکوردی به نمایش در می آید. %s بیانگر آیکن جستجو می باشد. جهت استفاده از مقدار پیشفرض این گزینه را خالی رها کنید.', + 'property_recordfinder_list' => 'تنظیمات لیست', + 'property_recordfinder_list_description' => 'مرجعی برای تعریف ستون های لیست. علامت $ به پوشه افزونه ها اشاره میکند برای مثال: $/acme/blog/lists/_list.yaml', + 'property_recordfinder_list_required' => 'لطفا آدرس فایل YAML را وارد نمایید', + 'property_group_recordfinder' => 'انتخابگر رکورد', + 'property_mediafinder_mode' => 'حالت نمایش', + 'property_mediafinder_mode_file' => 'فایل', + 'property_mediafinder_mode_image' => 'تصویر', + 'property_mediafinder_prompt' => 'متن', + 'property_mediafinder_prompt_description' => 'متنی که به هنگام خالی بودن نمایش داده شود. %s به آیکن جستجو اشاره میکند. جهت استفاده از مقدار پیشفرض این گزینه را خالی بگذارید.', + 'property_group_relation' => 'ارتباط', + 'property_relation_select' => 'تحديد', + 'property_relation_select_description' => 'كونكات أعمدة متعددة معا لعرض اسم', + 'property_relation_prompt' => 'متن', + 'property_relation_prompt_description' => 'متنی که به هنگام موجود نبودن موردی جهت انتخاب نمایش داده میشود.', + 'control_group_standard' => 'استاندارد', + 'control_group_widgets' => 'ابزارک ها', + 'click_to_add_control' => 'افزودن کنترل', + 'loading' => 'درحال بارگذاری...', + 'control_text' => 'متن', + 'control_text_description' => 'ابزار ورود متن تک خطی', + 'control_password' => 'کلمه عبور', + 'control_password_description' => 'ابزار ورود کلمه عبور', + 'control_checkbox' => 'چک باکس', + 'control_checkbox_description' => 'یک چک باکس', + 'control_switch' => 'سویچ', + 'control_switch_description' => 'سوئیچ روشن و خاموش که میتواند جایگزین چک باکس شود.', + 'control_textarea' => 'متن چند خطی', + 'control_textarea_description' => 'ابزار ورود متن چند خطی', + 'control_dropdown' => 'لیست بازشونده', + 'control_dropdown_description' => 'لیست بازشونده با موارد مشخص و یا متغیر', + 'control_unknown' => 'نوع ابزار :type یافت نشد', + 'control_repeater' => 'تکرار کننده', + 'control_repeater_description' => 'تکرار کننده مجموعه ای از ابزار ها', + 'control_number' => 'عدد', + 'control_number_description' => 'ابزار تک خطی جهت ورود عدد.', + 'control_hint' => 'هشدار', + 'control_hint_description' => 'نشان دهنده یک بخش به عنوان هشدار و یا راهنمایی که میتواند توسط کاربر مخفی شود.', + 'control_partial' => 'بخش', + 'control_partial_description' => 'نشان دهنده محتوی یک بخش', + 'control_section' => 'قسمت', + 'control_section_description' => 'نمایش یک قسمت از فرم با عنوان و زیر عنوان', + 'control_radio' => 'لیست رادیویی', + 'control_radio_description' => 'لیستی از انتخاب گر های رادیویی که در هر لحظه فقط یک مورد میتواند انتخاب شود.', + 'control_radio_option_1' => 'گزینه 1', + 'control_radio_option_2' => 'گزینه 2', + 'control_checkboxlist' => 'لیست چک باکس', + 'control_checkboxlist_description' => 'لیستی از چک باکس', + 'control_codeeditor' => 'ادیتور کد', + 'control_codeeditor_description' => 'ادیتور کد که جهت ورود کد مورد استفاده قرار میگیرد', + 'control_colorpicker' => 'انتخابگر رنگ', + 'control_colorpicker_description' => 'فیلدی جهت انتخاب کد هگزادسیمال رنگ', + 'control_datepicker' => 'انتخابگر تاریخ', + 'control_datepicker_description' => 'ابزاری جهت انتخای تاریخ و زمان', + 'control_richeditor' => 'ویرایشگر متن', + 'control_richeditor_description' => 'ابزاری جهت ویرایش و فرمت بندی متن', + 'control_markdown' => 'ویرایشگر مارک داون', + 'control_markdown_description' => 'ویرایشگر ابتدایی جهت ورود و ویرایش متن در قالب مارک داون', + 'control_fileupload' => 'ارسال فایل', + 'control_fileupload_description' => 'ارسال کننده فایل جهت ارسال تصویر و یا فایل', + 'control_recordfinder' => 'انتخاب گر موارد', + 'control_recordfinder_description' => 'ابزاری جهت انتخاب موارد مرتبط در پایگاه داده با امکان جستجو', + 'control_mediafinder' => 'انتخابگر چند رسانه ای', + 'control_mediafinder_description' => 'ابزاری جهت انتخاب فایل های چند رسانه ای در ابزار مدیریت چند رسانه ای', + 'control_relation' => 'ارتباط', + 'control_relation_description' => 'نمایش لیست بازشونده و یا لیست چک باکس جهت انتخاب ارتباطات پایگاه داده', + 'error_file_name_required' => 'لطفا نام فایل فرم را وارد نمایید.', + 'error_file_name_invalid' => 'نام فایل میتواند شامل حروف لاتین، اعداد، خط زیر، خط تیره و یا نقطه باشد.', + 'span_left' => 'چپ', + 'span_right' => 'راست', + 'span_full' => 'کامل', + 'span_auto' => 'خودکار', + 'empty_tab' => 'بخش خالی', + 'confirm_close_tab' => 'بخش حاوی ابزار هایی می باشد که پاک خواهند شد. آیا میخواهید ادامه دهید؟', + 'tab' => 'بخش فرم', + 'tab_title' => 'عنوان', + 'controls' => 'ابزار ها', + 'property_tab_title_required' => 'وارد کردن عنوان بخش اجباریست', + 'tabs_primary' => 'بخش اصلی', + 'tabs_secondary' => 'بخش ثانویه', + 'tab_stretch' => 'کامل', + 'tab_stretch_description' => 'مشخص میکند که طول بخش برابر با طول والد خود باشد یا خیر', + 'tab_css_class' => 'کلاس CSS', + 'tab_css_class_description' => 'مقدار دهی خاصیت کلاس دربرگیرنده ابزار', + 'tab_name_template' => 'بخش %s', + 'tab_already_exists' => 'بخشی با نام مشخص شده وجود دارد' + ], + 'list' => [ + 'tab_new_list' => 'لیست جدید', + 'saved'=> 'لیست با موفقیت ذخیره شد.', + 'confirm_delete' => 'آیا از حذف این لیست اطمینان دارید؟', + 'tab_columns' => 'ستون ها', + 'btn_add_column' => 'ستون جدید', + 'btn_delete_column' => 'حذف ستون', + 'column_dbfield_label' => 'فیلد', + 'column_dbfield_required' => 'لطفا فیلد مدل را وارد نمایید', + 'column_name_label' => 'عنوان', + 'column_label_required' => 'لطفا عنوان ستون را وارد نمایید.', + 'column_type_label' => 'نوع', + 'column_type_required' => 'لطفا نوع ستون را وارد نمایید.', + 'column_type_text' => 'متن', + 'column_type_number' => 'عدد', + 'column_type_switch' => 'سوییچ', + 'column_type_datetime' => 'تاریخ و زمان', + 'column_type_date' => 'تاریخ', + 'column_type_time' => 'زمان', + 'column_type_timesince' => 'تفاوت زمانی', + 'column_type_timetense' => 'تفاوت زمانی', + 'column_type_select' => 'انتخاب', + 'column_type_partial' => 'بخش', + 'column_label_default' => 'پیشفرض', + 'column_label_searchable' => 'قابلیت جستجو', + 'column_label_sortable' => 'قابلیت مرتب سازی', + 'column_label_invisible' => 'مخفی', + 'column_label_select' => 'انتخاب', + 'column_label_relation' => 'ارتباط پایگاه داده', + 'column_label_css_class' => 'کلاس CSS', + 'column_label_width' => 'عرض', + 'column_label_path' => 'مسیر', + 'column_label_format' => 'قالب', + 'column_label_value_from' => 'مقدار گرفته شده از', + 'error_duplicate_column' => "نام ':column' برای ستون تکراری میباشد." + ], + 'controller' => [ + 'menu_label' => 'کنترلر ها', + 'no_records' => 'کنترلری در افزونه یافت نشد.', + 'controller' => 'کنترلر', + 'behaviors' => 'کنترل کننده رفتار از پیش تایین شده', + 'new_controller' => 'کنترلر جدید', + 'error_controller_has_no_behaviors' => 'کنترلر حاوی کنترل کننده رفتار از پیش تایین شده که حاوی تنظیمات باشد ندارد', + 'error_invalid_yaml_configuration' => 'خطایی در بارگذاری فایل :file مربوط به تنظیمات کنترل کننده رفتار از پیش تایین شده به وجود آمده است', + 'behavior_form_controller' => 'کنترل کننده رفتار از پیش تایین شده فرم', + 'behavior_form_controller_description' => 'افزودن امکان مدیریت فرم ها به صفحه مدیریت. این امکان سه صفحه ایجاد، به روزرسانی و پیش نمایش را اضافه میکند.', + 'property_behavior_form_placeholder' => '--انتخاب فرم--', + 'property_behavior_form_name' => 'نام', + 'property_behavior_form_name_description' => 'نام شی ای که توسط فرم مدیریت می شود', + 'property_behavior_form_name_required' => 'لطفا نام فرم را وارد نمایید.', + 'property_behavior_form_file' => 'تنظیمات فرم', + 'property_behavior_form_file_description' => 'به یک فایل تعریف فرم اشاره میکند.', + 'property_behavior_form_file_required' => 'لطفا آدرس فایل تنظیمات فرم را وارد نمایید.', + 'property_behavior_form_model_class' => 'کلاس مدل', + 'property_behavior_form_model_class_description' => 'نام کلاس مدل که داده ها از آن بارگذاری شده و ذخیره می شوند.', + 'property_behavior_form_model_class_required' => 'لطفا نام کلاس مدل را وارد نمایید', + 'property_behavior_form_default_redirect' => 'مسیر انتقال پیشفرض', + 'property_behavior_form_default_redirect_description' => 'آدرس صفحه ای جهت انتقال به هنگامی که فرم ذخیره میشود یا کاربر از ادامه کار انصراف می دهد.', + 'property_behavior_form_create' => 'صفحه ایجاد', + 'property_behavior_form_redirect' => 'انتقال', + 'property_behavior_form_redirect_description' => 'آدرس صفحه ای که به هنگام ایجاد مورد جدید به آن انتقال داده میشود', + 'property_behavior_form_redirect_close' => 'انتقال به هنگام خروج', + 'property_behavior_form_redirect_close_description' => 'آدرس صفحه ای که به هنگام کلیک دکمه انتقال و خروج به آن انتقال داده می شود.', + 'property_behavior_form_flash_save' => 'پیغام نمایش داده شده به هنگام ذخیره', + 'property_behavior_form_flash_save_description' => 'پیغامی که به هنگام ذخیره مورد نمایش داده می شود.', + 'property_behavior_form_page_title' => 'عنوان صفحه', + 'property_behavior_form_update' => 'صفحه ویرایش', + 'property_behavior_form_update_redirect' => 'انتقال', + 'property_behavior_form_create_redirect_description' => 'صفحه ای که به هنگام ذخیره مورد به آن انتقال داده می شود.', + 'property_behavior_form_flash_delete' => 'پیغام حذف', + 'property_behavior_form_flash_delete_description' => 'پیغامی که به هنگام حذف نمایش داده میشود.', + 'property_behavior_form_preview' => 'صفحه پیش نمایش', + 'behavior_list_controller' => 'کنترل کننده رفتار از پیش تایین شده لیست', + 'behavior_list_controller_description' => 'امکان نمایش لیستی با قابلیت جستجو و مرتب سازی را به کنترلر اظافه میکند. این امکان صفحه اصلی (index) را در کنترلر ایجاد میکند.', + 'property_behavior_list_title' => 'عنوان لیست', + 'property_behavior_list_title_required' => 'لطفا عنوان لیست را وارد نمایید', + 'property_behavior_list_placeholder' => '--انتخاب لیست--', + 'property_behavior_list_model_class' => 'کلاس مدل', + 'property_behavior_list_model_class_description' => 'نام کلاس مدلی که اطلاعات لیست از آن بارگذاری میشود.', + 'property_behavior_form_model_class_placeholder' => '--انتخاب مدل--', + 'property_behavior_list_model_class_required' => 'لطفا کلاس مدل را انتخاب نمایید', + 'property_behavior_list_model_placeholder' => '--انتخاب مدل--', + 'property_behavior_list_file' => 'فایل تنظیمات لیست', + 'property_behavior_list_file_description' => 'به یک فایل تعریف لیست اشاره میکند', + 'property_behavior_list_file_required' => 'لطفا مسیر فایل تنظیمات لیست را وارد نمایید.', + 'property_behavior_list_record_url' => 'آدرس مورد', + 'property_behavior_list_record_url_description' => 'آدرس صفحه هر مورد در لیست که در آن :id به مشخصه لیست اشاره میکند برای مثال: users/update:id', + 'property_behavior_list_no_records_message' => 'پیغام خالی بودن لیست', + 'property_behavior_list_no_records_message_description' => 'پیغامی که به هنگام خالی بودن لیست به نمایش در می آید.', + 'property_behavior_list_recs_per_page' => 'تعداد موارد در هر صفحه', + 'property_behavior_list_recs_per_page_description' => 'تعداد موارد در هر صفحه را مشخص میکند برای نمایش تمام موارد در یک صفحه این مقدار را 0 قرار دهید. مقدار پیشفرض: 0', + 'property_behavior_list_recs_per_page_regex' => 'مقدار تعداد موارد در هر صفحه باید یک عدد صحیح باشد.', + 'property_behavior_list_show_setup' => 'نمایش دکمه تنظیمات', + 'property_behavior_list_show_sorting' => 'نمایش مرتب سازی', + 'property_behavior_list_default_sort' => 'مرتب سازی پیشفرض', + 'property_behavior_form_ds_column' => 'ستون', + 'property_behavior_form_ds_direction' => 'جهت مرتب سازی', + 'property_behavior_form_ds_asc' => 'صعودی', + 'property_behavior_form_ds_desc' => 'نزولی', + 'property_behavior_list_show_checkboxes' => 'نمایش چک باکس', + 'property_behavior_list_onclick' => 'کنترل کننده کلیک', + 'property_behavior_list_onclick_description' => 'کد شخصی سازی شده جاوا اسکریپت به هنگام کلیک هر رکورد.', + 'property_behavior_list_show_tree' => 'نمایش درخت وار', + 'property_behavior_list_show_tree_description' => 'نمایش درخت وار موارد والد و فرزندی.', + 'property_behavior_list_tree_expanded' => 'درخت باز شده', + 'property_behavior_list_tree_expanded_description' => 'آیا تمامی موارد درخت به صورت پیشفرض باز باشند؟', + 'property_behavior_list_toolbar' => 'نوار ابزار', + 'property_behavior_list_toolbar_buttons' => 'بخش دکمه ها', + 'property_behavior_list_toolbar_buttons_description' => 'به یک فایل بخش موجود در کنترلر اشاره میکند. به عنوان مثال: list_toolbar', + 'property_behavior_list_search' => 'جستجو', + 'property_behavior_list_search_prompt' => 'متن جستجو', + 'property_behavior_list_filter' => 'تنظیمات فیلتر', + 'error_controller_not_found' => 'فایل کنترلر یافت نشد', + 'error_invalid_config_file_name' => 'تعریف فایل (:file) مربوط به کنترل کننده از پیش تایین شده :class صحیح نمی باشد.', + 'error_file_not_yaml' => 'فایل تنطیمات (:file) مربوط به کنترل کننده از پیش تایین شده باید از نوع YAML باشد.', + 'saved' => 'کنترلر با موفقیت ذخیره شدو', + 'controller_name' => 'نام کنترلر', + 'controller_name_description' => 'نام کنترلر مشخص کننده نام و آدرس آن در صفحه مدیریت می باشد و باید از استاندارد های نامگذاری متغیر در PHP پیروی کند. همچنین نام باید با حرف بزرگ لاتین شروع شود برای مثال: Categories', + 'base_model_class' => 'کلاس مدل', + 'base_model_class_description' => 'نام کلاس مدلی را که جهت استفاده توسط کنترل کننده های رفتار از پیش تایین شده مورد استفاده قرار میگیرد را وارد نمایید.', + 'base_model_class_placeholder' => '--انتخاب مدل--', + 'controller_behaviors' => 'کنترل کننده های رفتار از پیش تایین شده', + 'controller_behaviors_description' => 'لطفا کنترل کننده های رفتار از پیش تایین شده برای کنترلر را انتخاب نمایید. سازنده فایل های نمایش مربوط به هر یک از آنها را به صورت خودکار ایجاد میکند.', + 'controller_permissions' => 'مجوزهای دسترسی', + 'controller_permissions_description' => 'مجوز های دسترسی برای هر یک از بخش های کنترلر را وارد نمایید. مجوز ها در بخش مجوز ها قابل تعریف میباشند و شما میتوانید آنها را بعدا در کد PHP ویرایش نمایید.', + 'controller_permissions_no_permissions' => 'این افزونه دارای مجوزی نمی باشد.', + 'menu_item' => 'منوی فعال', + 'menu_item_description' => 'منو ای را که میخواهید به هنگام نمایش صفحه کنترلر فعال شود انتخاب نمایید. این گزینه بعدا در کد PHP کنترلر قابل تغییر می باشد.', + 'menu_item_placeholder' => '--انتخاب منو--', + 'error_unknown_behavior' => 'کنترل کننده رفتار از پیش تایین شده :class در شی مدیریت این موارد اضافه نشده است.', + 'error_behavior_view_conflict' => 'کنترل کننده های رفتار از پیش تایین شده انتخاب شده دارای موارد تداخلی (:view) می باشد و نمیتواند همزمان استفاده شود.', + 'error_behavior_config_conflict' => 'کنترل کننده های رفتار انتخاب شده حاوی فایل تنظیمات (:file) تداخلی بود و نمی توانند همزمان استفاده شوند.', + 'error_behavior_view_file_not_found' => 'قالب نمایشی :view در کنترل کننده رفتار از پیش تایین شده :class یافت نشد.', + 'error_behavior_config_file_not_found' => 'قالب فایل تنظیمات :file در کنترل کننده رفتار از پیش تایین شده :class یافت نشد.', + 'error_controller_exists' => 'فایل کنترلر :file قبلا ایجاد شده است.', + 'error_controller_name_invalid' => 'نام کنترلر صحیح نمی باشد. نام میتواند شامل حروف لاتین و اعداد بوده و باید با یک حرف بزرگ لاتین شروع شود.', + 'error_behavior_view_file_exists' => 'فایل نمایشی کنترلر :view قبلا ایجاد شده است.', + 'error_behavior_config_file_exists' => 'فایل تنظیمات :file مربوط به کنترل کننده رفتار از پیش تایین شده قبلا ایجاد شده است.', + 'error_save_file' => 'خطا به هنگام ذخیره فایل کنترلر: :file', + 'error_behavior_requires_base_model' => 'کنترل کننده رفتار از پیش تایین شده :behavior نیاز به انتخاب شدن کلاس مدل دارد.', + 'error_model_doesnt_have_lists' => 'مدل انتخاب شده حاوی لیستی نمی باشد. لطفا یک لیست برای آن ایجاد کنید.', + 'error_model_doesnt_have_forms' => 'مدل انتخاب شده حاوی فرمی نمی باشد. لطفا یک فرم برای آن ایجاد کنید.' + ], + 'version' => [ + 'menu_label' => 'ویرایش ها', + 'no_records' => 'ویرایشی برای افزونه یافت نشد', + 'search' => 'جستجو...', + 'tab' => 'ویرایش ها', + 'saved' => 'ویرایش با موفقیت ذخیره شد.', + 'confirm_delete' => 'آیا از حذف این ویرایش اطمینان دارید؟', + 'tab_new_version' => 'ویرایش جدید', + 'migration' => 'ساختار پایگاه داده', + 'seeder' => 'داده های پایگاه داده', + 'custom' => 'افزودن عدد ویرایش', + 'apply_version' => 'اعمال ویرایش', + 'applying' => 'درحال اعمال...', + 'rollback_version' => 'عقب گرد ویرایش', + 'rolling_back' => 'درحال عقبگرد...', + 'applied' => 'ویرایش با موفقیت اعمال شد.', + 'rolled_back' => 'ویرایش با موفقیت به عقب بازگشت.', + 'hint_save_unapplied' => 'شما یک نسخه اعمال نشده را ذخیره کردید. این نسخه ها به هنگام ورود شما و یا کاربر دیگری و یا ذخیره جدولی در پایگاه داده به صورت خودکار اعمال خواهند شد.', + 'hint_rollback' => 'ویرایش های قبلی و بازگشت داده شده به صورت خودکار در هنگام اعمال ویرایش جدید تر، ورود به بخش مدیریت و یا ایجاد و ذخیره جدولی در پایگاه داده به صورت خودکار اعمال خواهند شد.', + 'hint_apply' => 'اعمال یک ویرایش تمامی ویرایش های قبلی اعمال نشده را نیز اعمال خواهد کرد', + 'dont_show_again' => 'مجددا نمایش نده.', + 'save_unapplied_version' => 'ذخیره ویرایش اعمال نشده' + ], + 'menu' => [ + 'menu_label' => 'منوی مدیریت', + 'tab' => 'منو ها', + 'items' => 'موارد منو', + 'saved' => 'این منو با موفقیت ذخیره شد.', + 'add_main_menu_item' => 'افزودن منوی جدید در ریشه', + 'new_menu_item' => 'مورد منو', + 'add_side_menu_item' => 'افزودن زیر منو', + 'side_menu_item' => 'مورد منوی کناری', + 'property_label' => 'عنوان', + 'property_label_required' => 'لطفا عنوان منو را وارد نمایید', + 'property_url_required' => 'لطفا آدرس منو را وارد نمایید', + 'property_url' => 'آدرس', + 'property_icon' => 'آیکن', + 'property_icon_required' => 'لطفا آیکن منو را وارد نمایید', + 'property_permissions' => 'مجوز ها', + 'property_order' => 'ترتیب', + 'property_order_invalid' => 'مقدار وارد شده برای ترتیب منو باید عدد صحیح باشد.', + 'property_order_description' => 'ترتیب منو مشخص کننده ترتیب قرارگیری آن می باشد و اگر وارد نشود منو در انتهای لیست قرار میگیرد. مقدار این مورد بهتر است بیش از عدد 100 باشد.', + 'property_attributes' => 'خصوصیات HTML', + 'property_code' => 'کد', + 'property_code_invalid' => 'کد میتواند حاوی حروف لاتین و اعداد باشد.', + 'property_code_required' => 'لطفا کد مربوط به منو را وارد نمایید.', + 'error_duplicate_main_menu_code' => "کد ':code' وارد شده برای منوی اصلی تکراریست.", + 'error_duplicate_side_menu_code' => "کد ':code' وارد شده برای منوی کناری تکراریست." + ], + 'localization' => [ + 'menu_label' => 'بومی سازی', + 'language' => 'زبان', + 'strings' => 'رشته های متنی', + 'confirm_delete' => 'آیا از حذف این زبان اطمینان دارید؟', + 'tab_new_language' => 'ربان جدید', + 'no_records' => 'زبانی یافت نشد.', + 'saved' => 'فایل زبان با موفقیت ذخیره شد.', + 'error_cant_load_file' => 'فایل زبان مورد درخواست یافت نشد.', + 'error_bad_localization_file_contents' => 'خطا در بارگذاری فایل زبان. فایل زبان میتواند شامل تعریف آرایه و رشته های متنی باشد.', + 'error_file_not_array' => 'خطا در بارگذاری فایل زبان. فایل زبان باید یک آرایه بازگرداند/', + 'save_error' => "خطا در ذخیره فایل ':name'. لطفا مجوز خای ذخیره فایل را بررسی نمایید.", + 'error_delete_file' => 'خطا در حذف فایل زبان.', + 'add_missing_strings' => 'افزودن رشته های جدید', + 'copy' => 'کپی', + 'add_missing_strings_label' => 'زبانی را که حاوی رشته جدید میباشد را انتخاب نمایید.', + 'no_languages_to_copy_from' => 'زبان دیگری جهت کپی رشته های جدید موجود نمی باشد.', + 'new_string_warning' => 'رشته یا بخش جدید', + 'structure_mismatch' => 'ساختار فایل منبع زبان با فایلی که در حال ویرایش می باشد مطابقت ندارد. برخی رشته ها در فایل در حال ویرایش فایل منبع را دچار مشکل میکند و فایل ها به صورت خودکار قابلیت تجمیع ندارند. ', + 'create_string' => 'ایجاد رشته متنی جدید', + 'string_key_label' => 'کلید رشته متنی', + 'string_key_comment' => 'کلید رشته متنی را که از نقطه به عنوان جدا کننده بخش ها استفاده میکند وارد نمایید. به عنوان مثال: plugin.search. رشته متنی در زبان پیشفرض بومی سازی افزونه ذخیره خواهد شد.', + 'string_value' => 'مقدار رشته متنی', + 'string_key_is_empty' => 'ورود کلید رشته متنی اجباریست.', + 'string_value_is_empty' => 'ورود مقدار رشته متنی اجباریست.', + 'string_key_exists' => 'کلید رشته وارد شده تکراری می باشد.' + ], + 'permission' => [ + 'menu_label' => 'مجوز های دسترسی', + 'tab' => 'مجوز های دسترسی', + 'form_tab_permissions' => 'مجوز های دسترسی', + 'btn_add_permission' => 'مجوز دسترسی جدید', + 'btn_delete_permission' => 'حذف مجوز دسترسی', + 'column_permission_label' => 'کد مجوز دسترسی', + 'column_permission_required' => 'لطفا کد مجوز دسترسی را وارد نمایید', + 'column_tab_label' => 'عنوان بخش', + 'column_tab_required' => 'لطفا عنوان بخش مجوز دسترسی را وارد نمایید', + 'column_label_label' => 'عنوان', + 'column_label_required' => 'لطفا عنوان مجوز دسترسی را وارد نمایید.', + 'saved' => 'مجوز های دسترسی با موفقیت ذخیره شدند.', + 'error_duplicate_code' => "کد وارد شده ':code' برای مجوز دسترسی تکراری می باشد." + ], + 'yaml' => [ + 'save_error' => "خطا در ذخیره فایل ':name'. لطفا مجوزهای مربوط به نوشتن بر روی دیسک را بررسی نمایید." + ], + 'common' => [ + 'error_file_exists' => "فایل ':path' قبلا ایجاد شده است.", + 'field_icon_description' => 'اکتبر از آیکن فونت خود به آدری http://daftspunk.github.io/Font-Autumn استفاده می نماید', + 'destination_dir_not_exists' => "پوشه هدف به آدرس ':path' یافت نشد.", + 'error_make_dir' => "خطا در ایجاد پوشه به آدرس ':name'", + 'error_dir_exists' => "پوشه ':path' قبلا ایجاد شده است.", + 'template_not_found' => "فایل قالب ':name' یافت نشد.", + 'error_generating_file' => "خطا در تولید فایل ':path'.", + 'error_loading_template' => "خطا در بارگذاری قالب ':name'.", + 'select_plugin_first' => 'لطفا افزونه ای را انتخاب نمایید. جهت انتخاب افزونه بر روی آیکون > در سمت راست منوی کناری کلیک نمایید.', + 'plugin_not_selected' => 'افزونه ای انتخاب نشده است', + 'add' => 'افرودن' + ], + 'migration' => [ + 'entity_name' => 'ساختار بانک اطلاعاتی', + 'error_version_invalid' => 'ویرایش باید در این قالب وارد شود: 1.0.1', + 'field_version' => 'ویرایش', + 'field_description' => 'توضیحات', + 'field_code' => 'کد', + 'field_code_comment' => 'کد ساختار بانک اطلاعاتی فقط خواندنی و فقط جهت پیش نمایش می باشد. شما میتوانید ساختار بانک اطلاعاتی سفارشی را به صورت دستی در بخش ویرایش ها ایجاد نمایید.', + 'save_and_apply' => 'ذخیره و اعمال', + 'error_version_exists' => 'فایل ساختار بانک اطلاعاتی قبلا تعریف شده است.', + 'error_script_filename_invalid' => 'نام فایل ساختار بانک اطلاعاتی فقط میتواند حاوی حروف لاتین، اعداد و خط زیر باشد و با یک حرف لاتین بزرگ شروع شود.', + 'error_cannot_change_version_number' => 'شماره ویرایش اعمال شده قابل تغییر نمی باشد.', + 'error_file_must_define_class' => 'کد ساختار بانک اطلاعاتی باید کلاس migration و یا seeder را تعریف کند. اگر فقط میخواهید فقط نسخه را افزایش دهید کد را خالی بگذارید.', + 'error_file_must_define_namespace' => 'ساختار بانک اطلاعاتی باشد شامل نیم اسپیس باشد. اگر فقط میخواهید شماره ویرایش را افزایش دهید کد را خالی بگذارید.', + 'no_changes_to_save' => 'تغییراتی جهت ذخیره وجود ندارد.', + 'error_namespace_mismatch' => "کد ساختار بانک اطلاعاتی باید از نیم اسپیس افزونه :namespace استفاده نماید.", + 'error_migration_file_exists' => "فایل ساختار بانک اطلاعات :file وجود دارد لطفا نام دیگری را وارد نمایید.", + 'error_cant_delete_applied' => 'این ویرایش اعمال شده است و شما نمیتوانید آن را حذف کنید لطفا جهت حذف آن ویرایش را به عقب باز گردانید.' + ], + 'components' => [ + 'list_title' => 'لیست موارد', + 'list_description' => 'نمایش لیستی از موارد مدل انتخاب شده', + 'list_page_number' => 'شماره صفحه', + 'list_page_number_description' => 'این مقدار جهت تعیین صفحه ای که کاربر در آن می باشد مورد استفاده قرار میگیرد.', + 'list_records_per_page' => 'تعداد موارد در هر صفحه', + 'list_records_per_page_description' => 'تعداد مواردی که در هر صفحه به نمایش در می آیند. جهت استفاده نکردن از خاصیت چند صفحه ای این مورد را خالی بگذارید.', + 'list_records_per_page_validation' => 'مقدار وارد شده در تعداد موارد در هر صفحه باید یک عدد صحیح باشد.', + 'list_no_records' => 'پیغام خالی بودن لیست', + 'list_no_records_description' => 'پیغامی که به هنگام نبودن موردی جهت نمایش به نمایش در می آید.', + 'list_no_records_default' => 'موردی یافت نشد', + 'list_sort_column' => 'مرتب سازی بر اساس', + 'list_sort_column_description' => 'ستونی که موارد بر اساس آن باید مرتب شوند', + 'list_sort_direction' => 'ترتیب مرتب سازی', + 'list_display_column' => 'نمایش ستون', + 'list_display_column_description' => 'ستونی که در لیست به نمایش در می آید.', + 'list_display_column_required' => 'لطفا ستونی را جهت نمایش انتخاب کنید.', + 'list_details_page' => 'صفحه جزییات', + 'list_details_page_description' => 'صفحه ای جهت نمایش جزییات موارد', + 'list_details_page_no' => '--صفحه جزییات موجود نیست--', + 'list_sorting' => 'مرتب سازی', + 'list_pagination' => 'صفحه بندی', + 'list_order_direction_asc' => 'صعودی', + 'list_order_direction_desc' => 'نزولی', + 'list_model' => 'کلاس مدل', + 'list_scope' => 'محدوده', + 'list_scope_description' => 'محدوده اختیاری کلاس مدل جهت واکشی موارد', + 'list_scope_default' => '--محدوده را انتخاب نمایید، اختیاری--', + 'list_details_page_link' => 'آدرس صفحه جزییات', + 'list_details_key_column' => 'ستون کلید جزییات', + 'list_details_key_column_description' => 'ستونی در مدل به عنوان کلید که مورد جهت نمایش جزییات از طریق آن در پایگاه داده یافت می شود.', + 'list_details_url_parameter' => 'پارامتر نام آدرس', + 'list_details_url_parameter_description' => 'نام پارامتر آدرس صفحه جزییات که کلید مورد را دریافت میکند.', + 'details_title' => 'جزییات مورد', + 'details_description' => 'نمایش جزییات مورد از مدل انتخاب شده', + 'details_model' => 'کلاس مدل', + 'details_identifier_value' => 'مقدار مشخصه', + 'details_identifier_value_description' => 'مقدار مشخصه جهت بارگذاری مورد از پایگاه داده. میتواند یک مقدار ثابت و یا پارامتر آدرس باشد.', + 'details_identifier_value_required' => 'وارد کردن مقدار مشخصه اجباریست', + 'details_key_column' => 'ستون کلید', + 'details_key_column_description' => 'ستونی در مدل که به عنوان مشخصه برای واکشی مورد در پایگاه داده مورد استفاده قرار میگیرد.', + 'details_key_column_required' => 'وارد کردن ستون کلید اجباریست', + 'details_display_column' => 'ستون نمایشی', + 'details_display_column_description' => 'ستونی در مدل که جهت نمایش در صفحه جزییات مورد استفاده قرار میگیرد.', + 'details_display_column_required' => 'وارد کردن ستون نمایشی اجباریست', + 'details_not_found_message' => 'موردی یافت نشد', + 'details_not_found_message_description' => 'پیغامی که به هنگام یافت نشدن مورد مورد استفاده قرار میگیرد.', + 'details_not_found_message_default' => 'موردی یافت نشد.', + ] +]; diff --git a/server/plugins/rainlab/builder/lang/nl/lang.php b/server/plugins/rainlab/builder/lang/nl/lang.php new file mode 100644 index 0000000..699c61a --- /dev/null +++ b/server/plugins/rainlab/builder/lang/nl/lang.php @@ -0,0 +1,654 @@ + [ + 'name' => 'Builder', + 'description' => 'Stelt visuele hulpmiddelen beschikbaar om October plugins te maken.', + 'add' => 'Maak plugin', + 'no_records' => 'Geen plugins aanwezig', + 'no_name' => 'Geen naam', + 'search' => 'Zoeken...', + 'filter_description' => 'Toon alle plugins of alleen eigen plugins.', + 'settings' => 'Instellingen', + 'entity_name' => 'Plugin', + 'field_name' => 'Naam', + 'field_author' => 'Auteur', + 'field_description' => 'Omschrijving', + 'field_icon' => 'Icoon', + 'field_plugin_namespace' => 'Plugin namespace', + 'field_author_namespace' => 'Auteur namespace', + 'field_namespace_description' => 'Een namespace kan alleen latijnse letters en cijfers bevatten en mag ook alleen met een letter beginnen. Bijvoorbeeld: Blog', + 'field_author_namespace_description' => 'Je kan de namespace van een Builder plugin niet meer wijzigen nadat je de plugin hebt gemaakt. Bijvoorbeeld: JohnSmith', + 'tab_general' => 'Algemeen', + 'tab_description' => 'Details', + 'field_homepage' => 'Plugin homepagina URL', + 'no_description' => 'Er is geen omschrijving opgegeven voor deze plugin.', + 'error_settings_not_editable' => 'De instellingen van deze plugin kunnen niet met Builder worden gewijzigd.', + 'update_hint' => 'Je kan de naam en omschrijving van de plugin vertalen in de \'Vertalen\' tab.', + ], + 'author_name' => [ + 'title' => 'Auteursnaam', + 'description' => 'Dit is de standaard auteursnaam die wordt gebruikt bij het maken van plugins. Deze naam staat niet vast, je kan hem altijd wijzigen in de instellingen van de plugin.', + ], + 'author_namespace' => [ + 'title' => 'Auteur namespace', + 'description' => 'Als je plugins maakt voor de Marketplace, dan moet de namespace gelijk zijn aan de auteur code en niet gewijzigd worden. Raadpleeg de documentatie voor aanvullende details.', + ], + 'database' => [ + 'menu_label' => 'Database', + 'no_records' => 'Geen database tabellen aanwezig', + 'search' => 'Zoeken...', + 'confirmation_delete_multiple' => 'Weet je zeker dat je de geselecteerde tabellen wilt verwijderen?', + 'field_name' => 'Tabelnaam', + 'tab_columns' => 'Kolommen', + 'column_name_name' => 'Kolom', + 'column_name_required' => 'Geef kolomnaam op', + 'column_name_type' => 'Type', + 'column_type_required' => 'Selecteer kolomtype', + 'column_name_length' => 'Lengte', + 'column_validation_length' => 'Lengte moet een getal zijn of een getal met dicimalen (10,2). Spaties zijn niet toegestaan.', + 'column_validation_title' => 'Alleen getallen, kleine letters en underscores zijn toegestaan in kolomnamen', + 'column_name_unsigned' => 'Unsigned', + 'column_name_nullable' => 'Nullable', + 'column_auto_increment' => 'AUTOINCR', + 'column_default' => 'Standaardwaarde', + 'column_auto_primary_key' => 'PK', + 'tab_new_table' => 'Nieuwe tabel', + 'btn_add_column' => 'Kolom toevoegen', + 'btn_delete_column' => 'Kolom verwijderen', + 'confirm_delete' => 'Do you really want to delete the table?', + 'error_enum_not_supported' => 'De tabel bevat kolom(men) van het type "enum", deze worden momenteel niet ondersteund door Builder.', + 'error_table_name_invalid_prefix' => "De tabelnaam moet starten met de plugin prefix: ':prefix'.", + 'error_table_name_invalid_characters' => 'Ongeldige tabelnaam. Tabelnamen mogen alleen latijnse letters, cijfers en underscores bevatten. Tabelnamen moeten beginnen met een letter en mogen geen spaties bevatten.', + 'error_table_duplicate_column' => "Kolomnaam bestaat reeds: ':column'.", + 'error_table_auto_increment_in_compound_pk' => 'Een `auto-increment` kolom kan geen deel uitmaken van een `compound primary key`.', + 'error_table_mutliple_auto_increment' => 'De tabel kan niet meerdere `auto-increment` kolommen bevatten.', + 'error_table_auto_increment_non_integer' => 'Auto-increment kolommen moeten van het type `integer` zijn.', + 'error_table_decimal_length' => "De lengte voor type `:type` moet voldoen aan het formaat '10,2', zonder spaties.", + 'error_table_length' => 'De lengte voor type `:type` moet als een integer worden gespecificeerd.', + 'error_unsigned_type_not_int' => "Fout gevonden in kolomdefinitie ':column'. De `unsigned` vlag mag alleen op type `integer` kolommen worden toegepast.", + 'error_integer_default_value' => "Ongeldige standaardwaarde voor kolom ':column'. Toegestane waardes zijn '10', '-10'.", + 'error_decimal_default_value' => "Ongeldige standaardwaarde voor kolom ':column'. Toegestane waardes zijn '1.00', '-1.00'.", + 'error_boolean_default_value' => "Ongeldige standaardwaarde voor kolom ':column'. Toegestane waardes zijn '0' and '1'.", + 'error_unsigned_negative_value' => "De standaardwaarde voor de kolom ':column' mag niet negatief zijn.", + 'error_table_already_exists' => "De tabel ':name' bestaat reeds in de database.", + ], + 'model' => [ + 'menu_label' => 'Models', + 'entity_name' => 'Model', + 'no_records' => 'Geen models aanwezig', + 'search' => 'Zoeken...', + 'add' => 'Toevoegen...', + 'forms' => 'Formulieren', + 'lists' => 'Lijsten', + 'field_class_name' => 'Klasse naam', + 'field_database_table' => 'Database tabel', + 'error_class_name_exists' => 'Model bestand bestaat reeds voor de opgegeven klasse naam: :path', + 'add_form' => 'Fomulier toevoegen', + 'add_list' => 'Lijst toevoegen', + ], + 'form' => [ + 'saved' => 'Het formulier is succesvol opgeslagen.', + 'confirm_delete' => 'Weet je zeker dat je het formulier wilt verwijderen?', + 'tab_new_form' => 'Nieuw formulier', + 'property_label_title' => 'Label', + 'property_label_required' => 'Voor waarde voor label in.', + 'property_span_title' => 'Uitlijning', + 'property_comment_title' => 'Toelichting', + 'property_comment_above_title' => 'Toelichting (boven)', + 'property_default_title' => 'Standaard', + 'property_checked_default_title' => 'Standaard aangevinkt', + 'property_css_class_title' => 'CSS klassenaam', + 'property_css_class_description' => 'Optionele CSS klassenaam die wordt toegewezen aan het veld element.', + 'property_disabled_title' => 'Uitgeschakeld', + 'property_hidden_title' => 'Verborgen', + 'property_required_title' => 'Verplicht', + 'property_field_name_title' => 'Veldnaam', + 'property_placeholder_title' => 'Tijdelijke aanduiding', + 'property_default_from_title' => 'Waarde van', + 'property_stretch_title' => 'Uitrekken', + 'property_stretch_description' => 'Geeft aan of dit veld uitrekt naar de breedte van het bovenliggende element.', + 'property_context_title' => 'Context', + 'property_context_description' => 'Geeft aan welk formulier context gebruikt moet worden om het veld weer te geven.', + 'property_context_create' => 'Aanmaken', + 'property_context_update' => 'Wijzigen', + 'property_context_preview' => 'Voorvertoning', + 'property_dependson_title' => 'Afhankelijk van', + 'property_trigger_action' => 'Actie', + 'property_trigger_show' => 'Weergeven', + 'property_trigger_hide' => 'Verbergen', + 'property_trigger_enable' => 'Inschakelen', + 'property_trigger_disable' => 'Uitschakelen', + 'property_trigger_empty' => 'Leeg', + 'property_trigger_field' => 'Veld', + 'property_trigger_field_description' => 'Geeft het veld aan wat de actie veroorzaakt.', + 'property_trigger_condition' => 'Voorwaarde', + 'property_trigger_condition_description' => 'Bepaald de voorwaarde waaraan het betreffende veld aan moet voldoen. Ondersteunde waarden: checked, unchecked, value[waarde].', + 'property_trigger_condition_checked' => 'Aangevinkt: checked', + 'property_trigger_condition_unchecked' => 'Uitgevinkt: unchecked', + 'property_trigger_condition_somevalue' => 'Waarde: value[waarde]', + 'property_preset_title' => 'Voorinstelling', + 'property_preset_description' => 'Zorgt ervoor dat de veldwaarde initieel wordt gevuld met de waarde van een ander veld, al dan niet geconverteerd.', + 'property_preset_field' => 'Veld', + 'property_preset_field_description' => 'Het veld waarvan de waarde moet overgenomen worden.', + 'property_preset_type' => 'Type', + 'property_preset_type_description' => 'Conversie type', + 'property_attributes_title' => 'Attributen', + 'property_attributes_description' => 'Custom HTML attributen die aan het formulier veld moeten worden toegevoegd.', + 'property_container_attributes_title' => 'Container attributen', + 'property_container_attributes_description' => 'Custom HTML attributen die aan het formulier veld container moeten worden toegevoegd.', + 'property_group_advanced' => 'Geavanceerd', + 'property_dependson_description' => 'Een lijst van veldnamen waar dit veld van afhankelijk is. Als die velden een andere waarde krijgen, zal dit veld worden bijgewerkt. Een veld per regel.', + 'property_trigger_title' => 'Trigger', + 'property_trigger_description' => 'Zorgt ervoor dat veld eigenschappen veranderen, zoals bijvoorbeeld zichtbaarheid of waarde, gebaseerd op de staat van een ander veld.', + 'property_default_from_description' => 'Neemt de standaardwaarde over van een ander veld.', + 'property_field_name_required' => 'Veldnaam is verplicht', + 'property_field_name_regex' => 'Veldnaam kan alleen latijnse karakters bevatten of _ - [ ] .', + 'property_attributes_size' => 'Grootte', + 'property_attributes_size_tiny' => 'Kleiner', + 'property_attributes_size_small' => 'Klein', + 'property_attributes_size_large' => 'Groter', + 'property_attributes_size_huge' => 'Groot', + 'property_attributes_size_giant' => 'Grootst', + 'property_comment_position' => 'Toelichting positie', + 'property_comment_position_above' => 'Boven', + 'property_comment_position_below' => 'Beneden', + 'property_hint_path' => 'Pad naar hint-sjabloon', + 'property_hint_path_description' => 'Pad naar sjabloon bestand die de hint tekst bevat. Gebruik het $ symbool om het hoofdpad van de plugin aan te geven. Voorbeeld: $/acme/blog/partials/_partial.htm', + 'property_hint_path_required' => 'Geef het hint-sjabloon pad op', + 'property_partial_path' => 'Pad naar sjabloon', + 'property_partial_path_description' => 'Pad naar sjabloon bestand. Gebruik het $ symbool om het hoofdpad van de plugin aan te geven. Voorbeeld: $/acme/blog/partials/_partial.htm', + 'property_partial_path_required' => 'Geef het sjabloon pad op', + 'property_code_language' => 'Taal', + 'property_code_theme' => 'Thema', + 'property_theme_use_default' => 'Gebruik standaard thema', + 'property_group_code_editor' => 'Code editor', + 'property_gutter' => 'Goot', + 'property_gutter_show' => 'Weergeven', + 'property_gutter_hide' => 'Verbergen', + 'property_wordwrap' => 'Woordafbreking', + 'property_wordwrap_wrap' => 'Afbreken', + 'property_wordwrap_nowrap' => 'Niet afbreken', + 'property_fontsize' => 'Grootte lettertype', + 'property_codefolding' => 'Code inklappen', + 'property_codefolding_manual' => 'Handmatig', + 'property_codefolding_markbegin' => 'Begin markeren', + 'property_codefolding_markbeginend' => 'Begin en einde markeren', + 'property_autoclosing' => 'Automatisch sluiten', + 'property_enabled' => 'Ingeschakeld', + 'property_disabled' => 'Uitgeschakeld', + 'property_soft_tabs' => 'Zachte tabs', + 'property_tab_size' => 'Tab grootte', + 'property_readonly' => 'Alleen-lezen', + 'property_use_default' => 'Standaard instelling', + 'property_options' => 'Opties', + 'property_prompt' => 'Invoer', + 'property_prompt_description' => 'Tekst op de toevoegknop.', + 'property_prompt_default' => 'Nieuw item', + 'property_available_colors' => 'Beschikbare kleuren', + 'property_available_colors_description' => 'Lijst van beschikbare kleuren in HEX formaat (#FF0000). Laat leeg voor standaard kleuren set. Een waarde per regel.', + 'property_datepicker_mode' => 'Modus', + 'property_datepicker_mode_date' => 'Datum', + 'property_datepicker_mode_datetime' => 'Datum en tijd', + 'property_datepicker_mode_time' => 'Tijd', + 'property_datepicker_min_date' => 'Minimale datum', + 'property_datepicker_min_date_description' => 'De minimale datum die geselecteerd kan worden. Laat leeg om de standaardwaarde te gebruiken (2000-01-01).', + 'property_datepicker_max_date' => 'Maximale datum', + 'property_datepicker_max_date_description' => 'De maximale datum die geselecteerd kan worden. Laat leeg om de standaardwaarde te gebruiken (2020-12-31).', + 'property_datepicker_date_invalid_format' => 'Ongeldig datum formaat. Gebruik het formaat YYYY-MM-DD.', + 'property_markdown_mode' => 'Modus', + 'property_markdown_mode_split' => 'Gesplitst', + 'property_markdown_mode_tab' => 'Tabblad', + 'property_fileupload_mode' => 'Modus', + 'property_fileupload_mode_file' => 'Bestand', + 'property_fileupload_mode_image' => 'Afbeelding', + 'property_group_fileupload' => 'Bestandsupload', + 'property_fileupload_prompt' => 'Prompt', + 'property_fileupload_prompt_description' => 'Tekst op de upload knop. Alleen van toepassing op bestandsmodus (optioneel).', + 'property_fileupload_image_width' => 'Breedte afbeelding', + 'property_fileupload_image_width_description' => 'Afbeeldingen zullen geschaald worden naar deze breedte (optioneel).', + 'property_fileupload_invalid_dimension' => 'Ongeldige waarde voor breedte/hoogte afbeelding, geef een getal in.', + 'property_fileupload_image_height' => 'Hoogte afbeelding', + 'property_fileupload_image_height_description' => 'Afbeeldingen zullen geschaald worden naar deze hoogte (optioneel).', + 'property_fileupload_file_types' => 'Bestandstypes', + 'property_fileupload_file_types_description' => 'Komma gescheiden lijst van toegestane bestandsextenties, bijvoorbeeld: zip,txt (optioneel).', + 'property_fileupload_mime_types' => 'MIME typen', + 'property_fileupload_mime_types_description' => 'Komma gescheiden lijst van toegestane MIME-typen; bestandsextenties of volledige namen, bijvoorbeeld: zip,txt', + 'property_fileupload_use_caption' => 'Gebruik annotatie', + 'property_fileupload_use_caption_description' => 'Staat toe dat er een titel en omschrijving kunnen worden opgegeven voor het bestand.', + 'property_fileupload_thumb_options' => 'Miniatuurweergave opties', + 'property_fileupload_thumb_options_description' => 'Beheer opties voor de automatisch gegenereerde miniatuurweergaven. Alleen van toepassing bij Afbeelding modus.', + 'property_fileupload_thumb_mode' => 'Modus', + 'property_fileupload_thumb_auto' => 'Automatisch', + 'property_fileupload_thumb_exact' => 'Exact', + 'property_fileupload_thumb_portrait' => 'Staand', + 'property_fileupload_thumb_landscape' => 'Liggend', + 'property_fileupload_thumb_crop' => 'Uitsnijden', + 'property_fileupload_thumb_extension' => 'Bestandsextentie', + 'property_name_from' => 'Kolomnaam', + 'property_name_from_description' => 'Gerelateerde kolomnaam die gebruikt moet worden voor het weergeven van een naam.', + 'property_description_from' => 'Omschrijving kolom', + 'property_description_from_description' => 'Gerelateerde kolomnaam die gebruikt moet worden voor het weergeven van een omschrijving.', + 'property_recordfinder_prompt' => 'Prompt', + 'property_recordfinder_prompt_description' => 'Text to display when there is no record selected. The %s character represents the search icon. Leave empty for the default prompt.', + 'property_recordfinder_list' => 'Lijst configuratie', + 'property_recordfinder_list_description' => 'Een referentie naar een lijstkolom definitie bestand. Gebruik het $ symbool om te refereren naar de plugin map, bijvoorbeeld: $/acme/blog/lists/_list.yaml', + 'property_recordfinder_list_required' => 'Geef een pad op naar het YAML bestand', + 'property_group_recordfinder' => 'Record zoeker', + 'property_mediafinder_mode' => 'Modus', + 'property_mediafinder_mode_file' => 'Bestand', + 'property_mediafinder_mode_image' => 'Afbeelding', + 'property_mediafinder_prompt' => 'Prompt', + 'property_mediafinder_prompt_description' => 'Tekst om weer te geven als er geen item geselecteerd is. Het karakter %s representeerd het media beheer icoon. Laat leeg voor de standaard prompt.', + 'property_group_relation' => 'Relatie', + 'property_relation_select' => 'kiezen', + 'property_relation_select_description' => 'CONCAT meerdere kolommen samen voor het weergeven van een naam', + 'property_relation_prompt' => 'Prompt', + 'property_relation_prompt_description' => 'Tekst om weer te geven als er geen selecties beschikbaar zijn.', + 'property_max_items' => 'Maximum aantal', + 'property_max_items_description' => 'Maximum toegelaten aantal items in de herhaler.', + 'control_group_standard' => 'Standaard', + 'control_group_widgets' => 'Widgets', + 'click_to_add_control' => 'Element toevoegen', + 'loading' => 'Bezig met laden...', + 'control_text' => 'Tekst', + 'control_text_description' => 'Invoerveld voor één regel tekst.', + 'control_password' => 'Wachtwoord', + 'control_password_description' => 'Invoerveld voor een wachtwoord.', + 'control_checkbox' => 'Keuzevakje', + 'control_checkbox_description' => 'Enkelvoudig keuzevakje.', + 'control_switch' => 'Schakelaar', + 'control_switch_description' => 'Enkelvoudige schakelaar, een alternatief voor het keuzevakje.', + 'control_textarea' => 'Tekst', + 'control_textarea_description' => 'Tekstvak voor meerdere regels met instelbare hoogte.', + 'control_dropdown' => 'Selectieveld', + 'control_dropdown_description' => 'Een selectie lijst met vaste of dynamische opties.', + 'control_unknown' => 'Onbekend element type: :type', + 'control_repeater' => 'Herhaler', + 'control_repeater_description' => 'Toont een set van herhalende formulier elementen.', + 'control_number' => 'Nummer', + 'control_number_description' => 'Invoerveld voor een nummer.', + 'control_hint' => 'Tip', + 'control_hint_description' => 'Toont een tip in een vakje die verborgen kan worden door een gebruiker.', + 'control_partial' => 'Partial', + 'control_partial_description' => 'Toont inhoud van een zgn. partial.', + 'control_section' => 'Sectie', + 'control_section_description' => 'Toont een formuliersectie met een kop- en subkoptekst.', + 'control_radio' => 'Lijst van invoerrondjes', + 'control_radio_description' => 'Een lijst van invoerrondjes, er kan maar één invoerrondje geselecteerd worden.', + 'control_radio_option_1' => 'Optie 1', + 'control_radio_option_2' => 'Optie 2', + 'control_checkboxlist' => 'Lijst van keuzevakjes', + 'control_checkboxlist_description' => 'Een lijst van keuzevakjes, er kunnen meerdere keuzevakjes geselecteerd worden.', + 'control_codeeditor' => 'Code editor', + 'control_codeeditor_description' => 'Een editor voor het bewerken van geformatteerde code of opmaakcode.', + 'control_colorpicker' => 'Kleur kiezer', + 'control_colorpicker_description' => 'Een veld met de mogelijkheid voor het selecteren van een hexadecimale kleurcode.', + 'control_datepicker' => 'Datum kiezer', + 'control_datepicker_description' => 'Een veld met de mogelijkheid voor het selecteren van een datum en tijd.', + 'control_richeditor' => 'WYSIWYG editor', + 'control_richeditor_description' => 'Een editor voor het bewerken van uitgebreide opgemaakte tekst.', + 'control_markdown' => 'Markdown editor', + 'control_markdown_description' => 'Een editor voor het bewerken van tekst in het Markdown formaat.', + 'control_fileupload' => 'Bestand uploader', + 'control_fileupload_description' => 'Een bestandsuploader voor afbeeldingen of reguliere bestanden.', + 'control_recordfinder' => 'Record veld', + 'control_recordfinder_description' => 'Een zoekveld met details van een gerelateerd record.', + 'control_mediafinder' => 'Media veld', + 'control_mediafinder_description' => 'Een veld die een item uit de Media bibliotheek kan bevatten.', + 'control_relation' => 'Relatie', + 'control_relation_description' => 'Toont een selectieveld of een lijst van keuzevakjes om een gerelateerd record te selecteren.', + 'error_file_name_required' => 'Voer bestandsnaam in van het formulier.', + 'error_file_name_invalid' => 'Bestandsnaam kan alleen latijnse karakters, cijfers of een van de volgende tekens bevatten: _ - #', + 'span_left' => 'Links', + 'span_right' => 'Rechts', + 'span_full' => 'Volledige breedte', + 'span_auto' => 'Automatisch', + 'empty_tab' => 'Leeg tabblad', + 'confirm_close_tab' => 'Het tabblad bevat elementen die verwijderd zullen worden. Doorgaan?', + 'tab' => 'Formulier tabblad', + 'tab_title' => 'Titel', + 'controls' => 'Elementen', + 'property_tab_title_required' => 'De titel van het tabblad is verplicht.', + 'tabs_primary' => 'Primaire tabs', + 'tabs_secondary' => 'Secundaire tabs', + 'tab_stretch' => 'Uitrekken', + 'tab_stretch_description' => 'Met deze optie geef je aan dat de inhoud van het tabblad meerekt naar de hoogte van het bovenliggende element.', + 'tab_css_class' => 'CSS class', + 'tab_css_class_description' => 'Wijst een CSS class toe aan de inhoud van het tabblad.', + 'tab_name_template' => 'Tabblad %s', + 'tab_already_exists' => 'Tabblad met opgegeven titel bestaat reeds.', + ], + 'list' => [ + 'tab_new_list' => 'Nieuwe lijst', + 'saved' => 'De lijst is succesvol opgeslagen.', + 'confirm_delete' => 'Weet je zeker dat je de lijst wilt verwijderen?', + 'tab_columns' => 'Kolommen', + 'btn_add_column' => 'Kolom toevoegen', + 'btn_delete_column' => 'Kolom verwijderen', + 'column_dbfield_label' => 'Veld', + 'column_dbfield_required' => 'Geef Model veld op', + 'column_name_label' => 'Label', + 'column_label_required' => 'Geef kolom label op', + 'column_type_label' => 'Type', + 'column_type_required' => 'Geef kolomtype op', + 'column_type_text' => 'Tekst', + 'column_type_number' => 'Numeriek', + 'column_type_switch' => 'Schakelaar', + 'column_type_datetime' => 'Datum & Tijd', + 'column_type_date' => 'Datum', + 'column_type_time' => 'Tijd', + 'column_type_timesince' => 'Datum & tijd sinds', + 'column_type_timetense' => 'Datum & tijd afgekort', + 'column_type_select' => 'Keuze', + 'column_type_partial' => 'Partial', + 'column_label_default' => 'Standaard', + 'column_label_searchable' => 'Zoeken', + 'column_label_sortable' => 'Sorteerbaar', + 'column_label_invisible' => 'Onzichtbaar', + 'column_label_select' => 'Select', + 'column_label_relation' => 'Relatie', + 'column_label_css_class' => 'CSS class', + 'column_label_width' => 'Breedte', + 'column_label_path' => 'Pad', + 'column_label_format' => 'Formaat', + 'column_label_value_from' => 'Waarde van', + 'error_duplicate_column' => "Kolom veldnaam bestaat reeds: ':column'.", + ], + 'controller' => [ + 'menu_label' => 'Controllers', + 'no_records' => 'Geen controllers aanwezig', + 'controller' => 'Controller', + 'behaviors' => 'Behaviors', + 'new_controller' => 'Nieuwe controller', + 'error_controller_has_no_behaviors' => 'De controller heeft geen configureerbare behaviors.', + 'error_invalid_yaml_configuration' => 'Fout bij laden behavior configuratie bestand: :file', + 'behavior_form_controller' => 'Formulier controller behavior', + 'behavior_form_controller_description' => 'Voegt formulier functionaliteit toe aan een back-end pagina. Deze behavior bevat drie pagina\'s: Create (aanmaken), Update (wijzigen) en Preview (voorbeeldweergave).', + 'property_behavior_form_placeholder' => '-- Selecteer formulier --', + 'property_behavior_form_name' => 'Naam', + 'property_behavior_form_name_description' => 'De naam van het object wat beheerd wordt door dit formulier.', + 'property_behavior_form_name_required' => 'Geef de naam van het formulier op', + 'property_behavior_form_file' => 'Formulier configuratie', + 'property_behavior_form_file_description' => 'Referentie naar het formulieren veld definitie bestand.', + 'property_behavior_form_file_required' => 'Geef het pad op naar het configuratiebestand van het formulier', + 'property_behavior_form_model_class' => 'Model class', + 'property_behavior_form_model_class_description' => 'Klassenaam van een model, de data van het formulier wordt geladen en opgeslagen met dit model.', + 'property_behavior_form_model_class_required' => 'Selecteer een model class', + 'property_behavior_form_default_redirect' => 'Standaard redirect', + 'property_behavior_form_default_redirect_description' => 'De standaard pagina waarnaar verwezen wordt nadat het formulier is opgeslagen.', + 'property_behavior_form_create' => 'Maak record pagina', + 'property_behavior_form_redirect' => 'Redirect', + 'property_behavior_form_redirect_description' => 'Een pagina waarnaar verwezen wordt wanneer een record is aangemaakt.', + 'property_behavior_form_redirect_close' => 'Sluiten redirect', + 'property_behavior_form_redirect_close_description' => 'Een pagina waarnaar verwezen wordt wanneer er gekozen is voor \'Opslaan en sluiten\'.', + 'property_behavior_form_flash_save' => 'Bericht bij opslaan', + 'property_behavior_form_flash_save_description' => 'Bericht om weer te geven nadat een record is opgeslagen.', + 'property_behavior_form_page_title' => 'Paginatitel', + 'property_behavior_form_update' => 'Record bijwerken pagina', + 'property_behavior_form_update_redirect' => 'Redirect', + 'property_behavior_form_create_redirect_description' => 'Een pagina waarnaar verwezen wordt als een record wordt opgeslagen.', + 'property_behavior_form_flash_delete' => 'Delete flash message', + 'property_behavior_form_flash_delete_description' => 'Flash message to display when record is deleted.', + 'property_behavior_form_preview' => 'Voorbeeldweergave record pagina', + 'behavior_list_controller' => 'Lijst controller behavior', + 'behavior_list_controller_description' => 'Stelt een sorteerbare en doorzoekbare lijst beschikbaar. De \'behavior\' maakt de controller action "index" beschikbaar.', + 'property_behavior_list_title' => 'Titel lijst', + 'property_behavior_list_title_required' => 'Geeft de titel van de lijst op', + 'property_behavior_list_placeholder' => '-- Selecteer lijst --', + 'property_behavior_list_model_class' => 'Model class', + 'property_behavior_list_model_class_description' => 'Klassenaam van een model, de lijst wordt geladen m.b.v. dit model.', + 'property_behavior_form_model_class_placeholder' => '-- Selecteer model --', + 'property_behavior_list_model_class_required' => 'Selecteer een model class', + 'property_behavior_list_model_placeholder' => '-- Selecteer model --', + 'property_behavior_list_file' => 'Configuratiebestand lijst', + 'property_behavior_list_file_description' => 'Referentie naar een definitiebestand van een lijst.', + 'property_behavior_list_file_required' => 'Geeft het pad op naar het configuratiebestand van de lijst', + 'property_behavior_list_record_url' => 'Record URL', + 'property_behavior_list_record_url_description' => 'Koppel elk record van de lijst aan een andere pagina. Bijv. users/update:id. Het :id gedeelte wordt vervangen met het identificatie nummer van het record.', + 'property_behavior_list_no_records_message' => 'Bericht bij geen records', + 'property_behavior_list_no_records_message_description' => 'Het bericht wat moet worden weergegeven als er geen records gevonden zijn.', + 'property_behavior_list_recs_per_page' => 'Records per pagina', + 'property_behavior_list_recs_per_page_description' => 'Aantal records wat weergegeven moet worden per pagina. Geef 0 op om geen paginatie te gebruiken. Standaardwaarde: 0', + 'property_behavior_list_recs_per_page_regex' => 'Het aantal records per pagina moet een numerieke waarde zijn', + 'property_behavior_list_show_setup' => 'Toon setup knop', + 'property_behavior_list_show_sorting' => 'Toon sorteren', + 'property_behavior_list_default_sort' => 'Standaard sortering', + 'property_behavior_form_ds_column' => 'Kolom', + 'property_behavior_form_ds_direction' => 'Richting', + 'property_behavior_form_ds_asc' => 'Oplopend', + 'property_behavior_form_ds_desc' => 'Aflopend', + 'property_behavior_list_show_checkboxes' => 'Toon keuzevakjes', + 'property_behavior_list_onclick' => 'Klik handler', + 'property_behavior_list_onclick_description' => 'JavaScript code wat uitgevoerd moet worden als er op een record wordt geklikt.', + 'property_behavior_list_show_tree' => 'Toon hiërarchie', + 'property_behavior_list_show_tree_description' => 'Toont een hiërarchie boom voor ouder/kind-records.', + 'property_behavior_list_tree_expanded' => 'Uitgeklapte weergave', + 'property_behavior_list_tree_expanded_description' => 'Geeft aan of de hiërarchische boom standaard uitgeklapt moet worden weergegeven.', + 'property_behavior_list_toolbar' => 'Toolbar', + 'property_behavior_list_toolbar_buttons' => 'Knoppen partial bestand', + 'property_behavior_list_toolbar_buttons_description' => 'Referentie naar een partial bestand met de toolbar knoppen. Bijv. list_toolbar', + 'property_behavior_list_search' => 'Zoeken', + 'property_behavior_list_search_prompt' => 'Zoek prompt', + 'property_behavior_list_filter' => 'Filter configuratie', + 'behavior_reorder_controller' => 'Reorder controller behavior', + 'behavior_reorder_controller_description' => 'Stelt functies beschikbaar voor het sorteren en rangschikken van records. De behavior maakt automatisch de "reorder" controller actie aan.', + 'property_behavior_reorder_title' => 'Rangschik titel', + 'property_behavior_reorder_title_required' => 'De rangschik titel is verplicht.', + 'property_behavior_reorder_name_from' => 'Attribuut naam', + 'property_behavior_reorder_name_from_description' => 'Attribuut van het model wat als weergavenaam van het record moet worden gebruikt.', + 'property_behavior_reorder_name_from_required' => 'De attribuut naam is verplicht.', + 'property_behavior_reorder_model_class' => 'Model class', + 'property_behavior_reorder_model_class_description' => 'Model klassenaam, de rangschik data wordt geladen uit dit model.', + 'property_behavior_reorder_model_class_placeholder' => '-- Selecteer model --', + 'property_behavior_reorder_model_class_required' => 'Selecteer een model class', + 'property_behavior_reorder_model_placeholder' => '-- Selecteer model --', + 'property_behavior_reorder_toolbar' => 'Toolbar', + 'property_behavior_reorder_toolbar_buttons' => 'Knoppen partial bestand', + 'property_behavior_reorder_toolbar_buttons_description' => 'Referentie naar een partial bestand met de toolbar knoppen. Bijv. reorder_toolbar', + 'error_controller_not_found' => 'Het originele controller bestand kan niet gevonden worden.', + 'error_invalid_config_file_name' => 'De bestandsnaam van configuratiebestand :fil) (van behavior :class) bevat ongeldige karakters en kan daarom niet worden geladen.', + 'error_file_not_yaml' => 'Het configuratiebestad :file (van behavior :class) is geen YAML-bestand. Alleen YAML-bestanden worden ondersteund.', + 'saved' => 'De controller is succesvol opgeslagen.', + 'controller_name' => 'Naam controller', + 'controller_name_description' => 'De naam van de controller bepaald de uiteindelijk URL waarmee de controller beschikbaar is in de back-end. De standaard PHP conventies zijn van toepassing. Het eerste karakter moet een hoofdletter zijn. Voorbeelden van geldige namen: Categories, Posts of Products.', + 'base_model_class' => 'Basis model class', + 'base_model_class_description' => 'Selecteer een model class om te gebruiken als basis model in behaviors die models vereisen of ondersteunen. Je kan de behaviors later configureren.', + 'base_model_class_placeholder' => '-- Selecteer model --', + 'controller_behaviors' => 'Behaviors', + 'controller_behaviors_description' => 'Seleteer de behaviors die de controller moet implementeren. De view bestanden, die vereist zijn voor de behaviors, zullen automatisch worden aangemaakt.', + 'controller_permissions' => 'Toegangsrechten', + 'controller_permissions_description' => 'Selecteer de gebruikersrechten die toegang hebben tot de controller view. Toegangsrechten kunnen aangemaakt worden via het tabblad Toegangsrechten in het linkermenu. Je kunt deze optie ook later aanpassen in de PHP-code van de controller.', + 'controller_permissions_no_permissions' => 'De plugin heeft (nog) geen toegangsrechten gedefinieerd.', + 'menu_item' => 'Actief menu item', + 'menu_item_description' => 'Selecteer een menu item dat geactiveerd moet worden voor de pagina\'s van deze controller. Je kunt deze optie ook later aanpassen in de PHP-code van de controller.', + 'menu_item_placeholder' => '-- Selecteer menu item --', + 'error_unknown_behavior' => 'De behavior class :class is niet geregistreerd in de behavior bibliotheek.', + 'error_behavior_view_conflict' => 'De geselecteerde behaviors leveren conflicterende views (:view) en kunnen daarom niet samen worden gebruikt in een controller.', + 'error_behavior_config_conflict' => 'De geselecteerde behaviors leveren conflicterende configuratiebestanden op (:file) en kunnen daarom niet samen worden gebruikt in een controller.', + 'error_behavior_view_file_not_found' => 'De view template :view van behavior :class kan niet worden gevonden.', + 'error_behavior_config_file_not_found' => 'Het configuratiebestand template :file van behavior :class kan niet worden gevonden.', + 'error_controller_exists' => 'Het controller bestand :file bestaat reeds.', + 'error_controller_name_invalid' => 'Ongeldigde controllernaam. Voorbeelden van geldige namen: Posts, Categories of Products.', + 'error_behavior_view_file_exists' => 'De view :view bestaat reeds voor deze controller.', + 'error_behavior_config_file_exists' => 'Het behavior configuratiebestand: file bestaat reeds.', + 'error_save_file' => 'Fout bij opslaan van het controller bestand :file.', + 'error_behavior_requires_base_model' => 'Er moet een basis model class worden geselecteer voor behavior :behavior.', + 'error_model_doesnt_have_lists' => 'Het geselecteerde model heeft geen lijsten. Maak eerst een lijst.', + 'error_model_doesnt_have_forms' => 'Het geselecteerde model heeft geen formulieren. Maak eerst een formulier.', + ], + 'version' => [ + 'menu_label' => 'Versies', + 'no_records' => 'Geen plugin versies aanwezig', + 'search' => 'Zoeken...', + 'tab' => 'Versies', + 'saved' => 'De versie is succesvol opgeslagen.', + 'confirm_delete' => 'Weet je zeker dat je deze versie wilt verwijderen?', + 'tab_new_version' => 'Nieuwe versie', + 'migration' => 'Migratie', + 'seeder' => 'Seeder', + 'custom' => 'Versienummer ophogen', + 'apply_version' => 'Versie toepassen', + 'applying' => 'Bezig met toepassen...', + 'rollback_version' => 'Versie terugzetten', + 'rolling_back' => 'Bezig met terugzerren...', + 'applied' => 'De versie is succesvol toegepast.', + 'rolled_back' => 'De versie is succesvol teruggezet.', + 'hint_save_unapplied' => 'Je hebt een nog niet geactiveerde versie opgeslagen. Niet geactiveerde versies kunnen automatisch worden geactiveerd als jij of een andere gebruiker inlogd op de back-end. Of als een database tabel wordt opgeslagen binnen de Database sectie van de Builder plugin.', + 'hint_rollback' => 'Het terugzetten van een versie zal ook alle versies nieuwer dan deze versie terugzetten. Wees je ervan bewust dat niet geactiveerde versies automatisch geactiveerd kunnen worden, als jij of een andere gebruiker inlogd op de back-end. Of als een database tabel wordt opgeslagen binnen de Database sectie van de Builder plugin.', + 'hint_apply' => 'Het activeren van een versie zal ook oudere niet geactiveerde versies activeren.', + 'dont_show_again' => 'Laat niet meer zien', + 'save_unapplied_version' => 'Niet geactiveerde versie opslaan', + ], + 'menu' => [ + 'menu_label' => 'Backend menu', + 'tab' => 'Menu\'s', + 'items' => 'Menu items', + 'saved' => 'De menu\'s zijn succesvol opgeslagen.', + 'add_main_menu_item' => 'Hoofdmenu item toevoegen', + 'new_menu_item' => 'Menu item', + 'add_side_menu_item' => 'Sub-item toevoegen', + 'side_menu_item' => 'Linker menu item', + 'property_label' => 'Label', + 'property_label_required' => 'Voer label in van menu item.', + 'property_url_required' => 'Voer URL in van menu item.', + 'property_url' => 'URL', + 'property_icon' => 'Icoon', + 'property_icon_required' => 'Selecteer een icoon.', + 'property_permissions' => 'Toegangsrechten', + 'property_order' => 'Volgorde', + 'property_order_invalid' => 'Geef de volgorde aan met een getal.', + 'property_order_description' => 'De volgorde bepaalde de positie van het menu item. Als de volgorde niet is opgegeven zal het item aan het einde van het menu worden toegevoegd. De standaardwaarden van de volgordes worden elke keer opgehoogd met 100.', + 'property_attributes' => 'HTML attributen', + 'property_code' => 'Code', + 'property_code_invalid' => 'De code mag alleen bestaan uit letters en cijfers.', + 'property_code_required' => 'Geef menu item code op.', + 'error_duplicate_main_menu_code' => "Dupliceer hoofdmenu item code: ':code'.", + 'error_duplicate_side_menu_code' => "Dupliceer linker menu item code: ':code'.", + ], + 'localization' => [ + 'menu_label' => 'Vertalen', + 'language' => 'Taal', + 'strings' => 'Taallabels', + 'confirm_delete' => 'Weet je zeker dat je deze taal wilt verwijderen?', + 'tab_new_language' => 'Nieuwe taal', + 'no_records' => 'Geen talen aanwezig', + 'saved' => 'Het taalbestand is succesvol opgeslagen.', + 'error_cant_load_file' => 'Kan het taalbestand niet laden, bestand is niet gevonden.', + 'error_bad_localization_file_contents' => 'Kan het taalbestand niet laden. Taalbestanden kunnen alleen array-definities en teksten bevatten.', + 'error_file_not_array' => 'Kan het taalbestand niet laden. Taalbestanden moeten een array teruggeven.', + 'save_error' => "Fout bij opslaan van bestand ':name'. Controleer schrijfrechten.", + 'error_delete_file' => 'Fout bij verwijderen van taalbestand.', + 'add_missing_strings' => 'Toevoegen van ontbrekende taallabels.', + 'copy' => 'Kopiëren', + 'add_missing_strings_label' => 'Selecteer een taal waarvan de taallabels gekopiëerd moeten worden.', + 'no_languages_to_copy_from' => 'Er zijn geen andere talen waar de taallabels van gekopiëerd kunnen worden.', + 'new_string_warning' => 'Nieuwe taallabel of sectie', + 'structure_mismatch' => 'De structuur van het bron taalbestand komt niet overeen met het bestand wat nu wordt gewijzigd. Een aantal taallabels in het gewijzigde bestand corresponderen met secties in het bronbestand (of vice versa) en kunnen daarom niet automatisch worden samengevoegd.', + 'create_string' => 'Nieuw taallabel toevoegen', + 'string_key_label' => 'Taallabel ID', + 'string_key_comment' => 'Geef het taallabel ID op gescheiden met een punt, bijvoorbeeld: plugin.search. De taallabel zal worden aangemaakt in het standaard taalbestand van de plugin.', + 'string_value' => 'Taallabel waarde', + 'string_key_is_empty' => 'Het taallabel ID mag niet leeg zijn.', + 'string_value_is_empty' => 'Taallabel waarde mag niet leeg zijn.', + 'string_key_exists' => 'Het taallabel ID bestaat reeds. Geef een ander ID op.', + ], + 'permission' => [ + 'menu_label' => 'Toegangsrechten', + 'tab' => 'Toegangsrechten', + 'form_tab_permissions' => 'Toegangsrechten', + 'btn_add_permission' => 'Toegangsrechten toevoegen', + 'btn_delete_permission' => 'Toegangsrechten verwijderen', + 'column_permission_label' => 'Code', + 'column_permission_required' => 'Geef de code op.', + 'column_tab_label' => 'Tabblad titel', + 'column_tab_required' => 'Geef tabblad titel op.', + 'column_label_label' => 'Label', + 'column_label_required' => 'Geef een label op.', + 'saved' => 'Toegangsrechten zijn succesvol opgeslagen.', + 'error_duplicate_code' => "Dupliceer code: ':code'.", + ], + 'yaml' => [ + 'save_error' => "Fout bij opslaan bestan ':name'. Controleer schrijfrechten.", + ], + 'common' => [ + 'error_file_exists' => "Het bestand bestaat reeds: ':path'.", + 'field_icon_description' => 'OctoberCMS gebruikt Font Autumn iconen, zie: http://octobercms.com/docs/ui/icon', + 'destination_dir_not_exists' => "De doel directory bestaat niet: ':path'.", + 'error_make_dir' => "Fout bij aanmaken van directory: ':name'.", + 'error_dir_exists' => "Directory bestaat reeds: ':path'.", + 'template_not_found' => "Template-bestand kan niet worden gevonden: ':name'.", + 'error_generating_file' => "Fout bij genreren van bestand: ':path'.", + 'error_loading_template' => "Fout bij laden van template-bestand: ':name'.", + 'select_plugin_first' => 'Selecteer eerst een plugin. Om een lijst van plugins te tonen, klik op het > icoon in de linker zijbalk.', + 'plugin_not_selected' => 'Plugin is niet geselecteerd.', + 'add' => 'Toevoegen', + ], + 'migration' => [ + 'entity_name' => 'Migratie', + 'error_version_invalid' => 'Het versienummer moet voldoen aan het formaat 1.0.1', + 'field_version' => 'Versie', + 'field_description' => 'Omschrijving', + 'field_code' => 'Code', + 'field_code_comment' => 'De migratie-code in alleen-lezen en alleen voor voorbeeldweergave. Je kan handmatig migraties aanmaken in het Versies onderdeel van Builder.', + 'save_and_apply' => 'Opslaan & toepassen', + 'error_version_exists' => 'De migratie-versie bestaat reeds.', + 'error_script_filename_invalid' => 'De bestandsnaam van de migratie kan alleen letters, getallen en underscores bevatten. De naam moet beginnen met een letter en mag geen spaties bevatten.', + 'error_cannot_change_version_number' => 'Kan het versienummer niet aanpassen voor een reeds toegepaste versie.', + 'error_file_must_define_class' => 'De migratie code moet een migratie of een seeder class definieren. Laat het code veld leeg als je alleen het versienummer wilt bijwerken.', + 'error_file_must_define_namespace' => 'De migratie code moet een namespace definieren. Laat het code veld leeg als je alleen het versienummer wilt bijwerken.', + 'no_changes_to_save' => 'Er zijn geen wijzigingen om op te slaan.', + 'error_namespace_mismatch' => 'The migratie code moet de plugin namespace :namespace gebruiken.', + 'error_migration_file_exists' => 'Het migratie bestand :file bestaat reeds. Gebruik een andere klasse naam.', + 'error_cant_delete_applied' => 'Deze versie is reeds toegepast en kan daarom niet worden verwijderd. Ga eerst terug naar deze versie (rollback).', + ], + 'components' => [ + 'list_title' => 'Record lijst', + 'list_description' => 'Toont een lijst van records voor geselecteerde model.', + 'list_page_number' => 'Paginanummer', + 'list_page_number_description' => 'De waarde hiervan wordt gebruikt om te bepalen op welke pagina de gebruiker zit.', + 'list_records_per_page' => 'Records per pagina', + 'list_records_per_page_description' => 'Het aantal records wat per pagina moet worden weergegeven. Laat leeg om paginatie uit te schakelen.', + 'list_records_per_page_validation' => 'Ongeldige waarde. Het aantal records per pagina moet worden aangegeven met een nummer.', + 'list_no_records' => 'Bericht bij geen records', + 'list_no_records_description' => 'Bericht wat moet worden weergegeven als er geen records zijn.', + 'list_no_records_default' => 'Geen records gevonden', + 'list_sort_column' => 'Sorteer op kolom', + 'list_sort_column_description' => 'Kolom van model waarop de records gesorteerd moeten worden.', + 'list_sort_direction' => 'Sorteerrichting', + 'list_display_column' => 'Weergave kolom', + 'list_display_column_description' => 'Kolom die moet worden weergegeven in de lijst.', + 'list_display_column_required' => 'Selecteer een weergave kolom.', + 'list_details_page' => 'Detailpagina', + 'list_details_page_description' => 'Pagina waarop record details worden weergegeven.', + 'list_details_page_no' => '-- Geen detailpagina --', + 'list_sorting' => 'Sortering', + 'list_pagination' => 'Paginatie', + 'list_order_direction_asc' => 'Oplopend', + 'list_order_direction_desc' => 'Aflopend', + 'list_model' => 'Model class', + 'list_scope' => 'Scope', + 'list_scope_description' => 'Model scope waarin de records moeten worden opgevraagd (optioneel).', + 'list_scope_default' => '-- Selecteer een scope (optioneel) --', + 'list_details_page_link' => 'Link naar de detailpagina', + 'list_details_key_column' => 'Detail sleutelkolom', + 'list_details_key_column_description' => 'Model kolom die moet worden gebruikt als record ID in de detailpagina links.', + 'list_details_url_parameter' => 'URL parameter naam', + 'list_details_url_parameter_description' => 'Naam van de detailpagina URL parameter. De parameter bevat het record ID.', + 'details_title' => 'Record details', + 'details_description' => 'Toont record details voor een geselecteerd model.', + 'details_model' => 'Model class', + 'details_identifier_value' => 'ID-waarde', + 'details_identifier_value_description' => 'ID-waarde waarmee het record wordt opgevraagd uit de database. Geef een vaste waarde op of een parameter naam voor in de URL.', + 'details_identifier_value_required' => 'De ID-waarde mag niet leeg zijn.', + 'details_key_column' => 'Sleutelkolom', + 'details_key_column_description' => 'De kolom die gebruikt moet worden om het record (met ID-waarde) uit de database te kunnen opvragen.', + 'details_key_column_required' => 'De sleutelkolom mag niet leeg zijn.', + 'details_display_column' => 'Weergave kolom', + 'details_display_column_description' => 'De kolom uit het model die moet worden weergegeven op de detailpagina.', + 'details_display_column_required' => 'Selecteer de weergave kolom.', + 'details_not_found_message' => 'Bericht voor niet gevonden', + 'details_not_found_message_description' => 'Bericht wat moet worden weergegeven als het record niet is gevonden.', + 'details_not_found_message_default' => 'Record niet gevonden', + ], +]; diff --git a/server/plugins/rainlab/builder/lang/pt-br/lang.php b/server/plugins/rainlab/builder/lang/pt-br/lang.php new file mode 100644 index 0000000..95a5e01 --- /dev/null +++ b/server/plugins/rainlab/builder/lang/pt-br/lang.php @@ -0,0 +1,679 @@ + [ + 'name' => 'Builder', + 'description' => 'Provê ferramentas visuais para construir plugins para October CMS.', + 'add' => 'Criar plugin', + 'no_records' => 'Nenhum plugins encontrado', + 'no_name' => 'Sem nome', + 'search' => 'Buscar...', + 'filter_description' => 'Exibe todos os plugins ou apenas os seus plugins.', + 'settings' => 'Configurações', + 'entity_name' => 'Plugin', + 'field_name' => 'Nome', + 'field_author' => 'Autor', + 'field_description' => 'Descrição', + 'field_icon' => 'Ícone do Plugin', + 'field_plugin_namespace' => 'Namespace Plugin', + 'field_author_namespace' => 'Namespace Autor', + 'field_namespace_description' => 'Namespace pode conter apenas letras latinas, numeros e deve começar com uma letra latina. Exemplo de namespace plugin: Blog', + 'field_author_namespace_description' => 'Você não pode alterar o namespace com Builder depois que você criar o plugin. Exemplo de namespace autor: JohnSmith', + 'tab_general' => 'Parâmetros gerais', + 'tab_description' => 'Descrição', + 'field_homepage' => 'URL da homepage do Plugin', + 'no_description' => 'Nenhuma descrição informada para este plugin', + 'error_settings_not_editable' => 'Configurações deste plugin não podem ser editadas com Builder.', + 'update_hint' => 'Você pode editar nome e descrição dos plugins localizados na aba localização.', + 'manage_plugins' => 'Criar e editar plugins', + ], + 'author_name' => [ + 'title' => 'Nome do autor', + 'description' => 'Nome padrão de autor para usar para seus novos plugins. O nome do autor não é fixo - você pode altera-lo nas configurações do plugin a qualquer hora.', + ], + 'author_namespace' => [ + 'title' => 'Namespace Autor', + 'description' => 'Se você desenvolve para a Marketplace, o namespace deve combinar com o código de autor e não pode ser mudado. Veja a documentação para mais detalhes.', + ], + 'database' => [ + 'menu_label' => 'Banco de Dados', + 'no_records' => 'Nenhuma tabela encontrada', + 'search' => 'Buscar...', + 'confirmation_delete_multiple' => 'Deletar as tabelas selecionadas?', + 'field_name' => 'Nome da tabela', + 'tab_columns' => 'Colunas', + 'column_name_name' => 'Coluna', + 'column_name_required' => 'Por favor, informe um nome da tabela', + 'column_name_type' => 'Tipo', + 'column_type_required' => 'Por favor, selecione o tipo da coluna', + 'column_name_length' => 'Tamanho', + 'column_validation_length' => 'O valor do tamanho deve ser integer ou especificado como precisão e escala (10,2) para colunas decimais. Espaços não são permitidos na coluna tamanho.', + 'column_validation_title' => 'Apenas números, letras latinas minusculas e underlines são permitidos nos nomes das colunas', + 'column_name_unsigned' => 'Sem assinatura', + 'column_name_nullable' => 'Nulo', + 'column_auto_increment' => 'AUTOINCR', + 'column_default' => 'Padrão', + 'column_auto_primary_key' => 'Primary Key', + 'tab_new_table' => 'Nova Tabela', + 'btn_add_column' => 'Acrescentar coluna', + 'btn_delete_column' => 'Deletar coluna', + 'btn_add_timestamps' => 'Acrescentar timestamps', + 'btn_add_soft_deleting' => 'Acrescentar suporte a soft deleting', + 'timestamps_exist' => 'Colunas created_at e deleted_at já existem na tabela.', + 'soft_deleting_exist' => 'Coluna deleted_at já existe na tabela.', + 'confirm_delete' => 'Deletar a tabela?', + 'error_enum_not_supported' => 'A tabela contem coluna(s) com tipo "enum" que não é atualmente suportado pelo Builder.', + 'error_table_name_invalid_prefix' => "Nome da tabela deve começar com o prefixo do plugin: ':prefix'.", + 'error_table_name_invalid_characters' => 'Nome de tabela inválido. Nomes de tabelas devem conter apenas letras latinas, números e underlines. Nomes devem começar com uma letra latina e não podem conter espaços.', + 'error_table_duplicate_column' => "Nome de coluna duplicado: ':column'.", + 'error_table_auto_increment_in_compound_pk' => 'Uma coluna auto-increment não pode ser parte de um componente de chave primária.', + 'error_table_mutliple_auto_increment' => 'A tabela não pode conter multiplas colunas auto-increment.', + 'error_table_auto_increment_non_integer' => 'Colunas auto-increment devem ser do tipo integer.', + 'error_table_decimal_length' => "O parâmetro de tamanho para o tipo :type deve ser no formato '10,2', sem espaços.", + 'error_table_length' => 'O parâmetro de tamanho para o tipo :type deve ser especificado como integer.', + 'error_unsigned_type_not_int' => "Erro na coluna ':column'. A bandeira não assinada só pode ser aplicada a colunas do tipo integer.", + 'error_integer_default_value' => "Valor padrão inválido para a coluna integer ':column'. Os formatos permitidos são '10', '-10'.", + 'error_decimal_default_value' => "Valor padrão inválido para a coluna decimal ou double ':column'. Os formatos permitodos são '1.00', '-1.00'.", + 'error_boolean_default_value' => "Valor padrão inválido para a coluna booleana ':column'. Os valores permitidos são '0' e '1'.", + 'error_unsigned_negative_value' => "O valor padrão para a coluna não assinada ':column' não pode ser negativo.", + 'error_table_already_exists' => "A tabela ':name' já existe no banco de dados.", + 'error_table_name_too_long' => "O nome da tabela não deve ser maior que 64 caracteres.", + 'error_column_name_too_long' => "O nome da coluna ':column' é muito longo. Nomes de colunas não podem ser maiores que 64 caracteres." + ], + 'model' => [ + 'menu_label' => 'Models', + 'entity_name' => 'Model', + 'no_records' => 'Nenhum model encontrado', + 'search' => 'Buscar...', + 'add' => 'Acrescentar...', + 'forms' => 'Formulários', + 'lists' => 'Listas', + 'field_class_name' => 'Nome da classe', + 'field_database_table' => 'Nome do Banco de dados', + 'field_add_timestamps' => 'Acrescentar suporte a timestamp', + 'field_add_timestamps_description' => 'A tabela do banco de dados precisa conter as colunas created_at e updated_at.', + 'field_add_soft_deleting' => 'Acrescentar suporte a soft deleting', + 'field_add_soft_deleting_description' => 'A tabela do banco de dados precisa conter a coluna deleted_at.', + 'error_class_name_exists' => 'Arquivo Model já existe para o nome da classe especificada: :path', + 'error_timestamp_columns_must_exist' => 'A tabela do banco de dados precisa conter as colunas created_at e updated_at.', + 'error_deleted_at_column_must_exist' => 'A tabela do banco de dados precisa conter a coluna deleted_at.', + 'add_form' => 'Acrescentar formulário', + 'add_list' => 'Acrescentar lista', + ], + 'form' => [ + 'saved' => 'Formulário Salvo', + 'confirm_delete' => 'Deletar o formulário?', + 'tab_new_form' => 'Novo formulário', + 'property_label_title' => 'Título', + 'property_label_required' => 'Por favor, especifique o título do control.', + 'property_span_title' => 'Span', + 'property_comment_title' => 'Comentário', + 'property_comment_above_title' => 'Comentário a cima', + 'property_default_title' => 'Padrão', + 'property_checked_default_title' => 'Marcado por padrão', + 'property_css_class_title' => 'Classe CSS', + 'property_css_class_description' => 'Classe CSS opcional para assinar o campo container.', + 'property_disabled_title' => 'Desabilitado', + 'property_hidden_title' => 'Oculto', + 'property_required_title' => 'Obrigatório', + 'property_field_name_title' => 'Nome do campo', + 'property_placeholder_title' => 'Placeholder', + 'property_default_from_title' => 'Padrão de', + 'property_stretch_title' => 'estender', + 'property_stretch_description' => 'Especifica se este campo se estende para se ajustar à altura dos pais.', + 'property_context_title' => 'Contexto', + 'property_context_description' => 'Especifica que conceito de formulário deve ser usado quando exibir o campo.', + 'property_context_create' => 'Criar', + 'property_context_update' => 'Atualizar', + 'property_context_preview' => 'Preview', + 'property_dependson_title' => 'Depende de', + 'property_trigger_action' => 'Ação', + 'property_trigger_show' => 'Exibir', + 'property_trigger_hide' => 'Ocultar', + 'property_trigger_enable' => 'Habilitar', + 'property_trigger_disable' => 'Desabilitar', + 'property_trigger_empty' => 'Vazio', + 'property_trigger_field' => 'Campo', + 'property_trigger_field_description' => 'Define o outro nome de campo que dispara a ação.', + 'property_trigger_condition' => 'Condição', + 'property_trigger_condition_description' => 'Determina a condição que especifica o campo deve satisfazer a condição a ser considerada "true".Valores suportados: marcado, não marcado, valor[algumvalor].', + 'property_trigger_condition_checked' => 'Marcado', + 'property_trigger_condition_unchecked' => 'Não marcado', + 'property_trigger_condition_somevalue' => 'valor[digite-o-valor-aqui]', + 'property_preset_title' => 'Preconfigurado', + 'property_preset_description' => 'Permite o valor do campo a ser inicalmente configurado pelo valor de outro campo, convertido usando a entrada de conversor preconfigurada.', + 'property_preset_field' => 'Campo', + 'property_preset_field_description' => 'Define o nome do campo pelo valor de fonte de outro campo.', + 'property_preset_type' => 'Tipo', + 'property_preset_type_description' => 'Especifica o tipo de conversão', + 'property_attributes_title' => 'Atributos', + 'property_attributes_description' => 'Atributos HTML customizados para acrescentar ao elemento do campo do formulário.', + 'property_container_attributes_title' => 'Atributos do container', + 'property_container_attributes_description' => 'Atributos HTML customizados para adicionar ao elemento container do campo do formulário.', + 'property_group_advanced' => 'Avançado', + 'property_dependson_description' => 'Uma lista de outros nomes de campos dos quais este compo depende, quando os outros compos são modificados, este compo será atualizado. Um campo por linha.', + 'property_trigger_title' => 'Gatilho (Trigger)', + 'property_trigger_description' => 'Permite mudar os atributos do elemento assim como visibilidade ou valor, baseado no estado de outros elementos.', + 'property_default_from_description' => 'Pega o valor padrão do valor de outro campo.', + 'property_field_name_required' => 'O nome do campo é obrigatório', + 'property_field_name_regex' => 'O nome do campo apenas pode conter letras latinas, números, underlines, traços e colchetes.', + 'property_attributes_size' => 'Tamanho', + 'property_attributes_size_tiny' => 'Minusculo', + 'property_attributes_size_small' => 'Pequeno', + 'property_attributes_size_large' => 'Largo', + 'property_attributes_size_huge' => 'Grande', + 'property_attributes_size_giant' => 'Gigante', + 'property_comment_position' => 'Posição do Comentário', + 'property_comment_position_above' => 'A cima', + 'property_comment_position_below' => 'A baixo', + 'property_hint_path' => 'Caminho sugerido do partial', + 'property_hint_path_description' => 'Caminho para um arquivo partial que contenha o texto sugerido. Use o simbolo $ para referenciar à raiz do diretório, por exemplo: $/acme/blog/partials/_sugestao.htm', + 'property_hint_path_required' => 'Por favor, digite a sugestão de caminho para o partial', + 'property_partial_path' => 'Caminho para o partial', + 'property_partial_path_description' => 'Caminho para um arquivo partial. Use o simbolo $ para referenciar ao diretório raiz dos plugins, por exemplo: $/acme/blog/partials/_partial.htm', + 'property_partial_path_required' => 'Por favor, digite o caminho do partial', + 'property_code_language' => 'Linguagem', + 'property_code_theme' => 'Tema', + 'property_theme_use_default' => 'Use o tema padrão', + 'property_group_code_editor' => 'Editor de código', + 'property_gutter' => 'Gutter', + 'property_gutter_show' => 'Visivel', + 'property_gutter_hide' => 'Oculto', + 'property_wordwrap' => 'Abreviar palavra', + 'property_wordwrap_wrap' => 'Abreviar', + 'property_wordwrap_nowrap' => 'Não abreviar', + 'property_fontsize' => 'Tamanho da fonte', + 'property_codefolding' => 'Duplicar código', + 'property_codefolding_manual' => 'Manual', + 'property_codefolding_markbegin' => 'Marcar início', + 'property_codefolding_markbeginend' => 'Marcar início e fim', + 'property_autoclosing' => 'Auto encerrar', + 'property_enabled' => 'Habilitado', + 'property_disabled' => 'Desabilitado', + 'property_soft_tabs' => 'Tabelas suaves', + 'property_tab_size' => 'tamanho da tabela', + 'property_readonly' => 'Somente leitura', + 'property_use_default' => 'Usar configurações padrão', + 'property_options' => 'Opções', + 'property_prompt' => 'Pronto', + 'property_prompt_description' => 'Texto a exibir para o botão criar.', + 'property_prompt_default' => 'Acrescentar novo item', + 'property_available_colors' => 'Cores disponíveis', + 'property_available_colors_description' => 'Lista de cores disponíveis no frmato hexadecimal (#FF0000). Deixe em branco para a configuração padrão de cores. Digite um valor por linha.', + 'property_datepicker_mode' => 'Modo', + 'property_datepicker_mode_date' => 'Data', + 'property_datepicker_mode_datetime' => 'Data e hora', + 'property_datepicker_mode_time' => 'Hora', + 'property_datepicker_min_date' => 'Data mínima', + 'property_datepicker_min_date_description' => 'A data minima ou mais proxima que pode ser selecionada. Deixe em branco para o valor padrão (2000-01-01).', + 'property_datepicker_max_date' => 'Data máxima', + 'property_datepicker_max_date_description' => 'A data máxima ou mais distante que pode ser selecionada. Deixe em branco para o valor padrão (2020-12-31).', + 'property_datepicker_date_invalid_format' => 'Formato de data inválido. Use o formato YYYY-MM-DD.', + 'property_datepicker_year_range' => 'Alcançe de Anos', + 'property_datepicker_year_range_description' => 'Número de anos que cada lado (ex. 10) ou array de alcançe superior/inferior (ex. [1900,2015]). Deixe em branco para o valor padrão (10).', + 'property_datepicker_year_range_invalid_format' => 'Formato de alcançe de anos inválido. Use Números (ex. "10") ou array de alcançe superior/inferior (ex. "[1900,2015]")', + 'property_markdown_mode' => 'Modo', + 'property_markdown_mode_split' => 'Dividir', + 'property_markdown_mode_tab' => 'Tabela', + 'property_fileupload_mode' => 'Modo', + 'property_fileupload_mode_file' => 'Arquivo', + 'property_fileupload_mode_image' => 'Imagem', + 'property_group_fileupload' => 'Upload de arquivo', + 'property_fileupload_prompt' => 'Pronto', + 'property_fileupload_prompt_description' => 'Testo para exibir para o botão upload, aplica-se apenas ao modo Arquivos, opcional.', + 'property_fileupload_image_width' => 'Largura da imagem', + 'property_fileupload_image_width_description' => 'Parametro original - imagens serão redimensionadas para esta largura, aplica-se apenas ao modo Imagem.', + 'property_fileupload_invalid_dimension' => 'Valor de dimensão inválido - por favor, digite um número.', + 'property_fileupload_image_height' => 'Altura da imagem', + 'property_fileupload_image_height_description' => 'Parâmetro opcional - imagens serão redimensionadas para esta altura. Aplica-se apernas ao modo Imagem.', + 'property_fileupload_file_types' => 'Tipos de arquivos', + 'property_fileupload_file_types_description' => 'Lista opcional separada por virgula das extensões de arquivos que são aceitas pelo uploadre. Ex: zip,txt', + 'property_fileupload_mime_types' => 'Tipos MIME', + 'property_fileupload_mime_types_description' => 'Lista opcional separada por virgula dos tipos MIME que são aceitas pelo uploader, assim como extensões ou nomes totalmente qualificados. Ex: bin,txt', + 'property_fileupload_use_caption' => 'Usar legenda', + 'property_fileupload_use_caption_description' => 'Permite um titulo e descrição a serem configurados para o arquivo.', + 'property_fileupload_thumb_options' => 'Opções de miniatua', + 'property_fileupload_thumb_options_description' => 'Gerencia opções para as miniaturas geradas automaticamente. Aplica-se apenas ao modo imagem.', + 'property_fileupload_thumb_mode' => 'Modo', + 'property_fileupload_thumb_auto' => 'Automático', + 'property_fileupload_thumb_exact' => 'Exato', + 'property_fileupload_thumb_portrait' => 'Retrato', + 'property_fileupload_thumb_landscape' => 'Paisagem', + 'property_fileupload_thumb_crop' => 'Cropar', + 'property_fileupload_thumb_extension' => 'Extensão de arquivo', + 'property_name_from' => 'Nome da coluna', + 'property_name_from_description' => 'Relação de nome de coluna a usar para exibir um nome.', + 'property_relation_select' => 'Selecionar', + 'property_relation_select_description' => 'CONCATENA multiplas colunas para exibir um nome', + 'property_description_from' => 'Coluna Descrição', + 'property_description_from_description' => 'Relação de nome de coluna a usar para exibir uma descrição.', + 'property_recordfinder_prompt' => 'Pronto', + 'property_recordfinder_prompt_description' => 'Texto para exibir quando não há gravação selecionada. O caractere %s representa o ícone buscar. Deixe em branco para o padrão pronto.', + 'property_recordfinder_list' => 'Configuração de lista', + 'property_recordfinder_list_description' => 'Uma referencia a um arquivo de definições de listas de colunas. Use o simbolo $ para referenciar a raiz de diretório do plugin, por exemplo: $/acme/blog/lists/_lista.yaml', + 'property_recordfinder_list_required' => 'Por favor, forneça um caminho para a lista de arquivos YAML', + 'property_group_recordfinder' => 'Gravar buscador', + 'property_mediafinder_mode' => 'Modo', + 'property_mediafinder_mode_file' => 'Arquivo', + 'property_mediafinder_mode_image' => 'Imagem', + 'property_mediafinder_prompt' => 'Pronto', + 'property_mediafinder_prompt_description' => 'Texto a exibir quando não há itens selecionados. O caractere %s representa o ícone gerenciador de mídias. Deixe em branco para o padrão pronto.', + 'property_mediafinder_image_width_description' => 'Se estiver usando o tipo imagem, o preview de imagem será exibido nesta largura, opcional.', + 'property_mediafinder_image_height_description' => 'Se estiver usando o modo imagem, o preview de imagem será exibido nesta altura, opcional.', + 'property_group_relation' => 'Relação', + 'property_relation_prompt' => 'Pronto', + 'property_relation_prompt_description' => 'Texto a exibir quando não há seleções disponíveis.', + 'property_empty_option' => 'Opção Vazia', + 'property_empty_option_description' => 'A opção Vazia corresponde a seleção vazia, mas ao contrário do marcador, ele pode ser selecionado novamente.', + 'property_max_items' => 'Maximo de itens', + 'property_max_items_description' => 'Número maximo de itens a permitir com o repetidor.', + 'control_group_standard' => 'Comum', + 'control_group_widgets' => 'Widgets', + 'click_to_add_control' => 'Acrescentar control', + 'loading' => 'carregando...', + 'control_text' => 'Texto', + 'control_text_description' => 'Caixa de texto único', + 'control_password' => 'Senha', + 'control_password_description' => 'Campo de texto para senha de linha única', + 'control_checkbox' => 'Checkbox', + 'control_checkbox_description' => 'Único checkbox', + 'control_switch' => 'Switch', + 'control_switch_description' => 'Switchbox único, uma alternativa ao checkbox', + 'control_textarea' => 'Text area', + 'control_textarea_description' => 'Multiplas caixas de texto com altura controlavel', + 'control_dropdown' => 'Dropdown', + 'control_dropdown_description' => 'Lista dropdown com opções estáticas ou dinâmicas', + 'control_unknown' => 'Unknown control type: :tipo', + 'control_repeater' => 'Repetidor', + 'control_repeater_description' => 'Exibe um conjunto de repetições de form controls', + 'control_number' => 'Número', + 'control_number_description' => 'Text box de linha única que aceita apenas números', + 'control_hint' => 'Aviso', + 'control_hint_description' => 'Exibe o contedudo do contents em uma caixa que pode ser oculto pelo usuário', + 'control_partial' => 'Partial', + 'control_partial_description' => 'Exibe o conteúdo de um partial', + 'control_section' => 'Seção', + 'control_section_description' => 'Exibe uma seção de formulário com cabeçalho e subcabeçalho', + 'control_radio' => 'Lista Radio', + 'control_radio_description' => 'Uma lista de opções radio, onde apenas um item pode ser selecionado por vez', + 'control_radio_option_1' => 'Opção 1', + 'control_radio_option_2' => 'Opção 2', + 'control_checkboxlist' => 'Lista Checkbox', + 'control_checkboxlist_description' => 'Uma lista de checkboxes, onde multiplos itens podem ser selecionados', + 'control_codeeditor' => 'Editor de códigos', + 'control_codeeditor_description' => 'Editor modo texto para código formatado ou de marcação', + 'control_colorpicker' => 'Seletor de cor', + 'control_colorpicker_description' => 'Um campo para selecionar um valor haxadecimal de cor', + 'control_datepicker' => 'Seletor Data', + 'control_datepicker_description' => 'Campo texto usado para selecionar data e hora', + 'control_richeditor' => 'Editor Rico', + 'control_richeditor_description' => 'Editor visual para formatação rica de texto, também conhecido como um editor WYSIWYG', + 'control_markdown' => 'Editor Markdown', + 'control_markdown_description' => 'Editor básico para formatação de texto Markdown', + 'control_fileupload' => 'Upload de arquivo', + 'control_fileupload_description' => 'Uploader de arquivos para imagens ou arquivos comuns', + 'control_recordfinder' => 'Gravar buscador', + 'control_recordfinder_description' => 'Campo com detalhes de uma gravação relacionada com conteúdo da busca', + 'control_mediafinder' => 'Buscador de mídia', + 'control_mediafinder_description' => 'Campo para selecionar um item de uma biblioteca do gerenciador de mídia', + 'control_relation' => 'Relação', + 'control_relation_description' => 'Exibe tanto um dropdown ou uma lista checkbox para selecionar um registro relacionado', + 'error_file_name_required' => 'Por favor, digite o nome de arquivo do formulário.', + 'error_file_name_invalid' => 'O nome de arquivo pode conter apenas letras latinas, números, underlines, pontos e barras.', + 'span_left' => 'Esquerda', + 'span_right' => 'Direita', + 'span_full' => 'Completo', + 'span_auto' => 'Automático', + 'empty_tab' => 'Aba vazia', + 'confirm_close_tab' => 'A aba contem controles que serão deletados. Continuar?', + 'tab' => 'Aba formulário', + 'tab_title' => 'Titulo', + 'controls' => 'Controles', + 'property_tab_title_required' => 'A aba título é obrigatória.', + 'tabs_primary' => 'Abas primárias', + 'tabs_secondary' => 'Abas secundárias', + 'tab_stretch' => 'Extender', + 'tab_stretch_description' => 'Especifica se este contêiner de guias se estende para se ajustar à altura pai.', + 'tab_css_class' => 'Classe CSS', + 'tab_css_class_description' => 'Assinala uma classe CSS ao contêiner de abas.', + 'tab_name_template' => 'Aba %s', + 'tab_already_exists' => 'Aba com o título especificado já existe.', + ], + 'list' => [ + 'tab_new_list' => 'Nova lista', + 'saved' => 'Lista salva', + 'confirm_delete' => 'Deletar a lista?', + 'tab_columns' => 'Colunas', + 'btn_add_column' => 'Acrescentar coluna', + 'btn_delete_column' => 'Deletar coluna', + 'column_dbfield_label' => 'Campo', + 'column_dbfield_required' => 'Por favor, digite um campo model', + 'column_name_label' => 'Rótulo', + 'column_label_required' => 'Por favor, informe o rótulo da coluna', + 'column_type_label' => 'Tipo', + 'column_type_required' => 'Por favor, informe o tipo da coluna', + 'column_type_text' => 'Texto', + 'column_type_number' => 'Número', + 'column_type_switch' => 'switch', + 'column_type_datetime' => 'Data e Hora', + 'column_type_date' => 'Data', + 'column_type_time' => 'Hora', + 'column_type_timesince' => 'Des de', + 'column_type_timetense' => 'Tempo até', + 'column_type_select' => 'Seleção', + 'column_type_partial' => 'Partial', + 'column_label_default' => 'Padrão', + 'column_label_searchable' => 'Buscar', + 'column_label_sortable' => 'Aleatório', + 'column_label_invisible' => 'Invisível', + 'column_label_select' => 'Seleção', + 'column_label_relation' => 'Relação', + 'column_label_css_class' => 'Classe CSS', + 'column_label_width' => 'Largura', + 'column_label_path' => 'Caminho', + 'column_label_format' => 'Formato', + 'column_label_value_from' => 'Valor de', + 'error_duplicate_column' => "Campo nome de coluna duplicado: ':column'.", + 'btn_add_database_columns' => 'Acrescentar colunas ao banco de dados', + 'all_database_columns_exist' => 'Todas as colunas do banco de dados já estão definidas na lista' + ], + 'controller' => [ + 'menu_label' => 'Controllers', + 'no_records' => 'Nenhum controller de plugin encontrado', + 'controller' => 'Controller', + 'behaviors' => 'Comportamentos', + 'new_controller' => 'Novo controller', + 'error_controller_has_no_behaviors' => 'O controller não possui nenhum comportamento configuravel.', + 'error_invalid_yaml_configuration' => 'Erro ao carregar arquivo de configuração de comportamento: :file', + 'behavior_form_controller' => 'Comportamento de controller de formulários', + 'behavior_form_controller_description' => 'Acrescentar funcionalidade de formulários a uma pagina back-end. O comportamento provê três paginas chamadas Create, Update e Preview.', + 'property_behavior_form_placeholder' => '--selecionar formulário--', + 'property_behavior_form_name' => 'Nome', + 'property_behavior_form_name_description' => 'O nome do objeto gerenciado por este formulário', + 'property_behavior_form_name_required' => 'Por favor, digite o nome do formulário', + 'property_behavior_form_file' => 'Configuração de formulário', + 'property_behavior_form_file_description' => 'Refere-se a um arquivo de definição de campos de formulário', + 'property_behavior_form_file_required' => 'Por favor, digite um caminho para o arquivo de configuração do formulário', + 'property_behavior_form_model_class' => 'Classe Model', + 'property_behavior_form_model_class_description' => 'Um nome de classe model, os dados do formulário é carregado e salvo neste model.', + 'property_behavior_form_model_class_required' => 'Por favor, selecione uma classe de model', + 'property_behavior_form_default_redirect' => 'Redirecionamento padrão', + 'property_behavior_form_default_redirect_description' => 'Uma pagina para redirecionar por padrão quando o formulário for salvo ou cancelado.', + 'property_behavior_form_create' => 'Criar registrar pagina', + 'property_behavior_form_redirect' => 'Redirecionar', + 'property_behavior_form_redirect_description' => 'Uma pagina para redirecionar quando um registro é criado.', + 'property_behavior_form_redirect_close' => 'Encerrar redirecionamento', + 'property_behavior_form_redirect_close_description' => 'Uma pagina para redirecionar quando um registro é criado e a variável encerrar é enviada com o requerimento.', + 'property_behavior_form_flash_save' => 'Salvar menságem rápida', + 'property_behavior_form_flash_save_description' => 'Menságem rápida para exibir quando o registro é salvo.', + 'property_behavior_form_page_title' => 'Título da pagina', + 'property_behavior_form_update' => 'Atualizar registro da pagina', + 'property_behavior_form_update_redirect' => 'Redirecionar', + 'property_behavior_form_create_redirect_description' => 'Uma pagina para redirecionar quando um registro é salvo.', + 'property_behavior_form_flash_delete' => 'Deletar menságem rápida', + 'property_behavior_form_flash_delete_description' => 'Menságem rapida para exibir quando o registro é deletado.', + 'property_behavior_form_preview' => 'Preview registro da pagina', + 'behavior_list_controller' => 'Controller de Lista Comportamento', + 'behavior_list_controller_description' => 'Provê a lista sortida e buscavel com links opcionais em seus registros. O comportamento cria automaticamente a ação controller "index".', + 'property_behavior_list_title' => 'Título da lista', + 'property_behavior_list_title_required' => 'Por favor, digite o título da lista', + 'property_behavior_list_placeholder' => '--Selecione a lista--', + 'property_behavior_list_model_class' => 'Classe Model', + 'property_behavior_list_model_class_description' => 'Um nome de classe model, os dados da lista são carregados deste model.', + 'property_behavior_form_model_class_placeholder' => '--selecione o model--', + 'property_behavior_list_model_class_required' => 'Por favor, selecione uma classe model', + 'property_behavior_list_model_placeholder' => '--selecione o model--', + 'property_behavior_list_file' => 'Arquivo de configuração de lista', + 'property_behavior_list_file_description' => 'Refere-se a um arquivo de definição de lista', + 'property_behavior_list_file_required' => 'Por favor, digite um caminho para o arquivo de configuração de lista', + 'property_behavior_list_record_url' => 'Gravar URL', + 'property_behavior_list_record_url_description' => 'Link cada registro de lista a outra página. Ex: users/update:id. a :id parte é substituída com o identificador de registro.', + 'property_behavior_list_no_records_message' => 'Nenhum registro de mensagem', + 'property_behavior_list_no_records_message_description' => 'Uma menságem a exibir quando nenhum registro for encontrado', + 'property_behavior_list_recs_per_page' => 'Registros por pagina', + 'property_behavior_list_recs_per_page_description' => 'Registros a exibir por pagina, use 0 para nenhuma pagina. O padrão é: 0', + 'property_behavior_list_recs_per_page_regex' => 'Registros por pagina podem ser um valor integer', + 'property_behavior_list_show_setup' => 'Exibe botão configurações', + 'property_behavior_list_show_sorting' => 'Exibir variados', + 'property_behavior_list_default_sort' => 'Padrão variado', + 'property_behavior_form_ds_column' => 'Coluna', + 'property_behavior_form_ds_direction' => 'Direção', + 'property_behavior_form_ds_asc' => 'Ascendente', + 'property_behavior_form_ds_desc' => 'Descendente', + 'property_behavior_list_show_checkboxes' => 'Exibir checkboxes', + 'property_behavior_list_onclick' => 'Manusear On click', + 'property_behavior_list_onclick_description' => 'Customiza código JavaScript a executar quando clicar em um registro.', + 'property_behavior_list_show_tree' => 'Exibit arvore', + 'property_behavior_list_show_tree_description' => 'Exibe uma arvore de hierarquia para registros pai/filho.', + 'property_behavior_list_tree_expanded' => 'Expander arvore', + 'property_behavior_list_tree_expanded_description' => 'Determina se os nós da arvore devem ser expandidos por padrão.', + 'property_behavior_list_toolbar' => 'Barra de ferramentas', + 'property_behavior_list_toolbar_buttons' => 'Partial Botões', + 'property_behavior_list_toolbar_buttons_description' => 'Refere-se a um arquivo controller partial com os botões da barra de ferramentas. Ex: lista_BarradeFerramentas', + 'property_behavior_list_search' => 'Buscar', + 'property_behavior_list_search_prompt' => 'Buscar pronto', + 'property_behavior_list_filter' => 'Configurar filtros', + 'behavior_reorder_controller' => 'Reordenar controller de comportamento', + 'behavior_reorder_controller_description' => 'Provê adicionais para sortear e reordenar em seus registros. O comportamento cria automaticamente a ação controller "reordenar".', + 'property_behavior_reorder_title' => 'Título do reordenador', + 'property_behavior_reorder_title_required' => 'Por favor, digite o título do reordenador', + 'property_behavior_reorder_name_from' => 'Nome do atributo', + 'property_behavior_reorder_name_from_description' => 'Atributo do model que pode ser usado como um rótulo para cada registro.', + 'property_behavior_reorder_name_from_required' => 'Por favor, digite o nome do atributo', + 'property_behavior_reorder_model_class' => 'Classe Model', + 'property_behavior_reorder_model_class_description' => 'Um nome de classe model, o dado registrado é carregado deste model.', + 'property_behavior_reorder_model_class_placeholder' => '--selecionar model--', + 'property_behavior_reorder_model_class_required' => 'Por favor, selecione uma classe model', + 'property_behavior_reorder_model_placeholder' => '--selecione o model--', + 'property_behavior_reorder_toolbar' => 'Bara de ferramentas', + 'property_behavior_reorder_toolbar_buttons' => 'Botões da Partial', + 'property_behavior_reorder_toolbar_buttons_description' => 'Refere-se ao arquivo partial controller com os botões da barra de ferramentas. Ex: reordenar_BarradeFerramentas', + 'error_controller_not_found' => 'Arquivo original do controller não foi encontrado.', + 'error_invalid_config_file_name' => 'O nome do arquivo (:file) de configuração do comportamento :class contem caracteres inválidos e não pode ser carregado.', + 'error_file_not_yaml' => 'O nome do arquivo (:file) de configuração do comportamento :class não é um arquivo YAML. arquivos de configuração YAML são suportados.', + 'saved' => 'Controller salvo', + 'controller_name' => 'Nome do Controller', + 'controller_name_description' => 'O nome do controller define o nome da classe e URL das paginas back-end do controller. Convenções de nomenclatura de variáveis PHP padrão se aplicam. O primeiro símbolo deve ser uma letra latina maiúscula. Exemplos: Categorias, Postagens, Produtos.', + 'base_model_class' => 'Classe model base', + 'base_model_class_description' => 'Selecione uma classe model para usar como um model base no comportamento que necessita ou suporta models. Você pode configurar o comportamento depois.', + 'base_model_class_placeholder' => '--Selecione o model--', + 'controller_behaviors' => 'Comportamentos', + 'controller_behaviors_description' => 'Selecione os comportamentos que o controller deve implementar. O Builder criará arquivos de view necessários para os comportamentos automaticamente.', + 'controller_permissions' => 'Permissões', + 'controller_permissions_description' => 'Selecione permissões de usuário que podem acessar as views dos controllers. As permissões podem ser definidas na guia Permissões do Builder. Você pode alterar essa opção no script PHP do controller mais tarde.', + 'controller_permissions_no_permissions' => 'O plugin não definiu nenhuma permissão.', + 'menu_item' => 'Item de menu ativo', + 'menu_item_description' => 'Selecione um item de menu para tornar ativo para as páginas do controller. Você pode alterar essa opção no script PHP do controlador mais tarde.', + 'menu_item_placeholder' => '--selecione o item de menu--', + 'error_unknown_behavior' => 'A classe de comportamento :class não está registrada na biblioteca de comportamento.', + 'error_behavior_view_conflict' => 'Os comportamentos selecionados fornecem visualizações conflitantes (:view) e não podem ser usadas junto a um controller.', + 'error_behavior_config_conflict' => 'Os comportamentos selecionados fornecem arquivos de configuração conflitantes (:file) e não podem ser usadas junto a um controller.', + 'error_behavior_view_file_not_found' => 'A view do template :view do comportamento :class não pode ser localizado.', + 'error_behavior_config_file_not_found' => 'O template de configuração :file do comportamento :class não pode ser localizado.', + 'error_controller_exists' => 'O arquivo do controlador :file já existe.', + 'error_controller_name_invalid' => 'Formato de nome de controller inválido. O nome deve conter apenas letras latinas e números. O primeiro simbolo deve ser uma letra latina maiúscula.', + 'error_behavior_view_file_exists' => 'O arquivo de configuração do controller :view já existe.', + 'error_behavior_config_file_exists' => 'O arquivo de configuração do comportamento :file já existe.', + 'error_save_file' => 'Erro ao salvar o arquivo de controller :file', + 'error_behavior_requires_base_model' => 'O comportamento :behavior Necessita que seja selecionado umma classe model base.', + 'error_model_doesnt_have_lists' => 'O model selecionado não possui nenhuma lista. Por favor, crie primeiro uma lista.', + 'error_model_doesnt_have_forms' => 'O model selecionado não possui nenhum formulário. Por favor, crie primeiro um formulário.', + ], + 'version' => [ + 'menu_label' => 'Versões', + 'no_records' => 'Nenhuma versão de plugin encontrada', + 'search' => 'Buscar...', + 'tab' => 'Versões', + 'saved' => 'Versão salva', + 'confirm_delete' => 'Deletar a versão?', + 'tab_new_version' => 'Nova versão', + 'migration' => 'Migração', + 'seeder' => 'Semeador', + 'custom' => 'Aumente o número da versão', + 'apply_version' => 'Aplicar versão', + 'applying' => 'Aplicando...', + 'rollback_version' => 'Reverter versão', + 'rolling_back' => 'Revertendo...', + 'applied' => 'Versão aplicada', + 'rolled_back' => 'Versão revertida', + 'hint_save_unapplied' => 'Você salvou uma versão não aplicada. As versões não aplicadas podem ser aplicadas automaticamente quando você ou outro usuário faz o login no back-end ou quando uma tabela de banco de dados é salva na seção Banco de Dados do Builder.', + 'hint_rollback' => 'Reverter uma versão também reverterá todas as versões mais recentes que esta. Observe que versões não aplicadas podem ser aplicadas automaticamente pelo sistema quando você ou outro usuário faz o login no back-end ou quando uma tabela do banco de dados é salva na seção Banco de Dados do Builder.', + 'hint_apply' => 'A aplicação de uma versão também aplicará todas as versões antigas não aplicadas do plug-in.', + 'dont_show_again' => 'não mostrar novamente', + 'save_unapplied_version' => 'Valvar versão não aplicada', + ], + 'menu' => [ + 'menu_label' => 'Menu Backend', + 'tab' => 'Menus', + 'items' => 'Itens de Menu', + 'saved' => 'Menus salvos', + 'add_main_menu_item' => 'Acrescentar item de menu principal', + 'new_menu_item' => 'Item de menu', + 'add_side_menu_item' => 'Acrescentar sub-item', + 'side_menu_item' => 'Lado do item de menu', + 'property_label' => 'Rótulo', + 'property_label_required' => 'Por favor, digite os rótulos dos itens de menu.', + 'property_url_required' => 'Por favor, digite a URL do item de menu', + 'property_url' => 'URL', + 'property_icon' => 'Icone', + 'property_icon_required' => 'Por favor, selecione um ícone', + 'property_permissions' => 'Permissões', + 'property_order' => 'Ordenar', + 'property_order_invalid' => 'Por favor, insira a ordem do item de menu como valor integer.', + 'property_order_description' => 'A ordem do item de menu gerencia sua posição no menu. Se o pedido não for fornecido, o item será colocado no final do menu. Os valores de ordem padrão têm o incremento de 100.', + 'property_attributes' => 'Atributos HTML', + 'property_code' => 'Código', + 'property_code_invalid' => 'O código deve conter apenas letra latina e números', + 'property_code_required' => 'Por favor, insira o código do item de menu.', + 'error_duplicate_main_menu_code' => "Código de item de menu ':code' duplicado.", + 'error_duplicate_side_menu_code' => "Código de lado de item de menu ':code' duplicado.", + ], + 'localization' => [ + 'menu_label' => 'Idiomas', + 'language' => 'Idioma', + 'strings' => 'Strings', + 'confirm_delete' => 'Deletar o idioma?', + 'tab_new_language' => 'Novo idioma', + 'no_records' => 'Nenhum idioma encontrado', + 'saved' => 'Arquivo de idioma salvo', + 'error_cant_load_file' => 'Não é possível carregar o arquivo de idioma solicitado - arquivo não encontrado.', + 'error_bad_localization_file_contents' => 'Não é possível carregar o arquivo de idioma solicitado. Os arquivos de idiomas podem conter apenas definições e strings de array.', + 'error_file_not_array' => 'Não é possível carregar o arquivo de idioma solicitado. Arquivos de idioma devem retornar um array.', + 'save_error' => "Erro ao salvar o arquivo ':name'. Por favor, verifique as permissões de escrita.", + 'error_delete_file' => 'Erro ao deletar arquivo de idioma.', + 'add_missing_strings' => 'Acrescentar strings faltantes', + 'copy' => 'Copiar', + 'add_missing_strings_label' => 'Selecione o idioma para copiar as strings faltantes', + 'no_languages_to_copy_from' => 'Não há outro idioma para copiar strings.', + 'new_string_warning' => 'Nova string ou seção', + 'structure_mismatch' => 'A estrutura do arquivo fonte do idioma não combina com a estrutura do arquivo que está sendo editado. Algumas strings individuais do arquivo editado correspondente a seções no arquivo fonte (ou vice versa) e não pode ser mesclado automaticamente.', + 'create_string' => 'Criar nova string', + 'string_key_label' => 'Chave de String', + 'string_key_comment' => 'Digite a chave de string Insira a chave de string usando o ponto como um separador de seção. For example: plugin.buscar. A string será criada no arquivo de localização do idioma padrão do plugin.', + 'string_value' => 'Valor da string', + 'string_key_is_empty' => 'Chave de string não pode ser vazio', + 'string_key_is_a_string' => ':key é uma string e não pode conter outras strings.', + 'string_value_is_empty' => 'Valor da string não pode ser vazio', + 'string_key_exists' => 'A chave de string já existe', + ], + 'permission' => [ + 'menu_label' => 'Permissões', + 'tab' => 'Permissões', + 'form_tab_permissions' => 'Permissões', + 'btn_add_permission' => 'Acrescentar permissão', + 'btn_delete_permission' => 'Deletar permissão', + 'column_permission_label' => 'Código de permissão', + 'column_permission_required' => 'Por favor, digite o código de permissão', + 'column_tab_label' => 'Título da aba', + 'column_tab_required' => 'Por favor, digite o título da aba permissão', + 'column_label_label' => 'Rótulo', + 'column_label_required' => 'Por favor, digite o rótulo da permissão', + 'saved' => 'Permissões salvas', + 'error_duplicate_code' => "Código de permissão ':code' duplicado.", + ], + 'yaml' => [ + 'save_error' => "Erro ao salvar o arquivo ':name'. Por favor, verifique permissões de escrita.", + ], + 'common' => [ + 'error_file_exists' => "Arquivo ':path' já existe.", + 'field_icon_description' => 'October a ícones Font Autumn: http://octobercms.com/docs/ui/icon', + 'destination_dir_not_exists' => "O diretório de destino ':path' não existe.", + 'error_make_dir' => "Erro ao criar diretório: ':name'.", + 'error_dir_exists' => "Directorio ':path' já existe.", + 'template_not_found' => "Arquivo de template ':name' não encontrado.", + 'error_generating_file' => "Erro ao gerar arquivo: ':path'.", + 'error_loading_template' => "Erro ao carregar arquivo de template: ':name'.", + 'select_plugin_first' => 'Por favor, selecione um plugin primeiro. Para ver a lista de plugins, clique no ícone > na barra lateral esquerda.', + 'plugin_not_selected' => 'Plugin não selecionado', + 'add' => 'Acrescentar', + ], + 'migration' => [ + 'entity_name' => 'Migration', + 'error_version_invalid' => 'A versão deve ser especificada no formato 1.0.1', + 'field_version' => 'Versão', + 'field_description' => 'Descrição', + 'field_code' => 'Código', + 'field_code_comment' => 'O código da migration é apenas leitura e apenas para o propósito de preview. Você pode cdriar migrations customizadas manualmente na seção Versões do Builder.', + 'save_and_apply' => 'Salvar e aplicar', + 'error_version_exists' => 'A versão do migration já existe.', + 'error_script_filename_invalid' => 'O nome do arquivo de script do migration pode conter apenas letras latinas, números e underlines. O nome deve começar com uma letra latina e não pode conter espaços.', + 'error_cannot_change_version_number' => 'Não é possível alterar o número da versão para uma versão aplicada.', + 'error_file_must_define_class' => 'O código de migração deve definir uma migration ou classe de semeador. Deixe o campo de código em branco se você quiser apenas atualizar o número da versão.', + 'error_file_must_define_namespace' => 'O código do migration deve definir um namespace. Deixe o campo de código em branco se você quiser apenas atualizar o número da versão.', + 'no_changes_to_save' => 'Não há mudanças para salvar.', + 'error_namespace_mismatch' => "O código do migration deve usar o namespace :namespace do plugin", + 'error_migration_file_exists' => "O arquivo migration :file já existe. Por favor, use outro nome de classe.", + 'error_cant_delete_applied' => 'Esta versão já foi aplicada e não pode ser excluída. Por favor, reverter a versão primeiro.', + ], + 'components' => [ + 'list_title' => 'Lista de registros', + 'list_description' => 'Exibe uma lista de registros para um model selecionado', + 'list_page_number' => 'Número de pagina', + 'list_page_number_description' => 'Este valor é usado para determinar em qual paginao usuário está.', + 'list_records_per_page' => 'Registros por pagina', + 'list_records_per_page_description' => 'Número de registros para exibir em uma única pagina. Deixe em branco para desabilitar a paginação.', + 'list_records_per_page_validation' => 'Formato inválido dos registros por valor de página. O valor deve ser um número.', + 'list_no_records' => 'Nenhuma mensagem de registro', + 'list_no_records_description' => 'Mensagem a exibir na lista no caso de não haver registros. Usado no partial padrão do componente.', + 'list_no_records_default' => 'Nenhum registro encontrado', + 'list_sort_column' => 'Sortear por coluna', + 'list_sort_column_description' => 'A coluna modela como os registros devem ser ordenados', + 'list_sort_direction' => 'Direção', + 'list_display_column' => 'Exibir coluna', + 'list_display_column_description' => 'Coluna para exibir na lista. Usado no partial padrão do componente.', + 'list_display_column_required' => 'Por favor, selecione uma coluna exibida.', + 'list_details_page' => 'Pagina detalhes', + 'list_details_page_description' => 'Pagina para exibir detalhes dos registros.', + 'list_details_page_no' => '--nenhuma pagina de detalhes--', + 'list_sorting' => 'Sortear', + 'list_pagination' => 'Paginação', + 'list_order_direction_asc' => 'Ascendente', + 'list_order_direction_desc' => 'Descendente', + 'list_model' => 'classe Model', + 'list_scope' => 'Escopo', + 'list_scope_description' => 'Escopo do modelo opcional para buscar os registros', + 'list_scope_default' => '--selecione um escopo, opcional--', + 'list_scope_value' => 'Valor do escopo', + 'list_scope_value_description' => 'Valor opcional para passar para o escopo do modelo', + 'list_details_page_link' => 'Link para a pagina de detalhes', + 'list_details_key_column' => 'Coluna chave de detalhes', + 'list_details_key_column_description' => 'Coluna Modelo para usar como um identificador de registro nos links da página de detalhes.', + 'list_details_url_parameter' => 'Nome do parâmetro de URL ', + 'list_details_url_parameter_description' => 'Nome do parâmetro de URL da página de detalhes que leva o identificador de registro.', + 'details_title' => 'Detalhes de registros', + 'details_description' => 'Exibe detalhes de registros para um modelo selecionado', + 'details_model' => 'Classe Model', + 'details_identifier_value' => 'Valor do identificador', + 'details_identifier_value_description' => 'Valor identificador para carregar os registros do banco de dados. Especifique um valor fixo ou nome de parâmetro URL.', + 'details_identifier_value_required' => 'O valor do identificador é obrigatório', + 'details_key_column' => 'Coluna chave', + 'details_key_column_description' => 'Coluna model para usar como um identificador de registro para buscar os registros do banco de dados.', + 'details_key_column_required' => 'O nome de coluna chave é obrigatório', + 'details_display_column' => 'Exibir coluna', + 'details_display_column_description' => 'Coluna model para exibir na pagina de detalhes. Usado no partial padrão do componente.', + 'details_display_column_required' => 'Por favor, selecione uma coluna de exibição.', + 'details_not_found_message' => 'Mensagem nçai encontrada', + 'details_not_found_message_description' => 'Mensagem para exibir se o registro não for encontrado. Usado no partial padrão do componente.', + 'details_not_found_message_default' => 'Registro não encontrado', + ], +]; diff --git a/server/plugins/rainlab/builder/models/Settings.php b/server/plugins/rainlab/builder/models/Settings.php new file mode 100644 index 0000000..7353b21 --- /dev/null +++ b/server/plugins/rainlab/builder/models/Settings.php @@ -0,0 +1,29 @@ + 'required', + 'author_namespace' => ['required', 'regex:/^[a-z]+[a-z0-9]+$/i', 'reserved'] + ]; +} diff --git a/server/plugins/rainlab/builder/models/settings/fields.yaml b/server/plugins/rainlab/builder/models/settings/fields.yaml new file mode 100644 index 0000000..4080669 --- /dev/null +++ b/server/plugins/rainlab/builder/models/settings/fields.yaml @@ -0,0 +1,13 @@ +fields: + author_name: + span: left + label: rainlab.builder::lang.author_name.title + commentAbove: rainlab.builder::lang.author_name.description + + author_namespace: + span: right + label: rainlab.builder::lang.author_namespace.title + commentAbove: rainlab.builder::lang.author_namespace.description + preset: + field: author_name + type: namespace \ No newline at end of file diff --git a/server/plugins/rainlab/builder/phpunit.xml b/server/plugins/rainlab/builder/phpunit.xml new file mode 100644 index 0000000..db31479 --- /dev/null +++ b/server/plugins/rainlab/builder/phpunit.xml @@ -0,0 +1,23 @@ + + + + + ./tests/unit + + + + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/tests/TestCase.php b/server/plugins/rainlab/builder/tests/TestCase.php new file mode 100644 index 0000000..5bc4fe6 --- /dev/null +++ b/server/plugins/rainlab/builder/tests/TestCase.php @@ -0,0 +1,3 @@ +cleanUp(); + } + + public function tearDown() + { + $this->cleanUp(); + } + + public function testGenerate() + { + $generatedDir = $this->getFixturesDir('temporary/generated'); + $this->assertFileNotExists($generatedDir); + + File::makeDirectory($generatedDir, 0777, true, true); + $this->assertFileExists($generatedDir); + + $structure = [ + 'author', + 'author/plugin', + 'author/plugin/plugin.php' => 'plugin.php.tpl', + 'author/plugin/classes' + ]; + + $templatesDir = $this->getFixturesDir('templates'); + $generator = new FilesystemGenerator($generatedDir, $structure, $templatesDir); + + $variables = [ + 'authorNamespace' => 'Author', + 'pluginNamespace' => 'Plugin' + ]; + $generator->setVariables($variables); + $generator->setVariable('className', 'TestClass'); + + $generator->generate(); + + $this->assertFileExists($generatedDir.'/author/plugin/plugin.php'); + $this->assertFileExists($generatedDir.'/author/plugin/classes'); + + $content = file_get_contents($generatedDir.'/author/plugin/plugin.php'); + $this->assertContains('Author\Plugin', $content); + $this->assertContains('TestClass', $content); + } + + /** + * @expectedException October\Rain\Exception\SystemException + * @expectedExceptionMessage exists + */ + public function testDestNotExistsException() + { + $dir = $this->getFixturesDir('temporary/null'); + $generator = new FilesystemGenerator($dir, []); + $generator->generate(); + } + + /** + * @expectedException October\Rain\Exception\ApplicationException + * @expectedExceptionMessage exists + */ + public function testDirExistsException() + { + $generatedDir = $this->getFixturesDir('temporary/generated'); + $this->assertFileNotExists($generatedDir); + + File::makeDirectory($generatedDir.'/plugin', 0777, true, true); + $this->assertFileExists($generatedDir.'/plugin'); + + $structure = [ + 'plugin' + ]; + + $generator = new FilesystemGenerator($generatedDir, $structure); + $generator->generate(); + } + + /** + * @expectedException October\Rain\Exception\ApplicationException + * @expectedExceptionMessage exists + */ + public function testFileExistsException() + { + $generatedDir = $this->getFixturesDir('temporary/generated'); + $this->assertFileNotExists($generatedDir); + + File::makeDirectory($generatedDir, 0777, true, true); + $this->assertFileExists($generatedDir); + + File::put($generatedDir.'/plugin.php', 'contents'); + $this->assertFileExists($generatedDir.'/plugin.php'); + + $structure = [ + 'plugin.php' => 'plugin.php.tpl' + ]; + + $generator = new FilesystemGenerator($generatedDir, $structure); + $generator->generate(); + } + + /** + * @expectedException October\Rain\Exception\SystemException + * @expectedExceptionMessage found + */ + public function testTemplateNotFound() + { + $generatedDir = $this->getFixturesDir('temporary/generated'); + $this->assertFileNotExists($generatedDir); + + File::makeDirectory($generatedDir, 0777, true, true); + $this->assertFileExists($generatedDir); + + $structure = [ + 'plugin.php' => 'null.tpl' + ]; + + $generator = new FilesystemGenerator($generatedDir, $structure); + $generator->generate(); + } + + protected function getFixturesDir($subdir) + { + $result = __DIR__.'/../../fixtures/filesystemgenerator'; + + if (strlen($subdir)) { + $result .= '/'.$subdir; + } + + return $result; + } + + protected function cleanUp() + { + $generatedDir = $this->getFixturesDir('temporary/generated'); + File::deleteDirectory($generatedDir); + } +} diff --git a/server/plugins/rainlab/builder/tests/unit/classes/ModelModelTest.php b/server/plugins/rainlab/builder/tests/unit/classes/ModelModelTest.php new file mode 100644 index 0000000..24b95ca --- /dev/null +++ b/server/plugins/rainlab/builder/tests/unit/classes/ModelModelTest.php @@ -0,0 +1,68 @@ +assertTrue( ModelModel::validateModelClassName($unQualifiedClassName) ); + + $qualifiedClassName = 'RainLab\Builder\Models\Settings'; + $this->assertTrue( ModelModel::validateModelClassName($qualifiedClassName) ); + + $fullyQualifiedClassName = '\RainLab\Builder\Models\Settings'; + $this->assertTrue( ModelModel::validateModelClassName($fullyQualifiedClassName) ); + + $qualifiedClassNameStartingWithLowerCase = 'rainLab\Builder\Models\Settings'; + $this->assertTrue( ModelModel::validateModelClassName($qualifiedClassNameStartingWithLowerCase) ); + } + + public function testInvalidateModelClassName() + { + $unQualifiedClassName = 'myClassName'; // starts with lower case + $this->assertFalse( ModelModel::validateModelClassName($unQualifiedClassName) ); + + $qualifiedClassName = 'MyNameSpace\MyPlugin\Models\MyClassName'; // namespace\class doesn't exist + $this->assertFalse( ModelModel::validateModelClassName($qualifiedClassName) ); + + $fullyQualifiedClassName = '\MyNameSpace\MyPlugin\Models\MyClassName'; // namespace\class doesn't exist + $this->assertFalse( ModelModel::validateModelClassName($fullyQualifiedClassName) ); + } + + public function testGetModelFields(){ + // Invalid Class Name + try { + ModelModel::getModelFields(NULL, 'myClassName'); + } catch (SystemException $e) { + $this->assertEquals($e->getMessage(), 'Invalid model class name: myClassName'); + return; + } + + // Directory Not Found + $pluginCodeObj = PluginCode::createFromNamespace('MyNameSpace\MyPlugin\Models\MyClassName'); + $this->assertEquals([], ModelModel::getModelFields($pluginCodeObj, 'MyClassName') ); + + // Directory Found, but Class Not Found + $pluginCodeObj = PluginCode::createFromNamespace('RainLab\Builder\Models\MyClassName'); + $this->assertEquals([], ModelModel::getModelFields($pluginCodeObj, 'MyClassName') ); + + // Model without Table Name + $pluginCodeObj = PluginCode::createFromNamespace('RainLab\Builder\Models\Settings'); + $this->assertEquals([], ModelModel::getModelFields($pluginCodeObj, 'Settings') ); + + // Model with Table Name + copy(__DIR__."/../../fixtures/MyMock.php", __DIR__."/../../../models/MyMock.php"); + $pluginCodeObj = PluginCode::createFromNamespace('RainLab\Builder\Models\MyMock'); + $this->assertEquals([], ModelModel::getModelFields($pluginCodeObj, 'MyMock') ); + } + +} diff --git a/server/plugins/rainlab/builder/tests/unit/phpunit.xml b/server/plugins/rainlab/builder/tests/unit/phpunit.xml new file mode 100644 index 0000000..43f7f24 --- /dev/null +++ b/server/plugins/rainlab/builder/tests/unit/phpunit.xml @@ -0,0 +1,23 @@ + + + + + ./ + + + + + + + + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/updates/version.yaml b/server/plugins/rainlab/builder/updates/version.yaml new file mode 100644 index 0000000..5798699 --- /dev/null +++ b/server/plugins/rainlab/builder/updates/version.yaml @@ -0,0 +1,23 @@ +1.0.1: Initialize plugin. +1.0.2: Fixes the problem with selecting a plugin. Minor localization corrections. Configuration files in the list and form behaviors are now autocomplete. +1.0.3: Improved handling of the enum data type. +1.0.4: Added user permissions to work with the Builder. +1.0.5: Fixed permissions registration. +1.0.6: Fixed front-end record ordering in the Record List component. +1.0.7: Builder settings are now protected with user permissions. The database table column list is scrollable now. Minor code cleanup. +1.0.8: Added the Reorder Controller behavior. +1.0.9: Minor API and UI updates. +1.0.10: Minor styling update. +1.0.11: Fixed a bug where clicking placeholder in a repeater would open Inspector. Fixed a problem with saving forms with repeaters in tabs. Minor style fix. +1.0.12: Added support for the Trigger property to the Media Finder widget configuration. Names of form fields and list columns definition files can now contain underscores. +1.0.13: Minor styling fix on the database editor. +1.0.14: Added support for published_at timestamp field +1.0.15: Fixed a bug where saving a localization string in Inspector could cause a JavaScript error. Added support for Timestamps and Soft Deleting for new models. +1.0.16: Fixed a bug when saving a form with the Repeater widget in a tab could create invalid fields in the form's outside area. Added a check that prevents creating localization strings inside other existing strings. +1.0.17: Added support Trigger attribute support for RecordFinder and Repeater form widgets. +1.0.18: Fixes a bug where '::class' notations in a model class definition could prevent the model from appearing in the Builder model list. Added emptyOption property support to the dropdown form control. +1.0.19: Added a feature allowing to add all database columns to a list definition. Added max length validation for database table and column names. +1.0.20: Fixes a bug where form the builder could trigger the "current.hasAttribute is not a function" error. +1.0.21: Back-end navigation sort order updated. +1.0.22: Added scopeValue property to the RecordList component. +1.0.23: Added support for balloon-selector field type, added Brazilian Portuguese translation, fixed some bugs \ No newline at end of file diff --git a/server/plugins/rainlab/builder/validation/ReservedValidator.php b/server/plugins/rainlab/builder/validation/ReservedValidator.php new file mode 100644 index 0000000..5e9a58a --- /dev/null +++ b/server/plugins/rainlab/builder/validation/ReservedValidator.php @@ -0,0 +1,129 @@ +reserved); + } + + /** + * @param $message + * @param $attribute + * @param $rule + * @param $parameters + * @return mixed + */ + public function replaceReserved($message, $attribute, $rule, $parameters) + { + return $this->replaceAttributePlaceholder(e(trans('rainlab.builder::lang.validation.reserved')), ucfirst($this->getDisplayableAttribute($attribute))); + } +} diff --git a/server/plugins/rainlab/builder/vendor/autoload.php b/server/plugins/rainlab/builder/vendor/autoload.php new file mode 100644 index 0000000..7be4ef7 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/server/plugins/rainlab/builder/vendor/composer/LICENSE b/server/plugins/rainlab/builder/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/server/plugins/rainlab/builder/vendor/composer/autoload_classmap.php b/server/plugins/rainlab/builder/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/composer/installers/src/Composer/Installers'), +); diff --git a/server/plugins/rainlab/builder/vendor/composer/autoload_real.php b/server/plugins/rainlab/builder/vendor/composer/autoload_real.php new file mode 100644 index 0000000..171ca18 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/autoload_real.php @@ -0,0 +1,52 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit28556bde982901100539ddbc3fb5f3ba::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/autoload_static.php b/server/plugins/rainlab/builder/vendor/composer/autoload_static.php new file mode 100644 index 0000000..06e691f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/autoload_static.php @@ -0,0 +1,31 @@ + + array ( + 'Composer\\Installers\\' => 20, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Composer\\Installers\\' => + array ( + 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInit28556bde982901100539ddbc3fb5f3ba::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit28556bde982901100539ddbc3fb5f3ba::$prefixDirsPsr4; + + }, null, ClassLoader::class); + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installed.json b/server/plugins/rainlab/builder/vendor/composer/installed.json new file mode 100644 index 0000000..699edf1 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installed.json @@ -0,0 +1,124 @@ +[ + { + "name": "composer/installers", + "version": "v1.6.0", + "version_normalized": "1.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "^4.8.36" + }, + "time": "2018-08-27T06:10:37+00:00", + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Thelia", + "WolfCMS", + "agl", + "aimeos", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "joomla", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "majima", + "mako", + "mediawiki", + "modulework", + "modx", + "moodle", + "osclass", + "phpbb", + "piwik", + "ppi", + "puppet", + "pxcms", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "symfony", + "typo3", + "wordpress", + "yawik", + "zend", + "zikula" + ] + } +] diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/LICENSE b/server/plugins/rainlab/builder/vendor/composer/installers/LICENSE new file mode 100644 index 0000000..85f97fc --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Kyle Robinson Young + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/composer.json b/server/plugins/rainlab/builder/vendor/composer/installers/composer.json new file mode 100644 index 0000000..6de4085 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/composer.json @@ -0,0 +1,105 @@ +{ + "name": "composer/installers", + "type": "composer-plugin", + "license": "MIT", + "description": "A multi-framework Composer library installer", + "keywords": [ + "installer", + "Aimeos", + "AGL", + "AnnotateCms", + "Attogram", + "Bitrix", + "CakePHP", + "Chef", + "Cockpit", + "CodeIgniter", + "concrete5", + "Craft", + "Croogo", + "DokuWiki", + "Dolibarr", + "Drupal", + "Elgg", + "Eliasis", + "ExpressionEngine", + "eZ Platform", + "FuelPHP", + "Grav", + "Hurad", + "ImageCMS", + "iTop", + "Joomla", + "Kanboard", + "Kohana", + "Lan Management System", + "Laravel", + "Lavalite", + "Lithium", + "Magento", + "majima", + "Mako", + "Mautic", + "Maya", + "MODX", + "MODX Evo", + "MediaWiki", + "OXID", + "osclass", + "MODULEWork", + "Moodle", + "Piwik", + "pxcms", + "phpBB", + "Plentymarkets", + "PPI", + "Puppet", + "Porto", + "RadPHP", + "ReIndex", + "Roundcube", + "shopware", + "SilverStripe", + "SMF", + "SyDES", + "symfony", + "Thelia", + "TYPO3", + "WolfCMS", + "WordPress", + "YAWIK", + "Zend", + "Zikula" + ], + "homepage": "https://composer.github.io/installers/", + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "autoload": { + "psr-4": { "Composer\\Installers\\": "src/Composer/Installers" } + }, + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "replace": { + "shama/baton": "*", + "roundcube/plugin-installer": "*" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "^4.8.36" + }, + "scripts": { + "test": "phpunit" + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AglInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AglInstaller.php new file mode 100644 index 0000000..01b8a41 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AglInstaller.php @@ -0,0 +1,21 @@ + 'More/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) { + return strtoupper($matches[1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php new file mode 100644 index 0000000..79a0e95 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php @@ -0,0 +1,9 @@ + 'ext/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php new file mode 100644 index 0000000..89d7ad9 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php @@ -0,0 +1,11 @@ + 'addons/modules/{$name}/', + 'component' => 'addons/components/{$name}/', + 'service' => 'addons/services/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php new file mode 100644 index 0000000..22dad1b --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php @@ -0,0 +1,49 @@ + 'Modules/{$name}/', + 'theme' => 'Themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type asgard-module, cut off a trailing '-plugin' if present. + * + * For package type asgard-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'asgard-module') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'asgard-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php new file mode 100644 index 0000000..d62fd8f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php new file mode 100644 index 0000000..7082bf2 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php @@ -0,0 +1,136 @@ +composer = $composer; + $this->package = $package; + $this->io = $io; + } + + /** + * Return the install path based on package type. + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $type = $this->package->getType(); + + $prettyName = $this->package->getPrettyName(); + if (strpos($prettyName, '/') !== false) { + list($vendor, $name) = explode('/', $prettyName); + } else { + $vendor = ''; + $name = $prettyName; + } + + $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); + + $extra = $package->getExtra(); + if (!empty($extra['installer-name'])) { + $availableVars['name'] = $extra['installer-name']; + } + + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + if (!empty($extra['installer-paths'])) { + $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor); + if ($customPath !== false) { + return $this->templatePath($customPath, $availableVars); + } + } + } + + $packageType = substr($type, strlen($frameworkType) + 1); + $locations = $this->getLocations(); + if (!isset($locations[$packageType])) { + throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); + } + + return $this->templatePath($locations[$packageType], $availableVars); + } + + /** + * For an installer to override to modify the vars per installer. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + return $vars; + } + + /** + * Gets the installer's locations + * + * @return array + */ + public function getLocations() + { + return $this->locations; + } + + /** + * Replace vars in a path + * + * @param string $path + * @param array $vars + * @return string + */ + protected function templatePath($path, array $vars = array()) + { + if (strpos($path, '{') !== false) { + extract($vars); + preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); + if (!empty($matches[1])) { + foreach ($matches[1] as $var) { + $path = str_replace('{$' . $var . '}', $$var, $path); + } + } + } + + return $path; + } + + /** + * Search through a passed paths array for a custom install path. + * + * @param array $paths + * @param string $name + * @param string $type + * @param string $vendor = NULL + * @return string + */ + protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL) + { + foreach ($paths as $path => $names) { + if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) { + return $path; + } + } + + return false; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php new file mode 100644 index 0000000..e80cd1e --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php @@ -0,0 +1,126 @@ +.`. + * - `bitrix-d7-component` — copy the component to directory `bitrix/components//`. + * - `bitrix-d7-template` — copy the template to directory `bitrix/templates/_`. + * + * You can set custom path to directory with Bitrix kernel in `composer.json`: + * + * ```json + * { + * "extra": { + * "bitrix-dir": "s1/bitrix" + * } + * } + * ``` + * + * @author Nik Samokhvalov + * @author Denis Kulichkin + */ +class BitrixInstaller extends BaseInstaller +{ + protected $locations = array( + 'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) + 'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) + 'theme' => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) + 'd7-module' => '{$bitrix_dir}/modules/{$vendor}.{$name}/', + 'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/', + 'd7-template' => '{$bitrix_dir}/templates/{$vendor}_{$name}/', + ); + + /** + * @var array Storage for informations about duplicates at all the time of installation packages. + */ + private static $checkedDuplicates = array(); + + /** + * {@inheritdoc} + */ + public function inflectPackageVars($vars) + { + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + + if (isset($extra['bitrix-dir'])) { + $vars['bitrix_dir'] = $extra['bitrix-dir']; + } + } + + if (!isset($vars['bitrix_dir'])) { + $vars['bitrix_dir'] = 'bitrix'; + } + + return parent::inflectPackageVars($vars); + } + + /** + * {@inheritdoc} + */ + protected function templatePath($path, array $vars = array()) + { + $templatePath = parent::templatePath($path, $vars); + $this->checkDuplicates($templatePath, $vars); + + return $templatePath; + } + + /** + * Duplicates search packages. + * + * @param string $path + * @param array $vars + */ + protected function checkDuplicates($path, array $vars = array()) + { + $packageType = substr($vars['type'], strlen('bitrix') + 1); + $localDir = explode('/', $vars['bitrix_dir']); + array_pop($localDir); + $localDir[] = 'local'; + $localDir = implode('/', $localDir); + + $oldPath = str_replace( + array('{$bitrix_dir}', '{$name}'), + array($localDir, $vars['name']), + $this->locations[$packageType] + ); + + if (in_array($oldPath, static::$checkedDuplicates)) { + return; + } + + if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) { + + $this->io->writeError(' Duplication of packages:'); + $this->io->writeError(' Package ' . $oldPath . ' will be called instead package ' . $path . ''); + + while (true) { + switch ($this->io->ask(' Delete ' . $oldPath . ' [y,n,?]? ', '?')) { + case 'y': + $fs = new Filesystem(); + $fs->removeDirectory($oldPath); + break 2; + + case 'n': + break 2; + + case '?': + default: + $this->io->writeError(array( + ' y - delete package ' . $oldPath . ' and to continue with the installation', + ' n - don\'t delete and to continue with the installation', + )); + $this->io->writeError(' ? - print help'); + break; + } + } + } + + static::$checkedDuplicates[] = $oldPath; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php new file mode 100644 index 0000000..da3aad2 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php @@ -0,0 +1,9 @@ + 'Packages/{$vendor}/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php new file mode 100644 index 0000000..6352beb --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php @@ -0,0 +1,82 @@ + 'Plugin/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + return $vars; + } + + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + + return $vars; + } + + /** + * Change the default plugin location when cakephp >= 3.0 + */ + public function getLocations() + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; + } + return $this->locations; + } + + /** + * Check if CakePHP version matches against a version + * + * @param string $matcher + * @param string $version + * @return bool + */ + protected function matchesCakeVersion($matcher, $version) + { + if (class_exists('Composer\Semver\Constraint\MultiConstraint')) { + $multiClass = 'Composer\Semver\Constraint\MultiConstraint'; + $constraintClass = 'Composer\Semver\Constraint\Constraint'; + } else { + $multiClass = 'Composer\Package\LinkConstraint\MultiConstraint'; + $constraintClass = 'Composer\Package\LinkConstraint\VersionConstraint'; + } + + $repositoryManager = $this->composer->getRepositoryManager(); + if ($repositoryManager) { + $repos = $repositoryManager->getLocalRepository(); + if (!$repos) { + return false; + } + $cake3 = new $multiClass(array( + new $constraintClass($matcher, $version), + new $constraintClass('!=', '9999999-dev'), + )); + $pool = new Pool('dev'); + $pool->addRepository($repos); + $packages = $pool->whatProvides('cakephp/cakephp'); + foreach ($packages as $package) { + $installed = new $constraintClass('=', $package->getVersion()); + if ($cake3->matches($installed)) { + return true; + } + } + } + return false; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php new file mode 100644 index 0000000..ab2f9aa --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php @@ -0,0 +1,11 @@ + 'Chef/{$vendor}/{$name}/', + 'role' => 'Chef/roles/{$name}/', + ); +} + diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php new file mode 100644 index 0000000..6673aea --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php @@ -0,0 +1,9 @@ + 'ext/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php new file mode 100644 index 0000000..c887815 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php @@ -0,0 +1,10 @@ + 'CCF/orbit/{$name}/', + 'theme' => 'CCF/app/themes/{$name}/', + ); +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php new file mode 100644 index 0000000..c7816df --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php @@ -0,0 +1,34 @@ + 'cockpit/modules/addons/{$name}/', + ); + + /** + * Format module name. + * + * Strip `module-` prefix from package name. + * + * @param array @vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] == 'cockpit-module') { + return $this->inflectModuleVars($vars); + } + + return $vars; + } + + public function inflectModuleVars($vars) + { + $vars['name'] = ucfirst(preg_replace('/cockpit-/i', '', $vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php new file mode 100644 index 0000000..3b4a4ec --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php @@ -0,0 +1,11 @@ + 'application/libraries/{$name}/', + 'third-party' => 'application/third_party/{$name}/', + 'module' => 'application/modules/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php new file mode 100644 index 0000000..5c01baf --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php @@ -0,0 +1,13 @@ + 'concrete/', + 'block' => 'application/blocks/{$name}/', + 'package' => 'packages/{$name}/', + 'theme' => 'application/themes/{$name}/', + 'update' => 'updates/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php new file mode 100644 index 0000000..d37a77a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php @@ -0,0 +1,35 @@ + 'craft/plugins/{$name}/', + ); + + /** + * Strip `craft-` prefix and/or `-plugin` suffix from package names + * + * @param array $vars + * + * @return array + */ + final public function inflectPackageVars($vars) + { + return $this->inflectPluginVars($vars); + } + + private function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-' . self::NAME_SUFFIX . '$/i', '', $vars['name']); + $vars['name'] = preg_replace('/^' . self::NAME_PREFIX . '-/i', '', $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php new file mode 100644 index 0000000..d94219d --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php @@ -0,0 +1,21 @@ + 'Plugin/{$name}/', + 'theme' => 'View/Themed/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name'])); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php new file mode 100644 index 0000000..f4837a6 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php @@ -0,0 +1,10 @@ + 'app/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php new file mode 100644 index 0000000..cfd638d --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php @@ -0,0 +1,50 @@ + 'lib/plugins/{$name}/', + 'template' => 'lib/tpl/{$name}/', + ); + + /** + * Format package name. + * + * For package type dokuwiki-plugin, cut off a trailing '-plugin', + * or leading dokuwiki_ if present. + * + * For package type dokuwiki-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'dokuwiki-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'dokuwiki-template') { + return $this->inflectTemplateVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php new file mode 100644 index 0000000..21f7e8e --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php @@ -0,0 +1,16 @@ + + */ +class DolibarrInstaller extends BaseInstaller +{ + //TODO: Add support for scripts and themes + protected $locations = array( + 'module' => 'htdocs/custom/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php new file mode 100644 index 0000000..fef7c52 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php @@ -0,0 +1,16 @@ + 'core/', + 'module' => 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + 'library' => 'libraries/{$name}/', + 'profile' => 'profiles/{$name}/', + 'drush' => 'drush/{$name}/', + 'custom-theme' => 'themes/custom/{$name}/', + 'custom-module' => 'modules/custom/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php new file mode 100644 index 0000000..c0bb609 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php @@ -0,0 +1,9 @@ + 'mod/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php new file mode 100644 index 0000000..6f3dc97 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php @@ -0,0 +1,12 @@ + 'components/{$name}/', + 'module' => 'modules/{$name}/', + 'plugin' => 'plugins/{$name}/', + 'template' => 'templates/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php new file mode 100644 index 0000000..d5321a8 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php @@ -0,0 +1,29 @@ + 'system/expressionengine/third_party/{$name}/', + 'theme' => 'themes/third_party/{$name}/', + ); + + private $ee3Locations = array( + 'addon' => 'system/user/addons/{$name}/', + 'theme' => 'themes/user/{$name}/', + ); + + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + + $version = "{$frameworkType}Locations"; + $this->locations = $this->$version; + + return parent::getInstallPath($package, $frameworkType); + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php new file mode 100644 index 0000000..f30ebcc --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php @@ -0,0 +1,10 @@ + 'web/assets/ezplatform/', + 'assets' => 'web/assets/ezplatform/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php new file mode 100644 index 0000000..6eba2e3 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php @@ -0,0 +1,11 @@ + 'fuel/app/modules/{$name}/', + 'package' => 'fuel/packages/{$name}/', + 'theme' => 'fuel/app/themes/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php new file mode 100644 index 0000000..29d980b --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php @@ -0,0 +1,9 @@ + 'components/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/GravInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/GravInstaller.php new file mode 100644 index 0000000..dbe63e0 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/GravInstaller.php @@ -0,0 +1,30 @@ + 'user/plugins/{$name}/', + 'theme' => 'user/themes/{$name}/', + ); + + /** + * Format package name + * + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $restrictedWords = implode('|', array_keys($this->locations)); + + $vars['name'] = strtolower($vars['name']); + $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', + '$1', + $vars['name'] + ); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php new file mode 100644 index 0000000..8fe017f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php @@ -0,0 +1,25 @@ + 'plugins/{$name}/', + 'theme' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php new file mode 100644 index 0000000..5e2142e --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php @@ -0,0 +1,11 @@ + 'templates/{$name}/', + 'module' => 'application/modules/{$name}/', + 'library' => 'application/libraries/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Installer.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Installer.php new file mode 100644 index 0000000..352cb7f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Installer.php @@ -0,0 +1,274 @@ + 'AimeosInstaller', + 'asgard' => 'AsgardInstaller', + 'attogram' => 'AttogramInstaller', + 'agl' => 'AglInstaller', + 'annotatecms' => 'AnnotateCmsInstaller', + 'bitrix' => 'BitrixInstaller', + 'bonefish' => 'BonefishInstaller', + 'cakephp' => 'CakePHPInstaller', + 'chef' => 'ChefInstaller', + 'civicrm' => 'CiviCrmInstaller', + 'ccframework' => 'ClanCatsFrameworkInstaller', + 'cockpit' => 'CockpitInstaller', + 'codeigniter' => 'CodeIgniterInstaller', + 'concrete5' => 'Concrete5Installer', + 'craft' => 'CraftInstaller', + 'croogo' => 'CroogoInstaller', + 'dokuwiki' => 'DokuWikiInstaller', + 'dolibarr' => 'DolibarrInstaller', + 'decibel' => 'DecibelInstaller', + 'drupal' => 'DrupalInstaller', + 'elgg' => 'ElggInstaller', + 'eliasis' => 'EliasisInstaller', + 'ee3' => 'ExpressionEngineInstaller', + 'ee2' => 'ExpressionEngineInstaller', + 'ezplatform' => 'EzPlatformInstaller', + 'fuel' => 'FuelInstaller', + 'fuelphp' => 'FuelphpInstaller', + 'grav' => 'GravInstaller', + 'hurad' => 'HuradInstaller', + 'imagecms' => 'ImageCMSInstaller', + 'itop' => 'ItopInstaller', + 'joomla' => 'JoomlaInstaller', + 'kanboard' => 'KanboardInstaller', + 'kirby' => 'KirbyInstaller', + 'kodicms' => 'KodiCMSInstaller', + 'kohana' => 'KohanaInstaller', + 'lms' => 'LanManagementSystemInstaller', + 'laravel' => 'LaravelInstaller', + 'lavalite' => 'LavaLiteInstaller', + 'lithium' => 'LithiumInstaller', + 'magento' => 'MagentoInstaller', + 'majima' => 'MajimaInstaller', + 'mako' => 'MakoInstaller', + 'maya' => 'MayaInstaller', + 'mautic' => 'MauticInstaller', + 'mediawiki' => 'MediaWikiInstaller', + 'microweber' => 'MicroweberInstaller', + 'modulework' => 'MODULEWorkInstaller', + 'modx' => 'ModxInstaller', + 'modxevo' => 'MODXEvoInstaller', + 'moodle' => 'MoodleInstaller', + 'october' => 'OctoberInstaller', + 'ontowiki' => 'OntoWikiInstaller', + 'oxid' => 'OxidInstaller', + 'osclass' => 'OsclassInstaller', + 'pxcms' => 'PxcmsInstaller', + 'phpbb' => 'PhpBBInstaller', + 'pimcore' => 'PimcoreInstaller', + 'piwik' => 'PiwikInstaller', + 'plentymarkets'=> 'PlentymarketsInstaller', + 'ppi' => 'PPIInstaller', + 'puppet' => 'PuppetInstaller', + 'radphp' => 'RadPHPInstaller', + 'phifty' => 'PhiftyInstaller', + 'porto' => 'PortoInstaller', + 'redaxo' => 'RedaxoInstaller', + 'reindex' => 'ReIndexInstaller', + 'roundcube' => 'RoundcubeInstaller', + 'shopware' => 'ShopwareInstaller', + 'sitedirect' => 'SiteDirectInstaller', + 'silverstripe' => 'SilverStripeInstaller', + 'smf' => 'SMFInstaller', + 'sydes' => 'SyDESInstaller', + 'symfony1' => 'Symfony1Installer', + 'thelia' => 'TheliaInstaller', + 'tusk' => 'TuskInstaller', + 'typo3-cms' => 'TYPO3CmsInstaller', + 'typo3-flow' => 'TYPO3FlowInstaller', + 'userfrosting' => 'UserFrostingInstaller', + 'vanilla' => 'VanillaInstaller', + 'whmcs' => 'WHMCSInstaller', + 'wolfcms' => 'WolfCMSInstaller', + 'wordpress' => 'WordPressInstaller', + 'yawik' => 'YawikInstaller', + 'zend' => 'ZendInstaller', + 'zikula' => 'ZikulaInstaller', + 'prestashop' => 'PrestashopInstaller' + ); + + /** + * Installer constructor. + * + * Disables installers specified in main composer extra installer-disable + * list + * + * @param IOInterface $io + * @param Composer $composer + * @param string $type + * @param Filesystem|null $filesystem + * @param BinaryInstaller|null $binaryInstaller + */ + public function __construct( + IOInterface $io, + Composer $composer, + $type = 'library', + Filesystem $filesystem = null, + BinaryInstaller $binaryInstaller = null + ) { + parent::__construct($io, $composer, $type, $filesystem, + $binaryInstaller); + $this->removeDisabledInstallers(); + } + + /** + * {@inheritDoc} + */ + public function getInstallPath(PackageInterface $package) + { + $type = $package->getType(); + $frameworkType = $this->findFrameworkType($type); + + if ($frameworkType === false) { + throw new \InvalidArgumentException( + 'Sorry the package type of this package is not yet supported.' + ); + } + + $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + $installer = new $class($package, $this->composer, $this->getIO()); + + return $installer->getInstallPath($package, $frameworkType); + } + + public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) + { + parent::uninstall($repo, $package); + $installPath = $this->getPackageBasePath($package); + $this->io->write(sprintf('Deleting %s - %s', $installPath, !file_exists($installPath) ? 'deleted' : 'not deleted')); + } + + /** + * {@inheritDoc} + */ + public function supports($packageType) + { + $frameworkType = $this->findFrameworkType($packageType); + + if ($frameworkType === false) { + return false; + } + + $locationPattern = $this->getLocationPattern($frameworkType); + + return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; + } + + /** + * Finds a supported framework type if it exists and returns it + * + * @param string $type + * @return string + */ + protected function findFrameworkType($type) + { + $frameworkType = false; + + krsort($this->supportedTypes); + + foreach ($this->supportedTypes as $key => $val) { + if ($key === substr($type, 0, strlen($key))) { + $frameworkType = substr($type, 0, strlen($key)); + break; + } + } + + return $frameworkType; + } + + /** + * Get the second part of the regular expression to check for support of a + * package type + * + * @param string $frameworkType + * @return string + */ + protected function getLocationPattern($frameworkType) + { + $pattern = false; + if (!empty($this->supportedTypes[$frameworkType])) { + $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + /** @var BaseInstaller $framework */ + $framework = new $frameworkClass(null, $this->composer, $this->getIO()); + $locations = array_keys($framework->getLocations()); + $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; + } + + return $pattern ? : '(\w+)'; + } + + /** + * Get I/O object + * + * @return IOInterface + */ + private function getIO() + { + return $this->io; + } + + /** + * Look for installers set to be disabled in composer's extra config and + * remove them from the list of supported installers. + * + * Globals: + * - true, "all", and "*" - disable all installers. + * - false - enable all installers (useful with + * wikimedia/composer-merge-plugin or similar) + * + * @return void + */ + protected function removeDisabledInstallers() + { + $extra = $this->composer->getPackage()->getExtra(); + + if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) { + // No installers are disabled + return; + } + + // Get installers to disable + $disable = $extra['installer-disable']; + + // Ensure $disabled is an array + if (!is_array($disable)) { + $disable = array($disable); + } + + // Check which installers should be disabled + $all = array(true, "all", "*"); + $intersect = array_intersect($all, $disable); + if (!empty($intersect)) { + // Disable all installers + $this->supportedTypes = array(); + } else { + // Disable specified installers + foreach ($disable as $key => $installer) { + if (is_string($installer) && key_exists($installer, $this->supportedTypes)) { + unset($this->supportedTypes[$installer]); + } + } + } + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php new file mode 100644 index 0000000..c6c1b33 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php @@ -0,0 +1,9 @@ + 'extensions/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php new file mode 100644 index 0000000..9ee7759 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php @@ -0,0 +1,15 @@ + 'components/{$name}/', + 'module' => 'modules/{$name}/', + 'template' => 'templates/{$name}/', + 'plugin' => 'plugins/{$name}/', + 'library' => 'libraries/{$name}/', + ); + + // TODO: Add inflector for mod_ and com_ names +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php new file mode 100644 index 0000000..9cb7b8c --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php @@ -0,0 +1,18 @@ + 'plugins/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php new file mode 100644 index 0000000..36b2f84 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php @@ -0,0 +1,11 @@ + 'site/plugins/{$name}/', + 'field' => 'site/fields/{$name}/', + 'tag' => 'site/tags/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php new file mode 100644 index 0000000..7143e23 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php @@ -0,0 +1,10 @@ + 'cms/plugins/{$name}/', + 'media' => 'cms/media/vendor/{$name}/' + ); +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php new file mode 100644 index 0000000..dcd6d26 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php new file mode 100644 index 0000000..903143a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php @@ -0,0 +1,27 @@ + 'plugins/{$name}/', + 'template' => 'templates/{$name}/', + 'document-template' => 'documents/templates/{$name}/', + 'userpanel-module' => 'userpanel/modules/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php new file mode 100644 index 0000000..be4d53a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php @@ -0,0 +1,9 @@ + 'libraries/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php new file mode 100644 index 0000000..412c0b5 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php @@ -0,0 +1,10 @@ + 'packages/{$vendor}/{$name}/', + 'theme' => 'public/themes/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php new file mode 100644 index 0000000..47bbd4c --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php @@ -0,0 +1,10 @@ + 'libraries/{$name}/', + 'source' => 'libraries/_source/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php new file mode 100644 index 0000000..9c2e9fb --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php new file mode 100644 index 0000000..5a66460 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php @@ -0,0 +1,16 @@ + 'assets/snippets/{$name}/', + 'plugin' => 'assets/plugins/{$name}/', + 'module' => 'assets/modules/{$name}/', + 'template' => 'assets/templates/{$name}/', + 'lib' => 'assets/lib/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php new file mode 100644 index 0000000..cf18e94 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php @@ -0,0 +1,11 @@ + 'app/design/frontend/{$name}/', + 'skin' => 'skin/frontend/default/{$name}/', + 'library' => 'lib/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php new file mode 100644 index 0000000..e463756 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php @@ -0,0 +1,37 @@ + 'plugins/{$name}/', + ); + + /** + * Transforms the names + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + return $this->correctPluginName($vars); + } + + /** + * Change hyphenated names to camelcase + * @param array $vars + * @return array + */ + private function correctPluginName($vars) + { + $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + $vars['name'] = ucfirst($camelCasedName); + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php new file mode 100644 index 0000000..ca3cfac --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php @@ -0,0 +1,9 @@ + 'app/packages/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php new file mode 100644 index 0000000..3e1ce2b --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php @@ -0,0 +1,25 @@ + 'plugins/{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Format package name of mautic-plugins to CamelCase + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] == 'mautic-plugin') { + $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, ucfirst($vars['name'])); + } + + return $vars; + } + +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php new file mode 100644 index 0000000..30a9167 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php @@ -0,0 +1,33 @@ + 'modules/{$name}/', + ); + + /** + * Format package name. + * + * For package type maya-module, cut off a trailing '-module' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'maya-module') { + return $this->inflectModuleVars($vars); + } + + return $vars; + } + + protected function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php new file mode 100644 index 0000000..f5a8957 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php @@ -0,0 +1,51 @@ + 'core/', + 'extension' => 'extensions/{$name}/', + 'skin' => 'skins/{$name}/', + ); + + /** + * Format package name. + * + * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform + * to CamelCase keeping existing uppercase chars. + * + * For package type mediawiki-skin, cut off a trailing '-skin' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'mediawiki-extension') { + return $this->inflectExtensionVars($vars); + } + + if ($vars['type'] === 'mediawiki-skin') { + return $this->inflectSkinVars($vars); + } + + return $vars; + } + + protected function inflectExtensionVars($vars) + { + $vars['name'] = preg_replace('/-extension$/', '', $vars['name']); + $vars['name'] = str_replace('-', ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + + return $vars; + } + +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php new file mode 100644 index 0000000..4bbbec8 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php @@ -0,0 +1,111 @@ + 'userfiles/modules/{$name}/', + 'module-skin' => 'userfiles/modules/{$name}/templates/', + 'template' => 'userfiles/templates/{$name}/', + 'element' => 'userfiles/elements/{$name}/', + 'vendor' => 'vendor/{$name}/', + 'components' => 'components/{$name}/' + ); + + /** + * Format package name. + * + * For package type microweber-module, cut off a trailing '-module' if present + * + * For package type microweber-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'microweber-template') { + return $this->inflectTemplateVars($vars); + } + if ($vars['type'] === 'microweber-templates') { + return $this->inflectTemplatesVars($vars); + } + if ($vars['type'] === 'microweber-core') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-adapter') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-module') { + return $this->inflectModuleVars($vars); + } + if ($vars['type'] === 'microweber-modules') { + return $this->inflectModulesVars($vars); + } + if ($vars['type'] === 'microweber-skin') { + return $this->inflectSkinVars($vars); + } + if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { + return $this->inflectElementVars($vars); + } + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/template-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplatesVars($vars) + { + $vars['name'] = preg_replace('/-templates$/', '', $vars['name']); + $vars['name'] = preg_replace('/templates-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectCoreVars($vars) + { + $vars['name'] = preg_replace('/-providers$/', '', $vars['name']); + $vars['name'] = preg_replace('/-provider$/', '', $vars['name']); + $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = preg_replace('/module-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModulesVars($vars) + { + $vars['name'] = preg_replace('/-modules$/', '', $vars['name']); + $vars['name'] = preg_replace('/modules-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + $vars['name'] = preg_replace('/skin-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectElementVars($vars) + { + $vars['name'] = preg_replace('/-elements$/', '', $vars['name']); + $vars['name'] = preg_replace('/elements-$/', '', $vars['name']); + $vars['name'] = preg_replace('/-element$/', '', $vars['name']); + $vars['name'] = preg_replace('/element-$/', '', $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php new file mode 100644 index 0000000..0ee140a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php @@ -0,0 +1,12 @@ + 'core/packages/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php new file mode 100644 index 0000000..a89c82f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php @@ -0,0 +1,57 @@ + 'mod/{$name}/', + 'admin_report' => 'admin/report/{$name}/', + 'atto' => 'lib/editor/atto/plugins/{$name}/', + 'tool' => 'admin/tool/{$name}/', + 'assignment' => 'mod/assignment/type/{$name}/', + 'assignsubmission' => 'mod/assign/submission/{$name}/', + 'assignfeedback' => 'mod/assign/feedback/{$name}/', + 'auth' => 'auth/{$name}/', + 'availability' => 'availability/condition/{$name}/', + 'block' => 'blocks/{$name}/', + 'booktool' => 'mod/book/tool/{$name}/', + 'cachestore' => 'cache/stores/{$name}/', + 'cachelock' => 'cache/locks/{$name}/', + 'calendartype' => 'calendar/type/{$name}/', + 'format' => 'course/format/{$name}/', + 'coursereport' => 'course/report/{$name}/', + 'datafield' => 'mod/data/field/{$name}/', + 'datapreset' => 'mod/data/preset/{$name}/', + 'editor' => 'lib/editor/{$name}/', + 'enrol' => 'enrol/{$name}/', + 'filter' => 'filter/{$name}/', + 'gradeexport' => 'grade/export/{$name}/', + 'gradeimport' => 'grade/import/{$name}/', + 'gradereport' => 'grade/report/{$name}/', + 'gradingform' => 'grade/grading/form/{$name}/', + 'local' => 'local/{$name}/', + 'logstore' => 'admin/tool/log/store/{$name}/', + 'ltisource' => 'mod/lti/source/{$name}/', + 'ltiservice' => 'mod/lti/service/{$name}/', + 'message' => 'message/output/{$name}/', + 'mnetservice' => 'mnet/service/{$name}/', + 'plagiarism' => 'plagiarism/{$name}/', + 'portfolio' => 'portfolio/{$name}/', + 'qbehaviour' => 'question/behaviour/{$name}/', + 'qformat' => 'question/format/{$name}/', + 'qtype' => 'question/type/{$name}/', + 'quizaccess' => 'mod/quiz/accessrule/{$name}/', + 'quiz' => 'mod/quiz/report/{$name}/', + 'report' => 'report/{$name}/', + 'repository' => 'repository/{$name}/', + 'scormreport' => 'mod/scorm/report/{$name}/', + 'search' => 'search/engine/{$name}/', + 'theme' => 'theme/{$name}/', + 'tinymce' => 'lib/editor/tinymce/plugins/{$name}/', + 'profilefield' => 'user/profile/field/{$name}/', + 'webservice' => 'webservice/{$name}/', + 'workshopallocation' => 'mod/workshop/allocation/{$name}/', + 'workshopeval' => 'mod/workshop/eval/{$name}/', + 'workshopform' => 'mod/workshop/form/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php new file mode 100644 index 0000000..08d5dc4 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php @@ -0,0 +1,47 @@ + 'modules/{$name}/', + 'plugin' => 'plugins/{$vendor}/{$name}/', + 'theme' => 'themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type october-plugin, cut off a trailing '-plugin' if present. + * + * For package type october-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'october-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'october-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']); + $vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/^oc-|-theme$/', '', $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php new file mode 100644 index 0000000..5dd3438 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php @@ -0,0 +1,24 @@ + 'extensions/{$name}/', + 'theme' => 'extensions/themes/{$name}/', + 'translation' => 'extensions/translations/{$name}/', + ); + + /** + * Format package name to lower case and remove ".ontowiki" suffix + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower($vars['name']); + $vars['name'] = preg_replace('/.ontowiki$/', '', $vars['name']); + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + $vars['name'] = preg_replace('/-translation$/', '', $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php new file mode 100644 index 0000000..3ca7954 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php @@ -0,0 +1,14 @@ + 'oc-content/plugins/{$name}/', + 'theme' => 'oc-content/themes/{$name}/', + 'language' => 'oc-content/languages/{$name}/', + ); + +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php new file mode 100644 index 0000000..49940ff --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php @@ -0,0 +1,59 @@ +.+)\/.+/'; + + protected $locations = array( + 'module' => 'modules/{$name}/', + 'theme' => 'application/views/{$name}/', + 'out' => 'out/{$name}/', + ); + + /** + * getInstallPath + * + * @param PackageInterface $package + * @param string $frameworkType + * @return void + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $installPath = parent::getInstallPath($package, $frameworkType); + $type = $this->package->getType(); + if ($type === 'oxid-module') { + $this->prepareVendorDirectory($installPath); + } + return $installPath; + } + + /** + * prepareVendorDirectory + * + * Makes sure there is a vendormetadata.php file inside + * the vendor folder if there is a vendor folder. + * + * @param string $installPath + * @return void + */ + protected function prepareVendorDirectory($installPath) + { + $matches = ''; + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); + if (!$hasVendorDirectory) { + return; + } + + $vendorDirectory = $matches['vendor']; + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; + if (!file_exists($vendorPath)) { + mkdir($vendorPath, 0755, true); + } + + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; + touch($vendorMetaDataPath); + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php new file mode 100644 index 0000000..170136f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php new file mode 100644 index 0000000..4e59a8a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php @@ -0,0 +1,11 @@ + 'bundles/{$name}/', + 'library' => 'libraries/{$name}/', + 'framework' => 'frameworks/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php new file mode 100644 index 0000000..deb2b77 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php @@ -0,0 +1,11 @@ + 'ext/{$vendor}/{$name}/', + 'language' => 'language/{$name}/', + 'style' => 'styles/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php new file mode 100644 index 0000000..4781fa6 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php @@ -0,0 +1,21 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php new file mode 100644 index 0000000..c17f457 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php @@ -0,0 +1,32 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php new file mode 100644 index 0000000..903e55f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php @@ -0,0 +1,29 @@ + '{$name}/' + ); + + /** + * Remove hyphen, "plugin" and format to camelcase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = explode("-", $vars['name']); + foreach ($vars['name'] as $key => $name) { + $vars['name'][$key] = ucfirst($vars['name'][$key]); + if (strcasecmp($name, "Plugin") == 0) { + unset($vars['name'][$key]); + } + } + $vars['name'] = implode("",$vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Plugin.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Plugin.php new file mode 100644 index 0000000..5eb04af --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Plugin.php @@ -0,0 +1,17 @@ +getInstallationManager()->addInstaller($installer); + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php new file mode 100644 index 0000000..dbf85e6 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php @@ -0,0 +1,9 @@ + 'app/Containers/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php new file mode 100644 index 0000000..4c8421e --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php new file mode 100644 index 0000000..77cc3dd --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php @@ -0,0 +1,11 @@ + 'modules/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php new file mode 100644 index 0000000..6551058 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php @@ -0,0 +1,63 @@ + 'app/Modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Format package name. + * + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'pxcms-module') { + return $this->inflectModuleVars($vars); + } + + if ($vars['type'] === 'pxcms-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + /** + * For package type pxcms-module, cut off a trailing '-plugin' if present. + * + * return string + */ + protected function inflectModuleVars($vars) + { + $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) + $vars['name'] = str_replace('module-', '', $vars['name']); // strip out module- + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); // strip out -module + $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s + $vars['name'] = ucwords($vars['name']); // make module name camelcased + + return $vars; + } + + + /** + * For package type pxcms-module, cut off a trailing '-plugin' if present. + * + * return string + */ + protected function inflectThemeVars($vars) + { + $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) + $vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme- + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); // strip out -theme + $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s + $vars['name'] = ucwords($vars['name']); // make module name camelcased + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php new file mode 100644 index 0000000..0f78b5c --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php @@ -0,0 +1,24 @@ + 'src/{$name}/' + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php new file mode 100644 index 0000000..252c733 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php @@ -0,0 +1,10 @@ + 'themes/{$name}/', + 'plugin' => 'plugins/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php new file mode 100644 index 0000000..0954457 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php @@ -0,0 +1,10 @@ + 'redaxo/include/addons/{$name}/', + 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php new file mode 100644 index 0000000..d8d795b --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php @@ -0,0 +1,22 @@ + 'plugins/{$name}/', + ); + + /** + * Lowercase name and changes the name to a underscores + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace('-', '_', $vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php new file mode 100644 index 0000000..1acd3b1 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php @@ -0,0 +1,10 @@ + 'Sources/{$name}/', + 'theme' => 'Themes/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php new file mode 100644 index 0000000..7d20d27 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php @@ -0,0 +1,60 @@ + 'engine/Shopware/Plugins/Local/Backend/{$name}/', + 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/', + 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/', + 'theme' => 'templates/{$name}/', + 'plugin' => 'custom/plugins/{$name}/', + 'frontend-theme' => 'themes/Frontend/{$name}/', + ); + + /** + * Transforms the names + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'shopware-theme') { + return $this->correctThemeName($vars); + } + + return $this->correctPluginName($vars); + } + + /** + * Changes the name to a camelcased combination of vendor and name + * @param array $vars + * @return array + */ + private function correctPluginName($vars) + { + $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName); + + return $vars; + } + + /** + * Changes the name to a underscore separated name + * @param array $vars + * @return array + */ + private function correctThemeName($vars) + { + $vars['name'] = str_replace('-', '_', $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php new file mode 100644 index 0000000..81910e9 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php @@ -0,0 +1,35 @@ + '{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Return the install path based on package type. + * + * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework + * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0 + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + if ( + $package->getName() == 'silverstripe/framework' + && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion()) + && version_compare($package->getVersion(), '2.999.999') < 0 + ) { + return $this->templatePath($this->locations['module'], array('name' => 'sapphire')); + } + + return parent::getInstallPath($package, $frameworkType); + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php new file mode 100644 index 0000000..762d94c --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php @@ -0,0 +1,25 @@ + 'modules/{$vendor}/{$name}/', + 'plugin' => 'plugins/{$vendor}/{$name}/' + ); + + public function inflectPackageVars($vars) + { + return $this->parseVars($vars); + } + + protected function parseVars($vars) + { + $vars['vendor'] = strtolower($vars['vendor']) == 'sitedirect' ? 'SiteDirect' : $vars['vendor']; + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php new file mode 100644 index 0000000..83ef9d0 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php @@ -0,0 +1,49 @@ + 'app/modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Format module name. + * + * Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present. + * + * @param array @vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] == 'sydes-module') { + return $this->inflectModuleVars($vars); + } + + if ($vars['type'] === 'sydes-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + public function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/(^sydes-|-module$)/i', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/(^sydes-|-theme$)/', '', $vars['name']); + $vars['name'] = strtolower($vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php new file mode 100644 index 0000000..1675c4f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php @@ -0,0 +1,26 @@ + + */ +class Symfony1Installer extends BaseInstaller +{ + protected $locations = array( + 'plugin' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php new file mode 100644 index 0000000..b1663e8 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php @@ -0,0 +1,16 @@ + + */ +class TYPO3CmsInstaller extends BaseInstaller +{ + protected $locations = array( + 'extension' => 'typo3conf/ext/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php new file mode 100644 index 0000000..42572f4 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php @@ -0,0 +1,38 @@ + 'Packages/Application/{$name}/', + 'framework' => 'Packages/Framework/{$name}/', + 'plugin' => 'Packages/Plugins/{$name}/', + 'site' => 'Packages/Sites/{$name}/', + 'boilerplate' => 'Packages/Boilerplates/{$name}/', + 'build' => 'Build/{$name}/', + ); + + /** + * Modify the package name to be a TYPO3 Flow style key. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $autoload = $this->package->getAutoload(); + if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) { + $namespace = key($autoload['psr-0']); + $vars['name'] = str_replace('\\', '.', $namespace); + } + if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) { + $namespace = key($autoload['psr-4']); + $vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.'); + } + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php new file mode 100644 index 0000000..158af52 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php @@ -0,0 +1,12 @@ + 'local/modules/{$name}/', + 'frontoffice-template' => 'templates/frontOffice/{$name}/', + 'backoffice-template' => 'templates/backOffice/{$name}/', + 'email-template' => 'templates/email/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php new file mode 100644 index 0000000..7c0113b --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php @@ -0,0 +1,14 @@ + + */ + class TuskInstaller extends BaseInstaller + { + protected $locations = array( + 'task' => '.tusk/tasks/{$name}/', + 'command' => '.tusk/commands/{$name}/', + 'asset' => 'assets/tusk/{$name}/', + ); + } diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php new file mode 100644 index 0000000..fcb414a --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php @@ -0,0 +1,9 @@ + 'app/sprinkles/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php new file mode 100644 index 0000000..24ca645 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php @@ -0,0 +1,10 @@ + 'plugins/{$name}/', + 'theme' => 'themes/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php new file mode 100644 index 0000000..7d90c5e --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php @@ -0,0 +1,49 @@ + 'src/{$vendor}/{$name}/', + 'theme' => 'themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type vgmcp-bundle, cut off a trailing '-bundle' if present. + * + * For package type vgmcp-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'vgmcp-bundle') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'vgmcp-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-bundle$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php new file mode 100644 index 0000000..2cbb4a4 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php @@ -0,0 +1,10 @@ + 'modules/gateways/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php new file mode 100644 index 0000000..cb38788 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php @@ -0,0 +1,9 @@ + 'wolf/plugins/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php new file mode 100644 index 0000000..91c46ad --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php @@ -0,0 +1,12 @@ + 'wp-content/plugins/{$name}/', + 'theme' => 'wp-content/themes/{$name}/', + 'muplugin' => 'wp-content/mu-plugins/{$name}/', + 'dropin' => 'wp-content/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php new file mode 100644 index 0000000..27f429f --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php @@ -0,0 +1,32 @@ + 'module/{$name}/', + ); + + /** + * Format package name to CamelCase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php new file mode 100644 index 0000000..bde9bc8 --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php @@ -0,0 +1,11 @@ + 'library/{$name}/', + 'extra' => 'extras/library/{$name}/', + 'module' => 'module/{$name}/', + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php new file mode 100644 index 0000000..56cdf5d --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$vendor}-{$name}/', + 'theme' => 'themes/{$vendor}-{$name}/' + ); +} diff --git a/server/plugins/rainlab/builder/vendor/composer/installers/src/bootstrap.php b/server/plugins/rainlab/builder/vendor/composer/installers/src/bootstrap.php new file mode 100644 index 0000000..0de276e --- /dev/null +++ b/server/plugins/rainlab/builder/vendor/composer/installers/src/bootstrap.php @@ -0,0 +1,13 @@ +alias = $alias; + + parent::__construct($controller, []); + $this->bindToController(); + } + + /** + * Renders the widget. + * @return string + */ + public function render() + { + return $this->makePartial('body', $this->getRenderData()); + } + + public function updateList() + { + return ['#'.$this->getId('plugin-controller-list') => $this->makePartial('items', $this->getRenderData())]; + } + + public function refreshActivePlugin() + { + return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + } + + /* + * Event handlers + */ + + public function onUpdate() + { + return $this->updateList(); + } + + public function onSearch() + { + $this->setSearchTerm(Input::get('search')); + return $this->updateList(); + } + + /* + * Methods for the internal use + */ + + protected function getControllerList($pluginCode) + { + $result = ControllerModel::listPluginControllers($pluginCode); + + return $result; + } + + protected function getRenderData() + { + $activePluginVector = $this->controller->getBuilderActivePluginVector(); + if (!$activePluginVector) { + return [ + 'pluginVector'=>null, + 'items' => [] + ]; + } + + $items = $this->getControllerList($activePluginVector->pluginCodeObj); + + $searchTerm = Str::lower($this->getSearchTerm()); + if (strlen($searchTerm)) { + $words = explode(' ', $searchTerm); + $result = []; + + foreach ($items as $controller) { + if ($this->textMatchesSearch($words, $controller)) { + $result[] = $controller; + } + } + + $items = $result; + } + + return [ + 'pluginVector'=>$activePluginVector, + 'items'=>$items + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/DatabaseTableList.php b/server/plugins/rainlab/builder/widgets/DatabaseTableList.php new file mode 100644 index 0000000..4c1c482 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/DatabaseTableList.php @@ -0,0 +1,118 @@ +alias = $alias; + + parent::__construct($controller, []); + $this->bindToController(); + } + + /** + * Renders the widget. + * @return string + */ + public function render() + { + return $this->makePartial('body', $this->getRenderData()); + } + + public function updateList() + { + return ['#'.$this->getId('database-table-list') => $this->makePartial('items', $this->getRenderData())]; + } + + public function refreshActivePlugin() + { + return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + } + + /* + * Event handlers + */ + + public function onUpdate() + { + return $this->updateList(); + } + + public function onSearch() + { + $this->setSearchTerm(Input::get('search')); + return $this->updateList(); + } + + /* + * Methods for the internal use + */ + + protected function getData($pluginVector) + { + if (!$pluginVector) { + return []; + } + + $pluginCode = $pluginVector->pluginCodeObj->toCode(); + + if (!$pluginCode) { + return []; + } + + $tables = $this->getTableList($pluginCode); + $searchTerm = Str::lower($this->getSearchTerm()); + + // Apply the search + // + if (strlen($searchTerm)) { + $words = explode(' ', $searchTerm); + $result = []; + + foreach ($tables as $table) { + if ($this->textMatchesSearch($words, $table)) { + $result[] = $table; + } + } + + $tables = $result; + } + + return $tables; + } + + protected function getTableList($pluginCode) + { + $result = DatabaseTableModel::listPluginTables($pluginCode); + + return $result; + } + + protected function getRenderData() + { + $activePluginVector = $this->controller->getBuilderActivePluginVector(); + + return [ + 'pluginVector'=>$activePluginVector, + 'items'=>$this->getData($activePluginVector) + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/DefaultBehaviorDesignTimeProvider.php b/server/plugins/rainlab/builder/widgets/DefaultBehaviorDesignTimeProvider.php new file mode 100644 index 0000000..2f0a538 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/DefaultBehaviorDesignTimeProvider.php @@ -0,0 +1,196 @@ + 'form-controller', + 'Backend\Behaviors\ListController' => 'list-controller', + 'Backend\Behaviors\ReorderController' => 'reorder-controller' + ]; + + /** + * Renders behaivor body. + * @param string $class Specifies the behavior class to render. + * @param array $properties Behavior property values. + * @param \RainLab\Builder\FormWidgets\ControllerBuilder $controllerBuilder ControllerBuilder widget instance. + * @return string Returns HTML markup string. + */ + public function renderBehaviorBody($class, $properties, $controllerBuilder) + { + if (!array_key_exists($class, $this->defaultBehaviorClasses)) { + return $this->renderUnknownBehavior($class, $properties); + } + + $partial = $this->defaultBehaviorClasses[$class]; + + return $this->makePartial('behavior-'.$partial, [ + 'properties'=>$properties, + 'controllerBuilder' => $controllerBuilder + ]); + } + + /** + * Returns default behavior configuration as an array. + * @param string $class Specifies the behavior class name. + * @param string $controllerModel Controller model. + * @param mixed $controllerGenerator Controller generator object. + * @return array Returns the behavior configuration array. + */ + public function getDefaultConfiguration($class, $controllerModel, $controllerGenerator) + { + if (!array_key_exists($class, $this->defaultBehaviorClasses)) { + throw new SystemException('Unknown behavior class: '.$class); + } + + switch ($class) { + case 'Backend\Behaviors\FormController' : + return $this->getFormControllerDefaultConfiguration($controllerModel, $controllerGenerator); + case 'Backend\Behaviors\ListController' : + return $this->getListControllerDefaultConfiguration($controllerModel, $controllerGenerator); + case 'Backend\Behaviors\ReorderController' : + return $this->getReorderControllerDefaultConfiguration($controllerModel, $controllerGenerator); + } + } + + protected function renderUnknownControl($class, $properties) + { + return $this->makePartial('behavior-unknown', [ + 'properties'=>$properties, + 'class'=>$class + ]); + } + + protected function getFormControllerDefaultConfiguration($controllerModel, $controllerGenerator) + { + if (!$controllerModel->baseModelClassName) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_behavior_requires_base_model', [ + 'behavior' => 'Form Controller' + ])); + } + + $pluginCodeObj = $controllerModel->getPluginCodeObj(); + + $forms = ModelFormModel::listModelFiles($pluginCodeObj, $controllerModel->baseModelClassName); + if (!$forms) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_model_doesnt_have_forms')); + } + + $controllerUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller); + + $result = [ + 'name' => $controllerModel->controller, + 'form' => $this->getModelFilePath($pluginCodeObj, $controllerModel->baseModelClassName, $forms[0]), + 'modelClass' => $this->getFullModelClass($pluginCodeObj, $controllerModel->baseModelClassName), + 'defaultRedirect' => $controllerUrl, + 'create' => [ + 'redirect' => $controllerUrl.'/update/:id', + 'redirectClose' => $controllerUrl + ], + 'update' => [ + 'redirect' => $controllerUrl, + 'redirectClose' => $controllerUrl + ] + ]; + + return $result; + } + + protected function getListControllerDefaultConfiguration($controllerModel, $controllerGenerator) + { + if (!$controllerModel->baseModelClassName) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_behavior_requires_base_model', [ + 'behavior' => 'List Controller' + ])); + } + + $pluginCodeObj = $controllerModel->getPluginCodeObj(); + + $lists = ModelListModel::listModelFiles($pluginCodeObj, $controllerModel->baseModelClassName); + if (!$lists) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_model_doesnt_have_lists')); + } + + $result = [ + 'list' => $this->getModelFilePath($pluginCodeObj, $controllerModel->baseModelClassName, $lists[0]), + 'modelClass' => $this->getFullModelClass($pluginCodeObj, $controllerModel->baseModelClassName), + 'title' => $controllerModel->controller, + 'noRecordsMessage' => 'backend::lang.list.no_records', + 'showSetup' => true, + 'showCheckboxes' => true, + 'recordsPerPage' => 20, + 'toolbar' => [ + 'buttons' => 'list_toolbar', + 'search' => [ + 'prompt' => 'backend::lang.list.search_prompt' + ] + ] + ]; + + if (in_array('Backend\Behaviors\FormController', $controllerModel->behaviors)) { + $updateUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller).'/update/:id'; + $createUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller).'/create'; + + $result['recordUrl'] = $updateUrl; + + $controllerGenerator->setTemplateVariable('hasFormBehavior', true); + $controllerGenerator->setTemplateVariable('createUrl', $createUrl); + } + + if (in_array('Backend\Behaviors\ReorderController', $controllerModel->behaviors)) { + $reorderUrl = $this->getControllerlUrl($pluginCodeObj, $controllerModel->controller).'/reorder'; + $controllerGenerator->setTemplateVariable('hasReorderBehavior', true); + $controllerGenerator->setTemplateVariable('reorderUrl', $reorderUrl); + } + + return $result; + } + + protected function getReorderControllerDefaultConfiguration($controllerModel, $controllerGenerator) + { + if (!$controllerModel->baseModelClassName) { + throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_behavior_requires_base_model', [ + 'behavior' => 'Reorder Controller' + ])); + } + + $pluginCodeObj = $controllerModel->getPluginCodeObj(); + + $result = [ + 'title' => $controllerModel->controller, + 'modelClass' => $this->getFullModelClass($pluginCodeObj, $controllerModel->baseModelClassName), + 'toolbar' => [ + 'buttons' => 'reorder_toolbar', + ] + ]; + + return $result; + } + + protected function getFullModelClass($pluginCodeObj, $modelClassName) + { + return $pluginCodeObj->toPluginNamespace().'\\Models\\'.$modelClassName; + } + + protected function getModelFilePath($pluginCodeObj, $modelClassName, $file) + { + return '$/' . $pluginCodeObj->toFilesystemPath() . '/models/' . strtolower($modelClassName) . '/' . $file; + } + + protected function getControllerlUrl($pluginCodeObj, $controller) + { + return $pluginCodeObj->toUrl().'/'.strtolower($controller); + } +} diff --git a/server/plugins/rainlab/builder/widgets/DefaultControlDesignTimeProvider.php b/server/plugins/rainlab/builder/widgets/DefaultControlDesignTimeProvider.php new file mode 100644 index 0000000..b9b7a2f --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/DefaultControlDesignTimeProvider.php @@ -0,0 +1,119 @@ +defaultControlsTypes)) { + return $this->renderUnknownControl($type, $properties); + } + + return $this->makePartial('control-'.$type, [ + 'properties'=>$properties, + 'formBuilder' => $formBuilder + ]); + } + + /** + * Renders control static body. + * The control static body is never updated with AJAX during the form editing. + * @param string $type Specifies the control type to render. + * @param array $properties Control property values preprocessed for the Inspector. + * @param array $controlConfiguration Raw control property values. + * @param \RainLab\Builder\FormWidgets\FormBuilder $formBuilder FormBuilder widget instance. + * @return string Returns HTML markup string. + */ + public function renderControlStaticBody($type, $properties, $controlConfiguration, $formBuilder) + { + if (!in_array($type, $this->defaultControlsTypes)) { + return null; + } + + $partialName = 'control-static-'.$type; + $partialPath = $this->getViewPath('_'.$partialName.'.htm'); + + if (!File::exists($partialPath)) { + return null; + } + + return $this->makePartial($partialName, [ + 'properties'=>$properties, + 'controlConfiguration' => $controlConfiguration, + 'formBuilder' => $formBuilder + ]); + } + + /** + * Determines whether a control supports default labels and comments. + * @param string $type Specifies the control type. + * @return boolean + */ + public function controlHasLabels($type) + { + if (in_array($type, ['checkbox', 'switch', 'hint', 'partial', 'section'])) { + return false; + } + + return true; + } + + protected function getPropertyValue($properties, $property) + { + if (array_key_exists($property, $properties)) { + return $properties[$property]; + } + + return null; + } + + protected function renderUnknownControl($type, $properties) + { + return $this->makePartial('control-unknowncontrol', [ + 'properties'=>$properties, + 'type'=>$type + ]); + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/LanguageList.php b/server/plugins/rainlab/builder/widgets/LanguageList.php new file mode 100644 index 0000000..31b8f2f --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/LanguageList.php @@ -0,0 +1,104 @@ +alias = $alias; + + parent::__construct($controller, []); + $this->bindToController(); + } + + /** + * Renders the widget. + * @return string + */ + public function render() + { + return $this->makePartial('body', $this->getRenderData()); + } + + public function updateList() + { + return ['#'.$this->getId('plugin-language-list') => $this->makePartial('items', $this->getRenderData())]; + } + + public function refreshActivePlugin() + { + return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + } + + /* + * Event handlers + */ + + public function onUpdate() + { + return $this->updateList(); + } + + public function onSearch() + { + $this->setSearchTerm(Input::get('search')); + return $this->updateList(); + } + + /* + * Methods for the internal use + */ + + protected function getLanguageList($pluginCode) + { + $result = LocalizationModel::listPluginLanguages($pluginCode); + + return $result; + } + + protected function getRenderData() + { + $activePluginVector = $this->controller->getBuilderActivePluginVector(); + if (!$activePluginVector) { + return [ + 'pluginVector'=>null, + 'items' => [] + ]; + } + + $items = $this->getLanguageList($activePluginVector->pluginCodeObj); + + $searchTerm = Str::lower($this->getSearchTerm()); + if (strlen($searchTerm)) { + $words = explode(' ', $searchTerm); + $result = []; + + foreach ($items as $language) { + if ($this->textMatchesSearch($words, $language)) { + $result[] = $language; + } + } + + $items = $result; + } + + return [ + 'pluginVector'=>$activePluginVector, + 'items'=>$items + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/ModelList.php b/server/plugins/rainlab/builder/widgets/ModelList.php new file mode 100644 index 0000000..a30cb10 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/ModelList.php @@ -0,0 +1,129 @@ +alias = $alias; + + parent::__construct($controller, []); + $this->bindToController(); + } + + /** + * Renders the widget. + * @return string + */ + public function render() + { + return $this->makePartial('body', $this->getRenderData()); + } + + public function updateList() + { + return ['#'.$this->getId('plugin-model-list') => $this->makePartial('items', $this->getRenderData())]; + } + + public function refreshActivePlugin() + { + return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + } + + /* + * Event handlers + */ + + public function onUpdate() + { + return $this->updateList(); + } + + public function onSearch() + { + $this->setSearchTerm(Input::get('search')); + return $this->updateList(); + } + + /* + * Methods for the internal use + */ + + protected function getData($pluginVector) + { + if (!$pluginVector) { + return []; + } + + $pluginCode = $pluginVector->pluginCodeObj; + + if (!$pluginCode) { + return []; + } + + $models = $this->getModelList($pluginCode); + $searchTerm = Str::lower($this->getSearchTerm()); + + // Apply the search + // + if (strlen($searchTerm)) { + $words = explode(' ', $searchTerm); + $result = []; + + foreach ($models as $modelInfo) { + if ($this->textMatchesSearch($words, $modelInfo['model']->className)) { + $result[] = $modelInfo; + } + } + + $models = $result; + } + + return $models; + } + + protected function getModelList($pluginCode) + { + $models = ModelModel::listPluginModels($pluginCode); + $result = []; + + foreach ($models as $model) { + $result[] = [ + 'model' => $model, + 'forms' => ModelFormModel::listModelFiles($pluginCode, $model->className), + 'lists' => ModelListModel::listModelFiles($pluginCode, $model->className) + ]; + } + + return $result; + } + + protected function getRenderData() + { + $activePluginVector = $this->controller->getBuilderActivePluginVector(); + + return [ + 'pluginVector'=>$activePluginVector, + 'items'=>$this->getData($activePluginVector) + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/PluginList.php b/server/plugins/rainlab/builder/widgets/PluginList.php new file mode 100644 index 0000000..c1c9193 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/PluginList.php @@ -0,0 +1,201 @@ +alias = $alias; + + parent::__construct($controller, []); + $this->bindToController(); + } + + /** + * Renders the widget. + * @return string + */ + public function render() + { + return $this->makePartial('body', $this->getRenderData()); + } + + public function setActivePlugin($pluginCode) + { + $pluginCodeObj = new PluginCode($pluginCode); + + $this->putSession('activePlugin', $pluginCodeObj->toCode()); + } + + public function getActivePluginVector() + { + $pluginCode = $this->getActivePluginCode(); + + try { + if (strlen($pluginCode)) { + $pluginCodeObj = new PluginCode($pluginCode); + $path = $pluginCodeObj->toPluginInformationFilePath(); + if (!File::isFile(File::symbolizePath($path))) { + return null; + } + + $plugins = PluginManager::instance()->getPlugins(); + foreach ($plugins as $code=>$plugin) { + if ($code == $pluginCode) { + return new PluginVector($plugin, $pluginCodeObj); + } + } + } + } + catch (Exception $ex) { + return null; + } + + return null; + } + + public function updateList() + { + return ['#'.$this->getId('plugin-list') => $this->makePartial('items', $this->getRenderData())]; + } + + /* + * Event handlers + */ + + public function onUpdate() + { + return $this->updateList(); + } + + public function onSearch() + { + $this->setSearchTerm(Input::get('search')); + return $this->updateList(); + } + + public function onToggleFilter() + { + $mode = $this->getFilterMode(); + $this->setFilterMode($mode == 'my' ? 'all' : 'my'); + + $result = $this->updateList(); + $result['#'.$this->getId('toolbar-buttons')] = $this->makePartial('toolbar-buttons'); + + return $result; + } + + /* + * Methods for the internal use + */ + + protected function getData() + { + $plugins = $this->getPluginList(); + $searchTerm = Str::lower($this->getSearchTerm()); + + // Apply the search + // + if (strlen($searchTerm)) { + $words = explode(' ', $searchTerm); + $result = []; + + foreach ($plugins as $code=>$plugin) { + if ($this->textMatchesSearch($words, $plugin['full-text'])) { + $result[$code] = $plugin; + } + } + + $plugins = $result; + } + + // Apply the my plugins / all plugins filter + // + $mode = $this->getFilterMode(); + if ($mode == 'my') { + $namespace = PluginSettings::instance()->author_namespace; + + $result = []; + foreach ($plugins as $code=>$plugin) { + if (strcasecmp($plugin['namespace'], $namespace) === 0) { + $result[$code] = $plugin; + } + } + + $plugins = $result; + } + + return $plugins; + } + + protected function getPluginList() + { + $plugins = PluginManager::instance()->getPlugins(); + + $result = []; + foreach ($plugins as $code=>$plugin) { + $pluginInfo = $plugin->pluginDetails(); + + $itemInfo = [ + 'name' => isset($pluginInfo['name']) ? $pluginInfo['name'] : 'rainlab.builder::lang.plugin.no_name', + 'description' => isset($pluginInfo['description']) ? $pluginInfo['description'] : 'rainlab.builder::lang.plugin.no_description', + 'icon' => isset($pluginInfo['icon']) ? $pluginInfo['icon'] : null + ]; + + list($namespace) = explode('\\', get_class($plugin)); + $itemInfo['namespace'] = trim($namespace); + $itemInfo['full-text'] = trans($itemInfo['name']).' '.trans($itemInfo['description']); + + $result[$code] = $itemInfo; + } + + uasort($result, function($a, $b) { + return strcmp(trans($a['name']), trans($b['name'])); + }); + + return $result; + } + + protected function setFilterMode($mode) + { + $this->putSession('filter', $mode); + } + + protected function getFilterMode() + { + return $this->getSession('filter', 'my'); + } + + protected function getActivePluginCode() + { + return $this->getSession('activePlugin'); + } + + protected function getRenderData() + { + return [ + 'items'=>$this->getData() + ]; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/VersionList.php b/server/plugins/rainlab/builder/widgets/VersionList.php new file mode 100644 index 0000000..d754a72 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/VersionList.php @@ -0,0 +1,123 @@ +alias = $alias; + + parent::__construct($controller, []); + $this->bindToController(); + } + + /** + * Renders the widget. + * @return string + */ + public function render() + { + return $this->makePartial('body', $this->getRenderData()); + } + + public function updateList() + { + return ['#'.$this->getId('plugin-version-list') => $this->makePartial('items', $this->getRenderData())]; + } + + public function refreshActivePlugin() + { + return ['#'.$this->getId('body') => $this->makePartial('widget-contents', $this->getRenderData())]; + } + + /* + * Event handlers + */ + + public function onUpdate() + { + return $this->updateList(); + } + + public function onSearch() + { + $this->setSearchTerm(Input::get('search')); + return $this->updateList(); + } + + /* + * Methods for the internal use + */ + + protected function getRenderData() + { + $activePluginVector = $this->controller->getBuilderActivePluginVector(); + if (!$activePluginVector) { + return [ + 'pluginVector'=>null, + 'items' => [], + 'unappliedVersions' => [] + ]; + } + + $versionObj = new PluginVersion(); + $items = $versionObj->getPluginVersionInformation($activePluginVector->pluginCodeObj); + + $searchTerm = Str::lower($this->getSearchTerm()); + if (strlen($searchTerm)) { + $words = explode(' ', $searchTerm); + $result = []; + + foreach ($items as $version=>$versionInfo) { + $description = $this->getVersionDescription($versionInfo); + + if ( + $this->textMatchesSearch($words, $version) || + (strlen($description) && $this->textMatchesSearch($words, $description)) + ) { + $result[$version] = $versionInfo; + } + } + + $items = $result; + } + + $versionManager = VersionManager::instance(); + $unappliedVersions = $versionManager->listNewVersions($activePluginVector->pluginCodeObj->toCode()); + return [ + 'pluginVector'=>$activePluginVector, + 'items'=>$items, + 'unappliedVersions'=>$unappliedVersions + ]; + } + + protected function getVersionDescription($versionInfo) + { + if (is_array($versionInfo)) { + if (array_key_exists(0, $versionInfo)) { + return $versionInfo[0]; + } + } + + if (is_scalar($versionInfo)) { + return $versionInfo; + } + + return null; + } +} \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/controllerlist/partials/_body.htm b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_body.htm new file mode 100644 index 0000000..46306d3 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_body.htm @@ -0,0 +1,3 @@ +
    + makePartial('widget-contents', ['pluginVector'=>$pluginVector, 'items'=>$items]) ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/controllerlist/partials/_controller-list.htm b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_controller-list.htm new file mode 100644 index 0000000..c99bfa9 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_controller-list.htm @@ -0,0 +1,13 @@ +
    +
    +
    +
    + makePartial('items', ['items'=>$items, 'pluginVector'=>$pluginVector]) ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/controllerlist/partials/_items.htm b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_items.htm new file mode 100644 index 0000000..34e2db3 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_items.htm @@ -0,0 +1,20 @@ + +
      + pluginCodeObj->toCode(); + foreach ($items as $controller): + $dataId = 'controller-'.e($pluginCode).'-'.$controller; + ?> +
    • + data-id=""> + + + +
    • + +
    + +

    noRecordsMessage)) ?>

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/controllerlist/partials/_toolbar.htm b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_toolbar.htm new file mode 100644 index 0000000..5ce9f57 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_toolbar.htm @@ -0,0 +1,25 @@ +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/controllerlist/partials/_widget-contents.htm b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_widget-contents.htm new file mode 100644 index 0000000..14affab --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/controllerlist/partials/_widget-contents.htm @@ -0,0 +1,28 @@ +
    +
    + + getPluginName())) ?> + + + +
    +
    + + + makePartial('toolbar') ?> +
    +
    +
    + makePartial('controller-list', ['items'=>$items, 'pluginVector'=>$pluginVector]) ?> +
    +
    +
    + +
    +
    +
    +

    +
    +
    +
    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_body.htm b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_body.htm new file mode 100644 index 0000000..46306d3 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_body.htm @@ -0,0 +1,3 @@ +
    + makePartial('widget-contents', ['pluginVector'=>$pluginVector, 'items'=>$items]) ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_items.htm b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_items.htm new file mode 100644 index 0000000..90c821f --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_items.htm @@ -0,0 +1,18 @@ + + + +

    noRecordsMessage)) ?>

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_table-list.htm b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_table-list.htm new file mode 100644 index 0000000..0f711cd --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_table-list.htm @@ -0,0 +1,13 @@ +
    +
    +
    +
    + makePartial('items', ['items'=>$items]) ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_toolbar.htm b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_toolbar.htm new file mode 100644 index 0000000..b268611 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_toolbar.htm @@ -0,0 +1,24 @@ +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_widget-contents.htm b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_widget-contents.htm new file mode 100644 index 0000000..e529225 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/databasetablelist/partials/_widget-contents.htm @@ -0,0 +1,28 @@ +
    +
    + + getPluginName())) ?> + + + +
    +
    + + + makePartial('toolbar') ?> +
    +
    +
    + makePartial('table-list', ['items'=>$items]) ?> +
    +
    +
    + +
    +
    +
    +

    +
    +
    +
    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-form-controller.htm b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-form-controller.htm new file mode 100644 index 0000000..c0b7bd4 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-form-controller.htm @@ -0,0 +1,23 @@ +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-list-controller.htm b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-list-controller.htm new file mode 100644 index 0000000..803e47d --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-list-controller.htm @@ -0,0 +1,41 @@ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-reorder-controller.htm b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-reorder-controller.htm new file mode 100644 index 0000000..09c00eb --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-reorder-controller.htm @@ -0,0 +1,19 @@ +
    +
    + + + + + + + + + + + + + + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-unknown.htm b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-unknown.htm new file mode 100644 index 0000000..1a0e7af --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultbehaviordesigntimeprovider/partials/_behavior-unknown.htm @@ -0,0 +1 @@ +Unknown behavior \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-balloon-selector.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-balloon-selector.htm new file mode 100644 index 0000000..f834507 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-balloon-selector.htm @@ -0,0 +1,16 @@ +
    +
      + +
    • + +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkbox.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkbox.htm new file mode 100644 index 0000000..0b68995 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkbox.htm @@ -0,0 +1,9 @@ +getPropertyValue($properties, 'label'); + $comment = $this->getPropertyValue($properties, 'oc.comment'); +?> + +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkboxlist.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkboxlist.htm new file mode 100644 index 0000000..ef4c056 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-checkboxlist.htm @@ -0,0 +1,16 @@ +
    +
      + +
    • + +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-codeeditor.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-codeeditor.htm new file mode 100644 index 0000000..297f2e9 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-codeeditor.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-colorpicker.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-colorpicker.htm new file mode 100644 index 0000000..5ed57b6 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-colorpicker.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-datepicker.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-datepicker.htm new file mode 100644 index 0000000..4cf196f --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-datepicker.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-dropdown.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-dropdown.htm new file mode 100644 index 0000000..9b0fa20 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-dropdown.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-fileupload.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-fileupload.htm new file mode 100644 index 0000000..4988ad8 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-fileupload.htm @@ -0,0 +1,6 @@ +
    + + getPropertyValue($properties, 'mode') != 'image'): ?> + + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-hint.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-hint.htm new file mode 100644 index 0000000..fcd7858 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-hint.htm @@ -0,0 +1,7 @@ +
    + + getPropertyValue($properties, 'path'); + echo strlen($path) ? ' - '.$path : null; + ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-markdown.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-markdown.htm new file mode 100644 index 0000000..404c61c --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-markdown.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-mediafinder.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-mediafinder.htm new file mode 100644 index 0000000..14d7ec8 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-mediafinder.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-number.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-number.htm new file mode 100644 index 0000000..7a9ae7f --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-number.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-partial.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-partial.htm new file mode 100644 index 0000000..20f1a16 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-partial.htm @@ -0,0 +1,7 @@ +
    + + getPropertyValue($properties, 'path'); + echo strlen($path) ? ' - '.$path : null; + ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-password.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-password.htm new file mode 100644 index 0000000..d684156 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-password.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-radio.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-radio.htm new file mode 100644 index 0000000..6685f86 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-radio.htm @@ -0,0 +1,16 @@ +
    +
      + +
    • + +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-recordfinder.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-recordfinder.htm new file mode 100644 index 0000000..85f0d48 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-recordfinder.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-relation.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-relation.htm new file mode 100644 index 0000000..4bbfc9d --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-relation.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-repeater.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-repeater.htm new file mode 100644 index 0000000..d6c577d --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-repeater.htm @@ -0,0 +1,9 @@ +
    + getPropertyValue($properties, 'prompt'); + if (!strlen($prompt)) { + $prompt = 'rainlab.builder::lang.form.property_prompt_default'; + } + ?> +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-richeditor.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-richeditor.htm new file mode 100644 index 0000000..e56619b --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-richeditor.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-section.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-section.htm new file mode 100644 index 0000000..a9d75b3 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-section.htm @@ -0,0 +1,9 @@ +getPropertyValue($properties, 'label'); + $comment =$this->getPropertyValue($properties, 'oc.comment'); +?> + +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-static-repeater.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-static-repeater.htm new file mode 100644 index 0000000..5f2e08a --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-static-repeater.htm @@ -0,0 +1,11 @@ +
    + + + renderControlList($controls) ?> +
    diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-switch.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-switch.htm new file mode 100644 index 0000000..2d2adc4 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-switch.htm @@ -0,0 +1,9 @@ +getPropertyValue($properties, 'label'); + $comment = $this->getPropertyValue($properties, 'oc.comment'); +?> + +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-text.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-text.htm new file mode 100644 index 0000000..308339e --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-text.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-textarea.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-textarea.htm new file mode 100644 index 0000000..c9fd1f0 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-textarea.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-unknowncontrol.htm b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-unknowncontrol.htm new file mode 100644 index 0000000..fd2af48 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/defaultcontroldesigntimeprovider/partials/_control-unknowncontrol.htm @@ -0,0 +1,4 @@ +
    + $type])) ?> +
    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/languagelist/partials/_body.htm b/server/plugins/rainlab/builder/widgets/languagelist/partials/_body.htm new file mode 100644 index 0000000..46306d3 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/languagelist/partials/_body.htm @@ -0,0 +1,3 @@ +
    + makePartial('widget-contents', ['pluginVector'=>$pluginVector, 'items'=>$items]) ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/languagelist/partials/_items.htm b/server/plugins/rainlab/builder/widgets/languagelist/partials/_items.htm new file mode 100644 index 0000000..cb2e0b4 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/languagelist/partials/_items.htm @@ -0,0 +1,20 @@ + +
      + pluginCodeObj->toCode(); + foreach ($items as $language): + $dataId = 'localization-'.e($pluginCode).'-'.$language; + ?> +
    • + data-id=""> + + + +
    • + +
    + +

    noRecordsMessage)) ?>

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/languagelist/partials/_language-list.htm b/server/plugins/rainlab/builder/widgets/languagelist/partials/_language-list.htm new file mode 100644 index 0000000..ef3df47 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/languagelist/partials/_language-list.htm @@ -0,0 +1,13 @@ +
    +
    +
    +
    + makePartial('items', ['items'=>$items, 'pluginVector'=>$pluginVector]) ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/languagelist/partials/_toolbar.htm b/server/plugins/rainlab/builder/widgets/languagelist/partials/_toolbar.htm new file mode 100644 index 0000000..d8b409b --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/languagelist/partials/_toolbar.htm @@ -0,0 +1,24 @@ +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/languagelist/partials/_widget-contents.htm b/server/plugins/rainlab/builder/widgets/languagelist/partials/_widget-contents.htm new file mode 100644 index 0000000..2a9b2f9 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/languagelist/partials/_widget-contents.htm @@ -0,0 +1,28 @@ +
    +
    + + getPluginName())) ?> + + + +
    +
    + + + makePartial('toolbar') ?> +
    +
    +
    + makePartial('language-list', ['items'=>$items, 'pluginVector'=>$pluginVector]) ?> +
    +
    +
    + +
    +
    +
    +

    +
    +
    +
    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/modellist/partials/_body.htm b/server/plugins/rainlab/builder/widgets/modellist/partials/_body.htm new file mode 100644 index 0000000..46306d3 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/modellist/partials/_body.htm @@ -0,0 +1,3 @@ +
    + makePartial('widget-contents', ['pluginVector'=>$pluginVector, 'items'=>$items]) ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/modellist/partials/_items.htm b/server/plugins/rainlab/builder/widgets/modellist/partials/_items.htm new file mode 100644 index 0000000..b2196c4 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/modellist/partials/_items.htm @@ -0,0 +1,94 @@ + +
      + className; + + $modelGroup = $model->className; + $formsGroup = $modelGroup.'-forms'; + $listsGroup = $modelGroup.'-lists'; + $modelGroupStatus = $this->getCollapseStatus($modelGroup); + $formsGroupStatus = $this->getCollapseStatus($formsGroup); + $listsGroupStatus = $this->getCollapseStatus($listsGroup); + ?> +
    • +

      className) ?>

      +
        +
      • +

        +
        + +
        + +
          + className.'-'.$modelForm; + ?> +
        • + +
        • + +
        +
      • +
      • +

        +
        + +
        + +
          + className.'-'.$modelList; + ?> +
        • + +
        • + +
        +
      • +
      + +
    • + +
    + +

    noRecordsMessage)) ?>

    + diff --git a/server/plugins/rainlab/builder/widgets/modellist/partials/_model-list.htm b/server/plugins/rainlab/builder/widgets/modellist/partials/_model-list.htm new file mode 100644 index 0000000..d1ab5d9 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/modellist/partials/_model-list.htm @@ -0,0 +1,14 @@ +
    +
    +
    +
    + makePartial('items', ['items'=>$items]) ?> +
    +
    +
    +
    diff --git a/server/plugins/rainlab/builder/widgets/modellist/partials/_toolbar.htm b/server/plugins/rainlab/builder/widgets/modellist/partials/_toolbar.htm new file mode 100644 index 0000000..346057f --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/modellist/partials/_toolbar.htm @@ -0,0 +1,24 @@ +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/modellist/partials/_widget-contents.htm b/server/plugins/rainlab/builder/widgets/modellist/partials/_widget-contents.htm new file mode 100644 index 0000000..f87cd74 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/modellist/partials/_widget-contents.htm @@ -0,0 +1,28 @@ +
    +
    + + getPluginName())) ?> + + + +
    +
    + + + makePartial('toolbar') ?> +
    +
    +
    + makePartial('model-list', ['items'=>$items]) ?> +
    +
    +
    + +
    +
    +
    +

    +
    +
    +
    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/pluginlist/partials/_body.htm b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_body.htm new file mode 100644 index 0000000..0040fb2 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_body.htm @@ -0,0 +1,8 @@ +makePartial('toolbar') ?> +
    +
    +
    + makePartial('plugin-list', ['items'=>$items]) ?> +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/pluginlist/partials/_items.htm b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_items.htm new file mode 100644 index 0000000..b304288 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_items.htm @@ -0,0 +1,35 @@ + + getActivePluginCode(); ?> + + +

    noRecordsMessage)) ?>

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/pluginlist/partials/_plugin-list.htm b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_plugin-list.htm new file mode 100644 index 0000000..eab0976 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_plugin-list.htm @@ -0,0 +1,13 @@ +
    +
    +
    +
    + makePartial('items', ['items'=>$items]) ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar-buttons.htm b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar-buttons.htm new file mode 100644 index 0000000..d2226d8 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar-buttons.htm @@ -0,0 +1,14 @@ + + +getFilterMode(); ?> + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar.htm b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar.htm new file mode 100644 index 0000000..69d6269 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/pluginlist/partials/_toolbar.htm @@ -0,0 +1,22 @@ +
    +
    +
    +
    + makePartial("toolbar-buttons") ?> +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/versionlist/partials/_body.htm b/server/plugins/rainlab/builder/widgets/versionlist/partials/_body.htm new file mode 100644 index 0000000..b39cdd0 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/versionlist/partials/_body.htm @@ -0,0 +1,3 @@ +
    + makePartial('widget-contents', ['pluginVector'=>$pluginVector, 'items'=>$items, 'unappliedVersions'=>$unappliedVersions]) ?> +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/versionlist/partials/_items.htm b/server/plugins/rainlab/builder/widgets/versionlist/partials/_items.htm new file mode 100644 index 0000000..940a482 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/versionlist/partials/_items.htm @@ -0,0 +1,35 @@ + +
      + pluginCodeObj->toCode(); + foreach ($items as $versionNumber=>$versionInfo): + $dataId = 'version-'.e($pluginCode).'-'.$versionNumber; + $description = $this->getVersionDescription($versionInfo); + $applied = !array_key_exists($versionNumber, $unappliedVersions); + ?> +
    • + data-id=""> + + + + + + + + + + + + + + +
    • + +
    + +

    noRecordsMessage)) ?>

    + \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/versionlist/partials/_toolbar.htm b/server/plugins/rainlab/builder/widgets/versionlist/partials/_toolbar.htm new file mode 100644 index 0000000..3e49d70 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/versionlist/partials/_toolbar.htm @@ -0,0 +1,34 @@ +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/versionlist/partials/_version-list.htm b/server/plugins/rainlab/builder/widgets/versionlist/partials/_version-list.htm new file mode 100644 index 0000000..6d480c9 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/versionlist/partials/_version-list.htm @@ -0,0 +1,13 @@ +
    +
    +
    +
    + makePartial('items', ['items'=>$items, 'unappliedVersions'=>$unappliedVersions, 'pluginVector'=>$pluginVector]) ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/server/plugins/rainlab/builder/widgets/versionlist/partials/_widget-contents.htm b/server/plugins/rainlab/builder/widgets/versionlist/partials/_widget-contents.htm new file mode 100644 index 0000000..77031c4 --- /dev/null +++ b/server/plugins/rainlab/builder/widgets/versionlist/partials/_widget-contents.htm @@ -0,0 +1,28 @@ +
    +
    + + getPluginName())) ?> + + + +
    +
    + + + makePartial('toolbar') ?> +
    +
    +
    + makePartial('version-list', ['items'=>$items, 'unappliedVersions'=>$unappliedVersions, 'pluginVector'=>$pluginVector]) ?> +
    +
    +
    + +
    +
    +
    +

    +
    +
    +
    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/Plugin.php b/server/plugins/studiovx/marcleopold/Plugin.php new file mode 100644 index 0000000..833ea00 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/Plugin.php @@ -0,0 +1,44 @@ + [ + 'label' => 'Marc Leopold', + 'description' => 'Marc Leopold Plugin settings.', + 'icon' => 'icon-camera', + 'class' => 'studiovx\marcleopold\Models\Settings', + 'order' => 100, + ] + ]; + } + + public function boot() + { + + GrakerAlbumsController::extendFormFields(function($form, $model, $context) { + if (!$model instanceof GrakerAlbumModel) { + return; + } + + $form->addFields([ + 'sort_order' => [ + 'label' => 'Sort Order', + ] + ]); + }); + } +} diff --git a/server/plugins/studiovx/marcleopold/controllers/IndexImage.php b/server/plugins/studiovx/marcleopold/controllers/IndexImage.php new file mode 100644 index 0000000..9998feb --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/IndexImage.php @@ -0,0 +1,19 @@ + + + + +
    diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/_reorder_toolbar.htm b/server/plugins/studiovx/marcleopold/controllers/indeximage/_reorder_toolbar.htm new file mode 100644 index 0000000..d504dfc --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/_reorder_toolbar.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/config_form.yaml b/server/plugins/studiovx/marcleopold/controllers/indeximage/config_form.yaml new file mode 100644 index 0000000..ed1f0e1 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/config_form.yaml @@ -0,0 +1,10 @@ +name: IndexImage +form: $/studiovx/marcleopold/models/indeximage/fields.yaml +modelClass: Studiovx\Marcleopold\Models\IndexImage +defaultRedirect: studiovx/marcleopold/indeximage +create: + redirect: 'studiovx/marcleopold/indeximage/update/:id' + redirectClose: studiovx/marcleopold/indeximage +update: + redirect: studiovx/marcleopold/indeximage + redirectClose: studiovx/marcleopold/indeximage diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/config_list.yaml b/server/plugins/studiovx/marcleopold/controllers/indeximage/config_list.yaml new file mode 100644 index 0000000..dbe069f --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/config_list.yaml @@ -0,0 +1,12 @@ +list: $/studiovx/marcleopold/models/indeximage/columns.yaml +modelClass: Studiovx\Marcleopold\Models\IndexImage +title: IndexImage +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'studiovx/marcleopold/indeximage/update/:id' diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/config_reorder.yaml b/server/plugins/studiovx/marcleopold/controllers/indeximage/config_reorder.yaml new file mode 100644 index 0000000..a1b0aa2 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/config_reorder.yaml @@ -0,0 +1,5 @@ +title: IndexImage +modelClass: Studiovx\Marcleopold\Models\IndexImage +nameFrom: title +toolbar: + buttons: reorder_toolbar diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/create.htm b/server/plugins/studiovx/marcleopold/controllers/indeximage/create.htm new file mode 100644 index 0000000..620e151 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + +
    +
    + + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/index.htm b/server/plugins/studiovx/marcleopold/controllers/indeximage/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/preview.htm b/server/plugins/studiovx/marcleopold/controllers/indeximage/preview.htm new file mode 100644 index 0000000..999d907 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
    + formRenderPreview() ?> +
    + + +

    fatalError) ?>

    + + +

    + + + +

    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/reorder.htm b/server/plugins/studiovx/marcleopold/controllers/indeximage/reorder.htm new file mode 100644 index 0000000..d9402c7 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/reorder.htm @@ -0,0 +1,8 @@ + + + + +reorderRender() ?> \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indeximage/update.htm b/server/plugins/studiovx/marcleopold/controllers/indeximage/update.htm new file mode 100644 index 0000000..5978985 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indeximage/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + + + +
    +
    + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/_list_toolbar.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/_list_toolbar.htm new file mode 100644 index 0000000..acdc987 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/_list_toolbar.htm @@ -0,0 +1,19 @@ +
    + + + +
    diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/_reorder_toolbar.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/_reorder_toolbar.htm new file mode 100644 index 0000000..c0c673d --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/_reorder_toolbar.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/config_form.yaml b/server/plugins/studiovx/marcleopold/controllers/indextagline/config_form.yaml new file mode 100644 index 0000000..644d5cd --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/config_form.yaml @@ -0,0 +1,10 @@ +name: IndexTagline +form: $/studiovx/marcleopold/models/indextagline/fields.yaml +modelClass: Studiovx\Marcleopold\Models\IndexTagline +defaultRedirect: studiovx/marcleopold/indextagline +create: + redirect: 'studiovx/marcleopold/indextagline/update/:id' + redirectClose: studiovx/marcleopold/indextagline +update: + redirect: studiovx/marcleopold/indextagline + redirectClose: studiovx/marcleopold/indextagline diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/config_list.yaml b/server/plugins/studiovx/marcleopold/controllers/indextagline/config_list.yaml new file mode 100644 index 0000000..6415fe2 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/config_list.yaml @@ -0,0 +1,12 @@ +list: $/studiovx/marcleopold/models/indextagline/columns.yaml +modelClass: Studiovx\Marcleopold\Models\IndexTagline +title: IndexTagline +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'studiovx/marcleopold/indextagline/update/:id' diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/config_reorder.yaml b/server/plugins/studiovx/marcleopold/controllers/indextagline/config_reorder.yaml new file mode 100644 index 0000000..d7e3079 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/config_reorder.yaml @@ -0,0 +1,5 @@ +title: IndexTagline +modelClass: Studiovx\Marcleopold\Models\IndexTagline +nameFrom: text +toolbar: + buttons: reorder_toolbar diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/create.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/create.htm new file mode 100644 index 0000000..ff3fae1 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + +
    +
    + + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/index.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/preview.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/preview.htm new file mode 100644 index 0000000..9fe059a --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
    + formRenderPreview() ?> +
    + + +

    fatalError) ?>

    + + +

    + + + +

    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/reorder.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/reorder.htm new file mode 100644 index 0000000..302103b --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/reorder.htm @@ -0,0 +1,8 @@ + + + + +reorderRender() ?> \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/indextagline/update.htm b/server/plugins/studiovx/marcleopold/controllers/indextagline/update.htm new file mode 100644 index 0000000..20839ef --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/indextagline/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + + + +
    +
    + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/_list_toolbar.htm b/server/plugins/studiovx/marcleopold/controllers/pages/_list_toolbar.htm new file mode 100644 index 0000000..d09c543 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/_list_toolbar.htm @@ -0,0 +1,18 @@ +
    + + +
    diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/config_form.yaml b/server/plugins/studiovx/marcleopold/controllers/pages/config_form.yaml new file mode 100644 index 0000000..b13da04 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/config_form.yaml @@ -0,0 +1,10 @@ +name: Pages +form: $/studiovx/marcleopold/models/pages/fields.yaml +modelClass: Studiovx\Marcleopold\Models\Pages +defaultRedirect: studiovx/marcleopold/pages +create: + redirect: 'studiovx/marcleopold/pages/update/:id' + redirectClose: studiovx/marcleopold/pages +update: + redirect: studiovx/marcleopold/pages + redirectClose: studiovx/marcleopold/pages diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/config_list.yaml b/server/plugins/studiovx/marcleopold/controllers/pages/config_list.yaml new file mode 100644 index 0000000..5c2684e --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/config_list.yaml @@ -0,0 +1,12 @@ +list: $/studiovx/marcleopold/models/pages/columns.yaml +modelClass: Studiovx\Marcleopold\Models\Pages +title: Pages +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'studiovx/marcleopold/pages/update/:id' diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/create.htm b/server/plugins/studiovx/marcleopold/controllers/pages/create.htm new file mode 100644 index 0000000..1bfe840 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/create.htm @@ -0,0 +1,46 @@ + +
      +
    • Pages
    • +
    • pageTitle) ?>
    • +
    + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + +
    +
    + + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/index.htm b/server/plugins/studiovx/marcleopold/controllers/pages/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/preview.htm b/server/plugins/studiovx/marcleopold/controllers/pages/preview.htm new file mode 100644 index 0000000..53b0e8b --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/preview.htm @@ -0,0 +1,22 @@ + +
      +
    • Pages
    • +
    • pageTitle) ?>
    • +
    + + +fatalError): ?> + +
    + formRenderPreview() ?> +
    + + +

    fatalError) ?>

    + + +

    + + + +

    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/pages/update.htm b/server/plugins/studiovx/marcleopold/controllers/pages/update.htm new file mode 100644 index 0000000..c3a6e57 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/pages/update.htm @@ -0,0 +1,54 @@ + +
      +
    • Pages
    • +
    • pageTitle) ?>
    • +
    + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + + + +
    +
    + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/services/_list_toolbar.htm b/server/plugins/studiovx/marcleopold/controllers/services/_list_toolbar.htm new file mode 100644 index 0000000..aaf576f --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/_list_toolbar.htm @@ -0,0 +1,19 @@ +
    + + + +
    diff --git a/server/plugins/studiovx/marcleopold/controllers/services/_reorder_toolbar.htm b/server/plugins/studiovx/marcleopold/controllers/services/_reorder_toolbar.htm new file mode 100644 index 0000000..acc4d49 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/_reorder_toolbar.htm @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/services/config_form.yaml b/server/plugins/studiovx/marcleopold/controllers/services/config_form.yaml new file mode 100644 index 0000000..0ef5716 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/config_form.yaml @@ -0,0 +1,10 @@ +name: Services +form: $/studiovx/marcleopold/models/services/fields.yaml +modelClass: Studiovx\Marcleopold\Models\Services +defaultRedirect: studiovx/marcleopold/services +create: + redirect: 'studiovx/marcleopold/services/update/:id' + redirectClose: studiovx/marcleopold/services +update: + redirect: studiovx/marcleopold/services + redirectClose: studiovx/marcleopold/services diff --git a/server/plugins/studiovx/marcleopold/controllers/services/config_list.yaml b/server/plugins/studiovx/marcleopold/controllers/services/config_list.yaml new file mode 100644 index 0000000..6c44147 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/config_list.yaml @@ -0,0 +1,12 @@ +list: $/studiovx/marcleopold/models/services/columns.yaml +modelClass: Studiovx\Marcleopold\Models\Services +title: Services +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'studiovx/marcleopold/services/update/:id' diff --git a/server/plugins/studiovx/marcleopold/controllers/services/config_reorder.yaml b/server/plugins/studiovx/marcleopold/controllers/services/config_reorder.yaml new file mode 100644 index 0000000..c691918 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/config_reorder.yaml @@ -0,0 +1,5 @@ +title: Services +modelClass: Studiovx\Marcleopold\Models\Services +nameFrom: title +toolbar: + buttons: reorder_toolbar diff --git a/server/plugins/studiovx/marcleopold/controllers/services/create.htm b/server/plugins/studiovx/marcleopold/controllers/services/create.htm new file mode 100644 index 0000000..f1ee44f --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + +
    +
    + + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/services/index.htm b/server/plugins/studiovx/marcleopold/controllers/services/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/server/plugins/studiovx/marcleopold/controllers/services/preview.htm b/server/plugins/studiovx/marcleopold/controllers/services/preview.htm new file mode 100644 index 0000000..4a2f1f6 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
    + formRenderPreview() ?> +
    + + +

    fatalError) ?>

    + + +

    + + + +

    \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/services/reorder.htm b/server/plugins/studiovx/marcleopold/controllers/services/reorder.htm new file mode 100644 index 0000000..761fcbb --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/reorder.htm @@ -0,0 +1,8 @@ + + + + +reorderRender() ?> \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/controllers/services/update.htm b/server/plugins/studiovx/marcleopold/controllers/services/update.htm new file mode 100644 index 0000000..3c1a1a4 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/controllers/services/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
    + formRender() ?> +
    + +
    +
    + + + + + + + +
    +
    + + + +

    fatalError)) ?>

    +

    + \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/lang/en/lang.php b/server/plugins/studiovx/marcleopold/lang/en/lang.php new file mode 100644 index 0000000..22c418c --- /dev/null +++ b/server/plugins/studiovx/marcleopold/lang/en/lang.php @@ -0,0 +1,6 @@ + [ + 'name' => 'MarcLeopold', + 'description' => '' + ] +]; \ No newline at end of file diff --git a/server/plugins/studiovx/marcleopold/models/IndexImage.php b/server/plugins/studiovx/marcleopold/models/IndexImage.php new file mode 100644 index 0000000..ef0a58d --- /dev/null +++ b/server/plugins/studiovx/marcleopold/models/IndexImage.php @@ -0,0 +1,30 @@ +integer('sort_order'); + }); + } + + public function down() + { + // Schema::dropIfExists('graker_photoalbums_albums'); + $table->dropDown([ + 'sort_order' + ]); + } + +} + diff --git a/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_images.php b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_images.php new file mode 100644 index 0000000..6f80bc5 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_images.php @@ -0,0 +1,24 @@ +engine = 'InnoDB'; + $table->increments('id'); + $table->string('image'); + $table->string('title')->default(null); + $table->integer('sort_order')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('studiovx_marcleopold_index_images'); + } +} diff --git a/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_taglines.php b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_taglines.php new file mode 100644 index 0000000..df54341 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_index_taglines.php @@ -0,0 +1,23 @@ +engine = 'InnoDB'; + $table->increments('id'); + $table->text('text'); + $table->integer('sort_order')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('studiovx_marcleopold_index_taglines'); + } +} diff --git a/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_pages.php b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_pages.php new file mode 100644 index 0000000..cc00430 --- /dev/null +++ b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_pages.php @@ -0,0 +1,24 @@ +engine = 'InnoDB'; + $table->increments('id'); + $table->string('title'); + $table->string('slug'); + $table->string('featured_image')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('studiovx_marcleopold_pages'); + } +} diff --git a/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_services.php b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_services.php new file mode 100644 index 0000000..287634d --- /dev/null +++ b/server/plugins/studiovx/marcleopold/updates/builder_table_create_studiovx_marcleopold_services.php @@ -0,0 +1,27 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('title')->nullable(); + $table->string('url')->default('#'); + $table->string('service_url')->nullable()->default('#'); + $table->string('featured')->default('0'); + $table->text('description')->nullable(); + $table->integer('sort_order')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('studiovx_marcleopold_services'); + } +} diff --git a/server/plugins/studiovx/marcleopold/updates/version.yaml b/server/plugins/studiovx/marcleopold/updates/version.yaml new file mode 100644 index 0000000..4fc19fc --- /dev/null +++ b/server/plugins/studiovx/marcleopold/updates/version.yaml @@ -0,0 +1,14 @@ +1.0.1: + - 'Initialize plugin.' +1.0.2: + - 'Created table studiovx_marcleopold_index_images' + - builder_table_create_studiovx_marcleopold_index_images.php +1.0.3: + - 'Created table studiovx_marcleopold_index_taglines' + - builder_table_create_studiovx_marcleopold_index_taglines.php +1.0.4: + - 'Created table studiovx_marcleopold_services' + - builder_table_create_studiovx_marcleopold_services.php +1.0.5: + - 'Created table studiovx_marcleopold_pages' + - builder_table_create_studiovx_marcleopold_pages.php diff --git a/server/plugins/xeor/contenttype/LICENSE.md b/server/plugins/xeor/contenttype/LICENSE.md new file mode 100644 index 0000000..e2e7fe9 --- /dev/null +++ b/server/plugins/xeor/contenttype/LICENSE.md @@ -0,0 +1,21 @@ +The [MIT License (MIT)](http://opensource.org/licenses/mit-license.php) + +Copyright (c) 2016 [sozonovalexey](https://bitbucket.org/sozonovalexey) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/server/plugins/xeor/contenttype/Plugin.php b/server/plugins/xeor/contenttype/Plugin.php new file mode 100644 index 0000000..81a7101 --- /dev/null +++ b/server/plugins/xeor/contenttype/Plugin.php @@ -0,0 +1,117 @@ + 'xeor.contenttype::lang.plugin.name', + 'description' => 'xeor.contenttype::lang.plugin.description', + 'author' => 'Sozonov Alexey', + 'icon' => 'icon-file-code-o' + ]; + } + + public function boot() + { + Event::listen('backend.form.extendFields', function ($formWidget) { + if ($formWidget->model instanceof \Cms\Classes\Page) { + $formWidget->addFields( + [ + 'settings[contentType]' => [ + 'tab' => 'xeor.contenttype::lang.settings.tab', + 'type' => 'dropdown', + 'default' => 'html', + 'options' => [ + 'html' => 'html', + 'json' => 'json', + 'xml' => 'xml', + 'txt' => 'text', + 'pdf' => 'pdf', + 'js' => 'javascript', + 'css' => 'css', + ], + 'span' => 'left', + 'comment' => 'xeor.contenttype::lang.settings.content_type_comment' + ], + 'settings[customContentType]' => [ + 'tab' => 'xeor.contenttype::lang.settings.tab', + 'placeholder' => 'xeor.contenttype::lang.settings.custom_content_type_placeholder', + 'span' => 'right', + 'comment' => 'xeor.contenttype::lang.settings.custom_content_type_comment', + ], + 'settings[force_show]' => [ + 'tab' => 'xeor.contenttype::lang.settings.tab', + 'label' => 'xeor.contenttype::lang.settings.custom_content_force_show', + 'type' => 'checkbox', + 'span' => 'left', + 'comment' => 'xeor.contenttype::lang.settings.custom_content_force_show_comment', + ], + ], + 'primary' + ); + } + }); + + Event::listen('cms.page.beforeDisplay', function ($controller, $url, $page) { + + /* + * Maintenance mode + */ + if ( + MaintenanceSetting::isConfigured() && + MaintenanceSetting::get('is_enabled', false) && + !BackendAuth::getUser() + ) { + $currentPage = $controller->getRouter()->findByUrl($url); + if ($currentPage && isset($currentPage->force_show) && $currentPage->force_show && !$currentPage->is_hidden) { + $controller->setStatusCode(200); + $page = $currentPage; + } + + } + + return $page; + + }); + + Event::listen('cms.page.display', function ($controller, $url, $page, $result) { + + if (!is_string($result)) + return $result; + + $type = null; + $headers = []; + $types = array( + 'html' => 'text/html', + 'json' => 'application/json', + 'css' => 'text/css', + 'js' => 'application/javascript', + 'pdf' => 'application/pdf', + 'txt' => 'text/plain', + 'xml' => 'application/xml' + ); + + if (isset($page->settings['contentType']) && !empty($page->settings['contentType'])) + $type = $types[$page->settings['contentType']]; + + if (isset($page->settings['customContentType']) && !empty($page->settings['customContentType'])) + $type = $page->settings['customContentType']; + + if (!is_null($type)) + $headers = ['Content-Type' => $type]; + + return Response::make($result, $controller->getStatusCode(), $headers); + + }); + } + +} \ No newline at end of file diff --git a/server/plugins/xeor/contenttype/README.md b/server/plugins/xeor/contenttype/README.md new file mode 100644 index 0000000..60640a1 --- /dev/null +++ b/server/plugins/xeor/contenttype/README.md @@ -0,0 +1,12 @@ +# Content Type for OctoberCMS + +The **Content Type plugin** allows you to assign custom content types to CMS pages. It sets the correct HTTP headers for HTML, JSON, XML, PDF, JS or CSS output. + +## Documentation + +See the [Documentation tab](https://octobercms.com/plugin/xeor-contenttype#documentation) for the usage details. + +## Troubleshooting + +If you like living on the edge, please report any bugs you find on the +[issues](https://bitbucket.org/sozonovalexey/oc-contenttype-plugin/issues) page. diff --git a/server/plugins/xeor/contenttype/lang/en/lang.php b/server/plugins/xeor/contenttype/lang/en/lang.php new file mode 100644 index 0000000..b7add75 --- /dev/null +++ b/server/plugins/xeor/contenttype/lang/en/lang.php @@ -0,0 +1,16 @@ + [ + 'name' => 'Content Type', + 'description' => 'Assign custom content types to CMS pages.', + ], + 'settings' => [ + 'tab' => 'Content Type', + 'content_type_comment' => 'Select the content type', + 'custom_content_type_placeholder' => 'e.g., text/cache-manifest', + 'custom_content_type_comment' => 'or enter your own', + 'custom_content_force_show' => 'Force visible', + 'custom_content_force_show_comment' => 'Page is accessible when maintenance mode is activated.', + ], +]; \ No newline at end of file diff --git a/server/plugins/xeor/contenttype/updates/version.yaml b/server/plugins/xeor/contenttype/updates/version.yaml new file mode 100644 index 0000000..ee612aa --- /dev/null +++ b/server/plugins/xeor/contenttype/updates/version.yaml @@ -0,0 +1,7 @@ +1.0.0: 'First version.' +1.0.1: 'Bug fixes.' +1.1.0: 'Added support for custom types.' +1.1.1: 'Fixes problem with 404 pages.' +1.1.2: 'Fixes issue with status code.' +1.1.3: 'Pages can now be showed when maintenance mode is activated.' +1.1.4: 'Fixes another issue with status code.' \ No newline at end of file