Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jQuery-FileUpload is component which extends UploadControl in Nette form using [

```
extensions:
fileUpload: Zet\FileUpload\FileUploadExtension
fileUpload: Contributte\FileUpload\FileUploadExtension
```

### Configuration of DI extension options
Expand All @@ -17,7 +17,7 @@ extensions:
fileUpload:
maxFiles: 10
maxFileSize: 2M
fileFilter: Zet\FileUpload\Filter\ImageFilter
fileFilter: Contributte\FileUpload\Filter\ImageFilter
uploadModel: App\Model\MyUploadModel
uiMode: # full nebo minimal
```
Expand All @@ -31,8 +31,8 @@ This component needs for its precise functionality some third party scripts and
### Loading CSS and JS in layout.latte

```
{\Zet\FileUpload\FileUploadControl::getHead($basePath)}
{\Zet\FileUpload\FileUploadControl::getScripts($basePath)}
{\Contributte\FileUpload\FileUploadControl::getHead($basePath)}
{\Contributte\FileUpload\FileUploadControl::getScripts($basePath)}
```

## Upload model
Expand All @@ -41,15 +41,15 @@ Component can use custom processing file upload through `UploadModel` which does

### Interface

Custom `UploadModel` must implement interface **\Zet\FileUpload\Model\IUploadModel**.
Custom `UploadModel` must implement interface **\Contributte\FileUpload\Model\IUploadModel**.

```php
namespace Zet\FileUpload\Model;
namespace Contributte\FileUpload\Model;

/**
* Interface IUploadController
* @author Zechy <[email protected]>
* @package Zet\FileUpload\Model
* @package Contributte\FileUpload\Model
*/
interface IUploadModel {

Expand Down Expand Up @@ -97,7 +97,7 @@ fileUpload:

Uploaded files can be filtered using their mimetype or suffix, so it is possible to limit the upload of files to images only. There are filter classes for this purpose.

All filters are instances of the abstract class **\Zet\FileUpload\Filter\BaseFilter**, which implements the basic methodology for determining the correctness of a file using a mimetype, or according to the file extension. This basic filter implements the **\Zet\FileUpload\Filter\IMimeTypeFilter** interface.
All filters are instances of the abstract class **\Contributte\FileUpload\Filter\BaseFilter**, which implements the basic methodology for determining the correctness of a file using a mimetype, or according to the file extension. This basic filter implements the **\Contributte\FileUpload\Filter\IMimeTypeFilter** interface.

## Basic filters

Expand All @@ -110,13 +110,13 @@ FileUploadControl::FILTER_AUDIO; // Allows uploading of files mp3, ogg, aiff onl
FileUploadControl::setFileFilter("Constant or custom class"); // Sets the class to determine if the file can be uploaded
```

The setFileFilter method accepts as a parameter a string in which the class name is written, eg **Zet\FileUpload\Filter\ImageFilter**.
The setFileFilter method accepts as a parameter a string in which the class name is written, eg **Contributte\FileUpload\Filter\ImageFilter**.

## Custom filter

### Using BaseFilter

To use the basic methodology for determining the correctness of a file type, you can create your own class, which will be a child of **\Zet\FileUpload\Filter\BaseFilter**.
To use the basic methodology for determining the correctness of a file type, you can create your own class, which will be a child of **\Contributte\FileUpload\Filter\BaseFilter**.

The class created in this way must have its own implementation of the `getMimeTypes()` method, which returns an array of file mimetypes and their extensions, e.g.:

Expand All @@ -138,14 +138,14 @@ protected function getMimeTypes() {

### Own filtering methodology

If you want to create your own way of determining the file type, you can create your own class, but it must implement the **\Zet\FileUpload\Filter\IMimeTypeFilter** interface.
If you want to create your own way of determining the file type, you can create your own class, but it must implement the **\Contributte\FileUpload\Filter\IMimeTypeFilter** interface.

```php
/**
* Interface IMimeTypeFilters
* Interface for checking the mimetype of file
* @author Zechy <[email protected]>
* @package Zet\FileUpload\Filter
* @package Contributte\FileUpload\Filter
*/
interface IMimeTypeFilter {

Expand Down Expand Up @@ -213,7 +213,7 @@ Uploaded files can be obtained by processing the form from the field **$values**
FileUploadControl::setMaxFiles(25); // Setter for maximum of files.
FileUploadControl::setMaxFileSize("2M"); // Setter for maximum of file size.
FileUploadControl::setUploadModel('\Model\File\UploadModel'); // Setter for custom upload model.
FileUploadControl::setFileFilter('\Zet\FileUpload\Filter\ImageFilter'); // Setter for restrictions on uploading files to specified types. You can string a custom class or use the FileUploadControl constants.
FileUploadControl::setFileFilter('\Contributte\FileUpload\Filter\ImageFilter'); // Setter for restrictions on uploading files to specified types. You can string a custom class or use the FileUploadControl constants.
FileUploadControl::setUiTemplate(FileUploadControl::UI_FULL, __DIR__ . "/path/to/my/template.latte");
FileUploadControl::setParams(["productId" => 10]); // Setter for custom values for the uploaded file
```
Expand Down Expand Up @@ -305,7 +305,7 @@ Progress bars can be HTML5 tags &lt;progress&gt; or &lt;div&gt;.

#### BaseRenderer

The custom renderer must inherit from the **\Zet\FileUpload\Template\Renderer\BaseRenderer** class. This class has the attribute **$elements** in which are stored the Html Prototypes of all components in the field on indexes.
The custom renderer must inherit from the **\Contributte\FileUpload\Template\Renderer\BaseRenderer** class. This class has the attribute **$elements** in which are stored the Html Prototypes of all components in the field on indexes.

BaseRenderer contains three abstract methods that need to be implemented.

Expand All @@ -314,7 +314,7 @@ BaseRenderer contains three abstract methods that need to be implemented.
* Class BaseRenderer
*
* @author Zechy <[email protected]>
* @package Zet\FileUpload\Template\Renderer
* @package Contributte\FileUpload\Template\Renderer
*/
abstract class BaseRenderer extends Object implements IUploadRenderer {

Expand Down Expand Up @@ -351,7 +351,7 @@ Since version 2.0.0-beta2, default files can be entered into the uploader. When

### DefaultFile

Use the container **\Zet\FileUpload\Model\DefaultFile** to add a default file.
Use the container **\Contributte\FileUpload\Model\DefaultFile** to add a default file.

```php
class DefaultFile extends Object {
Expand Down
65 changes: 31 additions & 34 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- "*"
schedule:
- cron: "0 8 * * 1" # At 08:00 on Monday
workflow_dispatch:

env:
extensions: "json"
Expand All @@ -23,13 +24,13 @@ jobs:

strategy:
matrix:
php-version: [ "7.4" ]
php-version: [ "8.2" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

- name: "Setup PHP cache environment"
id: "extcache"
Expand All @@ -40,7 +41,7 @@ jobs:
key: "${{ env.cache-version }}"

- name: "Cache PHP extensions"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
Expand All @@ -51,17 +52,18 @@ jobs:
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }} "
tools: "composer:${{ env.composer-version }}"
coverage: "none"

- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

- name: "Cache PHP dependencies"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -82,13 +84,13 @@ jobs:

strategy:
matrix:
php-version: [ "7.4" ]
php-version: [ "8.2" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

- name: "Setup PHP cache environment"
id: "extcache"
Expand All @@ -99,7 +101,7 @@ jobs:
key: "${{ env.cache-version }}"

- name: "Cache PHP extensions"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
Expand All @@ -110,17 +112,18 @@ jobs:
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }} "
tools: "composer:${{ env.composer-version }}"
coverage: "none"

- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

- name: "Cache PHP dependencies"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -138,23 +141,18 @@ jobs:

strategy:
matrix:
php-version: [ "7.3", "7.4", "8.0" ]
php-version: [ "8.2", "8.3", "8.4" ]
operating-system: [ "ubuntu-latest" ]
composer-args: [ "" ]
include:
- php-version: "7.4"
- php-version: "8.2"
operating-system: "ubuntu-latest"
composer-args: "--prefer-lowest"
- php-version: "8.0"
operating-system: "ubuntu-latest"
composer-args: ""
fail-fast: false

continue-on-error: "${{ matrix.php-version == '8.0' }}"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

- name: "Setup PHP cache environment"
id: "extcache"
Expand All @@ -165,7 +163,7 @@ jobs:
key: "${{ env.cache-version }}"

- name: "Cache PHP extensions"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
Expand All @@ -176,17 +174,18 @@ jobs:
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }} "
tools: "composer:${{ env.composer-version }}"
coverage: "none"

- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

- name: "Cache PHP dependencies"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -195,9 +194,6 @@ jobs:
- name: "Install dependencies"
run: "${{ env.composer-install }} ${{ matrix.composer-args }}"

- name: "Setup problem matchers for PHPUnit"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"'

- name: "Tests"
run: "make tests"

Expand All @@ -207,15 +203,15 @@ jobs:

strategy:
matrix:
php-version: [ "7.4" ]
php-version: [ "8.2" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

if: "github.event_name == 'push'"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

- name: "Setup PHP cache environment"
id: "extcache"
Expand All @@ -226,7 +222,7 @@ jobs:
key: "${{ env.cache-version }}"

- name: "Cache PHP extensions"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.extcache.outputs.dir }}"
key: "${{ steps.extcache.outputs.key }}"
Expand All @@ -237,17 +233,18 @@ jobs:
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.extensions }}"
tools: "composer:${{ env.composer-version }} "
tools: "composer:${{ env.composer-version }}"
coverage: "pcov"

- name: "Setup problem matchers for PHP"
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'

- name: "Get Composer cache directory"
id: "composercache"
run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"'
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

- name: "Cache PHP dependencies"
uses: "actions/cache@v2"
uses: "actions/cache@v4"
with:
path: "${{ steps.composercache.outputs.dir }}"
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}"
Expand All @@ -257,7 +254,7 @@ jobs:
run: "${{ env.composer-install }}"

- name: "Tests"
run: "make coverage-clover"
run: "make coverage"

- name: "Coveralls.io"
env:
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# IDE
.idea

/.idea

# Composer
/vendor
/composer.lock

# Tests
/temp
/coverage.xml
/coverage.html
Loading