From c62abbd44af7159d23db5171da628cbf1f49d5c4 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 30 Apr 2018 15:02:43 -0500 Subject: [PATCH 1/6] Bumped to next dev version (1.1.1) --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 426f70c..c46f581 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 1.1.1 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + ## 1.1.0 - 2018-04-30 ### Added From 96c584b4d5a03c620ea61c3d4b7435e370470e5c Mon Sep 17 00:00:00 2001 From: webimpress Date: Sun, 20 Oct 2019 21:52:38 +0100 Subject: [PATCH 2/6] Update documentation of the package Use special homepage to render properly documentation page: http://docs.zendframework.com/zend-mvc-plugin-fileprg/ --- README.md | 27 ++++++++- docs/book/index.html | 139 ------------------------------------------- docs/book/index.md | 96 +++++++++++++++++++++++++++++- mkdocs.yml | 9 +-- 4 files changed, 125 insertions(+), 146 deletions(-) delete mode 100644 docs/book/index.html mode change 120000 => 100644 docs/book/index.md diff --git a/README.md b/README.md index 9f7d41d..84a2360 100644 --- a/README.md +++ b/README.md @@ -10,5 +10,28 @@ versions 3.0 and up, specifically for submissions that include file uploads. If you want a generic PRG plugin without file upload support, see [zend-mvc-plugin-prg](https://docs.zendframework.com/zend-mvc-plugin-prg). -- File issues at https://github.com/zendframework/zend-mvc-plugin-fileprg/issues -- Documentation is at https://docs.zendframework.com/zend-mvc-plugin-fileprg/ +## Installation + +Run the following to install this library: + +```bash +$ composer require zendframework/zend-mvc-plugin-fileprg +``` + +If you are using the [zend-component-installer](https://docs.zendframework.com/zend-component-installer/), +you're done! + +If not, you will need to add the component as a module to your +application. Add the entry `'Zend\Mvc\Plugin\FilePrg'` to +your list of modules in your application configuration (typically +one of `config/application.config.php` or `config/modules.config.php`). + +## Documentation + +Browse the documentation online at https://docs.zendframework.com/zend-mvc-plugin-fileprg/ + +## Support + +* [Issues](https://github.com/zendframework/zend-mvc-plugin-fileprg/issues/) +* [Chat](https://zendframework-slack.herokuapp.com/) +* [Forum](https://discourse.zendframework.com/) diff --git a/docs/book/index.html b/docs/book/index.html deleted file mode 100644 index dcaa05f..0000000 --- a/docs/book/index.html +++ /dev/null @@ -1,139 +0,0 @@ -
-
-

zend-mvc-plugin-fileprg

- -

Post/Redirect/Get plugin with file upload handling for zend-mvc controllers.

- -
$ composer require zendframework/zend-mvc-plugin-fileprg
-
-
- -
-
-
-
-
-

Installation

-
- -
-

- Install via composer: -

- -

-$ composer require zendframework/zend-mvc-plugin-fileprg
-          
- -

- If you are using the zend-component-installer, - you're done! -

- -

- If not, you will need to add the component as a module to your - application. Add the entry 'Zend\Mvc\Plugin\FilePrg' to - your list of modules in your application configuration (typically - one of config/application.config.php or - config/modules.config.php). -

-
-
-
- -
-

Usage

- -

- While similar to the Post/Redirect/Get - Plugin, the File PRG Plugin will work for forms with file inputs. - The difference is in the behavior: The File PRG Plugin will interact - directly with your form instance and the file inputs, rather than - only returning the POST params from the previous request. -

- -

- By interacting directly with the form, the File PRG Plugin will turn off any - file inputs required flags for already uploaded files (for a partially valid - form state), as well as run the file input filters to move the uploaded files - into a new location (configured by the user). -

- -
-

Files must be relocated on upload

- -

- You must attach a filter for moving the uploaded files to a new location, such as the - RenameUpload Filter, - or else your files will be removed upon the redirect. -

-
- -

- This plugin is invoked with three arguments: -

- -
    -
  • $form: the Zend\Form\Form instance.
  • -
  • $redirect: (Optional) a string containing the redirect - location, which can either be a named route or a URL, based on the - contents of the third parameter. If this argument is not provided, it - will default to the current matched route.
  • -
  • $redirectToUrl: (Optional) a boolean that when set to - TRUE, causes the second parameter to be treated as a URL - instead of a route name (this is required when redirecting to a URL - instead of a route). This argument defaults to - FALSE.
  • -
