Skip to content

Commit

Permalink
Initital commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 16, 2023
1 parent 305cea6 commit 1bdfa6f
Show file tree
Hide file tree
Showing 49 changed files with 2,390 additions and 55 deletions.
67 changes: 54 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<a href="https://github.com/yii2-extensions/template" target="_blank">
<a href="https://github.com/yii2-extensions/filepond" target="_blank">
<img src="https://www.yiiframework.com/image/yii_logo_light.svg" height="100px;">
</a>
<h1 align="center">Yii2-Template.</h1>
<h1 align="center">FilePond.</h1>
<br>
</p>

Expand All @@ -13,32 +13,73 @@
<a href="https://github.com/yiisoft/yii2/tree/2.2" target="_blank">
<img src="https://img.shields.io/badge/Yii2%20version-2.2-blue" alt="yii2-version">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/template/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
<a href="https://github.com/yii2-extensions/filepond/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/filepond/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii2-extensions/template" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/template/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
<a href="https://codecov.io/gh/yii2-extensions/filepond" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/filepond/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<a href="https://github.com/yii2-extensions/filepond/actions/workflows/static.yml" target="_blank">
<img src="https://github.com/yii2-extensions/gii/actions/workflows/static.yml/badge.svg" alt="PHPStan">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/badge/PHPStan%20level-2-blue" alt="PHPStan level">
<a href="https://github.com/yii2-extensions/filepond/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/badge/PHPStan%20level-5-blue" alt="PHPStan level">
</a>
<a href="https://github.styleci.io/repos/698621511?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/698621511/shield?branch=main" alt="Code style">
</a>
</p>

## Requirements
## Installation

The minimun version of `PHP` required by this package is `PHP 8.1`.
The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

