From 050752e358366e19182094deea644918cd65bd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Fri, 8 Jan 2021 12:18:52 +0100 Subject: [PATCH 1/4] Ability to use without CPT, ability to use with AJAX and use custom handlers --- .gitignore | 10 - composer.json | 27 - inc/Init.php | 1 - inc/Modules/Forms/CreateForm.php | 37 +- inc/Modules/Forms/CustomPostType.php | 5 +- inc/Modules/Forms/Init.php | 2 +- inc/Modules/Forms/Mail.php | 2 +- inc/Modules/Forms/RestApi.php | 93 ++ vendor/autoload.php | 7 + vendor/composer/ClassLoader.php | 445 +++++++++ vendor/composer/InstalledVersions.php | 245 +++++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 107 +++ vendor/composer/autoload_namespaces.php | 9 + vendor/composer/autoload_psr4.php | 10 + vendor/composer/autoload_real.php | 57 ++ vendor/composer/autoload_static.php | 133 +++ .../composer/installed.json | 223 ++--- vendor/composer/installed.php | 60 ++ vendor/composer/platform_check.php | 26 + .../nette/component-model/.phpstorm.meta.php | 7 + vendor/nette/component-model/composer.json | 39 + vendor/nette/component-model/contributing.md | 33 + vendor/nette/component-model/license.md | 60 ++ vendor/nette/component-model/readme.md | 31 + .../src/ComponentModel/ArrayAccess.php | 66 ++ .../src/ComponentModel/Component.php | 310 +++++++ .../src/ComponentModel/Container.php | 227 +++++ .../src/ComponentModel/IComponent.php | 33 + .../src/ComponentModel/IContainer.php | 40 + .../RecursiveComponentIterator.php | 45 + vendor/nette/forms/.phpstorm.meta.php | 8 + vendor/nette/forms/composer.json | 47 + vendor/nette/forms/contributing.md | 33 + vendor/nette/forms/examples/assets/logo.png | Bin 0 -> 1346 bytes vendor/nette/forms/examples/assets/style.css | 72 ++ vendor/nette/forms/examples/basic-example.php | 132 +++ .../forms/examples/bootstrap2-rendering.php | 97 ++ .../forms/examples/bootstrap3-rendering.php | 100 ++ .../forms/examples/bootstrap4-rendering.php | 107 +++ vendor/nette/forms/examples/containers.php | 64 ++ .../nette/forms/examples/custom-control.php | 140 +++ .../nette/forms/examples/custom-rendering.php | 127 +++ .../nette/forms/examples/custom-validator.php | 64 ++ vendor/nette/forms/examples/html5.php | 66 ++ vendor/nette/forms/examples/latte.php | 46 + .../nette/forms/examples/live-validation.php | 106 +++ vendor/nette/forms/examples/localization.ini | 12 + vendor/nette/forms/examples/localization.php | 89 ++ .../nette/forms/examples/manual-rendering.php | 95 ++ vendor/nette/forms/examples/template.latte | 29 + vendor/nette/forms/license.md | 60 ++ vendor/nette/forms/package.json | 21 + vendor/nette/forms/readme.md | 85 ++ .../src/Bridges/FormsDI/FormsExtension.php | 43 + .../src/Bridges/FormsLatte/FormMacros.php | 288 ++++++ .../forms/src/Bridges/FormsLatte/Runtime.php | 160 ++++ vendor/nette/forms/src/Forms/Container.php | 480 ++++++++++ vendor/nette/forms/src/Forms/ControlGroup.php | 121 +++ .../forms/src/Forms/Controls/BaseControl.php | 601 ++++++++++++ .../nette/forms/src/Forms/Controls/Button.php | 64 ++ .../forms/src/Forms/Controls/Checkbox.php | 92 ++ .../forms/src/Forms/Controls/CheckboxList.php | 138 +++ .../src/Forms/Controls/ChoiceControl.php | 155 ++++ .../src/Forms/Controls/CsrfProtection.php | 103 +++ .../forms/src/Forms/Controls/HiddenField.php | 116 +++ .../forms/src/Forms/Controls/ImageButton.php | 44 + .../src/Forms/Controls/MultiChoiceControl.php | 167 ++++ .../src/Forms/Controls/MultiSelectBox.php | 96 ++ .../forms/src/Forms/Controls/RadioList.php | 131 +++ .../forms/src/Forms/Controls/SelectBox.php | 139 +++ .../forms/src/Forms/Controls/SubmitButton.php | 111 +++ .../forms/src/Forms/Controls/TextArea.php | 36 + .../forms/src/Forms/Controls/TextBase.php | 150 +++ .../forms/src/Forms/Controls/TextInput.php | 107 +++ .../src/Forms/Controls/UploadControl.php | 113 +++ vendor/nette/forms/src/Forms/Form.php | 659 +++++++++++++ vendor/nette/forms/src/Forms/Helpers.php | 247 +++++ vendor/nette/forms/src/Forms/IControl.php | 42 + .../nette/forms/src/Forms/IFormRenderer.php | 22 + .../forms/src/Forms/ISubmitterControl.php | 22 + .../Forms/Rendering/DefaultFormRenderer.php | 510 ++++++++++ vendor/nette/forms/src/Forms/Rule.php | 39 + vendor/nette/forms/src/Forms/Rules.php | 345 +++++++ vendor/nette/forms/src/Forms/Validator.php | 374 ++++++++ vendor/nette/forms/src/assets/netteForms.js | 785 ++++++++++++++++ .../nette/forms/src/assets/netteForms.min.js | 23 + vendor/nette/http/.phpstorm.meta.php | 71 ++ vendor/nette/http/appveyor.yml | 33 + vendor/nette/http/composer.json | 48 + vendor/nette/http/contributing.md | 33 + vendor/nette/http/license.md | 60 ++ vendor/nette/http/readme.md | 776 ++++++++++++++++ .../http/src/Bridges/HttpDI/HttpExtension.php | 152 +++ .../src/Bridges/HttpDI/SessionExtension.php | 102 ++ .../src/Bridges/HttpTracy/SessionPanel.php | 43 + .../templates/SessionPanel.panel.phtml | 38 + .../templates/SessionPanel.tab.phtml | 11 + vendor/nette/http/src/Http/Context.php | 94 ++ vendor/nette/http/src/Http/FileUpload.php | 244 +++++ vendor/nette/http/src/Http/Helpers.php | 61 ++ vendor/nette/http/src/Http/IRequest.php | 120 +++ vendor/nette/http/src/Http/IResponse.php | 224 +++++ vendor/nette/http/src/Http/Request.php | 327 +++++++ vendor/nette/http/src/Http/RequestFactory.php | 365 ++++++++ vendor/nette/http/src/Http/Response.php | 301 ++++++ vendor/nette/http/src/Http/Session.php | 516 +++++++++++ vendor/nette/http/src/Http/SessionSection.php | 201 ++++ vendor/nette/http/src/Http/Url.php | 425 +++++++++ vendor/nette/http/src/Http/UrlImmutable.php | 329 +++++++ vendor/nette/http/src/Http/UrlScript.php | 111 +++ vendor/nette/http/src/Http/UserStorage.php | 185 ++++ vendor/nette/utils/.phpstorm.meta.php | 19 + vendor/nette/utils/composer.json | 50 + vendor/nette/utils/contributing.md | 33 + vendor/nette/utils/license.md | 60 ++ vendor/nette/utils/readme.md | 44 + .../utils/src/Iterators/CachingIterator.php | 166 ++++ vendor/nette/utils/src/Iterators/Mapper.php | 34 + vendor/nette/utils/src/Utils/ArrayHash.php | 97 ++ vendor/nette/utils/src/Utils/ArrayList.php | 113 +++ vendor/nette/utils/src/Utils/Arrays.php | 346 +++++++ vendor/nette/utils/src/Utils/Callback.php | 181 ++++ vendor/nette/utils/src/Utils/DateTime.php | 144 +++ vendor/nette/utils/src/Utils/FileSystem.php | 187 ++++ vendor/nette/utils/src/Utils/Floats.php | 107 +++ vendor/nette/utils/src/Utils/Helpers.php | 71 ++ vendor/nette/utils/src/Utils/Html.php | 875 ++++++++++++++++++ .../nette/utils/src/Utils/HtmlStringable.php | 22 + vendor/nette/utils/src/Utils/Image.php | 726 +++++++++++++++ vendor/nette/utils/src/Utils/Json.php | 64 ++ .../nette/utils/src/Utils/ObjectHelpers.php | 180 ++++ vendor/nette/utils/src/Utils/ObjectMixin.php | 41 + vendor/nette/utils/src/Utils/Paginator.php | 220 +++++ vendor/nette/utils/src/Utils/Random.php | 45 + vendor/nette/utils/src/Utils/Reflection.php | 417 +++++++++ vendor/nette/utils/src/Utils/SmartObject.php | 122 +++ vendor/nette/utils/src/Utils/StaticClass.php | 34 + vendor/nette/utils/src/Utils/Strings.php | 550 +++++++++++ vendor/nette/utils/src/Utils/Translator.php | 27 + vendor/nette/utils/src/Utils/Validators.php | 373 ++++++++ vendor/nette/utils/src/Utils/exceptions.php | 159 ++++ vendor/nette/utils/src/compatibility.php | 30 + 143 files changed, 20723 insertions(+), 218 deletions(-) delete mode 100644 .gitignore delete mode 100644 composer.json create mode 100644 inc/Modules/Forms/RestApi.php create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/InstalledVersions.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php rename composer.lock => vendor/composer/installed.json (59%) create mode 100644 vendor/composer/installed.php create mode 100644 vendor/composer/platform_check.php create mode 100644 vendor/nette/component-model/.phpstorm.meta.php create mode 100644 vendor/nette/component-model/composer.json create mode 100644 vendor/nette/component-model/contributing.md create mode 100644 vendor/nette/component-model/license.md create mode 100644 vendor/nette/component-model/readme.md create mode 100644 vendor/nette/component-model/src/ComponentModel/ArrayAccess.php create mode 100644 vendor/nette/component-model/src/ComponentModel/Component.php create mode 100644 vendor/nette/component-model/src/ComponentModel/Container.php create mode 100644 vendor/nette/component-model/src/ComponentModel/IComponent.php create mode 100644 vendor/nette/component-model/src/ComponentModel/IContainer.php create mode 100644 vendor/nette/component-model/src/ComponentModel/RecursiveComponentIterator.php create mode 100644 vendor/nette/forms/.phpstorm.meta.php create mode 100644 vendor/nette/forms/composer.json create mode 100644 vendor/nette/forms/contributing.md create mode 100644 vendor/nette/forms/examples/assets/logo.png create mode 100644 vendor/nette/forms/examples/assets/style.css create mode 100644 vendor/nette/forms/examples/basic-example.php create mode 100644 vendor/nette/forms/examples/bootstrap2-rendering.php create mode 100644 vendor/nette/forms/examples/bootstrap3-rendering.php create mode 100644 vendor/nette/forms/examples/bootstrap4-rendering.php create mode 100644 vendor/nette/forms/examples/containers.php create mode 100644 vendor/nette/forms/examples/custom-control.php create mode 100644 vendor/nette/forms/examples/custom-rendering.php create mode 100644 vendor/nette/forms/examples/custom-validator.php create mode 100644 vendor/nette/forms/examples/html5.php create mode 100644 vendor/nette/forms/examples/latte.php create mode 100644 vendor/nette/forms/examples/live-validation.php create mode 100644 vendor/nette/forms/examples/localization.ini create mode 100644 vendor/nette/forms/examples/localization.php create mode 100644 vendor/nette/forms/examples/manual-rendering.php create mode 100644 vendor/nette/forms/examples/template.latte create mode 100644 vendor/nette/forms/license.md create mode 100644 vendor/nette/forms/package.json create mode 100644 vendor/nette/forms/readme.md create mode 100644 vendor/nette/forms/src/Bridges/FormsDI/FormsExtension.php create mode 100644 vendor/nette/forms/src/Bridges/FormsLatte/FormMacros.php create mode 100644 vendor/nette/forms/src/Bridges/FormsLatte/Runtime.php create mode 100644 vendor/nette/forms/src/Forms/Container.php create mode 100644 vendor/nette/forms/src/Forms/ControlGroup.php create mode 100644 vendor/nette/forms/src/Forms/Controls/BaseControl.php create mode 100644 vendor/nette/forms/src/Forms/Controls/Button.php create mode 100644 vendor/nette/forms/src/Forms/Controls/Checkbox.php create mode 100644 vendor/nette/forms/src/Forms/Controls/CheckboxList.php create mode 100644 vendor/nette/forms/src/Forms/Controls/ChoiceControl.php create mode 100644 vendor/nette/forms/src/Forms/Controls/CsrfProtection.php create mode 100644 vendor/nette/forms/src/Forms/Controls/HiddenField.php create mode 100644 vendor/nette/forms/src/Forms/Controls/ImageButton.php create mode 100644 vendor/nette/forms/src/Forms/Controls/MultiChoiceControl.php create mode 100644 vendor/nette/forms/src/Forms/Controls/MultiSelectBox.php create mode 100644 vendor/nette/forms/src/Forms/Controls/RadioList.php create mode 100644 vendor/nette/forms/src/Forms/Controls/SelectBox.php create mode 100644 vendor/nette/forms/src/Forms/Controls/SubmitButton.php create mode 100644 vendor/nette/forms/src/Forms/Controls/TextArea.php create mode 100644 vendor/nette/forms/src/Forms/Controls/TextBase.php create mode 100644 vendor/nette/forms/src/Forms/Controls/TextInput.php create mode 100644 vendor/nette/forms/src/Forms/Controls/UploadControl.php create mode 100644 vendor/nette/forms/src/Forms/Form.php create mode 100644 vendor/nette/forms/src/Forms/Helpers.php create mode 100644 vendor/nette/forms/src/Forms/IControl.php create mode 100644 vendor/nette/forms/src/Forms/IFormRenderer.php create mode 100644 vendor/nette/forms/src/Forms/ISubmitterControl.php create mode 100644 vendor/nette/forms/src/Forms/Rendering/DefaultFormRenderer.php create mode 100644 vendor/nette/forms/src/Forms/Rule.php create mode 100644 vendor/nette/forms/src/Forms/Rules.php create mode 100644 vendor/nette/forms/src/Forms/Validator.php create mode 100644 vendor/nette/forms/src/assets/netteForms.js create mode 100644 vendor/nette/forms/src/assets/netteForms.min.js create mode 100644 vendor/nette/http/.phpstorm.meta.php create mode 100644 vendor/nette/http/appveyor.yml create mode 100644 vendor/nette/http/composer.json create mode 100644 vendor/nette/http/contributing.md create mode 100644 vendor/nette/http/license.md create mode 100644 vendor/nette/http/readme.md create mode 100644 vendor/nette/http/src/Bridges/HttpDI/HttpExtension.php create mode 100644 vendor/nette/http/src/Bridges/HttpDI/SessionExtension.php create mode 100644 vendor/nette/http/src/Bridges/HttpTracy/SessionPanel.php create mode 100644 vendor/nette/http/src/Bridges/HttpTracy/templates/SessionPanel.panel.phtml create mode 100644 vendor/nette/http/src/Bridges/HttpTracy/templates/SessionPanel.tab.phtml create mode 100644 vendor/nette/http/src/Http/Context.php create mode 100644 vendor/nette/http/src/Http/FileUpload.php create mode 100644 vendor/nette/http/src/Http/Helpers.php create mode 100644 vendor/nette/http/src/Http/IRequest.php create mode 100644 vendor/nette/http/src/Http/IResponse.php create mode 100644 vendor/nette/http/src/Http/Request.php create mode 100644 vendor/nette/http/src/Http/RequestFactory.php create mode 100644 vendor/nette/http/src/Http/Response.php create mode 100644 vendor/nette/http/src/Http/Session.php create mode 100644 vendor/nette/http/src/Http/SessionSection.php create mode 100644 vendor/nette/http/src/Http/Url.php create mode 100644 vendor/nette/http/src/Http/UrlImmutable.php create mode 100644 vendor/nette/http/src/Http/UrlScript.php create mode 100644 vendor/nette/http/src/Http/UserStorage.php create mode 100644 vendor/nette/utils/.phpstorm.meta.php create mode 100644 vendor/nette/utils/composer.json create mode 100644 vendor/nette/utils/contributing.md create mode 100644 vendor/nette/utils/license.md create mode 100644 vendor/nette/utils/readme.md create mode 100644 vendor/nette/utils/src/Iterators/CachingIterator.php create mode 100644 vendor/nette/utils/src/Iterators/Mapper.php create mode 100644 vendor/nette/utils/src/Utils/ArrayHash.php create mode 100644 vendor/nette/utils/src/Utils/ArrayList.php create mode 100644 vendor/nette/utils/src/Utils/Arrays.php create mode 100644 vendor/nette/utils/src/Utils/Callback.php create mode 100644 vendor/nette/utils/src/Utils/DateTime.php create mode 100644 vendor/nette/utils/src/Utils/FileSystem.php create mode 100644 vendor/nette/utils/src/Utils/Floats.php create mode 100644 vendor/nette/utils/src/Utils/Helpers.php create mode 100644 vendor/nette/utils/src/Utils/Html.php create mode 100644 vendor/nette/utils/src/Utils/HtmlStringable.php create mode 100644 vendor/nette/utils/src/Utils/Image.php create mode 100644 vendor/nette/utils/src/Utils/Json.php create mode 100644 vendor/nette/utils/src/Utils/ObjectHelpers.php create mode 100644 vendor/nette/utils/src/Utils/ObjectMixin.php create mode 100644 vendor/nette/utils/src/Utils/Paginator.php create mode 100644 vendor/nette/utils/src/Utils/Random.php create mode 100644 vendor/nette/utils/src/Utils/Reflection.php create mode 100644 vendor/nette/utils/src/Utils/SmartObject.php create mode 100644 vendor/nette/utils/src/Utils/StaticClass.php create mode 100644 vendor/nette/utils/src/Utils/Strings.php create mode 100644 vendor/nette/utils/src/Utils/Translator.php create mode 100644 vendor/nette/utils/src/Utils/Validators.php create mode 100644 vendor/nette/utils/src/Utils/exceptions.php create mode 100644 vendor/nette/utils/src/compatibility.php diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3f19c74..0000000 --- a/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Ignore .env files -.env - -# Editor files -.idea - -# Ignore vendor lib -vendor -node_modules -dist diff --git a/composer.json b/composer.json deleted file mode 100644 index 9adb1d5..0000000 --- a/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "develtio/develtio-wp-forms", - "description": "Make forms doable", - "type": "wordpress-muplugin", - "license": "MIT", - "keywords": ["wordpress", "plugin", "forms", "nette"], - "homepage": "https://develtio.com", - "require": { - "composer/installers": "~1.0", - "nette/forms": "^3.0" - }, - "authors": [ - { - "name": "Develtio", - "homepage": "https://develtio.com" - }, - { - "name": "Michał Malinowski", - "email": "mki.malinowski@gmail.com" - } - ], - "autoload": { - "psr-4": { - "Develtio\\WP\\Forms\\": "./inc" - } - } -} diff --git a/inc/Init.php b/inc/Init.php index cbadc67..4ac9dde 100644 --- a/inc/Init.php +++ b/inc/Init.php @@ -18,7 +18,6 @@ public static function get_services() Core\Pages\Dashboard::class, Core\Base\Enqueue::class, Core\Base\SettingsLinks::class, - Modules\Forms\Init::class, ]; } diff --git a/inc/Modules/Forms/CreateForm.php b/inc/Modules/Forms/CreateForm.php index 35dc826..dee4f48 100644 --- a/inc/Modules/Forms/CreateForm.php +++ b/inc/Modules/Forms/CreateForm.php @@ -72,13 +72,23 @@ class CreateForm extends BaseController */ public $mail; + /** + * Rest Api class + * @var RestApi + */ + public $rest_api; + + public $custom_handler = null; + /** * Options form customizing features and properties * @var array */ public $options = [ 'send_mail' => true, - 'send_confirm_mail' => false + 'send_confirm_mail' => false, + 'rest_api' => false, + 'create_cpt' => true ]; /** @@ -96,8 +106,18 @@ public function __construct( $form_name, $options = [] ) $this->mail = new Mail($this); $this->form_name = $form_name; $this->form_slug = sanitize_title( $form_name ); - $this->custom_post_types = new CustomPostType(); + if($this->options['create_cpt']) { + $this->custom_post_types = new CustomPostType(); + } + + if($this->options['rest_api']) { + $this->rest_api = new RestApi(); + } + + if(isset($this->options['custom_handler'])) { + $this->custom_handler = $this->options['custom_handler']; + } } /** @@ -106,15 +126,22 @@ public function __construct( $form_name, $options = [] ) public function save() { $this->setShortcode(); - $this->custom_post_types->storeCustomPostTypes( $this ); + if($this->options['create_cpt']) { + $this->custom_post_types->storeCustomPostTypes($this); + } + + if($this->options['rest_api']) { + $this->rest_api->exposeObject($this, $this->custom_handler); + } if ( isset( $_POST ) && !is_admin() && $this->form->isSubmitted() && $this->form->isSuccess() ) { $this->form_values = $this->form->getValues(); if ( $this->options['send_mail'] ) $this->mail->proceed(); - add_action( 'init', [ $this, 'saveFormData' ] ); - + if($this->options['create_cpt']) { + add_action('init', [$this, 'saveFormData']); + } } } diff --git a/inc/Modules/Forms/CustomPostType.php b/inc/Modules/Forms/CustomPostType.php index 3edd988..5834bf2 100644 --- a/inc/Modules/Forms/CustomPostType.php +++ b/inc/Modules/Forms/CustomPostType.php @@ -50,7 +50,6 @@ class CustomPostType extends BaseController */ public function registerCustomPostTypes() { - foreach ( $this->custom_post_types as $post_type ) { register_post_type( $post_type['name'], $post_type['args'] ); } @@ -65,6 +64,7 @@ public function registerCustomPostTypes() */ public function storeCustomPostTypes( CreateForm $instance ) { + $this->form_instance = $instance; $this->post_type_name = $instance->post_type_prefix . $instance->form_slug; $this->form_components = $instance->form->getComponents(); @@ -74,6 +74,7 @@ public function storeCustomPostTypes( CreateForm $instance ) return; } + array_push( $this->custom_post_types, [ 'name' => $this->post_type_name, @@ -92,7 +93,7 @@ public function storeCustomPostTypes( CreateForm $instance ) ); if ( !empty( $this->custom_post_types ) ) { - add_action( 'init', [ $this, 'registerCustomPostTypes' ] ); + add_action( 'init', [ $this, 'registerCustomPostTypes' ], 100 ); $this->meta_box = new MetaBoxApi(); $this->meta_box->init( diff --git a/inc/Modules/Forms/Init.php b/inc/Modules/Forms/Init.php index 6dcdfe8..3ddadba 100644 --- a/inc/Modules/Forms/Init.php +++ b/inc/Modules/Forms/Init.php @@ -18,7 +18,7 @@ public function init() { $option = get_option('develtio_plugin'); - if(!$option['develtio_forms']) return; + if(!isset($option['develtio_forms'])) return; $this->register_services(); } diff --git a/inc/Modules/Forms/Mail.php b/inc/Modules/Forms/Mail.php index 544c51e..74888d6 100644 --- a/inc/Modules/Forms/Mail.php +++ b/inc/Modules/Forms/Mail.php @@ -98,7 +98,7 @@ public function __construct(CreateForm $form) protected function setMailer() { - if(SMTP_HOST && SMTP_PORT && SMTP_USERNAME && SMTP_PASSWORD) { + if(defined('SMTP_HOST') && defined('SMTP_PORT') && defined('SMTP_USERNAME') && defined('SMTP_PASSWORD')) { $this->mailer = new Swift_Mailer(( new Swift_SmtpTransport( SMTP_HOST, SMTP_PORT, SMTP_ENCRYPTION ) ) ->setUsername( SMTP_USERNAME ) ->setPassword( SMTP_PASSWORD )); diff --git a/inc/Modules/Forms/RestApi.php b/inc/Modules/Forms/RestApi.php new file mode 100644 index 0000000..f8195ed --- /dev/null +++ b/inc/Modules/Forms/RestApi.php @@ -0,0 +1,93 @@ +form_instance = $instance; + $this->post_type_name = $instance->post_type_prefix . $instance->form_slug; + + $this->custom_handler = $customHandler; + + add_action('rest_api_init', [$this,'registerAPIRoute']); + return $this; + } + + public function registerAPIRoute() + { + register_rest_route('develtio/v1', '/form/' . $this->post_type_name, + array( + 'methods' => 'POST', + 'callback' => [$this, 'handleRoute'], + 'permission_callback' => '__return_true', + ) + ); + } + + public function handleRoute(\WP_REST_Request $request) + { + $this->form_instance->form->validate(); + $errors = $this->form_instance->form->getErrors(); + + if(!empty($errors)){ + $response = new \WP_REST_Response([ + 'success' => 'false', + 'errors' => $errors + ]); + $response->set_headers(array('Cache-Control' => 'no-cache')); + return $response; + } + + if ( $this->form_instance->options['send_mail'] ){ + $this->form_instance->mail->proceed(); + + $response = new \WP_REST_Response([ + 'success' => 'true' + ]); + $response->set_headers(array('Cache-Control' => 'no-cache')); + return $response; + } + + $customResponse = []; + if($this->custom_handler){ + require_once $this->custom_handler[1].$this->custom_handler[0].'.php'; + $responseObject = new $this->custom_handler[0]($request, $this->form_instance); + $customResponse = $responseObject->handle(); + } + + $response = new \WP_REST_Response($customResponse); + $response->set_headers(array('Cache-Control' => 'no-cache')); + $response->set_status(200); + return $response; + } + +} diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..8132c1a --- /dev/null +++ b/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 https://www.php-fig.org/psr/psr-0/ + * @see https://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', array_values($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') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $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/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..9663e52 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,245 @@ + + array ( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'aliases' => + array ( + ), + 'reference' => NULL, + 'name' => 'develtio/develtio-wp-forms', + ), + 'versions' => + array ( + 'develtio/develtio-wp-forms' => + array ( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'aliases' => + array ( + ), + 'reference' => NULL, + ), + 'nette/component-model' => + array ( + 'pretty_version' => 'v3.0.1', + 'version' => '3.0.1.0', + 'aliases' => + array ( + ), + 'reference' => '66409cf5507c77edb46ffa88cf6a92ff58395601', + ), + 'nette/forms' => + array ( + 'pretty_version' => 'v3.0.7', + 'version' => '3.0.7.0', + 'aliases' => + array ( + ), + 'reference' => 'cfe069b5880e07930e92058b774f22e491aa7b0e', + ), + 'nette/http' => + array ( + 'pretty_version' => 'v3.0.5', + 'version' => '3.0.5.0', + 'aliases' => + array ( + ), + 'reference' => '24647c6c52a9ed008b2d39494a8c4fc23c48e487', + ), + 'nette/utils' => + array ( + 'pretty_version' => 'v3.2.0', + 'version' => '3.2.0.0', + 'aliases' => + array ( + ), + 'reference' => 'd0427c1811462dbb6c503143eabe5478b26685f7', + ), + ), +); + + + + + + + +public static function getInstalledPackages() +{ +return array_keys(self::$installed['versions']); +} + + + + + + + + + +public static function isInstalled($packageName) +{ +return isset(self::$installed['versions'][$packageName]); +} + + + + + + + + + + + + + + +public static function satisfies(VersionParser $parser, $packageName, $constraint) +{ +$constraint = $parser->parseConstraints($constraint); +$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + +return $provided->matches($constraint); +} + + + + + + + + + + +public static function getVersionRanges($packageName) +{ +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + +$ranges = array(); +if (isset(self::$installed['versions'][$packageName]['pretty_version'])) { +$ranges[] = self::$installed['versions'][$packageName]['pretty_version']; +} +if (array_key_exists('aliases', self::$installed['versions'][$packageName])) { +$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']); +} +if (array_key_exists('replaced', self::$installed['versions'][$packageName])) { +$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']); +} +if (array_key_exists('provided', self::$installed['versions'][$packageName])) { +$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']); +} + +return implode(' || ', $ranges); +} + + + + + +public static function getVersion($packageName) +{ +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + +if (!isset(self::$installed['versions'][$packageName]['version'])) { +return null; +} + +return self::$installed['versions'][$packageName]['version']; +} + + + + + +public static function getPrettyVersion($packageName) +{ +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + +if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) { +return null; +} + +return self::$installed['versions'][$packageName]['pretty_version']; +} + + + + + +public static function getReference($packageName) +{ +if (!isset(self::$installed['versions'][$packageName])) { +throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); +} + +if (!isset(self::$installed['versions'][$packageName]['reference'])) { +return null; +} + +return self::$installed['versions'][$packageName]['reference']; +} + + + + + +public static function getRootPackage() +{ +return self::$installed['root']; +} + + + + + + + +public static function getRawData() +{ +return self::$installed; +} + + + + + + + + + + + + + + + + + + + +public static function reload($data) +{ +self::$installed = $data; +} +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/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/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..8160826 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,107 @@ + $vendorDir . '/composer/InstalledVersions.php', + 'Nette\\ArgumentOutOfRangeException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Bridges\\FormsDI\\FormsExtension' => $vendorDir . '/nette/forms/src/Bridges/FormsDI/FormsExtension.php', + 'Nette\\Bridges\\FormsLatte\\FormMacros' => $vendorDir . '/nette/forms/src/Bridges/FormsLatte/FormMacros.php', + 'Nette\\Bridges\\FormsLatte\\Runtime' => $vendorDir . '/nette/forms/src/Bridges/FormsLatte/Runtime.php', + 'Nette\\Bridges\\HttpDI\\HttpExtension' => $vendorDir . '/nette/http/src/Bridges/HttpDI/HttpExtension.php', + 'Nette\\Bridges\\HttpDI\\SessionExtension' => $vendorDir . '/nette/http/src/Bridges/HttpDI/SessionExtension.php', + 'Nette\\Bridges\\HttpTracy\\SessionPanel' => $vendorDir . '/nette/http/src/Bridges/HttpTracy/SessionPanel.php', + 'Nette\\ComponentModel\\ArrayAccess' => $vendorDir . '/nette/component-model/src/ComponentModel/ArrayAccess.php', + 'Nette\\ComponentModel\\Component' => $vendorDir . '/nette/component-model/src/ComponentModel/Component.php', + 'Nette\\ComponentModel\\Container' => $vendorDir . '/nette/component-model/src/ComponentModel/Container.php', + 'Nette\\ComponentModel\\IComponent' => $vendorDir . '/nette/component-model/src/ComponentModel/IComponent.php', + 'Nette\\ComponentModel\\IContainer' => $vendorDir . '/nette/component-model/src/ComponentModel/IContainer.php', + 'Nette\\ComponentModel\\RecursiveComponentIterator' => $vendorDir . '/nette/component-model/src/ComponentModel/RecursiveComponentIterator.php', + 'Nette\\DeprecatedException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\DirectoryNotFoundException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\FileNotFoundException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Forms\\Container' => $vendorDir . '/nette/forms/src/Forms/Container.php', + 'Nette\\Forms\\ControlGroup' => $vendorDir . '/nette/forms/src/Forms/ControlGroup.php', + 'Nette\\Forms\\Controls\\BaseControl' => $vendorDir . '/nette/forms/src/Forms/Controls/BaseControl.php', + 'Nette\\Forms\\Controls\\Button' => $vendorDir . '/nette/forms/src/Forms/Controls/Button.php', + 'Nette\\Forms\\Controls\\Checkbox' => $vendorDir . '/nette/forms/src/Forms/Controls/Checkbox.php', + 'Nette\\Forms\\Controls\\CheckboxList' => $vendorDir . '/nette/forms/src/Forms/Controls/CheckboxList.php', + 'Nette\\Forms\\Controls\\ChoiceControl' => $vendorDir . '/nette/forms/src/Forms/Controls/ChoiceControl.php', + 'Nette\\Forms\\Controls\\CsrfProtection' => $vendorDir . '/nette/forms/src/Forms/Controls/CsrfProtection.php', + 'Nette\\Forms\\Controls\\HiddenField' => $vendorDir . '/nette/forms/src/Forms/Controls/HiddenField.php', + 'Nette\\Forms\\Controls\\ImageButton' => $vendorDir . '/nette/forms/src/Forms/Controls/ImageButton.php', + 'Nette\\Forms\\Controls\\MultiChoiceControl' => $vendorDir . '/nette/forms/src/Forms/Controls/MultiChoiceControl.php', + 'Nette\\Forms\\Controls\\MultiSelectBox' => $vendorDir . '/nette/forms/src/Forms/Controls/MultiSelectBox.php', + 'Nette\\Forms\\Controls\\RadioList' => $vendorDir . '/nette/forms/src/Forms/Controls/RadioList.php', + 'Nette\\Forms\\Controls\\SelectBox' => $vendorDir . '/nette/forms/src/Forms/Controls/SelectBox.php', + 'Nette\\Forms\\Controls\\SubmitButton' => $vendorDir . '/nette/forms/src/Forms/Controls/SubmitButton.php', + 'Nette\\Forms\\Controls\\TextArea' => $vendorDir . '/nette/forms/src/Forms/Controls/TextArea.php', + 'Nette\\Forms\\Controls\\TextBase' => $vendorDir . '/nette/forms/src/Forms/Controls/TextBase.php', + 'Nette\\Forms\\Controls\\TextInput' => $vendorDir . '/nette/forms/src/Forms/Controls/TextInput.php', + 'Nette\\Forms\\Controls\\UploadControl' => $vendorDir . '/nette/forms/src/Forms/Controls/UploadControl.php', + 'Nette\\Forms\\Form' => $vendorDir . '/nette/forms/src/Forms/Form.php', + 'Nette\\Forms\\Helpers' => $vendorDir . '/nette/forms/src/Forms/Helpers.php', + 'Nette\\Forms\\IControl' => $vendorDir . '/nette/forms/src/Forms/IControl.php', + 'Nette\\Forms\\IFormRenderer' => $vendorDir . '/nette/forms/src/Forms/IFormRenderer.php', + 'Nette\\Forms\\ISubmitterControl' => $vendorDir . '/nette/forms/src/Forms/ISubmitterControl.php', + 'Nette\\Forms\\Rendering\\DefaultFormRenderer' => $vendorDir . '/nette/forms/src/Forms/Rendering/DefaultFormRenderer.php', + 'Nette\\Forms\\Rule' => $vendorDir . '/nette/forms/src/Forms/Rule.php', + 'Nette\\Forms\\Rules' => $vendorDir . '/nette/forms/src/Forms/Rules.php', + 'Nette\\Forms\\Validator' => $vendorDir . '/nette/forms/src/Forms/Validator.php', + 'Nette\\HtmlStringable' => $vendorDir . '/nette/utils/src/Utils/HtmlStringable.php', + 'Nette\\Http\\Context' => $vendorDir . '/nette/http/src/Http/Context.php', + 'Nette\\Http\\FileUpload' => $vendorDir . '/nette/http/src/Http/FileUpload.php', + 'Nette\\Http\\Helpers' => $vendorDir . '/nette/http/src/Http/Helpers.php', + 'Nette\\Http\\IRequest' => $vendorDir . '/nette/http/src/Http/IRequest.php', + 'Nette\\Http\\IResponse' => $vendorDir . '/nette/http/src/Http/IResponse.php', + 'Nette\\Http\\Request' => $vendorDir . '/nette/http/src/Http/Request.php', + 'Nette\\Http\\RequestFactory' => $vendorDir . '/nette/http/src/Http/RequestFactory.php', + 'Nette\\Http\\Response' => $vendorDir . '/nette/http/src/Http/Response.php', + 'Nette\\Http\\Session' => $vendorDir . '/nette/http/src/Http/Session.php', + 'Nette\\Http\\SessionSection' => $vendorDir . '/nette/http/src/Http/SessionSection.php', + 'Nette\\Http\\Url' => $vendorDir . '/nette/http/src/Http/Url.php', + 'Nette\\Http\\UrlImmutable' => $vendorDir . '/nette/http/src/Http/UrlImmutable.php', + 'Nette\\Http\\UrlScript' => $vendorDir . '/nette/http/src/Http/UrlScript.php', + 'Nette\\Http\\UserStorage' => $vendorDir . '/nette/http/src/Http/UserStorage.php', + 'Nette\\IOException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\InvalidArgumentException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\InvalidStateException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Iterators\\CachingIterator' => $vendorDir . '/nette/utils/src/Iterators/CachingIterator.php', + 'Nette\\Iterators\\Mapper' => $vendorDir . '/nette/utils/src/Iterators/Mapper.php', + 'Nette\\Localization\\ITranslator' => $vendorDir . '/nette/utils/src/compatibility.php', + 'Nette\\Localization\\Translator' => $vendorDir . '/nette/utils/src/Utils/Translator.php', + 'Nette\\MemberAccessException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\NotImplementedException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\NotSupportedException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\OutOfRangeException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\SmartObject' => $vendorDir . '/nette/utils/src/Utils/SmartObject.php', + 'Nette\\StaticClass' => $vendorDir . '/nette/utils/src/Utils/StaticClass.php', + 'Nette\\UnexpectedValueException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\ArrayHash' => $vendorDir . '/nette/utils/src/Utils/ArrayHash.php', + 'Nette\\Utils\\ArrayList' => $vendorDir . '/nette/utils/src/Utils/ArrayList.php', + 'Nette\\Utils\\Arrays' => $vendorDir . '/nette/utils/src/Utils/Arrays.php', + 'Nette\\Utils\\AssertionException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Callback' => $vendorDir . '/nette/utils/src/Utils/Callback.php', + 'Nette\\Utils\\DateTime' => $vendorDir . '/nette/utils/src/Utils/DateTime.php', + 'Nette\\Utils\\FileSystem' => $vendorDir . '/nette/utils/src/Utils/FileSystem.php', + 'Nette\\Utils\\Floats' => $vendorDir . '/nette/utils/src/Utils/Floats.php', + 'Nette\\Utils\\Helpers' => $vendorDir . '/nette/utils/src/Utils/Helpers.php', + 'Nette\\Utils\\Html' => $vendorDir . '/nette/utils/src/Utils/Html.php', + 'Nette\\Utils\\IHtmlString' => $vendorDir . '/nette/utils/src/compatibility.php', + 'Nette\\Utils\\Image' => $vendorDir . '/nette/utils/src/Utils/Image.php', + 'Nette\\Utils\\ImageException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Json' => $vendorDir . '/nette/utils/src/Utils/Json.php', + 'Nette\\Utils\\JsonException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\ObjectHelpers' => $vendorDir . '/nette/utils/src/Utils/ObjectHelpers.php', + 'Nette\\Utils\\ObjectMixin' => $vendorDir . '/nette/utils/src/Utils/ObjectMixin.php', + 'Nette\\Utils\\Paginator' => $vendorDir . '/nette/utils/src/Utils/Paginator.php', + 'Nette\\Utils\\Random' => $vendorDir . '/nette/utils/src/Utils/Random.php', + 'Nette\\Utils\\Reflection' => $vendorDir . '/nette/utils/src/Utils/Reflection.php', + 'Nette\\Utils\\RegexpException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Strings' => $vendorDir . '/nette/utils/src/Utils/Strings.php', + 'Nette\\Utils\\UnknownImageFileException' => $vendorDir . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Validators' => $vendorDir . '/nette/utils/src/Utils/Validators.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..b7fc012 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/inc'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..e0490ee --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,57 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitabaead69424d0311da80db64174e22cf::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/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..dc3913f --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,133 @@ + + array ( + 'Develtio\\WP\\Forms\\' => 18, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Develtio\\WP\\Forms\\' => + array ( + 0 => __DIR__ . '/../..' . '/inc', + ), + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'Nette\\ArgumentOutOfRangeException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Bridges\\FormsDI\\FormsExtension' => __DIR__ . '/..' . '/nette/forms/src/Bridges/FormsDI/FormsExtension.php', + 'Nette\\Bridges\\FormsLatte\\FormMacros' => __DIR__ . '/..' . '/nette/forms/src/Bridges/FormsLatte/FormMacros.php', + 'Nette\\Bridges\\FormsLatte\\Runtime' => __DIR__ . '/..' . '/nette/forms/src/Bridges/FormsLatte/Runtime.php', + 'Nette\\Bridges\\HttpDI\\HttpExtension' => __DIR__ . '/..' . '/nette/http/src/Bridges/HttpDI/HttpExtension.php', + 'Nette\\Bridges\\HttpDI\\SessionExtension' => __DIR__ . '/..' . '/nette/http/src/Bridges/HttpDI/SessionExtension.php', + 'Nette\\Bridges\\HttpTracy\\SessionPanel' => __DIR__ . '/..' . '/nette/http/src/Bridges/HttpTracy/SessionPanel.php', + 'Nette\\ComponentModel\\ArrayAccess' => __DIR__ . '/..' . '/nette/component-model/src/ComponentModel/ArrayAccess.php', + 'Nette\\ComponentModel\\Component' => __DIR__ . '/..' . '/nette/component-model/src/ComponentModel/Component.php', + 'Nette\\ComponentModel\\Container' => __DIR__ . '/..' . '/nette/component-model/src/ComponentModel/Container.php', + 'Nette\\ComponentModel\\IComponent' => __DIR__ . '/..' . '/nette/component-model/src/ComponentModel/IComponent.php', + 'Nette\\ComponentModel\\IContainer' => __DIR__ . '/..' . '/nette/component-model/src/ComponentModel/IContainer.php', + 'Nette\\ComponentModel\\RecursiveComponentIterator' => __DIR__ . '/..' . '/nette/component-model/src/ComponentModel/RecursiveComponentIterator.php', + 'Nette\\DeprecatedException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\DirectoryNotFoundException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\FileNotFoundException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Forms\\Container' => __DIR__ . '/..' . '/nette/forms/src/Forms/Container.php', + 'Nette\\Forms\\ControlGroup' => __DIR__ . '/..' . '/nette/forms/src/Forms/ControlGroup.php', + 'Nette\\Forms\\Controls\\BaseControl' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/BaseControl.php', + 'Nette\\Forms\\Controls\\Button' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/Button.php', + 'Nette\\Forms\\Controls\\Checkbox' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/Checkbox.php', + 'Nette\\Forms\\Controls\\CheckboxList' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/CheckboxList.php', + 'Nette\\Forms\\Controls\\ChoiceControl' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/ChoiceControl.php', + 'Nette\\Forms\\Controls\\CsrfProtection' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/CsrfProtection.php', + 'Nette\\Forms\\Controls\\HiddenField' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/HiddenField.php', + 'Nette\\Forms\\Controls\\ImageButton' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/ImageButton.php', + 'Nette\\Forms\\Controls\\MultiChoiceControl' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/MultiChoiceControl.php', + 'Nette\\Forms\\Controls\\MultiSelectBox' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/MultiSelectBox.php', + 'Nette\\Forms\\Controls\\RadioList' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/RadioList.php', + 'Nette\\Forms\\Controls\\SelectBox' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/SelectBox.php', + 'Nette\\Forms\\Controls\\SubmitButton' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/SubmitButton.php', + 'Nette\\Forms\\Controls\\TextArea' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/TextArea.php', + 'Nette\\Forms\\Controls\\TextBase' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/TextBase.php', + 'Nette\\Forms\\Controls\\TextInput' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/TextInput.php', + 'Nette\\Forms\\Controls\\UploadControl' => __DIR__ . '/..' . '/nette/forms/src/Forms/Controls/UploadControl.php', + 'Nette\\Forms\\Form' => __DIR__ . '/..' . '/nette/forms/src/Forms/Form.php', + 'Nette\\Forms\\Helpers' => __DIR__ . '/..' . '/nette/forms/src/Forms/Helpers.php', + 'Nette\\Forms\\IControl' => __DIR__ . '/..' . '/nette/forms/src/Forms/IControl.php', + 'Nette\\Forms\\IFormRenderer' => __DIR__ . '/..' . '/nette/forms/src/Forms/IFormRenderer.php', + 'Nette\\Forms\\ISubmitterControl' => __DIR__ . '/..' . '/nette/forms/src/Forms/ISubmitterControl.php', + 'Nette\\Forms\\Rendering\\DefaultFormRenderer' => __DIR__ . '/..' . '/nette/forms/src/Forms/Rendering/DefaultFormRenderer.php', + 'Nette\\Forms\\Rule' => __DIR__ . '/..' . '/nette/forms/src/Forms/Rule.php', + 'Nette\\Forms\\Rules' => __DIR__ . '/..' . '/nette/forms/src/Forms/Rules.php', + 'Nette\\Forms\\Validator' => __DIR__ . '/..' . '/nette/forms/src/Forms/Validator.php', + 'Nette\\HtmlStringable' => __DIR__ . '/..' . '/nette/utils/src/Utils/HtmlStringable.php', + 'Nette\\Http\\Context' => __DIR__ . '/..' . '/nette/http/src/Http/Context.php', + 'Nette\\Http\\FileUpload' => __DIR__ . '/..' . '/nette/http/src/Http/FileUpload.php', + 'Nette\\Http\\Helpers' => __DIR__ . '/..' . '/nette/http/src/Http/Helpers.php', + 'Nette\\Http\\IRequest' => __DIR__ . '/..' . '/nette/http/src/Http/IRequest.php', + 'Nette\\Http\\IResponse' => __DIR__ . '/..' . '/nette/http/src/Http/IResponse.php', + 'Nette\\Http\\Request' => __DIR__ . '/..' . '/nette/http/src/Http/Request.php', + 'Nette\\Http\\RequestFactory' => __DIR__ . '/..' . '/nette/http/src/Http/RequestFactory.php', + 'Nette\\Http\\Response' => __DIR__ . '/..' . '/nette/http/src/Http/Response.php', + 'Nette\\Http\\Session' => __DIR__ . '/..' . '/nette/http/src/Http/Session.php', + 'Nette\\Http\\SessionSection' => __DIR__ . '/..' . '/nette/http/src/Http/SessionSection.php', + 'Nette\\Http\\Url' => __DIR__ . '/..' . '/nette/http/src/Http/Url.php', + 'Nette\\Http\\UrlImmutable' => __DIR__ . '/..' . '/nette/http/src/Http/UrlImmutable.php', + 'Nette\\Http\\UrlScript' => __DIR__ . '/..' . '/nette/http/src/Http/UrlScript.php', + 'Nette\\Http\\UserStorage' => __DIR__ . '/..' . '/nette/http/src/Http/UserStorage.php', + 'Nette\\IOException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\InvalidArgumentException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\InvalidStateException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Iterators\\CachingIterator' => __DIR__ . '/..' . '/nette/utils/src/Iterators/CachingIterator.php', + 'Nette\\Iterators\\Mapper' => __DIR__ . '/..' . '/nette/utils/src/Iterators/Mapper.php', + 'Nette\\Localization\\ITranslator' => __DIR__ . '/..' . '/nette/utils/src/compatibility.php', + 'Nette\\Localization\\Translator' => __DIR__ . '/..' . '/nette/utils/src/Utils/Translator.php', + 'Nette\\MemberAccessException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\NotImplementedException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\NotSupportedException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\OutOfRangeException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\SmartObject' => __DIR__ . '/..' . '/nette/utils/src/Utils/SmartObject.php', + 'Nette\\StaticClass' => __DIR__ . '/..' . '/nette/utils/src/Utils/StaticClass.php', + 'Nette\\UnexpectedValueException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\ArrayHash' => __DIR__ . '/..' . '/nette/utils/src/Utils/ArrayHash.php', + 'Nette\\Utils\\ArrayList' => __DIR__ . '/..' . '/nette/utils/src/Utils/ArrayList.php', + 'Nette\\Utils\\Arrays' => __DIR__ . '/..' . '/nette/utils/src/Utils/Arrays.php', + 'Nette\\Utils\\AssertionException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Callback' => __DIR__ . '/..' . '/nette/utils/src/Utils/Callback.php', + 'Nette\\Utils\\DateTime' => __DIR__ . '/..' . '/nette/utils/src/Utils/DateTime.php', + 'Nette\\Utils\\FileSystem' => __DIR__ . '/..' . '/nette/utils/src/Utils/FileSystem.php', + 'Nette\\Utils\\Floats' => __DIR__ . '/..' . '/nette/utils/src/Utils/Floats.php', + 'Nette\\Utils\\Helpers' => __DIR__ . '/..' . '/nette/utils/src/Utils/Helpers.php', + 'Nette\\Utils\\Html' => __DIR__ . '/..' . '/nette/utils/src/Utils/Html.php', + 'Nette\\Utils\\IHtmlString' => __DIR__ . '/..' . '/nette/utils/src/compatibility.php', + 'Nette\\Utils\\Image' => __DIR__ . '/..' . '/nette/utils/src/Utils/Image.php', + 'Nette\\Utils\\ImageException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Json' => __DIR__ . '/..' . '/nette/utils/src/Utils/Json.php', + 'Nette\\Utils\\JsonException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\ObjectHelpers' => __DIR__ . '/..' . '/nette/utils/src/Utils/ObjectHelpers.php', + 'Nette\\Utils\\ObjectMixin' => __DIR__ . '/..' . '/nette/utils/src/Utils/ObjectMixin.php', + 'Nette\\Utils\\Paginator' => __DIR__ . '/..' . '/nette/utils/src/Utils/Paginator.php', + 'Nette\\Utils\\Random' => __DIR__ . '/..' . '/nette/utils/src/Utils/Random.php', + 'Nette\\Utils\\Reflection' => __DIR__ . '/..' . '/nette/utils/src/Utils/Reflection.php', + 'Nette\\Utils\\RegexpException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Strings' => __DIR__ . '/..' . '/nette/utils/src/Utils/Strings.php', + 'Nette\\Utils\\UnknownImageFileException' => __DIR__ . '/..' . '/nette/utils/src/Utils/exceptions.php', + 'Nette\\Utils\\Validators' => __DIR__ . '/..' . '/nette/utils/src/Utils/Validators.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitabaead69424d0311da80db64174e22cf::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitabaead69424d0311da80db64174e22cf::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitabaead69424d0311da80db64174e22cf::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/composer.lock b/vendor/composer/installed.json similarity index 59% rename from composer.lock rename to vendor/composer/installed.json index fdbaef7..7ac02ab 100644 --- a/composer.lock +++ b/vendor/composer/installed.json @@ -1,151 +1,9 @@ { - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "29e1cafce5905fac224e9d3c959a8ce3", "packages": [ - { - "name": "composer/installers", - "version": "v1.9.0", - "source": { - "type": "git", - "url": "https://github.com/composer/installers.git", - "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/b93bcf0fa1fccb0b7d176b0967d969691cd74cca", - "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0 || ^2.0" - }, - "replace": { - "roundcube/plugin-installer": "*", - "shama/baton": "*" - }, - "require-dev": { - "composer/composer": "1.6.* || 2.0.*@dev", - "composer/semver": "1.0.* || 2.0.*@dev", - "phpunit/phpunit": "^4.8.36", - "sebastian/comparator": "^1.2.4", - "symfony/process": "^2.3" - }, - "type": "composer-plugin", - "extra": { - "class": "Composer\\Installers\\Plugin", - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "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", - "MantisBT", - "Mautic", - "Maya", - "OXID", - "Plentymarkets", - "Porto", - "RadPHP", - "SMF", - "Thelia", - "Whmcs", - "WolfCMS", - "agl", - "aimeos", - "annotatecms", - "attogram", - "bitrix", - "cakephp", - "chef", - "cockpit", - "codeigniter", - "concrete5", - "croogo", - "dokuwiki", - "drupal", - "eZ Platform", - "elgg", - "expressionengine", - "fuelphp", - "grav", - "installer", - "itop", - "joomla", - "known", - "kohana", - "laravel", - "lavalite", - "lithium", - "magento", - "majima", - "mako", - "mediawiki", - "modulework", - "modx", - "moodle", - "osclass", - "phpbb", - "piwik", - "ppi", - "puppet", - "pxcms", - "reindex", - "roundcube", - "shopware", - "silverstripe", - "sydes", - "sylius", - "symfony", - "typo3", - "wordpress", - "yawik", - "zend", - "zikula" - ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2020-04-07T06:57:05+00:00" - }, { "name": "nette/component-model", "version": "v3.0.1", + "version_normalized": "3.0.1.0", "source": { "type": "git", "url": "https://github.com/nette/component-model.git", @@ -166,12 +24,14 @@ "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, + "time": "2020-04-21T13:48:20+00:00", "type": "library", "extra": { "branch-alias": { "dev-master": "3.0-dev" } }, + "installation-source": "dist", "autoload": { "classmap": [ "src/" @@ -199,20 +59,25 @@ "components", "nette" ], - "time": "2020-04-21T13:48:20+00:00" + "support": { + "issues": "https://github.com/nette/component-model/issues", + "source": "https://github.com/nette/component-model/tree/v3.0.1" + }, + "install-path": "../nette/component-model" }, { "name": "nette/forms", - "version": "v3.0.6", + "version": "v3.0.7", + "version_normalized": "3.0.7.0", "source": { "type": "git", "url": "https://github.com/nette/forms.git", - "reference": "ecb5f7b8c82585c5fc4698ccb6815542fe6b2db4" + "reference": "cfe069b5880e07930e92058b774f22e491aa7b0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/forms/zipball/ecb5f7b8c82585c5fc4698ccb6815542fe6b2db4", - "reference": "ecb5f7b8c82585c5fc4698ccb6815542fe6b2db4", + "url": "https://api.github.com/repos/nette/forms/zipball/cfe069b5880e07930e92058b774f22e491aa7b0e", + "reference": "cfe069b5880e07930e92058b774f22e491aa7b0e", "shasum": "" }, "require": { @@ -232,12 +97,14 @@ "phpstan/phpstan-nette": "^0.12", "tracy/tracy": "^2.4" }, + "time": "2020-11-02T15:52:20+00:00", "type": "library", "extra": { "branch-alias": { "dev-master": "3.0-dev" } }, + "installation-source": "dist", "autoload": { "classmap": [ "src/" @@ -269,20 +136,25 @@ "nette", "validation" ], - "time": "2020-07-13T12:29:50+00:00" + "support": { + "issues": "https://github.com/nette/forms/issues", + "source": "https://github.com/nette/forms/tree/v3.0.7" + }, + "install-path": "../nette/forms" }, { "name": "nette/http", - "version": "v3.0.4", + "version": "v3.0.5", + "version_normalized": "3.0.5.0", "source": { "type": "git", "url": "https://github.com/nette/http.git", - "reference": "e4d8d360c66c8af9512ca13ab629d312af2b3ce3" + "reference": "24647c6c52a9ed008b2d39494a8c4fc23c48e487" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/http/zipball/e4d8d360c66c8af9512ca13ab629d312af2b3ce3", - "reference": "e4d8d360c66c8af9512ca13ab629d312af2b3ce3", + "url": "https://api.github.com/repos/nette/http/zipball/24647c6c52a9ed008b2d39494a8c4fc23c48e487", + "reference": "24647c6c52a9ed008b2d39494a8c4fc23c48e487", "shasum": "" }, "require": { @@ -303,12 +175,14 @@ "ext-fileinfo": "to detect type of uploaded files", "nette/security": "allows use Nette\\Http\\UserStorage" }, + "time": "2020-11-02T15:42:36+00:00", "type": "library", "extra": { "branch-alias": { "dev-master": "3.0-dev" } }, + "installation-source": "dist", "autoload": { "classmap": [ "src/" @@ -343,24 +217,32 @@ "session", "url" ], - "time": "2020-03-31T13:31:41+00:00" + "support": { + "issues": "https://github.com/nette/http/issues", + "source": "https://github.com/nette/http/tree/v3.0.5" + }, + "install-path": "../nette/http" }, { "name": "nette/utils", - "version": "v3.1.2", + "version": "v3.2.0", + "version_normalized": "3.2.0.0", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "488f58378bba71767e7831c83f9e0fa808bf83b9" + "reference": "d0427c1811462dbb6c503143eabe5478b26685f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/488f58378bba71767e7831c83f9e0fa808bf83b9", - "reference": "488f58378bba71767e7831c83f9e0fa808bf83b9", + "url": "https://api.github.com/repos/nette/utils/zipball/d0427c1811462dbb6c503143eabe5478b26685f7", + "reference": "d0427c1811462dbb6c503143eabe5478b26685f7", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2 <8.1" + }, + "conflict": { + "nette/di": "<3.0.6" }, "require-dev": { "nette/tester": "~2.0", @@ -376,12 +258,14 @@ "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", "ext-xml": "to use Strings::length() etc. when mbstring is not available" }, + "time": "2020-11-25T23:47:50+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, + "installation-source": "dist", "autoload": { "classmap": [ "src/" @@ -403,7 +287,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", "homepage": "https://nette.org", "keywords": [ "array", @@ -421,16 +305,13 @@ "utility", "validation" ], - "time": "2020-05-27T09:58:51+00:00" + "support": { + "issues": "https://github.com/nette/utils/issues", + "source": "https://github.com/nette/utils/tree/v3.2.0" + }, + "install-path": "../nette/utils" } ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "1.1.0" + "dev": true, + "dev-package-names": [] } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..7e0cbf3 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,60 @@ + + array ( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'aliases' => + array ( + ), + 'reference' => NULL, + 'name' => 'develtio/develtio-wp-forms', + ), + 'versions' => + array ( + 'develtio/develtio-wp-forms' => + array ( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'aliases' => + array ( + ), + 'reference' => NULL, + ), + 'nette/component-model' => + array ( + 'pretty_version' => 'v3.0.1', + 'version' => '3.0.1.0', + 'aliases' => + array ( + ), + 'reference' => '66409cf5507c77edb46ffa88cf6a92ff58395601', + ), + 'nette/forms' => + array ( + 'pretty_version' => 'v3.0.7', + 'version' => '3.0.7.0', + 'aliases' => + array ( + ), + 'reference' => 'cfe069b5880e07930e92058b774f22e491aa7b0e', + ), + 'nette/http' => + array ( + 'pretty_version' => 'v3.0.5', + 'version' => '3.0.5.0', + 'aliases' => + array ( + ), + 'reference' => '24647c6c52a9ed008b2d39494a8c4fc23c48e487', + ), + 'nette/utils' => + array ( + 'pretty_version' => 'v3.2.0', + 'version' => '3.2.0.0', + 'aliases' => + array ( + ), + 'reference' => 'd0427c1811462dbb6c503143eabe5478b26685f7', + ), + ), +); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..589e9e7 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70200)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/nette/component-model/.phpstorm.meta.php b/vendor/nette/component-model/.phpstorm.meta.php new file mode 100644 index 0000000..9804e5a --- /dev/null +++ b/vendor/nette/component-model/.phpstorm.meta.php @@ -0,0 +1,7 @@ + '@'])); diff --git a/vendor/nette/component-model/composer.json b/vendor/nette/component-model/composer.json new file mode 100644 index 0000000..586f7b7 --- /dev/null +++ b/vendor/nette/component-model/composer.json @@ -0,0 +1,39 @@ +{ + "name": "nette/component-model", + "description": "⚛ Nette Component Model", + "keywords": ["nette", "components"], + "homepage": "https://nette.org", + "license": ["BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only"], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "require": { + "php": ">=7.1", + "nette/utils": "^2.5 || ^3.0" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3", + "phpstan/phpstan": "^0.12" + }, + "autoload": { + "classmap": ["src/"] + }, + "minimum-stability": "dev", + "scripts": { + "phpstan": "phpstan analyse --level 8 src", + "tester": "tester tests -s" + }, + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + } +} diff --git a/vendor/nette/component-model/contributing.md b/vendor/nette/component-model/contributing.md new file mode 100644 index 0000000..184152c --- /dev/null +++ b/vendor/nette/component-model/contributing.md @@ -0,0 +1,33 @@ +How to contribute & use the issue tracker +========================================= + +Nette welcomes your contributions. There are several ways to help out: + +* Create an issue on GitHub, if you have found a bug +* Write test cases for open bug issues +* Write fixes for open bug/feature issues, preferably with test cases included +* Contribute to the [documentation](https://nette.org/en/writing) + +Issues +------ + +Please **do not use the issue tracker to ask questions**. We will be happy to help you +on [Nette forum](https://forum.nette.org) or chat with us on [Gitter](https://gitter.im/nette/nette). + +A good bug report shouldn't leave others needing to chase you up for more +information. Please try to be as detailed as possible in your report. + +**Feature requests** are welcome. But take a moment to find out whether your idea +fits with the scope and aims of the project. It's up to *you* to make a strong +case to convince the project's developers of the merits of this feature. + +Contributing +------------ + +If you'd like to contribute, please take a moment to read [the contributing guide](https://nette.org/en/contributing). + +The best way to propose a feature is to discuss your ideas on [Nette forum](https://forum.nette.org) before implementing them. + +Please do not fix whitespace, format code, or make a purely cosmetic patch. + +Thanks! :heart: diff --git a/vendor/nette/component-model/license.md b/vendor/nette/component-model/license.md new file mode 100644 index 0000000..cf741bd --- /dev/null +++ b/vendor/nette/component-model/license.md @@ -0,0 +1,60 @@ +Licenses +======== + +Good news! You may use Nette Framework under the terms of either +the New BSD License or the GNU General Public License (GPL) version 2 or 3. + +The BSD License is recommended for most projects. It is easy to understand and it +places almost no restrictions on what you can do with the framework. If the GPL +fits better to your project, you can use the framework under this license. + +You don't have to notify anyone which license you are using. You can freely +use Nette Framework in commercial projects as long as the copyright header +remains intact. + +Please be advised that the name "Nette Framework" is a protected trademark and its +usage has some limitations. So please do not use word "Nette" in the name of your +project or top-level domain, and choose a name that stands on its own merits. +If your stuff is good, it will not take long to establish a reputation for yourselves. + + +New BSD License +--------------- + +Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of "Nette Framework" nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are +disclaimed. In no event shall the copyright owner or contributors be liable for +any direct, indirect, incidental, special, exemplary, or consequential damages +(including, but not limited to, procurement of substitute goods or services; +loss of use, data, or profits; or business interruption) however caused and on +any theory of liability, whether in contract, strict liability, or tort +(including negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. + + +GNU General Public License +-------------------------- + +GPL licenses are very very long, so instead of including them here we offer +you URLs with full text: + +- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html) +- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html) diff --git a/vendor/nette/component-model/readme.md b/vendor/nette/component-model/readme.md new file mode 100644 index 0000000..478b6c2 --- /dev/null +++ b/vendor/nette/component-model/readme.md @@ -0,0 +1,31 @@ +Nette Component Model +===================== + +[![Downloads this Month](https://img.shields.io/packagist/dm/nette/component-model.svg)](https://packagist.org/packages/nette/component-model) +[![Build Status](https://travis-ci.org/nette/component-model.svg?branch=master)](https://travis-ci.org/nette/component-model) +[![Coverage Status](https://coveralls.io/repos/github/nette/component-model/badge.svg?branch=master)](https://coveralls.io/github/nette/component-model?branch=master) +[![Latest Stable Version](https://poser.pugx.org/nette/component-model/v/stable)](https://github.com/nette/component-model/releases) +[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/component-model/blob/master/license.md) + + +Introduction +------------ + +Components are the foundation of reusable code. They make your work easier and allow you to profit from community work. Components are wonderful. +Nette Framework introduces several classes and interfaces for all these types of components. + +Documentation can be found on the [website](https://doc.nette.org/components). + +If you like Nette, **[please make a donation now](https://nette.org/donate)**. Thank you! + + +Installation +------------ + +The recommended way to install is via Composer: + +``` +composer require nette/component-model +``` + +It requires PHP version 7.1 and supports PHP up to 7.4. diff --git a/vendor/nette/component-model/src/ComponentModel/ArrayAccess.php b/vendor/nette/component-model/src/ComponentModel/ArrayAccess.php new file mode 100644 index 0000000..3d88e94 --- /dev/null +++ b/vendor/nette/component-model/src/ComponentModel/ArrayAccess.php @@ -0,0 +1,66 @@ +addComponent($component, $name); + } + + + /** + * Returns component specified by name. Throws exception if component doesn't exist. + * @param string|int $name + * @throws Nette\InvalidArgumentException + */ + public function offsetGet($name): IComponent + { + $name = is_int($name) ? (string) $name : $name; + return $this->getComponent($name); + } + + + /** + * Does component specified by name exists? + * @param string|int $name + */ + public function offsetExists($name): bool + { + $name = is_int($name) ? (string) $name : $name; + return $this->getComponent($name, false) !== null; + } + + + /** + * Removes component from the container. + * @param string|int $name + */ + public function offsetUnset($name): void + { + $name = is_int($name) ? (string) $name : $name; + if ($component = $this->getComponent($name, false)) { + $this->removeComponent($component); + } + } +} diff --git a/vendor/nette/component-model/src/ComponentModel/Component.php b/vendor/nette/component-model/src/ComponentModel/Component.php new file mode 100644 index 0000000..a14bff8 --- /dev/null +++ b/vendor/nette/component-model/src/ComponentModel/Component.php @@ -0,0 +1,310 @@ +}> means [type => [obj, depth, path, [attached, detached]]] */ + private $monitors = []; + + + /** + * Finds the closest ancestor specified by class or interface name. + * @param bool $throw throw exception if component doesn't exist? + */ + final public function lookup(?string $type, bool $throw = true): ?IComponent + { + if (!isset($this->monitors[$type])) { // not monitored or not processed yet + $obj = $this->parent; + $path = self::NAME_SEPARATOR . $this->name; + $depth = 1; + while ($obj !== null) { + $parent = $obj->getParent(); + if ($type ? $obj instanceof $type : $parent === null) { + break; + } + $path = self::NAME_SEPARATOR . $obj->getName() . $path; + $depth++; + $obj = $parent; // IComponent::getParent() + if ($obj === $this) { + $obj = null; // prevent cycling + } + } + + if ($obj) { + $this->monitors[$type] = [$obj, $depth, substr($path, 1), []]; + + } else { + $this->monitors[$type] = [null, null, null, []]; // not found + } + } + + if ($throw && $this->monitors[$type][0] === null) { + $message = $this->name !== null + ? "Component '$this->name' is not attached to '$type'." + : "Component of type '" . static::class . "' is not attached to '$type'."; + throw new Nette\InvalidStateException($message); + } + + return $this->monitors[$type][0]; + } + + + /** + * Finds the closest ancestor specified by class or interface name and returns backtrace path. + * A path is the concatenation of component names separated by self::NAME_SEPARATOR. + */ + final public function lookupPath(string $type = null, bool $throw = true): ?string + { + $this->lookup($type, $throw); + return $this->monitors[$type][2]; + } + + + /** + * Starts monitoring of ancestors. + */ + final public function monitor(string $type, callable $attached = null, callable $detached = null): void + { + if (func_num_args() === 1) { + $attached = [$this, 'attached']; + $detached = [$this, 'detached']; + } + if (($obj = $this->lookup($type, false)) && $attached && !in_array([$attached, $detached], $this->monitors[$type][3], true)) { + $attached($obj); + } + $this->monitors[$type][3][] = [$attached, $detached]; // mark as monitored + } + + + /** + * Stops monitoring of ancestors. + */ + final public function unmonitor(string $type): void + { + unset($this->monitors[$type]); + } + + + /** + * This method will be called when the component (or component's parent) + * becomes attached to a monitored object. Do not call this method yourself. + * @deprecated use monitor($type, $attached) + */ + protected function attached(IComponent $obj): void + { + } + + + /** + * This method will be called before the component (or component's parent) + * becomes detached from a monitored object. Do not call this method yourself. + * @deprecated use monitor($type, null, $detached) + */ + protected function detached(IComponent $obj): void + { + } + + + /********************* interface IComponent ****************d*g**/ + + + final public function getName(): ?string + { + return $this->name; + } + + + /** + * Returns the parent container if any. + */ + final public function getParent(): ?IContainer + { + return $this->parent; + } + + + /** + * Sets or removes the parent of this component. This method is managed by containers and should + * not be called by applications + * @return static + * @throws Nette\InvalidStateException + * @internal + */ + public function setParent(?IContainer $parent, string $name = null) + { + if ($parent === null && $this->parent === null && $name !== null) { + $this->name = $name; // just rename + return $this; + + } elseif ($parent === $this->parent && $name === null) { + return $this; // nothing to do + } + + // A component cannot be given a parent if it already has a parent. + if ($this->parent !== null && $parent !== null) { + throw new Nette\InvalidStateException("Component '$this->name' already has a parent."); + } + + // remove from parent? + if ($parent === null) { + $this->refreshMonitors(0); + $this->parent = null; + + } else { // add to parent + $this->validateParent($parent); + $this->parent = $parent; + if ($name !== null) { + $this->name = $name; + } + + $tmp = []; + $this->refreshMonitors(0, $tmp); + } + return $this; + } + + + /** + * Is called by a component when it is about to be set new parent. Descendant can + * override this method to disallow a parent change by throwing an Nette\InvalidStateException + * @throws Nette\InvalidStateException + */ + protected function validateParent(IContainer $parent): void + { + } + + + /** + * Refreshes monitors. + * @param array|null $missing (array = attaching, null = detaching) + * @param array $listeners + */ + private function refreshMonitors(int $depth, array &$missing = null, array &$listeners = []): void + { + if ($this instanceof IContainer) { + foreach ($this->getComponents() as $component) { + if ($component instanceof self) { + $component->refreshMonitors($depth + 1, $missing, $listeners); + } + } + } + + if ($missing === null) { // detaching + foreach ($this->monitors as $type => $rec) { + if (isset($rec[1]) && $rec[1] > $depth) { + if ($rec[3]) { // monitored + $this->monitors[$type] = [null, null, null, $rec[3]]; + foreach ($rec[3] as $pair) { + $listeners[] = [$pair[1], $rec[0]]; + } + } else { // not monitored, just randomly cached + unset($this->monitors[$type]); + } + } + } + + } else { // attaching + foreach ($this->monitors as $type => $rec) { + if (isset($rec[0])) { // is in cache yet + continue; + + } elseif (!$rec[3]) { // not monitored, just randomly cached + unset($this->monitors[$type]); + + } elseif (isset($missing[$type])) { // known from previous lookup + $this->monitors[$type] = [null, null, null, $rec[3]]; + + } else { + unset($this->monitors[$type]); // forces re-lookup + if ($obj = $this->lookup($type, false)) { + foreach ($rec[3] as $pair) { + $listeners[] = [$pair[0], $obj]; + } + } else { + $missing[$type] = true; + } + $this->monitors[$type][3] = $rec[3]; // mark as monitored + } + } + } + + if ($depth === 0) { // call listeners + $prev = []; + foreach ($listeners as $item) { + if ($item[0] && !in_array($item, $prev, true)) { + $item[0]($item[1]); + $prev[] = $item; + } + } + } + } + + + /********************* cloneable, serializable ****************d*g**/ + + + /** + * Object cloning. + */ + public function __clone() + { + if ($this->parent === null) { + return; + + } elseif ($this->parent instanceof Container) { + $this->parent = $this->parent->_isCloning(); + if ($this->parent === null) { // not cloning + $this->refreshMonitors(0); + } + + } else { + $this->parent = null; + $this->refreshMonitors(0); + } + } + + + /** + * Prevents serialization. + */ + final public function __sleep() + { + throw new Nette\NotImplementedException('Object serialization is not supported by class ' . get_class($this)); + } + + + /** + * Prevents unserialization. + */ + final public function __wakeup() + { + throw new Nette\NotImplementedException('Object unserialization is not supported by class ' . get_class($this)); + } +} diff --git a/vendor/nette/component-model/src/ComponentModel/Container.php b/vendor/nette/component-model/src/ComponentModel/Container.php new file mode 100644 index 0000000..c6272f9 --- /dev/null +++ b/vendor/nette/component-model/src/ComponentModel/Container.php @@ -0,0 +1,227 @@ +getName(); + if ($name === null) { + throw new Nette\InvalidStateException("Missing component's name."); + } + } + + if (!preg_match(self::NAME_REGEXP, $name)) { + throw new Nette\InvalidArgumentException("Component name must be non-empty alphanumeric string, '$name' given."); + } + + if (isset($this->components[$name])) { + throw new Nette\InvalidStateException("Component with name '$name' already exists."); + } + + // check circular reference + $obj = $this; + do { + if ($obj === $component) { + throw new Nette\InvalidStateException("Circular reference detected while adding component '$name'."); + } + $obj = $obj->getParent(); + } while ($obj !== null); + + // user checking + $this->validateChildComponent($component); + + if (isset($this->components[$insertBefore])) { + $tmp = []; + foreach ($this->components as $k => $v) { + if ((string) $k === $insertBefore) { + $tmp[$name] = $component; + } + $tmp[$k] = $v; + } + $this->components = $tmp; + } else { + $this->components[$name] = $component; + } + + try { + $component->setParent($this, $name); + } catch (\Throwable $e) { + unset($this->components[$name]); // undo + throw $e; + } + return $this; + } + + + /** + * Removes the component from the container. + */ + public function removeComponent(IComponent $component): void + { + $name = $component->getName(); + if (($this->components[$name] ?? null) !== $component) { + throw new Nette\InvalidArgumentException("Component named '$name' is not located in this container."); + } + + unset($this->components[$name]); + $component->setParent(null); + } + + + /** + * Returns component specified by name or path. + * @param bool $throw throw exception if component doesn't exist? + */ + final public function getComponent(string $name, bool $throw = true): ?IComponent + { + [$name] = $parts = explode(self::NAME_SEPARATOR, $name, 2); + + if (!isset($this->components[$name])) { + if (!preg_match(self::NAME_REGEXP, $name)) { + if ($throw) { + throw new Nette\InvalidArgumentException("Component name must be non-empty alphanumeric string, '$name' given."); + } + return null; + } + + $component = $this->createComponent($name); + if ($component && !isset($this->components[$name])) { + $this->addComponent($component, $name); + } + } + + $component = $this->components[$name] ?? null; + if ($component !== null) { + if (!isset($parts[1])) { + return $component; + + } elseif ($component instanceof IContainer) { + return $component->getComponent($parts[1], $throw); + + } elseif ($throw) { + throw new Nette\InvalidArgumentException("Component with name '$name' is not container and cannot have '$parts[1]' component."); + } + + } elseif ($throw) { + $hint = Nette\Utils\ObjectHelpers::getSuggestion(array_merge( + array_map('strval', array_keys($this->components)), + array_map('lcfirst', preg_filter('#^createComponent([A-Z0-9].*)#', '$1', get_class_methods($this))) + ), $name); + throw new Nette\InvalidArgumentException("Component with name '$name' does not exist" . ($hint ? ", did you mean '$hint'?" : '.')); + } + return null; + } + + + /** + * Component factory. Delegates the creation of components to a createComponent method. + */ + protected function createComponent(string $name): ?IComponent + { + $ucname = ucfirst($name); + $method = 'createComponent' . $ucname; + if ($ucname !== $name && method_exists($this, $method) && (new \ReflectionMethod($this, $method))->getName() === $method) { + $component = $this->$method($name); + if (!$component instanceof IComponent && !isset($this->components[$name])) { + $class = get_class($this); + throw new Nette\UnexpectedValueException("Method $class::$method() did not return or create the desired component."); + } + return $component; + } + return null; + } + + + /** + * Iterates over descendants components. + * @return \Iterator + */ + final public function getComponents(bool $deep = false, string $filterType = null): \Iterator + { + $iterator = new RecursiveComponentIterator($this->components); + if ($deep) { + $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); + } + if ($filterType) { + $iterator = new \CallbackFilterIterator($iterator, function ($item) use ($filterType) { + return $item instanceof $filterType; + }); + } + return $iterator; + } + + + /** + * Descendant can override this method to disallow insert a child by throwing an Nette\InvalidStateException. + * @throws Nette\InvalidStateException + */ + protected function validateChildComponent(IComponent $child): void + { + } + + + /********************* cloneable, serializable ****************d*g**/ + + + /** + * Object cloning. + */ + public function __clone() + { + if ($this->components) { + $oldMyself = reset($this->components)->getParent(); + assert($oldMyself instanceof self); + $oldMyself->cloning = $this; + foreach ($this->components as $name => $component) { + $this->components[$name] = clone $component; + } + $oldMyself->cloning = null; + } + parent::__clone(); + } + + + /** + * Is container cloning now? + * @internal + */ + final public function _isCloning(): ?self + { + return $this->cloning; + } +} diff --git a/vendor/nette/component-model/src/ComponentModel/IComponent.php b/vendor/nette/component-model/src/ComponentModel/IComponent.php new file mode 100644 index 0000000..c962d21 --- /dev/null +++ b/vendor/nette/component-model/src/ComponentModel/IComponent.php @@ -0,0 +1,33 @@ + + */ + function getComponents(): \Iterator; +} diff --git a/vendor/nette/component-model/src/ComponentModel/RecursiveComponentIterator.php b/vendor/nette/component-model/src/ComponentModel/RecursiveComponentIterator.php new file mode 100644 index 0000000..6a43a78 --- /dev/null +++ b/vendor/nette/component-model/src/ComponentModel/RecursiveComponentIterator.php @@ -0,0 +1,45 @@ +current() instanceof IContainer; + } + + + /** + * The sub-iterator for the current element. + * @return \RecursiveIterator + */ + public function getChildren(): \RecursiveIterator + { + return $this->current()->getComponents(); + } + + + /** + * Returns the count of elements. + */ + public function count(): int + { + return iterator_count($this); + } +} diff --git a/vendor/nette/forms/.phpstorm.meta.php b/vendor/nette/forms/.phpstorm.meta.php new file mode 100644 index 0000000..7b299d1 --- /dev/null +++ b/vendor/nette/forms/.phpstorm.meta.php @@ -0,0 +1,8 @@ + '@|Nette\Utils\ArrayHash'])); +override(new \Nette\Forms\Container, map(['' => 'Nette\Forms\Controls\BaseControl'])); diff --git a/vendor/nette/forms/composer.json b/vendor/nette/forms/composer.json new file mode 100644 index 0000000..1f9108f --- /dev/null +++ b/vendor/nette/forms/composer.json @@ -0,0 +1,47 @@ +{ + "name": "nette/forms", + "description": "?? Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.", + "keywords": ["nette", "forms", "validation", "csrf", "javascript", "bootstrap"], + "homepage": "https://nette.org", + "license": ["BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only"], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "require": { + "php": ">=7.1", + "nette/component-model": "^3.0", + "nette/http": "^3.0", + "nette/utils": "^3.0" + }, + "require-dev": { + "nette/application": "^3.0", + "nette/di": "^3.0", + "nette/tester": "^2.0", + "latte/latte": "^2.8", + "tracy/tracy": "^2.4", + "phpstan/phpstan-nette": "^0.12" + }, + "conflict": { + "nette/di": "<3.0-stable" + }, + "autoload": { + "classmap": ["src/"] + }, + "minimum-stability": "dev", + "scripts": { + "phpstan": "phpstan analyse", + "tester": "tester tests -s" + }, + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + } +} diff --git a/vendor/nette/forms/contributing.md b/vendor/nette/forms/contributing.md new file mode 100644 index 0000000..184152c --- /dev/null +++ b/vendor/nette/forms/contributing.md @@ -0,0 +1,33 @@ +How to contribute & use the issue tracker +========================================= + +Nette welcomes your contributions. There are several ways to help out: + +* Create an issue on GitHub, if you have found a bug +* Write test cases for open bug issues +* Write fixes for open bug/feature issues, preferably with test cases included +* Contribute to the [documentation](https://nette.org/en/writing) + +Issues +------ + +Please **do not use the issue tracker to ask questions**. We will be happy to help you +on [Nette forum](https://forum.nette.org) or chat with us on [Gitter](https://gitter.im/nette/nette). + +A good bug report shouldn't leave others needing to chase you up for more +information. Please try to be as detailed as possible in your report. + +**Feature requests** are welcome. But take a moment to find out whether your idea +fits with the scope and aims of the project. It's up to *you* to make a strong +case to convince the project's developers of the merits of this feature. + +Contributing +------------ + +If you'd like to contribute, please take a moment to read [the contributing guide](https://nette.org/en/contributing). + +The best way to propose a feature is to discuss your ideas on [Nette forum](https://forum.nette.org) before implementing them. + +Please do not fix whitespace, format code, or make a purely cosmetic patch. + +Thanks! :heart: diff --git a/vendor/nette/forms/examples/assets/logo.png b/vendor/nette/forms/examples/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..c687118daf018d8cffe3f5622e4e58c45aacd767 GIT binary patch literal 1346 zcmV-I1-<%-P)Px(s7XXYRCwC#SlN=?ItVpr z7cKk$|281d=E*}+x9?k2Q!}1p1QHyU?(6zbE9aVD$Q$^|%C!>ElkU6$1TEfQw^reb z$vMOV1Nbxr=-b9>EQsiM1^PYk#YN5*#;QPi0pE-l4&Ca-Ol1Jy_hK5xrWaqp7Z>2$ zi|((y*omuxRo3AQdB<<_Or_;T#u=a!SW2mHJaln>FmVH>%I_hjl;V=e#E1*QrK`uI z=1&+G5ja5pOt*G`R(b^47hxT}HpverE=RjULS5#MOcadNh^)7h+-(cfT@Vj|)Kr}N z@S=AFSV{yAT4hL`XNsbOOu-!sbHWp7a!hDusbl4?*U2QT;MP8TvIMJdL1$@%fxx|t z{Qx+&8G@P$c9M}1Q#jPq8&z!SBamGmVF;PG`LZv7gOSInnG9iPX?|vk;JmhaBTrk? z*T`<=*h$!VeeSz~6e?#xdl+D0yBCMpye>zV6bYxp=hG*{a1_&`*(s<3fD)SXgV(hK zf=KPcd7Gi*%144K0k%Rk>O>-@qy@SMUu=lxt*!0AC}td|6+1c$jX(hNo?(V50+~>W zB%IFeei}P%FbwDb>|&gN@Nqa;yuVScd6j}^SiqP@zDT-M37S%4?=F4OkxC&A;wQ`M z6*A;wFVkFi!gQ{h(n7FcOZ!=sjRcEvdc+cD0o!US7dhH0EbY9((4d~DL#vf^Wai!y zdOC0rR4#AE0_*`~25!s=ZC29?uU2-=FdMLpVTc#lkut=*)vCJtl-aYi63l{67rLW! zu@ZL};{rE;H23it15Yc5v8BJw+}A7^^*?MbVpVnUO%L@3qIpn?vYcfai-$4z?Bx~N z8`6h_mK%Iu>8SVa{zP|{JRq6)nxMFxg+~A#o?1|fkrND`{0fY_UeWCA@_Vjx< z8nj=|%0JO_3I&+M&Zt6%8q3k1H-i)1*uh%I-L0J6qh}}Wal@Mn!NGObn#sLdoKrG) zNj`Sz8951{DNNNZch2mze%hVXsq+J1`(=xWYgR$3oIa%|Td8S*i%$tr37Fv#m!ou* zNMj__NdXtafE+la0c5Hv=&TV^g;BCOYJG5;3BgIlEn^#Z2%tBSZQ#ls+YpsHM5=B) z_FX>**#F}*&%gC={rSfdUh`><%JYd}{hOx<=a0M?Vl=mkh$Ro#6F5Ibf#=n&LGeD( zKu3Qhul+pF@Yv_eYsrU<-8ed;twN5N4iYs&1^&g&v$zhqz&@;+q|tYNMlPV?X!%5O?4&m(d{31 z#4HZyK9`4l8XMmM@e?SK_^EPRk}X+dpg!ts)brHjc}BN6m^O|H|)?MDsf&Zm_iVotbC+lZQSUwtfjP01~D&N+x9QX8-^I07*qoM6N<$ Ef_3zng8%>k literal 0 HcmV?d00001 diff --git a/vendor/nette/forms/examples/assets/style.css b/vendor/nette/forms/examples/assets/style.css new file mode 100644 index 0000000..e31f88b --- /dev/null +++ b/vendor/nette/forms/examples/assets/style.css @@ -0,0 +1,72 @@ +/** common style for Nette examples */ + +html { + font: 16px/1.5 sans-serif; + border-top: 4.7em solid #F4EBDB; +} + +body { + max-width: 990px; + margin: -4.7em auto 0; + background: white; + color: #333; +} + +h1 { + font-size: 1.9em; + margin: .5em 0 1.5em; + background: url(logo.png) right center no-repeat; + color: #7A7772; + text-shadow: 1px 1px 0 white; +} + +fieldset { + padding: .2em 1em 1em; + margin: .5em 0; + background: #E4F1FC; + border: 1px solid #B2D1EB; +} + +textarea, +select, +input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="image"]):not([type="range"]) { + padding: .3em .5em; + color: black; + background: white; + border: 1px solid silver; +} + +.has-error textarea, +.has-error select, +.has-error input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="image"]):not([type="range"]) { + border-color: #E22; +} + +select { + padding-right: .3em; +} + +input[type="submit"] { + font-size: 120%; +} + +th { + width: 10em; + text-align: right; + font-weight: normal; +} + +.required label { + font-weight: bold; +} + +.error { + color: #E22; + font-weight: bold; + margin-left: 1em; +} + +footer a { + font-size: 70%; + color: gray; +} diff --git a/vendor/nette/forms/examples/basic-example.php b/vendor/nette/forms/examples/basic-example.php new file mode 100644 index 0000000..4219ce9 --- /dev/null +++ b/vendor/nette/forms/examples/basic-example.php @@ -0,0 +1,132 @@ +addGroup('Personal data') + ->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.'); + +$form->addText('name', 'Your name:') + ->setRequired('Enter your name'); + +$form->addText('age', 'Your age:') + ->setRequired('Enter your age') + ->addRule($form::INTEGER, 'Age must be numeric value') + ->addRule($form::RANGE, 'Age must be in range from %d to %d', [10, 100]); + +$form->addRadioList('gender', 'Your gender:', [ + 'm' => 'male', + 'f' => 'female', +]); + +$form->addCheckboxList('colors', 'Favorite colors:', [ + 'r' => 'red', + 'g' => 'green', + 'b' => 'blue', +]); + +$form->addEmail('email', 'Email:') + ->setEmptyValue('@'); + + +// group Shipping address +$form->addGroup('Shipping address') + ->setOption('embedNext', true); + +$form->addCheckbox('send', 'Ship to address') + ->addCondition($form::FILLED) // conditional rule: if is checkbox checked... + ->toggle('sendBox'); // toggle div #sendBox + + +// subgroup +$form->addGroup() + ->setOption('container', Html::el('div')->id('sendBox')); + +$form->addText('street', 'Street:'); + +$form->addText('city', 'City:') + ->addConditionOn($form['send'], $form::FILLED) + ->setRequired('Enter your shipping address'); + +$countries = [ + 'World' => [ + 'bu' => 'Buranda', + 'qu' => 'Qumran', + 'st' => 'Saint Georges Island', + ], + '?' => 'other', +]; +$form->addSelect('country', 'Country:', $countries) + ->setPrompt('Select your country') + ->addConditionOn($form['send'], $form::FILLED) + ->setRequired('Select your country'); + + +// group Your account +$form->addGroup('Your account'); + +$form->addPassword('password', 'Choose password:') + ->setRequired('Choose your password') + ->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); + +$form->addPassword('password2', 'Reenter password:') + ->setRequired('Reenter your password') + ->addRule($form::EQUAL, 'Passwords do not match', $form['password']); + +$form->addUpload('avatar', 'Picture:') + ->addRule($form::IMAGE, 'Uploaded file is not image'); + +$form->addHidden('userid'); + +$form->addTextArea('note', 'Comment:'); + +// group for buttons +$form->addGroup(); + +$form->addSubmit('submit', 'Send'); + + +$form->setDefaults([ + 'name' => 'John Doe', + 'userid' => 231, +]); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues(), [Dumper::COLLAPSE => false]); + exit; +} + + +?> + + +Nette Forms basic example + + + +

