Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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@zechy.cz>
* @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@zechy.cz>
* @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@zechy.cz>
* @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
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
}
],
"require": {
"php": ">=7.2.0",
"php": ">=7.2.0 <8.5",
"ext-json": "*",
"latte/latte": "^2.10",
"latte/latte": "^2.10 || ^3.0",
"nette/application": "^3.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Questionable PHP upper bound
Moving from >=7.2.0 to >=7.2.0 <8.5 drops support for every future PHP release, which will force Composer to refuse installs as soon as PHP 8.5 lands. Unless we already know 8.5 is incompatible, we should keep the requirement open-ended (or document the incompatibility) so consumers aren’t surprised by an artificial block.

🤖 Prompt for AI Agents
In composer.json around lines 14 to 17, the PHP requirement currently pins an
upper bound ("php": ">=7.2.0 <8.5") which will block installs on future PHP
releases; remove the artificial "<8.5" upper bound (or if 8.5+ is truly
incompatible, replace it with a clear comment in README and a composer
"conflict" entry documenting the incompatibility) so the package does not refuse
installs on future PHP versions.

"nette/caching": "^3.1",
"nette/di": "^3.0",
Expand All @@ -31,14 +31,14 @@
"tracy/tracy": "^2.6"
},
"autoload": {
"classmap": [
"src/"
]
"psr-4": {
"Contributte\\FileUpload\\": "src/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ parameters:
message: '#Construct empty\(\) is not allowed\. Use more strict comparison\.#'
path: src/Model/UploadController.php
-
message: '#Property Zet\\FileUpload\\Model\\UploadController::\$renderer \(Zet\\FileUpload\\Template\\Renderer\\BaseRenderer\) does not accept object\.#'
message: '#Property Contributte\\FileUpload\\Model\\UploadController::\$renderer \(Contributte\\FileUpload\\Template\\Renderer\\BaseRenderer\) does not accept object\.#'
path: src/Model/UploadController.php

includes:
Expand Down
2 changes: 1 addition & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<properties>
<property name="extensions" type="array" value="php, phpt"/>
<property name="rootNamespaces" type="array">
<element key="src" value="Zet\FileUpload"/>
<element key="src" value="Contributte\FileUpload"/>
<element key="tests" value="Tests"/>
<element key="tests/cases" value="Tests\Cases"/>
<element key="tests/fixtures" value="Tests\Fixtures"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Exception;
namespace Contributte\FileUpload\Exception;

class InvalidArgumentException extends LogicalException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidFileException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Exception;
namespace Contributte\FileUpload\Exception;

use Exception;

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidValueException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Exception;
namespace Contributte\FileUpload\Exception;

use Exception;

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/LogicalException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Exception;
namespace Contributte\FileUpload\Exception;

use LogicException;

Expand Down
20 changes: 10 additions & 10 deletions src/FileUploadControl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload;
namespace Contributte\FileUpload;

use Nette;
use Nette\Application\UI\Form;
Expand All @@ -12,11 +12,11 @@
use Nette\Localization\Translator;
use Nette\Utils\Html;
use stdClass;
use Zet\FileUpload\Exception\InvalidValueException;
use Zet\FileUpload\Model\BaseUploadModel;
use Zet\FileUpload\Model\DefaultFile;
use Zet\FileUpload\Model\IUploadModel;
use Zet\FileUpload\Model\UploadController;
use Contributte\FileUpload\Exception\InvalidValueException;
use Contributte\FileUpload\Model\BaseUploadModel;
use Contributte\FileUpload\Model\DefaultFile;
use Contributte\FileUpload\Model\IUploadModel;
use Contributte\FileUpload\Model\UploadController;

/**
* Class FileUploadControl
Expand All @@ -32,22 +32,22 @@ class FileUploadControl extends UploadControl
/**
* Povolí nahrávat pouze obrázky png, jpeg, jpg, gif.
*/
public const FILTER_IMAGES = 'Zet\FileUpload\Filter\ImageFilter';
public const FILTER_IMAGES = 'Contributte\FileUpload\Filter\ImageFilter';

/**
* Povolí nahrávat pouze dokumenty typu txt, doc, docx, xls, xlsx, ppt, pptx, pdf.
*/
public const FILTER_DOCUMENTS = 'Zet\FileUpload\Filter\DocumentFilter';
public const FILTER_DOCUMENTS = 'Contributte\FileUpload\Filter\DocumentFilter';

/**
* Povolí nahrávat soubory zip, tar, rar, 7z.
*/
public const FILTER_ARCHIVE = 'Zet\FileUpload\Filter\ArchiveFilter';
public const FILTER_ARCHIVE = 'Contributte\FileUpload\Filter\ArchiveFilter';

/**
* Povolí nahrávat pouze soubory mp3, ogg, aiff.
*/
public const FILTER_AUDIO = 'Zet\FileUpload\Filter\AudioFilter';
public const FILTER_AUDIO = 'Contributte\FileUpload\Filter\AudioFilter';

/** @var Container */
private $container;
Expand Down
18 changes: 9 additions & 9 deletions src/FileUploadExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload;
namespace Contributte\FileUpload;

use Nette\DI\CompilerExtension;
use Nette\DI\Container;
Expand All @@ -9,12 +9,12 @@
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use Nette\UnexpectedValueException;
use Zet\FileUpload\Exception\InvalidArgumentException;
use Zet\FileUpload\Filter\IMimeTypeFilter;
use Zet\FileUpload\Model\BaseUploadModel;
use Zet\FileUpload\Model\IUploadModel;
use Zet\FileUpload\Template\Renderer\Html5Renderer;
use Zet\FileUpload\Template\Renderer\IUploadRenderer;
use Contributte\FileUpload\Exception\InvalidArgumentException;
use Contributte\FileUpload\Filter\IMimeTypeFilter;
use Contributte\FileUpload\Model\BaseUploadModel;
use Contributte\FileUpload\Model\IUploadModel;
use Contributte\FileUpload\Template\Renderer\Html5Renderer;
use Contributte\FileUpload\Template\Renderer\IUploadRenderer;

/**
* Class FileUploadExtension
Expand Down Expand Up @@ -91,9 +91,9 @@ public function getConfigSchema(): Schema

public function afterCompile(ClassType $class): void
{
$init = $class->methods['initialize'];
$init = $class->getMethod('initialize');

$init->addBody('\Zet\FileUpload\FileUploadControl::register($this->getService(?), ?);', [
$init->addBody('\Contributte\FileUpload\FileUploadControl::register($this->getService(?), ?);', [
$this->getContainerBuilder()->getByType(Container::class),
$this->getConfig(),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/ArchiveFilter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Filter;
namespace Contributte\FileUpload\Filter;

/**
* Class ArchiveFilter
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/AudioFilter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Filter;
namespace Contributte\FileUpload\Filter;

/**
* Class AudioFilter
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/BaseFilter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Filter;
namespace Contributte\FileUpload\Filter;

use Nette\Http\FileUpload;
use Nette\SmartObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/DocumentFilter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Filter;
namespace Contributte\FileUpload\Filter;

/**
* Class DocumentFilter
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/IMimeTypeFilter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Filter;
namespace Contributte\FileUpload\Filter;

use Nette\Http\FileUpload;

Expand Down
2 changes: 1 addition & 1 deletion src/Filter/ImageFilter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Filter;
namespace Contributte\FileUpload\Filter;

/**
* Class ImageFilter
Expand Down
2 changes: 1 addition & 1 deletion src/Model/BaseUploadModel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Model;
namespace Contributte\FileUpload\Model;

use Nette\Http\FileUpload;
use Nette\SmartObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/DefaultFile.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Model;
namespace Contributte\FileUpload\Model;

use Nette\SmartObject;

Expand Down
2 changes: 1 addition & 1 deletion src/Model/IUploadModel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Model;
namespace Contributte\FileUpload\Model;

use Nette\Http\FileUpload;

Expand Down
12 changes: 6 additions & 6 deletions src/Model/UploadController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Zet\FileUpload\Model;
namespace Contributte\FileUpload\Model;

use Nette\Application\AbortException;
use Nette\Application\Responses\JsonResponse;
Expand All @@ -12,11 +12,11 @@
use Nette\UnexpectedValueException;
use Nette\Utils\Html;
use Throwable;
use Zet\FileUpload\Exception\InvalidFileException;
use Zet\FileUpload\FileUploadControl;
use Zet\FileUpload\Filter\IMimeTypeFilter;
use Zet\FileUpload\Template\JavascriptBuilder;
use Zet\FileUpload\Template\Renderer\BaseRenderer;
use Contributte\FileUpload\Exception\InvalidFileException;
use Contributte\FileUpload\FileUploadControl;
use Contributte\FileUpload\Filter\IMimeTypeFilter;
use Contributte\FileUpload\Template\JavascriptBuilder;
use Contributte\FileUpload\Template\Renderer\BaseRenderer;

/**
* Class UploadController
Expand Down
Loading