For install this package, you need [composer](https://getcomposer.org/).
Either run

```
php composer.phar require --dev --prefer-dist yii2-extensions/filepond
```

or add

```
"yii2-extensions/filepond": "dev-main"
```

to the require-dev section of your `composer.json` file.

## Usage

[Check the documentation docs](/docs/README.md) to learn about usage.
### View

```php
<?=
$form
->field($formModel, 'image_file')
->widget(
FilePond::class,
[
'labelIdle' => Yii::t(
'yii.blog', 'Drag & Drop your files or <span class="filepond--label-action">Browse</span>',
),
'loadFileDefault' => $imageFile,
'imagePreviewHeight' => 170,
'imageCropAspectRatio' => '1:1',
],
)
?>
```

### Controller or Model

```php
$imageFile = FileProcessing::saveWithReturningFile(
$categoryForm->image_file,
Yii::getAlias('@uploads'),
"category{$category->id}",
false
);
```

## Testing

Expand Down
54 changes: 45 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,77 @@
{
"name": "yii2/template",
"type": "library",
"description": "_____",
"name": "yii2-extensions/filepond",
"type": "yii2-extension",
"description": "FilePond widget for PHP.",
"keywords": [
"_____"
"yii2",
"filepond",
"widget"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"yiisoft/yii2": "^2.2"
"ext-intl": "*",
"npm-asset/filepond": "^4.3",
"npm-asset/filepond-plugin-file-encode": "^2.1",
"npm-asset/filepond-plugin-file-rename": "^1.1",
"npm-asset/filepond-plugin-file-validate-size": "^2.2",
"npm-asset/filepond-plugin-file-validate-type": "^1.2",
"npm-asset/filepond-plugin-image-crop": "^2.0",
"npm-asset/filepond-plugin-image-exif-orientation": "^1.0",
"npm-asset/filepond-plugin-image-preview": "^4.6",
"npm-asset/filepond-plugin-image-transform": "^3.8",
"npm-asset/filepond-plugin-pdf-preview": "^1.0",
"oomphinc/composer-installers-extender": "^2.0",
"php-forge/html": "dev-main",
"yiisoft/yii2": "*"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.6",
"php-forge/support": "dev-main",
"phpunit/phpunit": "^10.2",
"roave/infection-static-analysis-plugin": "^1.32",
"yii2-extensions/phpstan": "dev-main"
},
"autoload": {
"psr-4": {
"yii\\template\\": "src"
"Yii\\FilePond\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"Yii\\FilePond\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
"dev-master": "1.0.x-dev"
},
"config-plugin": {
"yii2-filepond": "extension.php"
},
"config-plugin-options": {
"source-directory": "config"
},
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"./node_modules/{$name}/": [
"type:bower-asset",
"type:npm-asset"
]
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"composer/installers": true,
"oomphinc/composer-installers-extender": true,
"infection/extension-installer": true
}
},
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions config/extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use yii\i18n\PhpMessageSource;

return [
'components' => [
'i18n' => [
'translations' => [
'yii.filepond' => [
'class' => PhpMessageSource::class,
],
],
],
],
];
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parameters:
- YII_ENV_PROD
- YII_ENV_TEST

level: 2
level: 5

paths:
- src
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="Template">
<testsuite name="Yii2-FilePond">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
21 changes: 21 additions & 0 deletions src/Asset/Cdn/FilePondEncodePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Yii\FilePond\Asset\Cdn;

use yii\web\AssetBundle;

/**
* Asset bundle for the filepond encode plugin in content delivery network (CDN) mode, mainly used for publishing
* assets.
*/
final class FilePondEncodePlugin extends AssetBundle
{
/**
* {@inheritDoc}
*/
public $js = [
'https://unpkg.com/filepond-plugin-file-encode/dist/filepond-plugin-file-encode.js',
];
}
29 changes: 29 additions & 0 deletions src/Asset/Cdn/FilePondImageCropPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Yii\FilePond\Asset\Cdn;

use Yii\FilePond\Asset\FilePondAsset;
use yii\web\AssetBundle;

/**
* Asset bundle for the filepond image crop plugin in content delivery network (CDN) mode, mainly used for publishing
* assets.
*/
final class FilePondImageCropPlugin extends AssetBundle
{
/**
* {@inheritDoc}
*/
public $js = [
'https://unpkg.com/filepond-plugin-image-crop/dist/filepond-plugin-image-crop.min.js',
];

/**
* {@inheritDoc}
*/
public $depends = [
FilePondAsset::class,
];
}
21 changes: 21 additions & 0 deletions src/Asset/Cdn/FilePondImageExifOrientationPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Yii\FilePond\Asset\Cdn;

use yii\web\AssetBundle;

/**
* Asset bundle for the filepond image exif orientation plugin in content delivery network (CDN) mode, mainly used for
* publishing assets.
*/
final class FilePondImageExifOrientationPlugin extends AssetBundle
{
/**
* {@inheritdoc}
*/
public $js = [
'https://unpkg.com/filepond-plugin-image-exif-orientation/dist/filepond-plugin-image-exif-orientation.min.js',
];
}
28 changes: 28 additions & 0 deletions src/Asset/Cdn/FilePondImagePreviewPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Yii\FilePond\Asset\Cdn;

use yii\web\AssetBundle;

/**
* Asset bundle for the filepond image preview plugin in content delivery network (CDN) mode, mainly used for publishing
* assets.
*/
final class FilePondImagePreviewPlugin extends AssetBundle
{
/**
* {@inheritDoc}
*/
public $css = [
'https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css',
];

/**
* {@inheritDoc}
*/
public $js = [
'https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.js',
];
}
29 changes: 29 additions & 0 deletions src/Asset/Cdn/FilePondImageTransformPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Yii\FilePond\Asset\Cdn;

use Yii\FilePond\Asset\FilePondAsset;
use yii\web\AssetBundle;

/**
* Asset bundle for the filepond image transform plugin in content delivery network (CDN) mode, mainly used for publishing
* assets.
*/
final class FilePondImageTransformPlugin extends AssetBundle
{
/**
* {@inheritDoc}
*/
public $js = [
'https://unpkg.com/filepond-plugin-image-transform/dist/filepond-plugin-image-transform.min.js',
];

/**
* {@inheritDoc}
*/
public $depends = [
FilePondAsset::class,
];
}
Loading

0 comments on commit 1bdfa6f

Please sign in to comment.