Nette Forms basic example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/bootstrap2-rendering.php b/vendor/nette/forms/examples/bootstrap2-rendering.php new file mode 100644 index 0000000..3c83532 --- /dev/null +++ b/vendor/nette/forms/examples/bootstrap2-rendering.php @@ -0,0 +1,97 @@ +getRenderer(); + $renderer->wrappers['controls']['container'] = null; + $renderer->wrappers['pair']['container'] = 'div class=control-group'; + $renderer->wrappers['pair']['.error'] = 'error'; + $renderer->wrappers['control']['container'] = 'div class=controls'; + $renderer->wrappers['label']['container'] = 'div class=control-label'; + $renderer->wrappers['control']['description'] = 'span class=help-inline'; + $renderer->wrappers['control']['errorcontainer'] = 'span class=help-inline'; + $form->getElementPrototype()->class('form-horizontal'); + + foreach ($form->getControls() as $control) { + $type = $control->getOption('type'); + if ($type === 'button') { + $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn'); + $usedPrimary = true; + + } elseif (in_array($type, ['checkbox', 'radio'], true)) { + $control->getSeparatorPrototype()->setName('div')->addClass($type); + } + } +} + + +$form = new Form; +$form->onRender[] = 'makeBootstrap2'; + +$form->addGroup('Personal data'); +$form->addText('name', 'Your name') + ->setRequired('Enter your name'); + +$form->addRadioList('gender', 'Your gender', [ + 'male', 'female', +]); + +$form->addCheckboxList('colors', 'Favorite colors', [ + 'red', 'green', 'blue', +]); + +$form->addSelect('country', 'Country', [ + 'Buranda', 'Qumran', 'Saint Georges Island', +]); + +$form->addCheckbox('send', 'Ship to address'); + +$form->addGroup('Your account'); +$form->addPassword('password', 'Choose password'); +$form->addUpload('avatar', 'Picture'); +$form->addTextArea('note', 'Comment'); + +$form->addGroup(); +$form->addSubmit('submit', 'Send'); +$form->addSubmit('cancel', 'Cancel'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms & Bootstrap v2 rendering example + + + +
+ + + render() ?> +
diff --git a/vendor/nette/forms/examples/bootstrap3-rendering.php b/vendor/nette/forms/examples/bootstrap3-rendering.php new file mode 100644 index 0000000..9166e2c --- /dev/null +++ b/vendor/nette/forms/examples/bootstrap3-rendering.php @@ -0,0 +1,100 @@ +getRenderer(); + $renderer->wrappers['controls']['container'] = null; + $renderer->wrappers['pair']['container'] = 'div class=form-group'; + $renderer->wrappers['pair']['.error'] = 'has-error'; + $renderer->wrappers['control']['container'] = 'div class=col-sm-9'; + $renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"'; + $renderer->wrappers['control']['description'] = 'span class=help-block'; + $renderer->wrappers['control']['errorcontainer'] = 'span class=help-block'; + $form->getElementPrototype()->class('form-horizontal'); + + foreach ($form->getControls() as $control) { + $type = $control->getOption('type'); + if ($type === 'button') { + $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default'); + $usedPrimary = true; + + } elseif (in_array($type, ['text', 'textarea', 'select'], true)) { + $control->getControlPrototype()->addClass('form-control'); + + } elseif (in_array($type, ['checkbox', 'radio'], true)) { + $control->getSeparatorPrototype()->setName('div')->addClass($type); + } + } +} + + +$form = new Form; +$form->onRender[] = 'makeBootstrap3'; + +$form->addGroup('Personal data'); +$form->addText('name', 'Your name') + ->setRequired('Enter your name'); + +$form->addRadioList('gender', 'Your gender', [ + 'male', 'female', +]); + +$form->addCheckboxList('colors', 'Favorite colors', [ + 'red', 'green', 'blue', +]); + +$form->addSelect('country', 'Country', [ + 'Buranda', 'Qumran', 'Saint Georges Island', +]); + +$form->addCheckbox('send', 'Ship to address'); + +$form->addGroup('Your account'); +$form->addPassword('password', 'Choose password'); +$form->addUpload('avatar', 'Picture'); +$form->addTextArea('note', 'Comment'); + +$form->addGroup(); +$form->addSubmit('submit', 'Send'); +$form->addSubmit('cancel', 'Cancel'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms & Bootstrap v3 rendering example + + + +
+ + + render() ?> +
diff --git a/vendor/nette/forms/examples/bootstrap4-rendering.php b/vendor/nette/forms/examples/bootstrap4-rendering.php new file mode 100644 index 0000000..392ef10 --- /dev/null +++ b/vendor/nette/forms/examples/bootstrap4-rendering.php @@ -0,0 +1,107 @@ +getRenderer(); + $renderer->wrappers['controls']['container'] = null; + $renderer->wrappers['pair']['container'] = 'div class="form-group row"'; + $renderer->wrappers['pair']['.error'] = 'has-danger'; + $renderer->wrappers['control']['container'] = 'div class=col-sm-9'; + $renderer->wrappers['label']['container'] = 'div class="col-sm-3 col-form-label"'; + $renderer->wrappers['control']['description'] = 'span class=form-text'; + $renderer->wrappers['control']['errorcontainer'] = 'span class=form-control-feedback'; + $renderer->wrappers['control']['.error'] = 'is-invalid'; + + foreach ($form->getControls() as $control) { + $type = $control->getOption('type'); + if ($type === 'button') { + $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-secondary'); + $usedPrimary = true; + + } elseif (in_array($type, ['text', 'textarea', 'select'], true)) { + $control->getControlPrototype()->addClass('form-control'); + + } elseif ($type === 'file') { + $control->getControlPrototype()->addClass('form-control-file'); + + } elseif (in_array($type, ['checkbox', 'radio'], true)) { + if ($control instanceof Nette\Forms\Controls\Checkbox) { + $control->getLabelPrototype()->addClass('form-check-label'); + } else { + $control->getItemLabelPrototype()->addClass('form-check-label'); + } + $control->getControlPrototype()->addClass('form-check-input'); + $control->getSeparatorPrototype()->setName('div')->addClass('form-check'); + } + } +} + + +$form = new Form; +$form->onRender[] = 'makeBootstrap4'; + +$form->addGroup('Personal data'); +$form->addText('name', 'Your name') + ->setRequired('Enter your name'); + +$form->addRadioList('gender', 'Your gender', [ + 'male', 'female', +]); + +$form->addCheckboxList('colors', 'Favorite colors', [ + 'red', 'green', 'blue', +]); + +$form->addSelect('country', 'Country', [ + 'Buranda', 'Qumran', 'Saint Georges Island', +]); + +$form->addCheckbox('send', 'Ship to address'); + +$form->addGroup('Your account'); +$form->addPassword('password', 'Choose password'); +$form->addUpload('avatar', 'Picture'); +$form->addTextArea('note', 'Comment'); + +$form->addGroup(); +$form->addSubmit('submit', 'Send'); +$form->addSubmit('cancel', 'Cancel'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms & Bootstrap v4 rendering example + + + +
+

Nette Forms & Bootstrap v4 rendering example

+ + render() ?> +
diff --git a/vendor/nette/forms/examples/containers.php b/vendor/nette/forms/examples/containers.php new file mode 100644 index 0000000..b75a4c4 --- /dev/null +++ b/vendor/nette/forms/examples/containers.php @@ -0,0 +1,64 @@ +addGroup('First person'); + +$first = $form->addContainer('first'); +$first->addText('name', 'Your name:'); +$first->addText('email', 'Email:'); +$first->addText('street', 'Street:'); +$first->addText('city', 'City:'); + +// group Second person +$form->addGroup('Second person'); + +$second = $form->addContainer('second'); +$second->addText('name', 'Your name:'); +$second->addText('email', 'Email:'); +$second->addText('street', 'Street:'); +$second->addText('city', 'City:'); + +// group for button +$form->addGroup(); + +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms containers example + + +

Nette Forms containers example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/custom-control.php b/vendor/nette/forms/examples/custom-control.php new file mode 100644 index 0000000..ca1f3d2 --- /dev/null +++ b/vendor/nette/forms/examples/custom-control.php @@ -0,0 +1,140 @@ +addRule([self::class, 'validateDate'], 'Date is invalid.'); + } + + + public function setValue($value) + { + if ($value === null) { + $this->day = $this->month = $this->year = ''; + } else { + $date = Nette\Utils\DateTime::from($value); + $this->day = $date->format('j'); + $this->month = $date->format('n'); + $this->year = $date->format('Y'); + } + return $this; + } + + + public function getValue(): ?DateTimeImmutable + { + return self::validateDate($this) + ? (new DateTimeImmutable)->setDate((int) $this->year, (int) $this->month, (int) $this->day)->setTime(0, 0) + : null; + } + + + public function isFilled(): bool + { + return $this->day !== '' || $this->year !== ''; + } + + + public function loadHttpData(): void + { + $this->day = $this->getHttpData(Form::DATA_LINE, '[day]'); + $this->month = $this->getHttpData(Form::DATA_LINE, '[month]'); + $this->year = $this->getHttpData(Form::DATA_LINE, '[year]'); + } + + + /** + * Generates control's HTML element. + */ + public function getControl() + { + $name = $this->getHtmlName(); + return Html::el('input', [ + 'name' => $name . '[day]', + 'id' => $this->getHtmlId(), + 'value' => $this->day, + 'type' => 'number', + 'min' => 1, + 'max' => 31, + 'data-nette-rules' => Helpers::exportRules($this->getRules()) ?: null, + ]) + + . Helpers::createSelectBox( + [1 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], + [], + $this->month + )->name($name . '[month]') + + . Html::el('input', [ + 'name' => $name . '[year]', + 'value' => $this->year, + 'type' => 'number', + ]); + } + + + public static function validateDate(Nette\Forms\IControl $control): bool + { + return ctype_digit($control->day) + && ctype_digit($control->month) + && ctype_digit($control->year) + && checkdate((int) $control->month, (int) $control->day, (int) $control->year); + } +} + + +Tracy\Debugger::enable(); + +$form = new Form; + +$form['date'] = new DateInput('Date:'); +$form['date']->setDefaultValue(new DateTime); + +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Tracy\Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms custom control example + + + +

Nette Forms custom control example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/custom-rendering.php b/vendor/nette/forms/examples/custom-rendering.php new file mode 100644 index 0000000..6e2cbb3 --- /dev/null +++ b/vendor/nette/forms/examples/custom-rendering.php @@ -0,0 +1,127 @@ +getRenderer(); +$renderer->wrappers['form']['container'] = Html::el('div')->id('form'); +$renderer->wrappers['group']['container'] = null; +$renderer->wrappers['group']['label'] = 'h3'; +$renderer->wrappers['pair']['container'] = null; +$renderer->wrappers['controls']['container'] = 'dl'; +$renderer->wrappers['control']['container'] = 'dd'; +$renderer->wrappers['control']['.odd'] = 'odd'; +$renderer->wrappers['label']['container'] = 'dt'; +$renderer->wrappers['label']['suffix'] = ':'; +$renderer->wrappers['control']['requiredsuffix'] = " \u{2022}"; + + +$form->addGroup('Personal data'); +$form->addText('name', 'Your name') + ->setRequired('Enter your name'); + +$form->addRadioList('gender', 'Your gender', [ + 'm' => Html::el('span', 'male')->style('color: #248bd3'), + 'f' => Html::el('span', 'female')->style('color: #e948d4'), +]); + +$form->addSelect('country', 'Country', [ + 'Buranda', 'Qumran', 'Saint Georges Island', +]); + +$form->addCheckbox('send', 'Ship to address'); + +$form->addGroup('Your account'); +$form->addPassword('password', 'Choose password'); +$form->addUpload('avatar', 'Picture'); +$form->addTextArea('note', 'Comment'); + +$form->addGroup(); +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms custom rendering example + + + + + +

Nette Forms custom rendering example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/custom-validator.php b/vendor/nette/forms/examples/custom-validator.php new file mode 100644 index 0000000..eb2a788 --- /dev/null +++ b/vendor/nette/forms/examples/custom-validator.php @@ -0,0 +1,64 @@ +value % $arg === 0; + } +} + + +$form = new Form; + +$form->addText('num1', 'Multiple of 8:') + ->setDefaultValue(5) + ->addRule('MyValidators::divisibilityValidator', 'First number must be %d multiple', 8); + +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms custom validator example + + + + + +