- -

Example Usage

- -

-$myForm = new Zend\Form\Form('my-form');
-$myForm->add([
-    'type' => 'Zend\Form\Element\File',
-    'name' => 'file',
-]);
-
-// NOTE: Without a filter to move the file,
-//       our files will disappear between the requests
-$myForm->getInputFilter()->getFilterChain()->attach(
-    new Zend\Filter\File\RenameUpload([
-        'target'    => './data/tmpuploads/file',
-        'randomize' => true,
-    ])
-);
-
-// Pass in the form and optional the route/url you want to redirect to after the POST
-$prg = $this->fileprg($myForm, '/user/profile-pic', true);
-
-if ($prg instanceof \Zend\Http\PhpEnvironment\Response) {
-    // Returned a response to redirect us.
-    return $prg;
-}
-
-if ($prg === false) {
-    // First time the form was loaded.
-    return array('form' => $myForm);
-}
-
-// Form was submitted.
-// $prg is now an array containing the POST params from the previous request,
-// but we don't have to apply it to the form since that has already been done.
-
-// Process the form
-if ($form->isValid()) {
-    // ...Save the form...
-    return $this->redirect()->toRoute('/user/profile-pic/success');
-}
-
-// Form not valid, but file uploads might be valid and uploaded
-$fileErrors = $form->get('file')->getMessages();
-if (empty($fileErrors)) {
-    $tempFile = $form->get('file')->getValue();
-}
-      
-
-
-
diff --git a/docs/book/index.md b/docs/book/index.md deleted file mode 120000 index fe84005..0000000 --- a/docs/book/index.md +++ /dev/null @@ -1 +0,0 @@ -../../README.md \ No newline at end of file diff --git a/docs/book/index.md b/docs/book/index.md new file mode 100644 index 0000000..0fccb90 --- /dev/null +++ b/docs/book/index.md @@ -0,0 +1,95 @@ +## Installation + +Install via composer: + +```bash +$ composer require zendframework/zend-mvc-plugin-fileprg +``` + +If you are using the [zend-component-installer](https://docs.zendframework.com/zend-component-installer/), +you're done! + +If not, you will need to add the component as a module to your +application. Add the entry `'Zend\Mvc\Plugin\FilePrg'` to +your list of modules in your application configuration (typically +one of `config/application.config.php` or `config/modules.config.php`). + +## Usage + +While similar to the [Post/Redirect/Get Plugin](https://docs.zendframework.com/zend-mvc-plugin-prg/), +the File PRG Plugin will work for forms with file inputs. +The difference is in the behavior: The File PRG Plugin will interact +directly with your form instance and the file inputs, rather than +_only_ returning the POST params from the previous request. + +By interacting directly with the form, the File PRG Plugin will turn off any +file inputs `required` flags for already uploaded files (for a partially valid +form state), as well as run the file input filters to move the uploaded files +into a new location (configured by the user). + +> ### Files must be relocated on upload +> +> You __must__ attach a filter for moving the uploaded files to a new location, such as the +> [RenameUpload Filter](https://docs.zendframework.com/zend-filter/file/#renameupload), +> or else your files will be removed upon the redirect. + +This plugin is invoked with three arguments: + +- `$form`: the `Zend\Form\Form` instance. +- `$redirect`: (Optional) a string containing the redirect + location, which can either be a named route or a URL, based on the + contents of the third parameter. If this argument is not provided, it + will default to the current matched route. +- `$redirectToUrl`: (Optional) a boolean that when set to + `true`, causes the second parameter to be treated as a URL + instead of a route name (this is required when redirecting to a URL + instead of a route). This argument defaults to + `false`. + +### Example Usage + +```php +$myForm = new Zend\Form\Form('my-form'); +$myForm->add([ + 'type' => 'Zend\Form\Element\File', + 'name' => 'file', +]); + +// NOTE: Without a filter to move the file, +// our files will disappear between the requests +$myForm->getInputFilter()->getFilterChain()->attach( + new Zend\Filter\File\RenameUpload([ + 'target' => './data/tmpuploads/file', + 'randomize' => true, + ]) +); + +// Pass in the form and optional the route/url you want to redirect to after the POST +$prg = $this->fileprg($myForm, '/user/profile-pic', true); + +if ($prg instanceof Zend\Http\PhpEnvironment\Response) { + // Returned a response to redirect us. + return $prg; +} + +if ($prg === false) { + // First time the form was loaded. + return ['form' => $myForm]; +} + +// Form was submitted. +// $prg is now an array containing the POST params from the previous request, +// but we don't have to apply it to the form since that has already been done. + +// Process the form +if ($form->isValid()) { + // ...Save the form... + return $this->redirect()->toRoute('/user/profile-pic/success'); +} + +// Form not valid, but file uploads might be valid and uploaded +$fileErrors = $form->get('file')->getMessages(); +if (empty($fileErrors)) { + $tempFile = $form->get('file')->getValue(); +} +``` diff --git a/mkdocs.yml b/mkdocs.yml index 1c395de..3ab29b2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,8 +1,9 @@ docs_dir: docs/book site_dir: docs/html -pages: - - index.md +nav: + - Home: index.md site_name: zend-mvc-plugin-fileprg -site_description: 'zend-mvc-plugin-fileprg: Post-Redirect-Get controller plugin specifically for zend-mvc, specifically for handling file uploads' +site_description: 'Post/Redirect/Get plugin with file upload handling for zend-mvc controllers' repo_url: 'https://github.com/zendframework/zend-mvc-plugin-fileprg' -copyright: 'Copyright (c) 2005-2018 Zend Technologies USA Inc.' +extra: + show_special_homepage: true From 105d81eace98d78f13b881a1a86c45e586132916 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 31 Dec 2019 15:43:31 -0600 Subject: [PATCH 3/6] Marking package as abandoned --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84a2360..6628991 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # zend-mvc-plugin-fileprg +> ## Repository abandoned 2019-12-31 +> +> This repository has moved to laminas/laminas-mvc-plugin-fileprg. + [![Build Status](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg) [![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-mvc-plugin-fileprg/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-mvc-plugin-fileprg?branch=master) @@ -34,4 +38,4 @@ Browse the documentation online at https://docs.zendframework.com/zend-mvc-plugi * [Issues](https://github.com/zendframework/zend-mvc-plugin-fileprg/issues/) * [Chat](https://zendframework-slack.herokuapp.com/) -* [Forum](https://discourse.zendframework.com/) +* [Forum](https://discourse.zendframework.com/) \ No newline at end of file From d2d6432e5a86843398a5c94ea64ac99150980111 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 31 Dec 2019 17:13:25 -0600 Subject: [PATCH 4/6] Marking package as abandoned --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6628991..2d5d574 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ > > This repository has moved to laminas/laminas-mvc-plugin-fileprg. +> ## Repository abandoned 2019-12-31 +> +> This repository has moved to laminas/laminas-mvc-plugin-fileprg. + [![Build Status](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg) [![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-mvc-plugin-fileprg/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-mvc-plugin-fileprg?branch=master) From b1a1a106980fd3d3cd5b988b9ea88e189ddc12bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Thu, 16 Jan 2020 19:56:23 +0000 Subject: [PATCH 5/6] Remove duplicated abandoned notes in README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 2d5d574..65f896d 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ > > This repository has moved to laminas/laminas-mvc-plugin-fileprg. -> ## Repository abandoned 2019-12-31 -> -> This repository has moved to laminas/laminas-mvc-plugin-fileprg. - [![Build Status](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg) [![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-mvc-plugin-fileprg/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-mvc-plugin-fileprg?branch=master) @@ -42,4 +38,4 @@ Browse the documentation online at https://docs.zendframework.com/zend-mvc-plugi * [Issues](https://github.com/zendframework/zend-mvc-plugin-fileprg/issues/) * [Chat](https://zendframework-slack.herokuapp.com/) -* [Forum](https://discourse.zendframework.com/) \ No newline at end of file +* [Forum](https://discourse.zendframework.com/) From b286b481772c1ccacc348211fcdfa793bb1a21ef Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 20 Jan 2020 13:48:19 -0600 Subject: [PATCH 6/6] Link to new repository --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65f896d..bec0b44 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > ## Repository abandoned 2019-12-31 > -> This repository has moved to laminas/laminas-mvc-plugin-fileprg. +> This repository has moved to [laminas/laminas-mvc-plugin-fileprg](https://github.com/laminas/laminas-mvc-plugin-fileprg). [![Build Status](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-mvc-plugin-fileprg) [![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-mvc-plugin-fileprg/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-mvc-plugin-fileprg?branch=master)