Nette Forms custom validator example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/html5.php b/vendor/nette/forms/examples/html5.php new file mode 100644 index 0000000..cba484e --- /dev/null +++ b/vendor/nette/forms/examples/html5.php @@ -0,0 +1,66 @@ +addGroup(); + +$form->addText('query', 'Search:') + ->setHtmlType('search') + ->setHtmlAttribute('autofocus'); + +$form->addText('count', 'Number of results:') + ->setHtmlType('number') + ->setDefaultValue(10) + ->addRule($form::INTEGER, 'Must be numeric value') + ->addRule($form::RANGE, 'Must be in range from %d to %d', [1, 100]); + +$form->addText('precision', 'Precision:') + ->setHtmlType('range') + ->setDefaultValue(50) + ->addRule($form::INTEGER, 'Precision must be numeric value') + ->addRule($form::RANGE, 'Precision must be in range from %d to %d', [0, 100]); + +$form->addEmail('email', 'Send to email:') + ->setHtmlAttribute('autocomplete', 'off') + ->setHtmlAttribute('placeholder', 'Optional, but Recommended'); + +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms and HTML5 + + + +

Nette Forms and HTML5

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/latte.php b/vendor/nette/forms/examples/latte.php new file mode 100644 index 0000000..57b35fb --- /dev/null +++ b/vendor/nette/forms/examples/latte.php @@ -0,0 +1,46 @@ +addText('name', 'Your name:') + ->setRequired('Enter your name'); + +$form->addPassword('password', 'Choose password:') + ->setRequired('Choose your password') + ->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); + +$form->addPassword('password2', 'Reenter password:') + ->setRequired('Reenter your password') + ->addRule($form::EQUAL, 'Passwords do not match', $form['password']); + +$form->addSubmit('submit', 'Send'); + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + +$latte = new Latte\Engine; +$latte->onCompile[] = function ($latte) { + Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler()); +}; + +$latte->render('template.latte', ['form' => $form]); diff --git a/vendor/nette/forms/examples/live-validation.php b/vendor/nette/forms/examples/live-validation.php new file mode 100644 index 0000000..82e9ab4 --- /dev/null +++ b/vendor/nette/forms/examples/live-validation.php @@ -0,0 +1,106 @@ +addText('name', 'Your name:') + ->setRequired('Enter your name'); + +$form->addText('age', 'Your age:') + ->setRequired('Enter your age') + ->addRule($form::INTEGER, 'Age must be numeric value') + ->addRule($form::RANGE, 'Age must be in range from %d to %d', [10, 100]); + +$form->addPassword('password', 'Choose password:') + ->setRequired('Choose your password') + ->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); + +$form->addPassword('password2', 'Reenter password:') + ->setRequired('Reenter your password') + ->addRule($form::EQUAL, 'Passwords do not match', $form['password']); + +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + +$renderer = $form->getRenderer(); +$renderer->wrappers['pair']['.error'] = 'has-error'; + +?> + + +Nette Forms live validation example + + + + + + +

Nette Forms live validation example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/localization.ini b/vendor/nette/forms/examples/localization.ini new file mode 100644 index 0000000..f03ef27 --- /dev/null +++ b/vendor/nette/forms/examples/localization.ini @@ -0,0 +1,12 @@ +Personal data = Osobní údaje +Your name: = Jméno: +Enter your name = Zadejte jméno +Your age: = Věk: +Enter your age = Zadejte váš věk +Age must be numeric value = Věk musí být číslo +Age must be in range from %d to %d = Věk musí být v rozmezí %d až %d +Country: = Země: +Select your country = Vyberte zemi +World = Svět +other = jiná +Send = Odeslat diff --git a/vendor/nette/forms/examples/localization.php b/vendor/nette/forms/examples/localization.php new file mode 100644 index 0000000..5ef669b --- /dev/null +++ b/vendor/nette/forms/examples/localization.php @@ -0,0 +1,89 @@ +table = $table; + } + + + /** + * Translates the given string. + */ + public function translate($message, ...$parameters): string + { + return $this->table[$message] ?? $message; + } +} + + +$form = new Form; + +$translator = new MyTranslator(parse_ini_file(__DIR__ . '/localization.ini')); +$form->setTranslator($translator); + +$form->addGroup('Personal data'); +$form->addText('name', 'Your name:') + ->setRequired('Enter your name'); + +$form->addText('age', 'Your age:') + ->setRequired('Enter your age') + ->addRule($form::INTEGER, 'Age must be numeric value') + ->addRule($form::RANGE, 'Age must be in range from %d to %d', [10, 100]); + +$countries = [ + 'World' => [ + 'bu' => 'Buranda', + 'qu' => 'Qumran', + 'st' => 'Saint Georges Island', + ], + '?' => 'other', +]; +$form->addSelect('country', 'Country:', $countries) + ->setPrompt('Select your country'); + +$form->addSubmit('submit', 'Send'); + + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + +Nette Forms localization example + + + +

Nette Forms localization example

+ +render() ?> + + diff --git a/vendor/nette/forms/examples/manual-rendering.php b/vendor/nette/forms/examples/manual-rendering.php new file mode 100644 index 0000000..521af8d --- /dev/null +++ b/vendor/nette/forms/examples/manual-rendering.php @@ -0,0 +1,95 @@ +addText('name') + ->setRequired('Enter your name'); + +$form->addText('age') + ->setRequired('Enter your age'); + +$form->addRadioList('gender', null, [ + 'm' => 'male', + 'f' => 'female', +]); + +$form->addEmail('email'); + +$form->addSubmit('submit'); + +if ($form->isSuccess()) { + echo '

Form was submitted and successfully validated

'; + Dumper::dump($form->getValues()); + exit; +} + + +?> + + + + + Nette Forms manual form rendering + + + + + +

Nette Forms manual form rendering

+ + render('begin') ?> + + errors) { ?> +
    + errors as $error) { ?> +
  • + +
+ + +
+ Personal data + + + + + + + + + + + + + + + + + +
render()['name']->getLabel('Your name:') ?>render()['name']->control->cols(35) ?> render()['name']->error ?>
render()['age']->getLabel('Your age:') ?>render()['age']->control->cols(5) ?> render()['age']->error ?>
render()['gender']->getLabel('Your gender:') ?>render()['gender']->control ?> render()['gender']->error ?>
render()['email']->getLabel('Email:') ?>render()['email']->control->cols(35) ?> render()['email']->error ?>
+
+ +
+ render()['submit']->getControl('Send') ?> +
+ + render('end'); ?> + + diff --git a/vendor/nette/forms/examples/template.latte b/vendor/nette/forms/examples/template.latte new file mode 100644 index 0000000..fbe1a6e --- /dev/null +++ b/vendor/nette/forms/examples/template.latte @@ -0,0 +1,29 @@ + + + + + Nette Forms rendering using Latte + + + + + +

Nette Forms rendering using Latte

+ +
+
    +
  • {$error}
  • +
+ + + + + + + +
{label $input /}{input $input} {$input->error}
+
+ + diff --git a/vendor/nette/forms/license.md b/vendor/nette/forms/license.md new file mode 100644 index 0000000..cf741bd --- /dev/null +++ b/vendor/nette/forms/license.md @@ -0,0 +1,60 @@ +Licenses +======== + +Good news! You may use Nette Framework under the terms of either +the New BSD License or the GNU General Public License (GPL) version 2 or 3. + +The BSD License is recommended for most projects. It is easy to understand and it +places almost no restrictions on what you can do with the framework. If the GPL +fits better to your project, you can use the framework under this license. + +You don't have to notify anyone which license you are using. You can freely +use Nette Framework in commercial projects as long as the copyright header +remains intact. + +Please be advised that the name "Nette Framework" is a protected trademark and its +usage has some limitations. So please do not use word "Nette" in the name of your +project or top-level domain, and choose a name that stands on its own merits. +If your stuff is good, it will not take long to establish a reputation for yourselves. + + +New BSD License +--------------- + +Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of "Nette Framework" nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are +disclaimed. In no event shall the copyright owner or contributors be liable for +any direct, indirect, incidental, special, exemplary, or consequential damages +(including, but not limited to, procurement of substitute goods or services; +loss of use, data, or profits; or business interruption) however caused and on +any theory of liability, whether in contract, strict liability, or tort +(including negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. + + +GNU General Public License +-------------------------- + +GPL licenses are very very long, so instead of including them here we offer +you URLs with full text: + +- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html) +- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html) diff --git a/vendor/nette/forms/package.json b/vendor/nette/forms/package.json new file mode 100644 index 0000000..67e35da --- /dev/null +++ b/vendor/nette/forms/package.json @@ -0,0 +1,21 @@ +{ + "name": "nette-forms", + "version": "3.1.0", + "description": "Client side script for Nette Forms Component", + "keywords": [ + "nette", + "validation", + "forms" + ], + "homepage": "https://nette.org", + "author": "David Grudl (https://davidgrudl.com)", + "license": "BSD-3-Clause", + "main": "src/assets/netteForms.js", + "files": [ + "src/assets" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/nette/forms.git" + } +} diff --git a/vendor/nette/forms/readme.md b/vendor/nette/forms/readme.md new file mode 100644 index 0000000..116f942 --- /dev/null +++ b/vendor/nette/forms/readme.md @@ -0,0 +1,85 @@ +Nette Forms: greatly facilitates web forms +========================================== + +[![Downloads this Month](https://img.shields.io/packagist/dm/nette/forms.svg)](https://packagist.org/packages/nette/forms) +[![Build Status](https://travis-ci.org/nette/forms.svg?branch=master)](https://travis-ci.org/nette/forms) +[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=master)](https://coveralls.io/github/nette/forms?branch=master) +[![Latest Stable Version](https://poser.pugx.org/nette/forms/v/stable)](https://github.com/nette/forms/releases) +[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/forms/blob/master/license.md) + + +Introduction +------------ + +Nette\Forms greatly facilitates creating and processing web forms. What it can really do? + +- validate sent data both client-side (JavaScript) and server-side +- provide high level of security +- multiple render modes +- translations, i18n + +Why should you bother setting up framework for a simple web form? You won't have to take care about routine tasks such as writing two validation scripts (client and server) and your code will be safe against security breaches. + +Nette Framework puts a great effort to be safe and since forms are the most common user input, Nette forms are as good as impenetrable. All is maintained dynamically and transparently, nothing has to be set manually. Well known vulnerabilities such as Cross Site Scripting (XSS) and Cross-Site Request Forgery (CSRF) are filtered, as well as special control characters. All inputs are checked for UTF-8 validity. Every multiple-choice, select box and similar are checked for forged values upon validating. Sounds good? Let's try it out. + +Documentation can be found on the [website](https://doc.nette.org/forms). + +If you like Nette, **[please make a donation now](https://nette.org/donate)**. Thank you! + + +Installation +------------ + +The recommended way to install is via Composer: + +``` +composer require nette/forms +``` + +It requires PHP version 7.1 and supports PHP up to 8.0. + + +Client-side support can be installed with npm or yarn: + +``` +npm install nette-forms +``` + +Usage +----- + +Let's create a simple registration form: + +```php +use Nette\Forms\Form; + +$form = new Form; + +$form->addText('name', 'Name:'); +$form->addPassword('password', 'Password:'); +$form->addSubmit('send', 'Register'); + +echo $form; // renders the form +``` +Though we mentioned validation, yet our form has none. Let's fix it. We require users to tell us their name, so we should call a `setRequired()` method, which optional argument is an error message to show, if user does not fill his name in: + +```php +$form->addText('name', 'Name:') + ->setRequired('Please fill your name.'); +``` + +Try submitting a form without the name - you will keep seeing this message until you meet the validation rules. All that is left for us is setting up JavaScript rules. Luckily it's a piece of cake. We only have to link `netteForms.js`, which is located at `/client-side/forms` in the distribution package. + +```html + +``` + +Nette Framework adds `required` class to all mandatory elements. Adding the following style will turn label of *name* input to red. + +```html + +``` + +[Continue…](https://doc.nette.org/en/forms). diff --git a/vendor/nette/forms/src/Bridges/FormsDI/FormsExtension.php b/vendor/nette/forms/src/Bridges/FormsDI/FormsExtension.php new file mode 100644 index 0000000..5828178 --- /dev/null +++ b/vendor/nette/forms/src/Bridges/FormsDI/FormsExtension.php @@ -0,0 +1,43 @@ +config = new class { + /** @var string[] */ + public $messages = []; + }; + } + + + public function afterCompile(Nette\PhpGenerator\ClassType $class) + { + $initialize = $this->initialization ?? $class->getMethod('initialize'); + + foreach ($this->config->messages as $name => $text) { + if (defined('Nette\Forms\Form::' . $name)) { + $initialize->addBody('Nette\Forms\Validator::$messages[Nette\Forms\Form::?] = ?;', [$name, $text]); + } elseif (defined($name)) { + $initialize->addBody('Nette\Forms\Validator::$messages[' . $name . '] = ?;', [$text]); + } else { + throw new Nette\InvalidArgumentException('Constant Nette\Forms\Form::' . $name . ' or constant ' . $name . ' does not exist.'); + } + } + } +} diff --git a/vendor/nette/forms/src/Bridges/FormsLatte/FormMacros.php b/vendor/nette/forms/src/Bridges/FormsLatte/FormMacros.php new file mode 100644 index 0000000..34137a0 --- /dev/null +++ b/vendor/nette/forms/src/Bridges/FormsLatte/FormMacros.php @@ -0,0 +1,288 @@ +addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));'); + $me->addMacro('formContext', [$me, 'macroFormContext'], 'array_pop($this->global->formsStack);'); + $me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = $_form = end($this->global->formsStack)'); + $me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY); + $me->addMacro('input', [$me, 'macroInput']); + $me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']); + $me->addMacro('inputError', [$me, 'macroInputError']); + $me->addMacro('formPrint', [$me, 'macroFormPrint']); + } + + + /********************* macros ****************d*g**/ + + + /** + * {form ...} + */ + public function macroForm(MacroNode $node, PhpWriter $writer) + { + if ($node->modifiers) { + throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); + } + if ($node->prefix) { + throw new CompileException('Did you mean
?'); + } + $name = $node->tokenizer->fetchWord(); + if ($name == null) { // null or false + throw new CompileException('Missing form name in ' . $node->getNotation()); + } + $node->replaced = true; + $node->tokenizer->reset(); + return $writer->write( + "/* line $node->startLine */\n" + . 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form = $_form = $this->global->formsStack[] = ' + . ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '') + . '$this->global->uiControl[%node.word], %node.array);' + ); + } + + + /** + * {formContext ...} + */ + public function macroFormContext(MacroNode $node, PhpWriter $writer) + { + if ($node->modifiers) { + throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); + } + if ($node->prefix) { + throw new CompileException('Did you mean ?'); + } + $name = $node->tokenizer->fetchWord(); + if ($name == null) { // null or false + throw new CompileException('Missing form name in ' . $node->getNotation()); + } + $node->tokenizer->reset(); + return $writer->write( + '$form = $this->global->formsStack[] = ' + . ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '') + . '$this->global->uiControl[%node.word];' + ); + } + + + /** + * {formContainer ...} + */ + public function macroFormContainer(MacroNode $node, PhpWriter $writer) + { + if ($node->modifiers) { + throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); + } + $name = $node->tokenizer->fetchWord(); + if ($name == null) { // null or false + throw new CompileException('Missing name in ' . $node->getNotation()); + } + $node->tokenizer->reset(); + return $writer->write( + '$this->global->formsStack[] = $formContainer = $_form = ' + . ($name[0] === '$' ? 'is_object(%node.word) ? %node.word : ' : '') + . 'end($this->global->formsStack)[%node.word];' + ); + } + + + /** + * {label ...} + */ + public function macroLabel(MacroNode $node, PhpWriter $writer) + { + if ($node->modifiers) { + throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); + } + $words = $node->tokenizer->fetchWords(); + if (!$words) { + throw new CompileException('Missing name in ' . $node->getNotation()); + } + $node->replaced = true; + $name = array_shift($words); + return $writer->write( + ($name[0] === '$' ? '$_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; if ($_label = $_input' : 'if ($_label = end($this->global->formsStack)[%0.word]') + . '->%1.raw) echo $_label' + . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : ''), + $name, + $words ? ('getLabelPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')') : 'getLabel()' + ); + } + + + /** + * {/label} + */ + public function macroLabelEnd(MacroNode $node, PhpWriter $writer) + { + if ($node->content != null) { + $node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>'; + return $writer->write('if ($_label) echo $_label->endTag()'); + } + } + + + /** + * {input ...} + */ + public function macroInput(MacroNode $node, PhpWriter $writer) + { + if ($node->modifiers) { + throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); + } + $words = $node->tokenizer->fetchWords(); + if (!$words) { + throw new CompileException('Missing name in ' . $node->getNotation()); + } + $node->replaced = true; + $name = array_shift($words); + return $writer->write( + ($name[0] === '$' ? '$_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo $_input' : 'echo end($this->global->formsStack)[%0.word]') + . '->%1.raw' + . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : '') + . " /* line $node->startLine */", + $name, + $words ? 'getControlPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getControl()' + ); + } + + + /** + * , ,