image resize, api
This commit is contained in:
parent
ac002c1ac1
commit
8001e1a876
30
.htaccess
30
.htaccess
|
|
@ -1,3 +1,33 @@
|
|||
## START OFFLINE.ResponsiveImages - webp-rewrite
|
||||
# DO NOT REMOVE THESE LINES
|
||||
<IfModule mod_setenvif.c>
|
||||
# Vary: Accept for all the requests to jpeg and png
|
||||
SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image
|
||||
</IfModule>
|
||||
<ifModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
# If the Browser supports WebP images, and the .webp file exists, use it.
|
||||
RewriteCond %{HTTP_ACCEPT} image/webp
|
||||
RewriteCond %{REQUEST_URI} ^/?storage/.*\.(jpe?g|png)
|
||||
RewriteCond %{REQUEST_FILENAME}.webp -f
|
||||
RewriteRule ^/?(.*)$ $1.webp [NC,T=image/webp,END]
|
||||
|
||||
# If the Browser supports WebP images, and the .webp file does not exist, generate it.
|
||||
RewriteCond %{HTTP_ACCEPT} image/webp
|
||||
RewriteCond %{REQUEST_URI} ^/?storage/.*\.(jpe?g|png)
|
||||
RewriteCond %{REQUEST_FILENAME}\.webp !-f
|
||||
RewriteRule ^/?(.*)$ plugins/offline/responsiveimages/webp.php?path=$1 [NC,END]
|
||||
</ifModule>
|
||||
<IfModule mod_headers.c>
|
||||
Header append Vary Accept env=REQUEST_image
|
||||
</IfModule>
|
||||
<IfModule mod_mime.c>
|
||||
AddType image/webp .webp
|
||||
</IfModule>
|
||||
|
||||
## END OFFLINE.ResponsiveImages - webp-rewrite
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
|
||||
<IfModule mod_negotiation.c>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
# MIT licence
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Classes\Resizer;
|
||||
use ABWebDevelopers\ImageResize\Commands\ImageResizeClear;
|
||||
use ABWebDevelopers\ImageResize\Commands\ImageResizeGc;
|
||||
use ABWebDevelopers\ImageResize\Commands\ImageResizeResetPermalinks;
|
||||
use ABWebDevelopers\ImageResize\Models\ImagePermalink;
|
||||
use ABWebDevelopers\ImageResize\Models\Settings;
|
||||
use ABWebDevelopers\ImageResize\ReportWidgets\ImageResizeClearWidget;
|
||||
use App;
|
||||
use Artisan;
|
||||
use DB;
|
||||
use Event;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use System\Classes\PluginBase;
|
||||
|
||||
class Plugin extends PluginBase
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function pluginDetails()
|
||||
{
|
||||
return [
|
||||
'name' => 'abwebdevelopers.imageresize::lang.plugin.name',
|
||||
'description' => 'abwebdevelopers.imageresize::lang.plugin.description',
|
||||
'author' => 'AB Web Developers',
|
||||
'icon' => 'icon-file-image-o',
|
||||
'homepage' => 'https://abweb.com.au'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function registerMarkupTags()
|
||||
{
|
||||
return [
|
||||
'filters' => [
|
||||
'resize' => function ($image, $width, $height = null, $options = []) {
|
||||
$resizer = new Resizer();
|
||||
|
||||
$width = ($width !== null) ? (int) $width : null;
|
||||
$height = ($height !== null) ? (int) $height : null;
|
||||
$options = ($options instanceof Arrayable) ? $options->toArray() : (array) $options;
|
||||
|
||||
// If the given configuration has a permalink identifier then resize using it
|
||||
if (isset($options['permalink']) && strlen($options['permalink'])) {
|
||||
$resizer->preventDefaultImage();
|
||||
$resizer->setImage((string) $image);
|
||||
|
||||
return $resizer->resizePermalink($options['permalink'], $width, $height, $options)->permalink_url;
|
||||
}
|
||||
|
||||
$resizer->setImage((string) $image);
|
||||
|
||||
return $resizer->resize($width, $height, $options);
|
||||
},
|
||||
'modify' => function ($image, $options = []) {
|
||||
$resizer = new Resizer();
|
||||
|
||||
$width = null;
|
||||
$height = null;
|
||||
$options = ($options instanceof Arrayable) ? $options->toArray() : (array) $options;
|
||||
|
||||
// If the given configuration has a permalink identifier then resize using it
|
||||
if (isset($options['permalink']) && strlen($options['permalink'])) {
|
||||
$resizer->preventDefaultImage();
|
||||
$resizer->setImage((string) $image);
|
||||
|
||||
return $resizer->resizePermalink($options['permalink'], $width, $height, $options)->permalink_url;
|
||||
}
|
||||
|
||||
$resizer->setImage((string) $image);
|
||||
|
||||
return $resizer->resize($width, $height, $options);
|
||||
},
|
||||
'filterHtmlImageResize' => function ($html, $width, $height = null, $options = []) {
|
||||
$html = (string) $html;
|
||||
$width = ($width !== null) ? (int) $width : null;
|
||||
$height = ($height !== null) ? (int) $height : null;
|
||||
$options = ($options instanceof Arrayable) ? $options->toArray() : (array) $options;
|
||||
|
||||
return Resizer::parseFindReplaceImages($html, $width, $height, $options);
|
||||
},
|
||||
'filterHtmlImageModify' => function ($html, $options = []) {
|
||||
$html = (string) $html;
|
||||
$width = null;
|
||||
$height = null;
|
||||
$options = ($options instanceof Arrayable) ? $options->toArray() : (array) $options;
|
||||
|
||||
return Resizer::parseFindReplaceImages($html, $width, $height, $options);
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function registerSettings()
|
||||
{
|
||||
return [
|
||||
'settings' => [
|
||||
'label' => 'abwebdevelopers.imageresize::lang.plugin.name',
|
||||
'description' => 'Manage default settings for the Image Resizer plugin',
|
||||
'category' => 'Content',
|
||||
'icon' => 'icon-image',
|
||||
'class' => 'ABWebDevelopers\ImageResize\Models\Settings',
|
||||
'permissions' => ['abwebdevelopers.imageresize.access_settings'],
|
||||
'order' => 500,
|
||||
'keywords' => 'image resize resizing modify photo modifier'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function registerPermissions()
|
||||
{
|
||||
return [
|
||||
'abwebdevelopers.imageresize.access_settings' => ['tab' => 'abwebdevelopers.imageresize::lang.permissions.tab', 'label' => 'abwebdevelopers.imageresize::lang.permissions.access_settings'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Event::listen('backend.page.beforeDisplay', function ($controller, $action, $params) {
|
||||
if ($controller instanceof \System\Controllers\Settings) {
|
||||
// Check this is the settings page for this plugin:
|
||||
if ($params === ['abwebdevelopers', 'imageresize', 'settings']) {
|
||||
// Add CSS (minor patch)
|
||||
$controller->addCss('/plugins/abwebdevelopers/imageresize/assets/settings-patch.css');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Event::listen('cache:cleared', function () {
|
||||
$this->ifDatabaseExists(function () {
|
||||
if (Settings::cleanupOnCacheClear()) {
|
||||
if (App::runningInConsole()) {
|
||||
$output = new ConsoleOutput();
|
||||
$output->writeln('<info>Imagesizer: Deleting cached resized images...</info>');
|
||||
}
|
||||
|
||||
Artisan::call('imageresize:clear');
|
||||
|
||||
if (App::runningInConsole()) {
|
||||
$output->writeln('<info>Imagesizer: ' . Artisan::output() . '</info>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerConsoleCommand('imageresize:gc', ImageResizeGc::class);
|
||||
$this->registerConsoleCommand('imageresize:clear', ImageResizeClear::class);
|
||||
$this->registerConsoleCommand('imageresize:reset-permalink', ImageResizeResetPermalinks::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function registerSchedule($schedule)
|
||||
{
|
||||
// This is throttled by your settings, it won't necessarily clear all images every 5 minutes
|
||||
$schedule->command('imageresize:gc')->everyFiveMinutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function registerReportWidgets()
|
||||
{
|
||||
return [
|
||||
ImageResizeClearWidget::class => [
|
||||
'label' => 'Clear Image Resizer Cache',
|
||||
'context' => 'dashboard',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the callback only if/when the database exists (and system_settings table exists).
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function ifDatabaseExists(\Closure $callback)
|
||||
{
|
||||
$canConnectToDatabase = false;
|
||||
try {
|
||||
// Test database connection (throw exception if no DB is configured yet)
|
||||
$canConnectToDatabase = DB::table('system_settings')->exists();
|
||||
} catch (QueryException $e) {
|
||||
}
|
||||
|
||||
if ($canConnectToDatabase) {
|
||||
return $callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
# October CMS Image Resize Plugin
|
||||
|
||||
Resize and transform images on the fly in Twig and October CMS.
|
||||
|
||||
## Requirements
|
||||
|
||||
- October CMS
|
||||
- PHP 7.0 or above
|
||||
- PHP `fileinfo` extension
|
||||
- PHP `gd` extension **or** `imagick` extension
|
||||
|
||||
Please note that GD is bound by PHP's memory limits, whereas Imagick isn't. If your site returns 503 when resizing images, try Imagick (can be changed via Settings).
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
- [Installation](#installation)
|
||||
- [October CMS usage](#october-cms-usage)
|
||||
|
||||
### Installation
|
||||
|
||||
You can install this plugin in a number of ways:
|
||||
|
||||
#### Via Composer
|
||||
|
||||
Run the following commands in your October CMS project folder to install the plugin.
|
||||
|
||||
```bash
|
||||
composer require abwebdevelopers/oc-imageresize-plugin
|
||||
php artisan october:up
|
||||
```
|
||||
|
||||
#### Via Updates & Plugins screen
|
||||
|
||||
In the October CMS backend, you can navigate to *Settings > Updates & Plugins* and then click the
|
||||
*Install Plugins* button to install a plugin to your October CMS install. Add
|
||||
`ABWebDevelopers.ImageResize` to the search box to be able to select this plugin and install it.
|
||||
|
||||
#### Via command-line
|
||||
|
||||
Run the following command in your October CMS project folder to install the plugin.
|
||||
|
||||
```bash
|
||||
php artisan plugin:install ABWebDevelopers.ImageResize
|
||||
```
|
||||
|
||||
### October CMS usage
|
||||
|
||||
This plugin utilises [Intervention Image](https://github.com/Intervention/image)'s magical powers to resize and transform your images with ease. Please note that this plugin does not cover every feature of the Intervention Image library.
|
||||
|
||||
#### Basic Resizing
|
||||
|
||||
**Twig Filter:** `| resize(int $width, int $height, array $options)`
|
||||
|
||||
Basic resizing in Twig is done using the `| resize` filter. Resizing requires at least one of the two dimension arguments.
|
||||
|
||||
```html
|
||||
Resize to width 1000px and height 700px:
|
||||
<img src="{{ image | media | resize(1000, 700) }}">
|
||||
|
||||
Resize to width 1000px and automatically calculate height:
|
||||
<img src="{{ image | media | resize(1000) }}">
|
||||
|
||||
Resize to height 700px and automatically calculate width:
|
||||
<img src="{{ image | media | resize(null, 700) }}">
|
||||
```
|
||||
|
||||
A third argument is available, `options`, which allows you specify the resizing mode, along with any other image modifications which are detailed below.
|
||||
|
||||
#### Resizing Modes
|
||||
|
||||
Resizing modes are almost synonymous to CSS3 `background-size` modes to make it easier to remember. Available options are: `auto` (default), `cover` and `contain`, each doing the same as their CSS equivalent, with one additional mode: `stretch` which behaves how a basic `<img>` element would:
|
||||
|
||||
```html
|
||||
Default (image is displayed in its original size):
|
||||
<img src="{{ image | media | resize(1000, 700, { mode: 'auto' }) }}">
|
||||
|
||||
Resize the background image to make sure the image is fully visible
|
||||
<img src="{{ image | media | resize(1000, 700, { mode: 'contain' }) }}">
|
||||
|
||||
Resize the background image to cover the entire container, even if it has to cut a little bit off one of the edges
|
||||
<img src="{{ image | media | resize(1000, 700, { mode: 'cover' }) }}">
|
||||
|
||||
Stretch and morph it to fit exatly in the defined dimensions
|
||||
<img src="{{ image | media | resize(1000, 700, { mode: 'stretch' }) }}">
|
||||
```
|
||||
|
||||
When using `mode: cover` (alias `mode: crop`) you may specify the `fit_position` modifier to choose where the center of the resize should be focused.
|
||||
|
||||
**Further Modifications**
|
||||
|
||||
A few image adjustment tools and filters have been implemented into this plugin, which utilise their Intervention Image library counterparts.
|
||||
|
||||
Usage of the modifiers is simple, either add them in a `key: value` fashion in the 3rd argument of the resize filter, or by using the modify filter, as such:
|
||||
|
||||
```html
|
||||
<img src="{{ image | media | resize(1000, 700, { modifier: value }) }}">
|
||||
<img src="{{ image | media | modify({ modifier: value }) }}"> <!-- Same size, just modified -->
|
||||
```
|
||||
|
||||
| Modifier Name | Code | Rules | Examples | Details |
|
||||
| ------------- | ---------- | ---------------------- | ------------------------ | ------- |
|
||||
| Format | format | in:jpg,png,webp,bmp,gif,ico,auto | `jpg`, `png`, `auto`, ... | Change the format of the image.
|
||||
| Blur | blur | min:0 max:100 | `0`, `50`, `100` | Blurs the image
|
||||
| Sharpen | sharpen | min:0 max:100 | `0`, `50`, `100` | Sharpens the image
|
||||
| Brightness | brightness | min:-100 max:100 | `-100`, `50`, `100` | Brightens (or darkens) the image
|
||||
| Contrast | contrast | min:-100 max:100 | `-100`, `50`, `100` | Increases/decreases the contrast of the image
|
||||
| Pixelate | pixelate | min:1 max:1000 | `1`, `500`, `1000` | Pixelates the image
|
||||
| Greyscale | greyscale/grayscale | accepted | `true`, `1` | See [accepted](https://octobercms.com/docs/services/validation#rule-accepted) rule. Sets the image mode to greyscale. Both codes are accepted (one just maps to the other) |
|
||||
| Invert | invert | accepted | `true`, `1` | See [accepted](https://octobercms.com/docs/services/validation#rule-accepted) rule. Inverts all image colors |
|
||||
| Opacity | opacity | min:0 max:100 | `0`, `50`, `100` | Set the opacity of the image
|
||||
| Rotate | rotate | min:0 max:360 | `45`, `90`, `360` | Rotate the image (width / height does not constrain the rotated image, the image is resized prior to modifications)
|
||||
| Flip | flip | 'h' or 'v' | `h`, `v` | Flip horizontally (h) or vertically (v) |
|
||||
| Background | fill/background | Hex color | `#fff`, `#123456`, `000` | Set a background color - Hex color (with or without hashtag). Both codes are accepted (one just maps to the other) |
|
||||
| Colorize | colourise/colorize | string (format: r,g,b) | `255,0,0`, `0,50,25` | Colorize the image. String containing 3 numbers (0-255), comma separated. Both codes are accepted (one just maps to the other) |
|
||||
|
||||
A couple examples from the above:
|
||||
```html
|
||||
<img src="{{ image | media | resize(1000, 700, { brightness: 50 }) }}">
|
||||
<img src="{{ image | media | resize(1000, 700, { invert: true }) }}">
|
||||
<img src="{{ image | media | resize(1000, 700, { rotate: 45 }) }}">
|
||||
<img src="{{ image | media | resize(1000, 700, { background: '#fff' }) }}">
|
||||
<img src="{{ image | media | resize(1000, 700, { colorize: '65,35,5' }) }}">
|
||||
```
|
||||
|
||||
**Please Note:** In order to encode images to WebP format, you will need to enable WebP support on your chosen driver (Imagick or GD). It's likely that by default you will not have WebP support, so using this format may result in errors or broken images.
|
||||
|
||||
|
||||
### Filters (templates for configuration)
|
||||
|
||||
Filters in the Image Resize plugin, while following a similar concept to filters in Intervention Image, are handled differently in this plugin.
|
||||
|
||||
Filters are specified in the *Settings > Image Resizer* page. By clicking the *Filters* tab at the top, you can specify a filter "code" which can apply a set of enhancements and modifications to an image. Once saved, you can then use the `filter` option in the `resize` and `modify` Twig filters to specify the filter to use.
|
||||
|
||||
A common example would be a basic thumbnail - you want this to always be `format: jpg`, `mode: cover`, `quality: 60`, `max_width: 200`, `max_height: 200` and maybe `background: #fff`.
|
||||
|
||||
With filters, you can specify the above, call it something useful like `thumbnail`, then simply do the following:
|
||||
```html
|
||||
<!-- display thumbnail -->
|
||||
<img src="{{ image | media | modify({ filter: 'thumbnail' }) }}">
|
||||
or
|
||||
<!-- display thumbnail, but 150x150 -->
|
||||
<img src="{{ image | media | resize(150, 150, { filter: 'thumbnail' }) }}">
|
||||
```
|
||||
|
||||
Which will use the predefined list of modifiers and have them overwritten by any that are supplied, for example:
|
||||
|
||||
```html
|
||||
<img src="{{ image | media | modify({ filter: 'thumbnail', brightness: -30, contrast: 30 }) }}">
|
||||
```
|
||||
|
||||
> There are a couple new modifiers for filters which include: `min_width`, `max_width`, `min_height`, `max_height` which all act as constraints for the dimensions of the images using filters.
|
||||
>
|
||||
>Should you use one, please note that if you use it with the `| resize(w, h)` function, your supplied dimensions will be ignored *if* they are out of bounds of the constraints.
|
||||
|
||||
|
||||
**Using the library in PHP**
|
||||
|
||||
Should you want to implement your own use of this library outside of Twig, you can use it in a very similar manner:
|
||||
|
||||
```php
|
||||
$resizer = new \ABWebDevelopers\ImageResize\Classes\Resizer($image);
|
||||
$resizer->resize(800, 250, [
|
||||
'rotate' => 45
|
||||
]);
|
||||
// $resizer->render(); // only use this if you intend on aborting the script immediately at this point
|
||||
```
|
||||
|
||||
Which is synonymous to:
|
||||
|
||||
```html
|
||||
<img src="{{ image | resize(800, 250, { rotate: 45 }) }}">
|
||||
```
|
||||
|
||||
### Bugs and New Features
|
||||
|
||||
We encourage you to open PRs and/or issues relating to any bugs or features so that everyone can benefit from them.
|
||||
|
||||
### Special thanks to
|
||||
|
||||
- [Intervention Image](https://github.com/Intervention/image)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
|
@ -0,0 +1,4 @@
|
|||
/* Show 'comment' on new line for colorpickers instead of starting inline */
|
||||
.field-colorpicker + .help-block {
|
||||
clear: both;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Commands;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Classes\Resizer;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ImageResizeClear extends Command
|
||||
{
|
||||
protected $name = 'imageresize:clear';
|
||||
|
||||
protected $description = 'Clear all resized images.';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$deleted = Resizer::clearFiles();
|
||||
|
||||
$this->info('Successfully deleted ' . $deleted . ' ' . Str::plural('file', $deleted));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Commands;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Classes\Resizer;
|
||||
use ABWebDevelopers\ImageResize\Models\Settings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ImageResizeGc extends Command
|
||||
{
|
||||
protected $name = 'imageresize:gc';
|
||||
|
||||
protected $description = 'Garbage collect all old resized images.';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$minAge = Carbon::now()->modify('-' . Settings::getAgeToDelete());
|
||||
|
||||
$deleted = Resizer::clearFiles($minAge);
|
||||
|
||||
$this->info('Successfully deleted ' . $deleted . ' ' . Str::plural('file', $deleted));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Commands;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Models\ImagePermalink;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ImageResizeResetPermalinks extends Command
|
||||
{
|
||||
protected $name = 'imageresize:reset-permalinks';
|
||||
|
||||
protected $description = 'Delete all permalink configurations in case of needing to regenerate all images using new modifications. If all identifiers are the same, this should have no major affect on the website.';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$deleted = ImagePermalink::count();
|
||||
|
||||
// Delete all permalinks
|
||||
ImagePermalink::query()->delete();
|
||||
|
||||
$this->info('Successfully deleted ' . $deleted . ' ' . Str::plural('permalink', $deleted));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'plugin' => [
|
||||
'name' => 'Image Resizer',
|
||||
'description' => 'Adds filters for templates, allowing you to resize, crop, etc, images on the fly with caching',
|
||||
],
|
||||
'permissions' => [
|
||||
'tab' => 'Image Resizer',
|
||||
'access_settings' => 'Access to image resizer settings',
|
||||
],
|
||||
'settings' => [
|
||||
'tabs' => [
|
||||
'main' => 'Main',
|
||||
'filters' => 'Filters',
|
||||
'cache' => 'Caching',
|
||||
],
|
||||
'sections' => [
|
||||
'_404' => [
|
||||
'label' => 'Image Not Found',
|
||||
'comment' => 'Specify what to do when an image is not found'
|
||||
]
|
||||
],
|
||||
'fields' => [
|
||||
'driver' => [
|
||||
'label' => 'Image Driver for PHP',
|
||||
'comment' => 'Choose the image driver (only supports drivers supported by intervention\image library)',
|
||||
'options' => [
|
||||
'gd' => 'GD Library',
|
||||
'imagick' => 'Imagick Extension'
|
||||
],
|
||||
],
|
||||
'mode' => [
|
||||
'label' => 'Default resizing mode',
|
||||
'comment' => 'Choose the different mode to use when resizing to a specific size (CSS "background-size" options are supported, with an additional mode "stretch" which acts like an img element)',
|
||||
'options' => [
|
||||
'auto' => 'Auto',
|
||||
'contain' => 'Contain',
|
||||
'cover' => 'Cover',
|
||||
'stretch' => 'Stretch',
|
||||
],
|
||||
],
|
||||
'quality' => [
|
||||
'label' => 'Default Output Quality',
|
||||
'comment' => 'Default output quality for images (1-100)'
|
||||
],
|
||||
'image_not_found' => [
|
||||
'label' => '404 Image Source',
|
||||
'comment' => 'Select a different image to be displayed when images are not found',
|
||||
],
|
||||
'image_not_found_background' => [
|
||||
'label' => '404 Image Background Color',
|
||||
'comment' => 'Background color for the default 404 image',
|
||||
],
|
||||
'image_not_found_transparent' => [
|
||||
'label' => '404 Image Transparent?',
|
||||
'comment' => 'Should the 404 image be transparent?',
|
||||
],
|
||||
'image_not_found_mode' => [
|
||||
'label' => '404 Image Resize Mode',
|
||||
'comment' => 'Resizing mode for image above',
|
||||
],
|
||||
'image_not_found_format' => [
|
||||
'label' => '404 Image Format',
|
||||
'comment' => 'Output format for image above',
|
||||
],
|
||||
'image_not_found_quality' => [
|
||||
'label' => '404 Image Quality',
|
||||
'comment' => 'Default output quality for the image above',
|
||||
],
|
||||
'format' => [
|
||||
'label' => 'Default Output Format',
|
||||
'comment' => 'Select the default format to resize/export images to',
|
||||
'options' => [
|
||||
'auto' => 'Automatic (Use input format)',
|
||||
'jpg' => 'JPG',
|
||||
'png' => 'PNG',
|
||||
'webp' => 'WEBP',
|
||||
'bmp' => 'BMP',
|
||||
'gif' => 'GIF',
|
||||
'ico' => 'ICO',
|
||||
]
|
||||
],
|
||||
'background' => [
|
||||
'label' => 'Default Background Color',
|
||||
'comment' => 'When converting alpha-channel images (png, webp) to flat images (jpg, etc), define the default color of the background',
|
||||
],
|
||||
'filters' => [
|
||||
'label' => 'Filters',
|
||||
'prompt' => 'Add a new Filter',
|
||||
'fields' => [
|
||||
'code' => [
|
||||
'label' => 'Code',
|
||||
'comment' => 'Used in reference when using filters',
|
||||
],
|
||||
'description' => [
|
||||
'label' => 'Description',
|
||||
'comment' => 'Description of this filter',
|
||||
],
|
||||
'rules' => [
|
||||
'label' => 'Rules / Modifications',
|
||||
'prompt' => 'Add a new rule',
|
||||
'fields' => [
|
||||
'modifier' => [
|
||||
'label' => 'Modifier Rule',
|
||||
'comment' => 'Add a modifier',
|
||||
'options' => [
|
||||
'width' => 'Width',
|
||||
'height' => 'Height',
|
||||
'min_width' => 'Min Width',
|
||||
'min_height' => 'Min Height',
|
||||
'max_width' => 'Max Width',
|
||||
'max_height' => 'Max Height',
|
||||
'blur' => 'Blur',
|
||||
'sharpen' => 'Sharpen',
|
||||
'brightness' => 'Brightness',
|
||||
'contrast' => 'Contrast',
|
||||
'pixelate' => 'Pixelate',
|
||||
'greyscale' => 'Greyscale',
|
||||
'invert' => 'Invert',
|
||||
'opacity' => 'Opacity',
|
||||
'rotate' => 'Rotate',
|
||||
'flip' => 'Flip',
|
||||
'background' => 'Background',
|
||||
'colorize' => 'Colorize',
|
||||
'format' => 'Format',
|
||||
'quality' => 'Quality',
|
||||
'mode' => 'Mode',
|
||||
'fit_position' => 'Fit Position (for cover mode)',
|
||||
]
|
||||
],
|
||||
'value' => [
|
||||
'label' => 'Modifier Value',
|
||||
'comment' => 'Specify the value for this modifier',
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'cache_directory' => [
|
||||
'label' => 'Cache Directory',
|
||||
'comment' => 'The directory to store cached resized images (absolute or relative to base_path). Default: storage/temp/public/imageresizecache',
|
||||
],
|
||||
'cache_clear_interval' => [
|
||||
'label' => 'Cache Clear Interval',
|
||||
'comment' => 'Default/Empty: Disables auto clear. Else: Datetime intveral in human readable form (e.g. 12 hours, 5 days, 1 year)',
|
||||
],
|
||||
'cleanup_on_cache_clear' => [
|
||||
'label' => 'Clear Images on Cache Clear?',
|
||||
'comment' => 'When running `artisan cache:clear` should all images be cleared as well? Default: false'
|
||||
]
|
||||
],
|
||||
],
|
||||
'widgets' => [
|
||||
'clear' => [
|
||||
'cleared' => 'Successfully cleared all resized cached images (:size)',
|
||||
'showGcInterval' => 'Show Garbage Collection Interval',
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'plugin' => [
|
||||
'name' => 'Kuvamuunnin',
|
||||
'description' => 'Lisää suotimia sivupohjiin mahdollistaen kuvien kokomuunnokset, rajaukset, jne. (hyödyntää välimuistia)',
|
||||
],
|
||||
'permissions' => [
|
||||
'tab' => 'Kuvan muunnin',
|
||||
'access_settings' => 'Pääsy kuvamuutimen asetuksiin',
|
||||
],
|
||||
'settings' => [
|
||||
'tabs' => [
|
||||
'main' => 'Asetukset',
|
||||
'filters' => 'Suotimet'
|
||||
],
|
||||
'sections' => [
|
||||
'_404' => [
|
||||
'label' => 'Kuvaa ei löydy',
|
||||
'comment' => 'Määrittele toiminto tilanteeseen, kun kuvaa ei löydy'
|
||||
]
|
||||
],
|
||||
'fields' => [
|
||||
'driver' => [
|
||||
'label' => 'PHP-kuvaohjain',
|
||||
'comment' => 'Valitse kuvaohjain (tukee vain kuvakirjaston omia ominaisuuksia)',
|
||||
'options' => [
|
||||
'gd' => 'GD Library',
|
||||
'imagick' => 'Imagick Extension'
|
||||
],
|
||||
],
|
||||
'mode' => [
|
||||
'label' => 'Oletus muuntomoodi',
|
||||
'comment' => 'Choose the different mode to use when resizing to a specific size (CSS "background-size" options are supported, with an additional mode "stretch" which acts like an img element)',
|
||||
'options' => [
|
||||
'auto' => 'Autom.',
|
||||
'contain' => 'Säilytä',
|
||||
'cover' => 'Täytä',
|
||||
'stretch' => 'Venytä',
|
||||
],
|
||||
],
|
||||
'quality' => [
|
||||
'label' => 'Oletuslaatu',
|
||||
'comment' => 'Oletuslaatu kuville (1-100)'
|
||||
],
|
||||
'image_not_found' => [
|
||||
'label' => '404 kuvan lähde',
|
||||
'comment' => 'Valitse kuva, joka näytetään mikäli alkuperäistä ei löydy',
|
||||
],
|
||||
'image_not_found_background' => [
|
||||
'label' => '404 kuvan taustaväri',
|
||||
'comment' => 'Background color for the image above',
|
||||
],
|
||||
'image_not_found_mode' => [
|
||||
'label' => '404 kuvan kokomuuntimen moodi',
|
||||
'comment' => 'Kokomuuntimen toimintatapa',
|
||||
],
|
||||
'image_not_found_format' => [
|
||||
'label' => '404 kuvaformaatti',
|
||||
'comment' => 'Kuvan formaatti',
|
||||
],
|
||||
'image_not_found_quality' => [
|
||||
'label' => '404 kuvan laatu',
|
||||
'comment' => 'Kuvan laatu',
|
||||
],
|
||||
'format' => [
|
||||
'label' => 'Oletus kuvaformaatti',
|
||||
'comment' => 'Valitse oletus kuvaformaatti',
|
||||
'options' => [
|
||||
'auto' => 'automaattinen (käytä alkuperäistä)',
|
||||
'jpg' => 'JPG',
|
||||
'png' => 'PNG',
|
||||
'webp' => 'WEBP',
|
||||
'bmp' => 'BMP',
|
||||
'gif' => 'GIF',
|
||||
'ico' => 'ICO',
|
||||
]
|
||||
],
|
||||
'background' => [
|
||||
'label' => 'Taustan oletusväri',
|
||||
'comment' => 'Määritä taustaväri tilanteisiin, jossa läpinäkyvällä taustalla oleva kuva (png, webp) muunnetaan (jpg, etc) taustalliseksi',
|
||||
],
|
||||
'filters' => [
|
||||
'label' => 'Suotimet',
|
||||
'prompt' => 'Lisää suodin',
|
||||
'fields' => [
|
||||
'code' => [
|
||||
'label' => 'Koodi',
|
||||
'comment' => 'Käytetään suotimien referenssinä',
|
||||
],
|
||||
'description' => [
|
||||
'label' => 'Kuvaus',
|
||||
'comment' => 'Suotimen kuvaus',
|
||||
],
|
||||
'rules' => [
|
||||
'label' => 'Säännöt / Muokkaukset',
|
||||
'prompt' => 'Lisää uusi sääntö',
|
||||
'fields' => [
|
||||
'modifier' => [
|
||||
'label' => 'Muokkaussääntö',
|
||||
'comment' => 'Lisää muokkain',
|
||||
'options' => [
|
||||
'width' => 'Leveys',
|
||||
'height' => 'Korkeus',
|
||||
'min_width' => 'Min. leveys',
|
||||
'min_height' => 'Min. korkeus',
|
||||
'max_width' => 'Maks. leveys',
|
||||
'max_height' => 'Maks. korkeus',
|
||||
'blur' => 'Sumenna',
|
||||
'sharpen' => 'Terävöitä',
|
||||
'brightness' => 'Kirkkaus',
|
||||
'contrast' => 'Kontrasti',
|
||||
'pixelate' => 'Pikselöi',
|
||||
'greyscale' => 'Harmaasävy',
|
||||
'invert' => 'Käänteinen väri',
|
||||
'opacity' => 'Läpinäkyvyys',
|
||||
'rotate' => 'Pyöritä',
|
||||
'flip' => 'Käännä',
|
||||
'background' => 'Tausta',
|
||||
'colorize' => 'Väritä',
|
||||
'format' => 'Formaatti',
|
||||
'quality' => 'Laatu',
|
||||
'mode' => 'Moodi',
|
||||
]
|
||||
],
|
||||
'value' => [
|
||||
'label' => 'Muokkaimen arvo',
|
||||
'comment' => 'Määritä tämän muokkaimen arvo',
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
return [
|
||||
'plugin' => [
|
||||
'name' => 'Image Resizer',
|
||||
'description' => 'Добавляет фильтры, позволяющие обрабатывать изображения на лету (изменение размера, обрезка и пр.) с кешированием',
|
||||
],
|
||||
'permissions' => [
|
||||
'tab' => 'Image Resizer',
|
||||
'access_settings' => 'Настройки обработки изображений',
|
||||
],
|
||||
'settings' => [
|
||||
'tabs' => [
|
||||
'main' => 'Основные',
|
||||
'filters' => 'Фильтры'
|
||||
],
|
||||
'sections' => [
|
||||
'_404' => [
|
||||
'label' => 'Изображение не найдено',
|
||||
'comment' => 'Выберите, как поступить, если изображение не найдено'
|
||||
]
|
||||
],
|
||||
'fields' => [
|
||||
'driver' => [
|
||||
'label' => 'PHP-драйвер для обработки изображений',
|
||||
'comment' => 'Выберите драйвер (только поддерживаемые библиотекой intervention\image)',
|
||||
'options' => [
|
||||
'gd' => 'Библиотека GD',
|
||||
'imagick' => 'Расширение Imagick'
|
||||
],
|
||||
],
|
||||
'mode' => [
|
||||
'label' => 'Режим по-умолчанию',
|
||||
'comment' => 'Выберите режим, который будет использоваться, если заданы фиксированные значения ширины и высоты (поддерживаются опции CSS "background-size", с дополнительным режимом "stretch")',
|
||||
'options' => [
|
||||
'auto' => 'Автоматически',
|
||||
'contain' => 'Вписать (contain)',
|
||||
'cover' => 'Заполнить (cover)',
|
||||
'stretch' => 'Растянуть (stretch)',
|
||||
],
|
||||
],
|
||||
'format' => [
|
||||
'label' => 'Формат генерируемых изображений',
|
||||
'comment' => 'Выберите формат, в котором будут выводиться генерируемые изображения',
|
||||
'options' => [
|
||||
'auto' => 'Автоматически (исходный формат)',
|
||||
'jpg' => 'JPG',
|
||||
'png' => 'PNG',
|
||||
'webp' => 'WEBP',
|
||||
'bmp' => 'BMP',
|
||||
'gif' => 'GIF',
|
||||
'ico' => 'ICO',
|
||||
]
|
||||
],
|
||||
'quality' => [
|
||||
'label' => 'Качество по-умолчанию',
|
||||
'comment' => 'Выберите качество генерируемых изображений (1-100)'
|
||||
],
|
||||
'image_not_found' => [
|
||||
'label' => '404 Изображение не найдено',
|
||||
'comment' => 'Выберите изображение, которое будет выводиться, если исходное не найдено',
|
||||
],
|
||||
'image_not_found_background' => [
|
||||
'label' => 'Цвет фона изображения 404',
|
||||
'comment' => 'Выберите цвет фона для изображения, заданного выше',
|
||||
],
|
||||
'image_not_found_mode' => [
|
||||
'label' => 'Режим по-умолчанию изображения 404',
|
||||
'comment' => 'Выберите режим изменения размера для изображения 404',
|
||||
],
|
||||
'image_not_found_format' => [
|
||||
'label' => 'Формат изображения 404',
|
||||
'comment' => 'Выберите формат, в котором будут выводиться изображения 404',
|
||||
],
|
||||
'image_not_found_quality' => [
|
||||
'label' => 'Качество по-умолчанию изображения 404',
|
||||
'comment' => 'Выберите качество генерируемых изображений 404 (1-100)',
|
||||
],
|
||||
'background' => [
|
||||
'label' => 'Фон по-умолчанию',
|
||||
'comment' => 'Выберите цвет, который будет замещать прозрачные участки изображений с прозрачностью (png, webp) при конвертировании в форматы, не поддерживающие прозрачность (jpg, etc)',
|
||||
],
|
||||
'filters' => [
|
||||
'label' => 'Фильтры',
|
||||
'prompt' => 'Добавить фильтр',
|
||||
'fields' => [
|
||||
'code' => [
|
||||
'label' => 'Код фильтра',
|
||||
'comment' => 'Используется при ссылке на фильтр',
|
||||
],
|
||||
'description' => [
|
||||
'label' => 'Описание',
|
||||
'comment' => 'Напишите описание для этого фильтра',
|
||||
],
|
||||
'rules' => [
|
||||
'label' => 'Правила / Модификации',
|
||||
'prompt' => 'Добавить новое правило',
|
||||
'fields' => [
|
||||
'modifier' => [
|
||||
'label' => 'Свойство',
|
||||
'comment' => 'Выберите свойство',
|
||||
'options' => [
|
||||
'width' => 'Ширина',
|
||||
'height' => 'Высота',
|
||||
'min_width' => 'Минимальная ширина',
|
||||
'min_height' => 'Минимальная высота',
|
||||
'max_width' => 'Максимальная ширина',
|
||||
'max_height' => 'Максимальная высота',
|
||||
'blur' => 'Размытие',
|
||||
'sharpen' => 'Резкость',
|
||||
'brightness' => 'Яркость',
|
||||
'contrast' => 'Контрастность',
|
||||
'pixelate' => 'Пикселизация',
|
||||
'greyscale' => 'Оттенки серого',
|
||||
'invert' => 'Инвертировать',
|
||||
'opacity' => 'Прозрачность',
|
||||
'rotate' => 'Поворот',
|
||||
'flip' => 'Отражение',
|
||||
'background' => 'Цвет фона',
|
||||
'colorize' => 'Изменение оттенка',
|
||||
'format' => 'Формат',
|
||||
'quality' => 'Качество',
|
||||
'mode' => 'Режим',
|
||||
]
|
||||
],
|
||||
'value' => [
|
||||
'label' => 'Значение',
|
||||
'comment' => 'Задайте значение для выбранного свойства',
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Models;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Classes\Resizer;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Model;
|
||||
|
||||
class ImagePermalink extends Model
|
||||
{
|
||||
public $table = 'abweb_imageresize_permalinks';
|
||||
|
||||
/**
|
||||
* Define cast types for each modifier type
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $castModifiers = [
|
||||
'identifier' => 'string',
|
||||
'image' => 'string',
|
||||
'path' => 'string',
|
||||
];
|
||||
|
||||
public $jsonable = [
|
||||
'options',
|
||||
];
|
||||
|
||||
/**
|
||||
* When casting this object to string, retrieve the Permalink URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->permalink_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default for options (empty array) and path (empty string) on save
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function beforeSave()
|
||||
{
|
||||
if (is_null($this->options)) {
|
||||
$this->options = [];
|
||||
}
|
||||
|
||||
if (is_null($this->path)) {
|
||||
$this->path = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an ImagePermalink class by the given identifier (and provide
|
||||
* defaults for when not resized yet: width, height, options)
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param string $image
|
||||
* @param integer $width
|
||||
* @param integer $height
|
||||
* @param array $options
|
||||
* @return ImagePermalink
|
||||
*/
|
||||
public static function getPermalink(string $identifier, string $image, int $width = null, int $height = null, array $options = []): ImagePermalink
|
||||
{
|
||||
$resizer = new Resizer((string) $image);
|
||||
|
||||
$width = ($width !== null) ? (int) $width : null;
|
||||
$height = ($height !== null) ? (int) $height : null;
|
||||
$options = ($options instanceof Arrayable) ? $options->toArray() : (array) $options;
|
||||
|
||||
return $resizer->resizePermalink($identifier, $width, $height, $options)->permalink_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope all results by those matching the identifier (should always be only one)
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $identifier
|
||||
* @return void
|
||||
*/
|
||||
public function scopeByIdentifier(Builder $query, string $identifier): void
|
||||
{
|
||||
$query->where('identifier', $identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Image Permalink with this identifier if it exists
|
||||
*
|
||||
* @param string $identifier
|
||||
* @return ImagePermalink|null
|
||||
*/
|
||||
public static function withIdentifer(string $identifier): ?ImagePermalink
|
||||
{
|
||||
return static::byIdentifier($identifier)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the resized version of this image exist?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function resizeExists(): bool
|
||||
{
|
||||
return !empty($this->path) && file_exists($this->absolute_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a short life hash for this file.
|
||||
* This will be where the image is stored in the storage path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateShortLifeHash(): string
|
||||
{
|
||||
return hash('sha256', $this->identifier . ':permalink:' . json_encode($this->options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the image, if not already resized
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resize()
|
||||
{
|
||||
if ($this->resizeExists() === false) {
|
||||
$config = $this->options ?? [];
|
||||
|
||||
$resizer = Resizer::using($this->image)
|
||||
->setHash($hash = $this->generateShortLifeHash())
|
||||
->setOptions($config)
|
||||
->doResize();
|
||||
|
||||
$path = $resizer->getRelativePath();
|
||||
|
||||
$this->path = $path;
|
||||
$this->resized_at = now();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute path to the resized image
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAbsolutePathAttribute(): string
|
||||
{
|
||||
return base_path($this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permalink URL for this image
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalinkUrlAttribute(): string
|
||||
{
|
||||
return url('/imageresizestatic/' . $this->identifier . '.' . $this->extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the resized copy of this image exists, delete it.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function deleteResize()
|
||||
{
|
||||
if ($this->resizeExists()) {
|
||||
unlink($this->absolute_path);
|
||||
}
|
||||
|
||||
$this->path = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this image to screen, now.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->resize(); // if not resized
|
||||
|
||||
header('Content-Type: ' . $this->mime_type);
|
||||
header('Content-Length: ' . filesize($this->absolute_path));
|
||||
echo file_get_contents($this->absolute_path);
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a default 404 image not found mock permalink
|
||||
*
|
||||
* @return ImagePermalink
|
||||
*/
|
||||
public static function defaultNotFound(): ImagePermalink
|
||||
{
|
||||
$identifier = '404';
|
||||
$resizer = Resizer::using('');
|
||||
|
||||
return static::fromResizer($identifier, $resizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise an ImagePermalink from the given Resizer instance
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param Resizer $resizer
|
||||
* @return ImagePermalink
|
||||
*/
|
||||
public static function fromResizer(string $identifier, Resizer $resizer): ImagePermalink
|
||||
{
|
||||
$that = static::withIdentifer($identifier);
|
||||
|
||||
if ($that === null) {
|
||||
$that = new static();
|
||||
|
||||
$resizer->preventDefaultImage();
|
||||
$that->identifier = $identifier;
|
||||
$that->image = $resizer->getImagePathRelativePreferred();
|
||||
|
||||
list($mime, $format) = $resizer->detectFormat(true);
|
||||
|
||||
$that->mime_type = 'image/' . $mime;
|
||||
$that->extension = $format;
|
||||
$that->options = $resizer->getCacheableOptions();
|
||||
|
||||
$that->save();
|
||||
} elseif (($that->resizeExists() === false) || empty($that->image)) {
|
||||
// In the case where the resize doesn't exist (typically after cache:flush) we want
|
||||
// to update the image reference as well as options.
|
||||
$that->image = $resizer->getImagePathRelativePreferred();
|
||||
|
||||
// If resize exists, delete the resized copy
|
||||
$that->deleteResize();
|
||||
|
||||
list($mime, $format) = $resizer->detectFormat(true);
|
||||
|
||||
$that->mime_type = 'image/' . $mime;
|
||||
$that->extension = $format;
|
||||
$that->options = $resizer->getCacheableOptions();
|
||||
|
||||
$that->save();
|
||||
}
|
||||
|
||||
return $that;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,286 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Models;
|
||||
|
||||
use Model;
|
||||
use Validator;
|
||||
use October\Rain\Database\Traits\Validation;
|
||||
|
||||
class Settings extends Model
|
||||
{
|
||||
use Validation;
|
||||
|
||||
/** @var string The default Image Not Found image, @see ::getDefaultImageNotFound() */
|
||||
public const DEFAULT_IMAGE_NOT_FOUND = 'plugins/abwebdevelopers/imageresize/assets/image-not-found.png';
|
||||
|
||||
/** @var string Storage path for cached images, @see ::getBasePath() */
|
||||
public const DEFAULT_STORAGE_PATH = 'storage/temp/public/imageresizecache';
|
||||
|
||||
/** @var string The age a cached file must be before scheduled deletion, @see ::getAgeToDelete() */
|
||||
public const DEFAULT_CACHE_CLEAR_AGE = '1 week';
|
||||
|
||||
/**
|
||||
* Implement settings model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $implement = [
|
||||
'System.Behaviors.SettingsModel'
|
||||
];
|
||||
|
||||
/**
|
||||
* Define settings code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $settingsCode = 'abwebdevelopers_imageresize';
|
||||
|
||||
/**
|
||||
* Define settings fields
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $settingsFields = 'fields.yaml';
|
||||
|
||||
/**
|
||||
* Define validation rules for settings
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rules = [
|
||||
'driver' => 'required|string|in:gd,imagick',
|
||||
'background' => 'required|string|regex:/^#([a-f0-9]{3}){1,2}$/i',
|
||||
'mode' => 'required|string|in:auto,cover,contain,stretch',
|
||||
'quality' => 'required|min:1|max:100',
|
||||
'format' => 'required|string|in:auto,jpg,png,bmp,gif,ico,webp',
|
||||
'filters.*.modifier' => 'in:width,height,min_width,min_height,max_width,max_height,blur,sharpen,brightness,contrast,pixelate,greyscale,invert,opacity,rotate,flip,background,colorize,format,quality,mode',
|
||||
'filters.*.value' => 'string|min:0|max:10',
|
||||
'image_not_found' => 'nullable',
|
||||
'image_not_found_background' => 'required|regex:/^#([a-f0-9]{3}){1,2}$/i',
|
||||
'image_not_found_mode' => 'required|in:auto,cover,contain,stretch',
|
||||
'image_not_found_quality' => 'required|min:1|max:100',
|
||||
|
||||
'cache_directory' => 'nullable|string',
|
||||
'cache_clear_interval' => 'nullable|string',
|
||||
'cleanup_on_cache_clear' => 'nullable|boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define cast types for each modifier type
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $castModifiers = [
|
||||
'width' => 'int',
|
||||
'height' => 'int',
|
||||
'min_width' => 'int',
|
||||
'min_height' => 'int',
|
||||
'max_width' => 'int',
|
||||
'max_height' => 'int',
|
||||
'blur' => 'int',
|
||||
'sharpen' => 'int',
|
||||
'brightness' => 'int',
|
||||
'contrast' => 'int',
|
||||
'pixelate' => 'int',
|
||||
'greyscale' => 'bool',
|
||||
'invert' => 'bool',
|
||||
'opacity' => 'int',
|
||||
'rotate' => 'int',
|
||||
'flip' => 'string',
|
||||
'background' => 'string',
|
||||
'colorize' => 'string',
|
||||
'format' => 'string',
|
||||
'quality' => 'int',
|
||||
'mode' => 'string',
|
||||
'fit_position' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define validation rules for each modifier type
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $modifierRules = [
|
||||
'width' => 'bail|int|min:0|max:10000',
|
||||
'height' => 'bail|int|min:0|max:10000',
|
||||
'min_width' => 'bail|int|min:0|max:10000',
|
||||
'min_height' => 'bail|int|min:0|max:10000',
|
||||
'max_width' => 'bail|int|min:0|max:10000',
|
||||
'max_height' => 'bail|int|min:0|max:10000',
|
||||
'blur' => 'bail|int|min:0|max:100',
|
||||
'sharpen' => 'bail|int|min:0|max:100',
|
||||
'brightness' => 'bail|int|min:-100|max:100',
|
||||
'contrast' => 'bail|int|min:-100|max:100',
|
||||
'pixelate' => 'bail|int|min:1|max:1000',
|
||||
'greyscale' => 'bail|accepted',
|
||||
'invert' => 'bail|accepted',
|
||||
'opacity' => 'bail|int|min:0|max:100',
|
||||
'rotate' => 'bail|int|min:0|max:360',
|
||||
'flip' => 'bail|string|in:v,h',
|
||||
'background' => 'bail|string|regex:/^#([a-f0-9]{3}){1,2}$/',
|
||||
'colorize' => 'bail|string|regex:/^(?:-?(?:100|[0-9]{2})),(?:-?(?:100|[0-9]{2})),(?:-?(?:100|[0-9]{2}))$/',
|
||||
'format' => 'bail|string|in:auto,jpg,png,bmp,gif,ico,webp',
|
||||
'quality' => 'bail|int|min:1|max:100',
|
||||
'mode' => 'bail|string|in:auto,cover,contain,stretch',
|
||||
'fit_position' => 'bail|string|in:top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right',
|
||||
];
|
||||
|
||||
/**
|
||||
* Before validating, cast modifier values to their respective type
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function beforeValidate()
|
||||
{
|
||||
if (!empty($this->value)) {
|
||||
$data = $this->value;
|
||||
|
||||
if (!empty($data['filters'])) {
|
||||
foreach ($data['filters'] as $filterId => $filter) {
|
||||
foreach ($filter['rules'] as $ruleId => $rule) {
|
||||
switch ($this->castModifiers[$rule['modifier']]) {
|
||||
case 'int':
|
||||
$rule['value'] = (int) $rule['value'];
|
||||
break;
|
||||
case 'float':
|
||||
$rule['value'] = (float) $rule['value'];
|
||||
break;
|
||||
case 'bool':
|
||||
$rule['value'] = (bool) ($rule['value'] === '1' || $rule['value'] === 'true');
|
||||
break;
|
||||
case 'string':
|
||||
default:
|
||||
$rule['value'] = (string) $rule['value'];
|
||||
break;
|
||||
}
|
||||
$filter['rules'][$ruleId] = $rule;
|
||||
}
|
||||
$data['filters'][$filterId] = $filter;
|
||||
}
|
||||
}
|
||||
|
||||
$this->value = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Before saving, validate the modifiers which have their own validation logic. Throw an
|
||||
* exception on fail.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function beforeSave()
|
||||
{
|
||||
if (!empty($this->value)) {
|
||||
$data = $this->value;
|
||||
|
||||
if (empty($data['cache_directory'])) {
|
||||
$data['cache_directory'] = $this->getBasePath();
|
||||
}
|
||||
|
||||
if (empty($data['cache_clear_interval'])) {
|
||||
$data['cache_clear_interval'] = $this->getAgeToDelete();
|
||||
}
|
||||
|
||||
if (!empty($data['filters'])) {
|
||||
foreach ($data['filters'] as $filterId => $filter) {
|
||||
$validationData = [];
|
||||
$validationRules = [];
|
||||
|
||||
foreach ($filter['rules'] as $ruleId => $rule) {
|
||||
$validationData[$rule['modifier']] = $rule['value'];
|
||||
$validationRules[$rule['modifier']] = $this->modifierRules[$rule['modifier']];
|
||||
}
|
||||
|
||||
$validator = Validator::make($validationData, $validationRules);
|
||||
|
||||
if (!$validator->passes()) {
|
||||
$errors = [];
|
||||
foreach ($validator->messages()->toArray() as $field => $fieldErrors) {
|
||||
$errors[] = implode(", ", $fieldErrors);
|
||||
}
|
||||
throw new \Exception("Unable to save Settings: " . implode("\n", $errors));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the default "Not Found" image path
|
||||
*
|
||||
* @param bool $absolute Return absolute path?
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultImageNotFound(bool $absolute = false): string
|
||||
{
|
||||
$path = static::DEFAULT_IMAGE_NOT_FOUND;
|
||||
|
||||
if ($absolute) {
|
||||
$path = (substr($path, 0, 1) === '/') ? $path : base_path($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base path for all cached images.
|
||||
*
|
||||
* Similarly to base_path(), storage_path(), etc, you can provide a subdir path
|
||||
* as the first argument. This function will never return a trailing slash
|
||||
* unless you provide it in the first argument.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getBasePath(string $subdirectoryPath = null, bool $absolute = false): string
|
||||
{
|
||||
$path = rtrim(static::DEFAULT_STORAGE_PATH, '/');
|
||||
|
||||
// Get the cache directory from the Settings
|
||||
$that = static::instance();
|
||||
if (!empty($that->cache_directory)) {
|
||||
$path = rtrim($that->cache_directory, '/');
|
||||
}
|
||||
|
||||
// // Uncomment to initialise a gitignore file for this directory
|
||||
// if ($path === rtrim(static::DEFAULT_STORAGE_PATH, '/')) {
|
||||
// if (!is_file($path . '/.gitignore')) {
|
||||
// file_put_contents($path . '/.gitignore', "*\n!.gitignore\n!public");
|
||||
// }
|
||||
// }
|
||||
|
||||
if ($subdirectoryPath !== null) {
|
||||
$path .= '/' . ltrim($subdirectoryPath, '/');
|
||||
}
|
||||
|
||||
if ($absolute) {
|
||||
$path = (substr($path, 0, 1) === '/') ? $path : base_path($path);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the age a cached file must be before scheduled deletion.
|
||||
* Equivalent to: `->modify("-{$age}")` (now minus the age)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAgeToDelete(): string
|
||||
{
|
||||
$that = static::instance();
|
||||
|
||||
if (!empty($that->cache_clear_interval)) {
|
||||
return $that->cache_clear_interval;
|
||||
}
|
||||
|
||||
return static::DEFAULT_CACHE_CLEAR_AGE;
|
||||
}
|
||||
|
||||
public static function cleanupOnCacheClear(): bool
|
||||
{
|
||||
$that = static::instance();
|
||||
|
||||
return $that->cleanup_on_cache_clear ?? false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
tabs:
|
||||
fields:
|
||||
driver:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.driver.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.driver.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
required: 1
|
||||
type: dropdown
|
||||
options:
|
||||
gd: 'abwebdevelopers.imageresize::lang.settings.fields.driver.options.gd'
|
||||
imagick: 'abwebdevelopers.imageresize::lang.settings.fields.driver.options.imagick'
|
||||
default: gd
|
||||
background:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.background.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.background.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: right
|
||||
type: colorpicker
|
||||
default: '#ffffff'
|
||||
mode:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.mode.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.mode.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
required: 1
|
||||
type: dropdown
|
||||
options:
|
||||
auto: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.auto'
|
||||
contain: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.contain'
|
||||
cover: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.cover'
|
||||
stretch: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.stretch'
|
||||
default: auto
|
||||
format:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.format.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.format.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
required: 1
|
||||
type: dropdown
|
||||
options:
|
||||
auto: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.auto'
|
||||
jpg: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.jpg'
|
||||
png: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.png'
|
||||
webp: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.webp'
|
||||
bmp: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.bmp'
|
||||
gif: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.gif'
|
||||
ico: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.ico'
|
||||
default: auto
|
||||
quality:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.quality.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.quality.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
type: text
|
||||
default: 65
|
||||
_404:
|
||||
type: section
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.sections._404.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.sections._404.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
image_not_found:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
type: mediafinder
|
||||
image_not_found_background:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_background.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_background.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: right
|
||||
type: colorpicker
|
||||
default: '#c9d5d3'
|
||||
image_not_found_mode:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_mode.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_mode.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
type: dropdown
|
||||
options:
|
||||
auto: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.auto'
|
||||
contain: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.contain'
|
||||
cover: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.cover'
|
||||
stretch: 'abwebdevelopers.imageresize::lang.settings.fields.mode.options.stretch'
|
||||
default: contain
|
||||
image_not_found_transparent:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_transparent.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_transparent.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: right
|
||||
type: checkbox
|
||||
image_not_found_format:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_format.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_format.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
type: dropdown
|
||||
options:
|
||||
auto: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.auto'
|
||||
jpg: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.jpg'
|
||||
png: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.png'
|
||||
webp: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.webp'
|
||||
bmp: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.bmp'
|
||||
gif: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.gif'
|
||||
ico: 'abwebdevelopers.imageresize::lang.settings.fields.format.options.ico'
|
||||
default: contain
|
||||
image_not_found_quality:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_quality.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.image_not_found_quality.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.main'
|
||||
span: left
|
||||
type: text
|
||||
default: 65
|
||||
filters:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.filters.label'
|
||||
prompt: 'abwebdevelopers.imageresize::lang.settings.fields.filters.prompt'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.filters'
|
||||
type: repeater
|
||||
form:
|
||||
fields:
|
||||
code:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.code.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.code.comment'
|
||||
type: text
|
||||
span: left
|
||||
description:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.description.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.description.comment'
|
||||
type: text
|
||||
span: right
|
||||
rules:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.label'
|
||||
prompt: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.prompt'
|
||||
type: repeater
|
||||
form:
|
||||
fields:
|
||||
modifier:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.comment'
|
||||
type: dropdown
|
||||
span: left
|
||||
options:
|
||||
width: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.width'
|
||||
height: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.height'
|
||||
min_width: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.min_width'
|
||||
min_height: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.min_height'
|
||||
max_width: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.max_width'
|
||||
max_height: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.max_height'
|
||||
blur: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.blur'
|
||||
sharpen: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.sharpen'
|
||||
brightness: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.brightness'
|
||||
contrast: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.contrast'
|
||||
pixelate: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.pixelate'
|
||||
greyscale: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.greyscale'
|
||||
invert: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.invert'
|
||||
opacity: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.opacity'
|
||||
rotate: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.rotate'
|
||||
flip: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.flip'
|
||||
background: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.background'
|
||||
colorize: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.colorize'
|
||||
format: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.format'
|
||||
quality: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.quality'
|
||||
mode: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.mode'
|
||||
fit_position: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.modifier.options.fit_position'
|
||||
value:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.value.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.filters.fields.rules.fields.value.comment'
|
||||
type: text
|
||||
span: right
|
||||
cache_directory:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.cache_directory.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.cache_directory.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.cache'
|
||||
span: left
|
||||
type: text
|
||||
default: 'storage/app/media/imageresizecache'
|
||||
cache_clear_interval:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.cache_clear_interval.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.cache_clear_interval.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.cache'
|
||||
span: right
|
||||
type: text
|
||||
default: 604800
|
||||
cleanup_on_cache_clear:
|
||||
label: 'abwebdevelopers.imageresize::lang.settings.fields.cleanup_on_cache_clear.label'
|
||||
comment: 'abwebdevelopers.imageresize::lang.settings.fields.cleanup_on_cache_clear.comment'
|
||||
tab: 'abwebdevelopers.imageresize::lang.settings.tabs.cache'
|
||||
span: left
|
||||
type: checkbox
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\ReportWidgets;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Models\Settings;
|
||||
use Backend\Classes\ReportWidgetBase;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use October\Rain\Support\Facades\Flash;
|
||||
|
||||
class ImageResizeClearWidget extends ReportWidgetBase
|
||||
{
|
||||
public function defineProperties()
|
||||
{
|
||||
return [
|
||||
'showGcInterval' => [
|
||||
'title' => 'abwebdevelopers.imageresize::lang.widgets.clear.showGcInterval',
|
||||
'default' => true,
|
||||
'type' => 'checkbox',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Default handler: Render the widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->makePartial('default');
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX callback: Clear the cache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onClear()
|
||||
{
|
||||
$from = $this->directorySize();
|
||||
Artisan::call('imageresize:clear');
|
||||
$to = $this->directorySize();
|
||||
|
||||
$size = $this->formatSize($from - $to);
|
||||
Flash::success(Lang::get('abwebdevelopers.imageresize::lang.widgets.clear.cleared', [
|
||||
'size' => $size
|
||||
]));
|
||||
|
||||
return [
|
||||
'partial' => $this->render(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total size (in bytes) of all resized images
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function directorySize(): int
|
||||
{
|
||||
$size = 0;
|
||||
$path = Settings::getBasePath();
|
||||
|
||||
foreach (File::allFiles($path) as $file) {
|
||||
$size += $file->getSize();
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the bytes to human readable form
|
||||
*
|
||||
* @param int $size
|
||||
* @param int $precision
|
||||
* @return string
|
||||
*/
|
||||
protected function formatSize(int $size, int $precision = 2): string
|
||||
{
|
||||
if (empty($size)) {
|
||||
return '0B';
|
||||
}
|
||||
|
||||
$base = log($size, 1024);
|
||||
$suffixes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return 'Image Resize Cache';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of all cached images (formatted)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function size(): string
|
||||
{
|
||||
return $this->formatSize($this->directorySize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configured cache clear interval
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function garbageCollectionInterval(): ?string
|
||||
{
|
||||
return Settings::getAgeToDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the garbage collection interval be displayed in this widget?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function showGarbageCollectionInterval(): bool
|
||||
{
|
||||
return (bool) $this->property('showGcInterval', false);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<div id="imageresizeclearwidget" class="report-widget">
|
||||
<h3><?= e(trans($this->title())) ?></h3>
|
||||
<?php if ($this->garbageCollectionInterval() && $this->showGarbageCollectionInterval()): ?>
|
||||
<p style="color: #999;">Garbage collection interval: <?= e($this->garbageCollectionInterval()) ?></p>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="btn btn-success"
|
||||
title="Clearing the cache will NOT remove the original images, it will only remove the cached resized copies"
|
||||
data-request="<?= $this->getEventHandler('onClear') ?>"
|
||||
data-request-success="$('#imageresizeclearwidget').replaceWith(data.partial)">
|
||||
Clear all resized images (<?= $this->size() ?>) | <span class="fa icon-trash"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use ABWebDevelopers\ImageResize\Classes\Resizer;
|
||||
use ABWebDevelopers\ImageResize\Models\ImagePermalink;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
/**
|
||||
* Publicly accessible URL for resizing an image (lazy-resize), using a cache hash/ext.
|
||||
*/
|
||||
Route::get('imageresize/{hash}.{ext}', function (string $hash, string $ext) {
|
||||
$config = Cache::get(Resizer::CACHE_PREFIX . $hash);
|
||||
|
||||
if (empty($config)) {
|
||||
$config = [
|
||||
'image' => null,
|
||||
'options' => [],
|
||||
'formatCache' => [],
|
||||
];
|
||||
}
|
||||
|
||||
return Resizer::using($config['image'])
|
||||
->setHash($hash)
|
||||
->setOptions($config['options'] ?? [])
|
||||
->setFormatCache($config['formatCache'] ?? [])
|
||||
->doResize()
|
||||
->render();
|
||||
});
|
||||
|
||||
/**
|
||||
* Publicly accessible URL for permalink image using an identifier/ext.
|
||||
*/
|
||||
Route::get('imageresizestatic/{identifier}.{ext}', function (string $identifier, string $ext) {
|
||||
$perma = ImagePermalink::withIdentifer($identifier);
|
||||
|
||||
if ($perma === null) {
|
||||
$perma = ImagePermalink::defaultNotFound();
|
||||
}
|
||||
|
||||
return $perma->render();
|
||||
})->where('identifier', '(.+?)');
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Traits;
|
||||
|
||||
trait HasPermalinkIdentifiers
|
||||
{
|
||||
/**
|
||||
* Get the identifier for the permalink
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalinkIdentifier(string $key = null): string
|
||||
{
|
||||
if ($key !== null) {
|
||||
$key .= '/';
|
||||
}
|
||||
|
||||
return $key . strtolower(basename(str_replace('\\', '/', static::class))) . '/' . $this->slug;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\Portfolio\Updates;
|
||||
|
||||
use ABWebDevelopers\ImageResize\Classes\Resizer;
|
||||
use ABWebDevelopers\ImageResize\Models\Settings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class ClearOldCacheDir extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
// Check that the settings for this plugin exist
|
||||
if (DB::table('system_settings')->where('item', 'abwebdevelopers_imageresize')->exists()) {
|
||||
$oldpath = base_path('storage/app/media/imageresizecache');
|
||||
|
||||
if (Settings::instance()->cache_directory !== $oldpath) {
|
||||
if (is_dir($oldpath)) {
|
||||
Resizer::clearFiles(null, $oldpath);
|
||||
|
||||
File::deleteDirectory($oldpath);
|
||||
@unlink($oldpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace ABWebDevelopers\ImageResize\Updates;
|
||||
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
use Schema;
|
||||
|
||||
class CreatePermalinksTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('abweb_imageresize_permalinks') === false) {
|
||||
Schema::create('abweb_imageresize_permalinks', function ($table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->text('identifier');
|
||||
$table->text('image');
|
||||
$table->string('mime_type');
|
||||
$table->string('extension');
|
||||
$table->text('options');
|
||||
$table->text('path');
|
||||
$table->dateTime('resized_at')->nullable()->default(null);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if (Schema::hasTable('abweb_imageresize_permalinks') === true) {
|
||||
Schema::drop('abweb_imageresize_permalinks');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?php namespace ABWebDevelopers\Portfolio\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
use ABWebDevelopers\ImageResize\Models\Settings;
|
||||
|
||||
class SeedFilters extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$filters = Settings::get('filters');
|
||||
|
||||
$hasThumbnail = false;
|
||||
$hasHero = false;
|
||||
|
||||
foreach ($filters as $key => $value) {
|
||||
if ($value['code'] == 'thumbnail') {
|
||||
$hasThumbnail = true;
|
||||
} elseif ($value['code'] == 'hero') {
|
||||
$hasHero = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasThumbnail) {
|
||||
$filters[] = [
|
||||
"code" => "thumbnail",
|
||||
"description" => "Basic thumbnail filter",
|
||||
"rules" => [
|
||||
[
|
||||
"modifier" => "max_width",
|
||||
"value" => "500",
|
||||
],
|
||||
[
|
||||
"modifier" => "max_height",
|
||||
"value" => "500",
|
||||
],
|
||||
[
|
||||
"modifier" => "brightness",
|
||||
"value" => "50",
|
||||
],
|
||||
[
|
||||
"modifier" => "background",
|
||||
"value" => "#fff",
|
||||
],
|
||||
[
|
||||
"modifier" => "greyscale",
|
||||
"value" => "true",
|
||||
],
|
||||
[
|
||||
"modifier" => "quality",
|
||||
"value" => "60",
|
||||
],
|
||||
[
|
||||
"modifier" => "format",
|
||||
"value" => "jpg",
|
||||
],
|
||||
[
|
||||
"modifier" => "mode",
|
||||
"value" => "cover",
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if (!$hasHero) {
|
||||
$filters[] = [
|
||||
"code" => "hero",
|
||||
"description" => "Standard hero filter",
|
||||
"rules" => [
|
||||
[
|
||||
"modifier" => "width",
|
||||
"value" => "1920",
|
||||
],
|
||||
[
|
||||
"modifier" => "height",
|
||||
"value" => "500",
|
||||
],
|
||||
[
|
||||
"modifier" => "mode",
|
||||
"value" => "cover",
|
||||
],
|
||||
[
|
||||
"modifier" => "quality",
|
||||
"value" => "80",
|
||||
],
|
||||
[
|
||||
"modifier" => "format",
|
||||
"value" => "jpg",
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
1.0.0:
|
||||
- Initial version of Image Resize
|
||||
1.1.0:
|
||||
- Add settings, filters, image not found placeholder, and various other improvements
|
||||
1.1.1:
|
||||
- Enable image caching
|
||||
1.1.2:
|
||||
- Minor tweaks and improvements, ship plugin with 2 filters
|
||||
1.1.3:
|
||||
- Fix PHP 7.0 incompatibility issue, support all relative URL images
|
||||
1.1.4:
|
||||
- Register access permissions
|
||||
1.1.5:
|
||||
- Fix issue with spaces in filenames
|
||||
1.1.6:
|
||||
- Fix return type errors
|
||||
1.1.7:
|
||||
- Remove debug routes file
|
||||
2.0.0:
|
||||
- Optimise image resizing on initial pageload by offloading to separate thread (by resizing when requesting images)
|
||||
2.0.1:
|
||||
- Fix bug (since 2.0.0) where the 'default 404 image' does not utilise the configured background/mode/quality
|
||||
2.0.2:
|
||||
- Implement ability to add watermarks to images
|
||||
2.1.0:
|
||||
- Move default imageresizecache directory (out of app/media) and store+serve images with file extension (change default imagresize cache clear to 1 week)
|
||||
2.1.1:
|
||||
- Fix double slash issue in resized image URLs
|
||||
2.1.2:
|
||||
- Clear old images (for the v2.1.0 directory change)
|
||||
- clear_old_cache_dir.php
|
||||
2.1.3:
|
||||
- Fix - Generate absolute URLs instead of domain-relative URLs
|
||||
2.1.4:
|
||||
- Add new Dashboard Widget as an alternative method of clearing the image resize cache
|
||||
2.1.5:
|
||||
- Add new setting that runs `imageresize:clear` when `cache:clear` is run (if configured), and fix a Settings bug that was introduced from v2.1.0
|
||||
2.1.6:
|
||||
- Fix migration (2.1.2 migration) that causes installations to fail (due to plugin settings not existing for new projects at time of execution)
|
||||
2.1.7:
|
||||
- Fix - Update plugin's boot method to not directly reference Settings until DB connection is established
|
||||
2.1.8:
|
||||
- Added twig filter to parse and resize/modify images (via regex) using twig filter(s)
|
||||
2.1.9:
|
||||
- Improvement to the detection of the original image's mime type (uses less system resources)
|
||||
2.2.0:
|
||||
- Added optional permalinks for images to ensure image URLs always yield the same image after cache flushes
|
||||
- create_permalinks_table.php
|
||||
2.2.1:
|
||||
- Fix issue where REMOTE_ADDR server variable is not set when running through CLI
|
||||
2.2.2:
|
||||
- Fix MySQL issue where text fields had default values
|
||||
2.2.3:
|
||||
- Improvements to Permalinks
|
||||
2.2.4:
|
||||
- Fix exception when directory doesn't exist during cache clear
|
||||
2.2.5:
|
||||
- Fix regeneration of permalink images that previously defaulted to 404 image
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5081b5a1a3d18c299d648f7535618d68::getLoader();
|
||||
|
|
@ -0,0 +1,445 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* 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 <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://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', $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;
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
);
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
|
||||
'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'),
|
||||
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
|
||||
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
|
||||
);
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit5081b5a1a3d18c299d648f7535618d68
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5081b5a1a3d18c299d648f7535618d68', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5081b5a1a3d18c299d648f7535618d68', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit5081b5a1a3d18c299d648f7535618d68::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);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit5081b5a1a3d18c299d648f7535618d68::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire5081b5a1a3d18c299d648f7535618d68($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire5081b5a1a3d18c299d648f7535618d68($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit5081b5a1a3d18c299d648f7535618d68
|
||||
{
|
||||
public static $files = array (
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'P' =>
|
||||
array (
|
||||
'Psr\\Http\\Message\\' => 17,
|
||||
),
|
||||
'I' =>
|
||||
array (
|
||||
'Intervention\\Image\\' => 19,
|
||||
),
|
||||
'G' =>
|
||||
array (
|
||||
'GuzzleHttp\\Psr7\\' => 16,
|
||||
),
|
||||
'C' =>
|
||||
array (
|
||||
'Composer\\Installers\\' => 20,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Psr\\Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
),
|
||||
'Intervention\\Image\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image',
|
||||
),
|
||||
'GuzzleHttp\\Psr7\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
|
||||
),
|
||||
'Composer\\Installers\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
|
||||
),
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5081b5a1a3d18c299d648f7535618d68::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5081b5a1a3d18c299d648f7535618d68::$prefixDirsPsr4;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,373 @@
|
|||
[
|
||||
{
|
||||
"name": "composer/installers",
|
||||
"version": "v1.10.0",
|
||||
"version_normalized": "1.10.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/installers.git",
|
||||
"reference": "1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/installers/zipball/1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d",
|
||||
"reference": "1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0 || ^2.0"
|
||||
},
|
||||
"replace": {
|
||||
"roundcube/plugin-installer": "*",
|
||||
"shama/baton": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "1.6.* || ^2.0",
|
||||
"composer/semver": "^1 || ^3",
|
||||
"phpstan/phpstan": "^0.12.55",
|
||||
"phpstan/phpstan-phpunit": "^0.12.16",
|
||||
"symfony/phpunit-bridge": "^4.2 || ^5",
|
||||
"symfony/process": "^2.3"
|
||||
},
|
||||
"time": "2021-01-14T11:07:16+00:00",
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"class": "Composer\\Installers\\Plugin",
|
||||
"branch-alias": {
|
||||
"dev-main": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"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",
|
||||
"Starbug",
|
||||
"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",
|
||||
"processwire",
|
||||
"puppet",
|
||||
"pxcms",
|
||||
"reindex",
|
||||
"roundcube",
|
||||
"shopware",
|
||||
"silverstripe",
|
||||
"sydes",
|
||||
"sylius",
|
||||
"symfony",
|
||||
"typo3",
|
||||
"wordpress",
|
||||
"yawik",
|
||||
"zend",
|
||||
"zikula"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "1.7.0",
|
||||
"version_normalized": "1.7.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3",
|
||||
"reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"psr/http-message": "~1.0",
|
||||
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-zlib": "*",
|
||||
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10"
|
||||
},
|
||||
"suggest": {
|
||||
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
||||
},
|
||||
"time": "2020-09-30T07:37:11+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Psr7\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Schultze",
|
||||
"homepage": "https://github.com/Tobion"
|
||||
}
|
||||
],
|
||||
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||
"keywords": [
|
||||
"http",
|
||||
"message",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response",
|
||||
"stream",
|
||||
"uri",
|
||||
"url"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
"version": "2.4.3",
|
||||
"version_normalized": "2.4.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Intervention/image.git",
|
||||
"reference": "5f5e1c8768d6bb41a7f23706af754b92541de485"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Intervention/image/zipball/5f5e1c8768d6bb41a7f23706af754b92541de485",
|
||||
"reference": "5f5e1c8768d6bb41a7f23706af754b92541de485",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"guzzlehttp/psr7": "~1.1",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.2",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "to use GD library based image processing.",
|
||||
"ext-imagick": "to use Imagick based image processing.",
|
||||
"intervention/imagecache": "Caching extension for the Intervention Image library"
|
||||
},
|
||||
"time": "2019-05-31T17:08:36+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Intervention\\Image\\ImageServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Image": "Intervention\\Image\\Facades\\Image"
|
||||
}
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Intervention\\Image\\": "src/Intervention/Image"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Oliver Vogel",
|
||||
"email": "oliver@olivervogel.com",
|
||||
"homepage": "http://olivervogel.com/"
|
||||
}
|
||||
],
|
||||
"description": "Image handling and manipulation library with support for Laravel integration",
|
||||
"homepage": "http://image.intervention.io/",
|
||||
"keywords": [
|
||||
"gd",
|
||||
"image",
|
||||
"imagick",
|
||||
"laravel",
|
||||
"thumbnail",
|
||||
"watermark"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-message.git",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2016-08-06T14:39:51+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP messages",
|
||||
"homepage": "https://github.com/php-fig/http-message",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-message",
|
||||
"psr",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "3.0.3",
|
||||
"version_normalized": "3.0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ralouphie/getallheaders.git",
|
||||
"reference": "120b605dfeb996808c31b6477290a714d356e822"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
|
||||
"reference": "120b605dfeb996808c31b6477290a714d356e822",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.1",
|
||||
"phpunit/phpunit": "^5 || ^6.5"
|
||||
},
|
||||
"time": "2019-03-08T08:55:37+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/getallheaders.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ralph Khattar",
|
||||
"email": "ralph.khattar@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A polyfill for getallheaders."
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012 Kyle Robinson Young
|
||||
|
||||
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.
|
||||
119
plugins/abwebdevelopers/imageresize/vendor/composer/installers/composer.json
vendored
Normal file
119
plugins/abwebdevelopers/imageresize/vendor/composer/installers/composer.json
vendored
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
{
|
||||
"name": "composer/installers",
|
||||
"type": "composer-plugin",
|
||||
"license": "MIT",
|
||||
"description": "A multi-framework Composer library installer",
|
||||
"keywords": [
|
||||
"installer",
|
||||
"Aimeos",
|
||||
"AGL",
|
||||
"AnnotateCms",
|
||||
"Attogram",
|
||||
"Bitrix",
|
||||
"CakePHP",
|
||||
"Chef",
|
||||
"Cockpit",
|
||||
"CodeIgniter",
|
||||
"concrete5",
|
||||
"Craft",
|
||||
"Croogo",
|
||||
"DokuWiki",
|
||||
"Dolibarr",
|
||||
"Drupal",
|
||||
"Elgg",
|
||||
"Eliasis",
|
||||
"ExpressionEngine",
|
||||
"eZ Platform",
|
||||
"FuelPHP",
|
||||
"Grav",
|
||||
"Hurad",
|
||||
"ImageCMS",
|
||||
"iTop",
|
||||
"Joomla",
|
||||
"Kanboard",
|
||||
"Known",
|
||||
"Kohana",
|
||||
"Lan Management System",
|
||||
"Laravel",
|
||||
"Lavalite",
|
||||
"Lithium",
|
||||
"Magento",
|
||||
"majima",
|
||||
"Mako",
|
||||
"MantisBT",
|
||||
"Mautic",
|
||||
"Maya",
|
||||
"MODX",
|
||||
"MODX Evo",
|
||||
"MediaWiki",
|
||||
"OXID",
|
||||
"osclass",
|
||||
"MODULEWork",
|
||||
"Moodle",
|
||||
"Piwik",
|
||||
"pxcms",
|
||||
"phpBB",
|
||||
"Plentymarkets",
|
||||
"PPI",
|
||||
"Puppet",
|
||||
"Porto",
|
||||
"ProcessWire",
|
||||
"RadPHP",
|
||||
"ReIndex",
|
||||
"Roundcube",
|
||||
"shopware",
|
||||
"SilverStripe",
|
||||
"SMF",
|
||||
"Starbug",
|
||||
"SyDES",
|
||||
"Sylius",
|
||||
"symfony",
|
||||
"Thelia",
|
||||
"TYPO3",
|
||||
"WHMCS",
|
||||
"WolfCMS",
|
||||
"WordPress",
|
||||
"YAWIK",
|
||||
"Zend",
|
||||
"Zikula"
|
||||
],
|
||||
"homepage": "https://composer.github.io/installers/",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kyle Robinson Young",
|
||||
"email": "kyle@dontkry.com",
|
||||
"homepage": "https://github.com/shama"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": { "Composer\\Installers\\": "src/Composer/Installers" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Composer\\Installers\\Test\\": "tests/Composer/Installers/Test" }
|
||||
},
|
||||
"extra": {
|
||||
"class": "Composer\\Installers\\Plugin",
|
||||
"branch-alias": {
|
||||
"dev-main": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"shama/baton": "*",
|
||||
"roundcube/plugin-installer": "*"
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "1.6.* || ^2.0",
|
||||
"composer/semver": "^1 || ^3",
|
||||
"symfony/phpunit-bridge": "^4.2 || ^5",
|
||||
"phpstan/phpstan": "^0.12.55",
|
||||
"symfony/process": "^2.3",
|
||||
"phpstan/phpstan-phpunit": "^0.12.16"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit",
|
||||
"phpstan": "vendor/bin/phpstan analyse"
|
||||
}
|
||||
}
|
||||
10
plugins/abwebdevelopers/imageresize/vendor/composer/installers/phpstan.neon.dist
vendored
Normal file
10
plugins/abwebdevelopers/imageresize/vendor/composer/installers/phpstan.neon.dist
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
parameters:
|
||||
level: 5
|
||||
paths:
|
||||
- src
|
||||
- tests
|
||||
excludes_analyse:
|
||||
- tests/Composer/Installers/Test/PolyfillTestCase.php
|
||||
|
||||
includes:
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class AglInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'More/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
|
||||
return strtoupper($matches[1]);
|
||||
}, $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class AimeosInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'extension' => 'ext/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class AnnotateCmsInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'addons/modules/{$name}/',
|
||||
'component' => 'addons/components/{$name}/',
|
||||
'service' => 'addons/services/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class AsgardInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'Modules/{$name}/',
|
||||
'theme' => 'Themes/{$name}/'
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name.
|
||||
*
|
||||
* For package type asgard-module, cut off a trailing '-plugin' if present.
|
||||
*
|
||||
* For package type asgard-theme, cut off a trailing '-theme' if present.
|
||||
*
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($vars['type'] === 'asgard-module') {
|
||||
return $this->inflectPluginVars($vars);
|
||||
}
|
||||
|
||||
if ($vars['type'] === 'asgard-theme') {
|
||||
return $this->inflectThemeVars($vars);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectPluginVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-module$/', '', $vars['name']);
|
||||
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectThemeVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
|
||||
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class AttogramInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Composer;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
abstract class BaseInstaller
|
||||
{
|
||||
protected $locations = array();
|
||||
protected $composer;
|
||||
protected $package;
|
||||
protected $io;
|
||||
|
||||
/**
|
||||
* Initializes base installer.
|
||||
*
|
||||
* @param PackageInterface $package
|
||||
* @param Composer $composer
|
||||
* @param IOInterface $io
|
||||
*/
|
||||
public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null)
|
||||
{
|
||||
$this->composer = $composer;
|
||||
$this->package = $package;
|
||||
$this->io = $io;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the install path based on package type.
|
||||
*
|
||||
* @param PackageInterface $package
|
||||
* @param string $frameworkType
|
||||
* @return string
|
||||
*/
|
||||
public function getInstallPath(PackageInterface $package, $frameworkType = '')
|
||||
{
|
||||
$type = $this->package->getType();
|
||||
|
||||
$prettyName = $this->package->getPrettyName();
|
||||
if (strpos($prettyName, '/') !== false) {
|
||||
list($vendor, $name) = explode('/', $prettyName);
|
||||
} else {
|
||||
$vendor = '';
|
||||
$name = $prettyName;
|
||||
}
|
||||
|
||||
$availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
|
||||
|
||||
$extra = $package->getExtra();
|
||||
if (!empty($extra['installer-name'])) {
|
||||
$availableVars['name'] = $extra['installer-name'];
|
||||
}
|
||||
|
||||
if ($this->composer->getPackage()) {
|
||||
$extra = $this->composer->getPackage()->getExtra();
|
||||
if (!empty($extra['installer-paths'])) {
|
||||
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor);
|
||||
if ($customPath !== false) {
|
||||
return $this->templatePath($customPath, $availableVars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$packageType = substr($type, strlen($frameworkType) + 1);
|
||||
$locations = $this->getLocations();
|
||||
if (!isset($locations[$packageType])) {
|
||||
throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
|
||||
}
|
||||
|
||||
return $this->templatePath($locations[$packageType], $availableVars);
|
||||
}
|
||||
|
||||
/**
|
||||
* For an installer to override to modify the vars per installer.
|
||||
*
|
||||
* @param array<string, string> $vars This will normally receive array{name: string, vendor: string, type: string}
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the installer's locations
|
||||
*
|
||||
* @return array<string, string> map of package types => install path
|
||||
*/
|
||||
public function getLocations()
|
||||
{
|
||||
return $this->locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace vars in a path
|
||||
*
|
||||
* @param string $path
|
||||
* @param array<string, string> $vars
|
||||
* @return string
|
||||
*/
|
||||
protected function templatePath($path, array $vars = array())
|
||||
{
|
||||
if (strpos($path, '{') !== false) {
|
||||
extract($vars);
|
||||
preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches);
|
||||
if (!empty($matches[1])) {
|
||||
foreach ($matches[1] as $var) {
|
||||
$path = str_replace('{$' . $var . '}', $$var, $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search through a passed paths array for a custom install path.
|
||||
*
|
||||
* @param array $paths
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @param string $vendor = NULL
|
||||
* @return string|false
|
||||
*/
|
||||
protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
|
||||
{
|
||||
foreach ($paths as $path => $names) {
|
||||
$names = (array) $names;
|
||||
if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\Util\Filesystem;
|
||||
|
||||
/**
|
||||
* Installer for Bitrix Framework. Supported types of extensions:
|
||||
* - `bitrix-d7-module` — copy the module to directory `bitrix/modules/<vendor>.<name>`.
|
||||
* - `bitrix-d7-component` — copy the component to directory `bitrix/components/<vendor>/<name>`.
|
||||
* - `bitrix-d7-template` — copy the template to directory `bitrix/templates/<vendor>_<name>`.
|
||||
*
|
||||
* You can set custom path to directory with Bitrix kernel in `composer.json`:
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "extra": {
|
||||
* "bitrix-dir": "s1/bitrix"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @author Nik Samokhvalov <nik@samokhvalov.info>
|
||||
* @author Denis Kulichkin <onexhovia@gmail.com>
|
||||
*/
|
||||
class BitrixInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
|
||||
'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
|
||||
'theme' => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
|
||||
'd7-module' => '{$bitrix_dir}/modules/{$vendor}.{$name}/',
|
||||
'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/',
|
||||
'd7-template' => '{$bitrix_dir}/templates/{$vendor}_{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array Storage for informations about duplicates at all the time of installation packages.
|
||||
*/
|
||||
private static $checkedDuplicates = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($this->composer->getPackage()) {
|
||||
$extra = $this->composer->getPackage()->getExtra();
|
||||
|
||||
if (isset($extra['bitrix-dir'])) {
|
||||
$vars['bitrix_dir'] = $extra['bitrix-dir'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($vars['bitrix_dir'])) {
|
||||
$vars['bitrix_dir'] = 'bitrix';
|
||||
}
|
||||
|
||||
return parent::inflectPackageVars($vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function templatePath($path, array $vars = array())
|
||||
{
|
||||
$templatePath = parent::templatePath($path, $vars);
|
||||
$this->checkDuplicates($templatePath, $vars);
|
||||
|
||||
return $templatePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicates search packages.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $vars
|
||||
*/
|
||||
protected function checkDuplicates($path, array $vars = array())
|
||||
{
|
||||
$packageType = substr($vars['type'], strlen('bitrix') + 1);
|
||||
$localDir = explode('/', $vars['bitrix_dir']);
|
||||
array_pop($localDir);
|
||||
$localDir[] = 'local';
|
||||
$localDir = implode('/', $localDir);
|
||||
|
||||
$oldPath = str_replace(
|
||||
array('{$bitrix_dir}', '{$name}'),
|
||||
array($localDir, $vars['name']),
|
||||
$this->locations[$packageType]
|
||||
);
|
||||
|
||||
if (in_array($oldPath, static::$checkedDuplicates)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) {
|
||||
|
||||
$this->io->writeError(' <error>Duplication of packages:</error>');
|
||||
$this->io->writeError(' <info>Package ' . $oldPath . ' will be called instead package ' . $path . '</info>');
|
||||
|
||||
while (true) {
|
||||
switch ($this->io->ask(' <info>Delete ' . $oldPath . ' [y,n,?]?</info> ', '?')) {
|
||||
case 'y':
|
||||
$fs = new Filesystem();
|
||||
$fs->removeDirectory($oldPath);
|
||||
break 2;
|
||||
|
||||
case 'n':
|
||||
break 2;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
$this->io->writeError(array(
|
||||
' y - delete package ' . $oldPath . ' and to continue with the installation',
|
||||
' n - don\'t delete and to continue with the installation',
|
||||
));
|
||||
$this->io->writeError(' ? - print help');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static::$checkedDuplicates[] = $oldPath;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class BonefishInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'package' => 'Packages/{$vendor}/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\DependencyResolver\Pool;
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
|
||||
class CakePHPInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'Plugin/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
||||
return $vars;
|
||||
}
|
||||
|
||||
$nameParts = explode('/', $vars['name']);
|
||||
foreach ($nameParts as &$value) {
|
||||
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
|
||||
$value = str_replace(array('-', '_'), ' ', $value);
|
||||
$value = str_replace(' ', '', ucwords($value));
|
||||
}
|
||||
$vars['name'] = implode('/', $nameParts);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the default plugin location when cakephp >= 3.0
|
||||
*/
|
||||
public function getLocations()
|
||||
{
|
||||
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
||||
$this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
|
||||
}
|
||||
return $this->locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if CakePHP version matches against a version
|
||||
*
|
||||
* @param string $matcher
|
||||
* @param string $version
|
||||
* @return bool
|
||||
*/
|
||||
protected function matchesCakeVersion($matcher, $version)
|
||||
{
|
||||
$repositoryManager = $this->composer->getRepositoryManager();
|
||||
if (! $repositoryManager) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$repos = $repositoryManager->getLocalRepository();
|
||||
if (!$repos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $repos->findPackage('cakephp/cakephp', new Constraint($matcher, $version)) !== null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class ChefInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'cookbook' => 'Chef/{$vendor}/{$name}/',
|
||||
'role' => 'Chef/roles/{$name}/',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class CiviCrmInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'ext' => 'ext/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class ClanCatsFrameworkInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'ship' => 'CCF/orbit/{$name}/',
|
||||
'theme' => 'CCF/app/themes/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class CockpitInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'cockpit/modules/addons/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format module name.
|
||||
*
|
||||
* Strip `module-` prefix from package name.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($vars['type'] == 'cockpit-module') {
|
||||
return $this->inflectModuleVars($vars);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function inflectModuleVars($vars)
|
||||
{
|
||||
$vars['name'] = ucfirst(preg_replace('/cockpit-/i', '', $vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class CodeIgniterInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'library' => 'application/libraries/{$name}/',
|
||||
'third-party' => 'application/third_party/{$name}/',
|
||||
'module' => 'application/modules/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class Concrete5Installer extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'core' => 'concrete/',
|
||||
'block' => 'application/blocks/{$name}/',
|
||||
'package' => 'packages/{$name}/',
|
||||
'theme' => 'application/themes/{$name}/',
|
||||
'update' => 'updates/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
/**
|
||||
* Installer for Craft Plugins
|
||||
*/
|
||||
class CraftInstaller extends BaseInstaller
|
||||
{
|
||||
const NAME_PREFIX = 'craft';
|
||||
const NAME_SUFFIX = 'plugin';
|
||||
|
||||
protected $locations = array(
|
||||
'plugin' => 'craft/plugins/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Strip `craft-` prefix and/or `-plugin` suffix from package names
|
||||
*
|
||||
* @param array $vars
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
final public function inflectPackageVars($vars)
|
||||
{
|
||||
return $this->inflectPluginVars($vars);
|
||||
}
|
||||
|
||||
private function inflectPluginVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-' . self::NAME_SUFFIX . '$/i', '', $vars['name']);
|
||||
$vars['name'] = preg_replace('/^' . self::NAME_PREFIX . '-/i', '', $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class CroogoInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'Plugin/{$name}/',
|
||||
'theme' => 'View/Themed/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class DecibelInstaller extends BaseInstaller
|
||||
{
|
||||
/** @var array */
|
||||
protected $locations = array(
|
||||
'app' => 'app/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Composer\Installers;
|
||||
|
||||
class DframeInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$vendor}/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class DokuWikiInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'lib/plugins/{$name}/',
|
||||
'template' => 'lib/tpl/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name.
|
||||
*
|
||||
* For package type dokuwiki-plugin, cut off a trailing '-plugin',
|
||||
* or leading dokuwiki_ if present.
|
||||
*
|
||||
* For package type dokuwiki-template, cut off a trailing '-template' if present.
|
||||
*
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
|
||||
if ($vars['type'] === 'dokuwiki-plugin') {
|
||||
return $this->inflectPluginVars($vars);
|
||||
}
|
||||
|
||||
if ($vars['type'] === 'dokuwiki-template') {
|
||||
return $this->inflectTemplateVars($vars);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectPluginVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
|
||||
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectTemplateVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-template$/', '', $vars['name']);
|
||||
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
/**
|
||||
* Class DolibarrInstaller
|
||||
*
|
||||
* @package Composer\Installers
|
||||
* @author Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
*/
|
||||
class DolibarrInstaller extends BaseInstaller
|
||||
{
|
||||
//TODO: Add support for scripts and themes
|
||||
protected $locations = array(
|
||||
'module' => 'htdocs/custom/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class DrupalInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'core' => 'core/',
|
||||
'module' => 'modules/{$name}/',
|
||||
'theme' => 'themes/{$name}/',
|
||||
'library' => 'libraries/{$name}/',
|
||||
'profile' => 'profiles/{$name}/',
|
||||
'database-driver' => 'drivers/lib/Drupal/Driver/Database/{$name}/',
|
||||
'drush' => 'drush/{$name}/',
|
||||
'custom-theme' => 'themes/custom/{$name}/',
|
||||
'custom-module' => 'modules/custom/{$name}/',
|
||||
'custom-profile' => 'profiles/custom/{$name}/',
|
||||
'drupal-multisite' => 'sites/{$name}/',
|
||||
'console' => 'console/{$name}/',
|
||||
'console-language' => 'console/language/{$name}/',
|
||||
'config' => 'config/sync/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class ElggInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'mod/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class EliasisInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'component' => 'components/{$name}/',
|
||||
'module' => 'modules/{$name}/',
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
'template' => 'templates/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
class ExpressionEngineInstaller extends BaseInstaller
|
||||
{
|
||||
|
||||
protected $locations = array();
|
||||
|
||||
private $ee2Locations = array(
|
||||
'addon' => 'system/expressionengine/third_party/{$name}/',
|
||||
'theme' => 'themes/third_party/{$name}/',
|
||||
);
|
||||
|
||||
private $ee3Locations = array(
|
||||
'addon' => 'system/user/addons/{$name}/',
|
||||
'theme' => 'themes/user/{$name}/',
|
||||
);
|
||||
|
||||
public function getInstallPath(PackageInterface $package, $frameworkType = '')
|
||||
{
|
||||
|
||||
$version = "{$frameworkType}Locations";
|
||||
$this->locations = $this->$version;
|
||||
|
||||
return parent::getInstallPath($package, $frameworkType);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class EzPlatformInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'meta-assets' => 'web/assets/ezplatform/',
|
||||
'assets' => 'web/assets/ezplatform/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class FuelInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'fuel/app/modules/{$name}/',
|
||||
'package' => 'fuel/packages/{$name}/',
|
||||
'theme' => 'fuel/app/themes/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class FuelphpInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'component' => 'components/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class GravInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'user/plugins/{$name}/',
|
||||
'theme' => 'user/themes/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name
|
||||
*
|
||||
* @param array $vars
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$restrictedWords = implode('|', array_keys($this->locations));
|
||||
|
||||
$vars['name'] = strtolower($vars['name']);
|
||||
$vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
|
||||
'$1',
|
||||
$vars['name']
|
||||
);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class HuradInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
'theme' => 'plugins/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$nameParts = explode('/', $vars['name']);
|
||||
foreach ($nameParts as &$value) {
|
||||
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
|
||||
$value = str_replace(array('-', '_'), ' ', $value);
|
||||
$value = str_replace(' ', '', ucwords($value));
|
||||
}
|
||||
$vars['name'] = implode('/', $nameParts);
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class ImageCMSInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'template' => 'templates/{$name}/',
|
||||
'module' => 'application/modules/{$name}/',
|
||||
'library' => 'application/libraries/{$name}/',
|
||||
);
|
||||
}
|
||||
294
plugins/abwebdevelopers/imageresize/vendor/composer/installers/src/Composer/Installers/Installer.php
vendored
Normal file
294
plugins/abwebdevelopers/imageresize/vendor/composer/installers/src/Composer/Installers/Installer.php
vendored
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
<?php
|
||||
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Installer\BinaryInstaller;
|
||||
use Composer\Installer\LibraryInstaller;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\Util\Filesystem;
|
||||
use React\Promise\PromiseInterface;
|
||||
|
||||
class Installer extends LibraryInstaller
|
||||
{
|
||||
|
||||
/**
|
||||
* Package types to installer class map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $supportedTypes = array(
|
||||
'aimeos' => 'AimeosInstaller',
|
||||
'asgard' => 'AsgardInstaller',
|
||||
'attogram' => 'AttogramInstaller',
|
||||
'agl' => 'AglInstaller',
|
||||
'annotatecms' => 'AnnotateCmsInstaller',
|
||||
'bitrix' => 'BitrixInstaller',
|
||||
'bonefish' => 'BonefishInstaller',
|
||||
'cakephp' => 'CakePHPInstaller',
|
||||
'chef' => 'ChefInstaller',
|
||||
'civicrm' => 'CiviCrmInstaller',
|
||||
'ccframework' => 'ClanCatsFrameworkInstaller',
|
||||
'cockpit' => 'CockpitInstaller',
|
||||
'codeigniter' => 'CodeIgniterInstaller',
|
||||
'concrete5' => 'Concrete5Installer',
|
||||
'craft' => 'CraftInstaller',
|
||||
'croogo' => 'CroogoInstaller',
|
||||
'dframe' => 'DframeInstaller',
|
||||
'dokuwiki' => 'DokuWikiInstaller',
|
||||
'dolibarr' => 'DolibarrInstaller',
|
||||
'decibel' => 'DecibelInstaller',
|
||||
'drupal' => 'DrupalInstaller',
|
||||
'elgg' => 'ElggInstaller',
|
||||
'eliasis' => 'EliasisInstaller',
|
||||
'ee3' => 'ExpressionEngineInstaller',
|
||||
'ee2' => 'ExpressionEngineInstaller',
|
||||
'ezplatform' => 'EzPlatformInstaller',
|
||||
'fuel' => 'FuelInstaller',
|
||||
'fuelphp' => 'FuelphpInstaller',
|
||||
'grav' => 'GravInstaller',
|
||||
'hurad' => 'HuradInstaller',
|
||||
'imagecms' => 'ImageCMSInstaller',
|
||||
'itop' => 'ItopInstaller',
|
||||
'joomla' => 'JoomlaInstaller',
|
||||
'kanboard' => 'KanboardInstaller',
|
||||
'kirby' => 'KirbyInstaller',
|
||||
'known' => 'KnownInstaller',
|
||||
'kodicms' => 'KodiCMSInstaller',
|
||||
'kohana' => 'KohanaInstaller',
|
||||
'lms' => 'LanManagementSystemInstaller',
|
||||
'laravel' => 'LaravelInstaller',
|
||||
'lavalite' => 'LavaLiteInstaller',
|
||||
'lithium' => 'LithiumInstaller',
|
||||
'magento' => 'MagentoInstaller',
|
||||
'majima' => 'MajimaInstaller',
|
||||
'mantisbt' => 'MantisBTInstaller',
|
||||
'mako' => 'MakoInstaller',
|
||||
'maya' => 'MayaInstaller',
|
||||
'mautic' => 'MauticInstaller',
|
||||
'mediawiki' => 'MediaWikiInstaller',
|
||||
'microweber' => 'MicroweberInstaller',
|
||||
'modulework' => 'MODULEWorkInstaller',
|
||||
'modx' => 'ModxInstaller',
|
||||
'modxevo' => 'MODXEvoInstaller',
|
||||
'moodle' => 'MoodleInstaller',
|
||||
'october' => 'OctoberInstaller',
|
||||
'ontowiki' => 'OntoWikiInstaller',
|
||||
'oxid' => 'OxidInstaller',
|
||||
'osclass' => 'OsclassInstaller',
|
||||
'pxcms' => 'PxcmsInstaller',
|
||||
'phpbb' => 'PhpBBInstaller',
|
||||
'pimcore' => 'PimcoreInstaller',
|
||||
'piwik' => 'PiwikInstaller',
|
||||
'plentymarkets'=> 'PlentymarketsInstaller',
|
||||
'ppi' => 'PPIInstaller',
|
||||
'puppet' => 'PuppetInstaller',
|
||||
'radphp' => 'RadPHPInstaller',
|
||||
'phifty' => 'PhiftyInstaller',
|
||||
'porto' => 'PortoInstaller',
|
||||
'processwire' => 'ProcessWireInstaller',
|
||||
'redaxo' => 'RedaxoInstaller',
|
||||
'redaxo5' => 'Redaxo5Installer',
|
||||
'reindex' => 'ReIndexInstaller',
|
||||
'roundcube' => 'RoundcubeInstaller',
|
||||
'shopware' => 'ShopwareInstaller',
|
||||
'sitedirect' => 'SiteDirectInstaller',
|
||||
'silverstripe' => 'SilverStripeInstaller',
|
||||
'smf' => 'SMFInstaller',
|
||||
'starbug' => 'StarbugInstaller',
|
||||
'sydes' => 'SyDESInstaller',
|
||||
'sylius' => 'SyliusInstaller',
|
||||
'symfony1' => 'Symfony1Installer',
|
||||
'tao' => 'TaoInstaller',
|
||||
'thelia' => 'TheliaInstaller',
|
||||
'tusk' => 'TuskInstaller',
|
||||
'typo3-cms' => 'TYPO3CmsInstaller',
|
||||
'typo3-flow' => 'TYPO3FlowInstaller',
|
||||
'userfrosting' => 'UserFrostingInstaller',
|
||||
'vanilla' => 'VanillaInstaller',
|
||||
'whmcs' => 'WHMCSInstaller',
|
||||
'wolfcms' => 'WolfCMSInstaller',
|
||||
'wordpress' => 'WordPressInstaller',
|
||||
'yawik' => 'YawikInstaller',
|
||||
'zend' => 'ZendInstaller',
|
||||
'zikula' => 'ZikulaInstaller',
|
||||
'prestashop' => 'PrestashopInstaller'
|
||||
);
|
||||
|
||||
/**
|
||||
* Installer constructor.
|
||||
*
|
||||
* Disables installers specified in main composer extra installer-disable
|
||||
* list
|
||||
*
|
||||
* @param IOInterface $io
|
||||
* @param Composer $composer
|
||||
* @param string $type
|
||||
* @param Filesystem|null $filesystem
|
||||
* @param BinaryInstaller|null $binaryInstaller
|
||||
*/
|
||||
public function __construct(
|
||||
IOInterface $io,
|
||||
Composer $composer,
|
||||
$type = 'library',
|
||||
Filesystem $filesystem = null,
|
||||
BinaryInstaller $binaryInstaller = null
|
||||
) {
|
||||
parent::__construct($io, $composer, $type, $filesystem,
|
||||
$binaryInstaller);
|
||||
$this->removeDisabledInstallers();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getInstallPath(PackageInterface $package)
|
||||
{
|
||||
$type = $package->getType();
|
||||
$frameworkType = $this->findFrameworkType($type);
|
||||
|
||||
if ($frameworkType === false) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Sorry the package type of this package is not yet supported.'
|
||||
);
|
||||
}
|
||||
|
||||
$class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
|
||||
$installer = new $class($package, $this->composer, $this->getIO());
|
||||
|
||||
return $installer->getInstallPath($package, $frameworkType);
|
||||
}
|
||||
|
||||
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
{
|
||||
$installPath = $this->getPackageBasePath($package);
|
||||
$io = $this->io;
|
||||
$outputStatus = function () use ($io, $installPath) {
|
||||
$io->write(sprintf('Deleting %s - %s', $installPath, !file_exists($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
|
||||
};
|
||||
|
||||
$promise = parent::uninstall($repo, $package);
|
||||
|
||||
// Composer v2 might return a promise here
|
||||
if ($promise instanceof PromiseInterface) {
|
||||
return $promise->then($outputStatus);
|
||||
}
|
||||
|
||||
// If not, execute the code right away as parent::uninstall executed synchronously (composer v1, or v2 without async)
|
||||
$outputStatus();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function supports($packageType)
|
||||
{
|
||||
$frameworkType = $this->findFrameworkType($packageType);
|
||||
|
||||
if ($frameworkType === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$locationPattern = $this->getLocationPattern($frameworkType);
|
||||
|
||||
return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a supported framework type if it exists and returns it
|
||||
*
|
||||
* @param string $type
|
||||
* @return string|false
|
||||
*/
|
||||
protected function findFrameworkType($type)
|
||||
{
|
||||
krsort($this->supportedTypes);
|
||||
|
||||
foreach ($this->supportedTypes as $key => $val) {
|
||||
if ($key === substr($type, 0, strlen($key))) {
|
||||
return substr($type, 0, strlen($key));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the second part of the regular expression to check for support of a
|
||||
* package type
|
||||
*
|
||||
* @param string $frameworkType
|
||||
* @return string
|
||||
*/
|
||||
protected function getLocationPattern($frameworkType)
|
||||
{
|
||||
$pattern = false;
|
||||
if (!empty($this->supportedTypes[$frameworkType])) {
|
||||
$frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
|
||||
/** @var BaseInstaller $framework */
|
||||
$framework = new $frameworkClass(null, $this->composer, $this->getIO());
|
||||
$locations = array_keys($framework->getLocations());
|
||||
$pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
|
||||
}
|
||||
|
||||
return $pattern ? : '(\w+)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get I/O object
|
||||
*
|
||||
* @return IOInterface
|
||||
*/
|
||||
private function getIO()
|
||||
{
|
||||
return $this->io;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for installers set to be disabled in composer's extra config and
|
||||
* remove them from the list of supported installers.
|
||||
*
|
||||
* Globals:
|
||||
* - true, "all", and "*" - disable all installers.
|
||||
* - false - enable all installers (useful with
|
||||
* wikimedia/composer-merge-plugin or similar)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeDisabledInstallers()
|
||||
{
|
||||
$extra = $this->composer->getPackage()->getExtra();
|
||||
|
||||
if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) {
|
||||
// No installers are disabled
|
||||
return;
|
||||
}
|
||||
|
||||
// Get installers to disable
|
||||
$disable = $extra['installer-disable'];
|
||||
|
||||
// Ensure $disabled is an array
|
||||
if (!is_array($disable)) {
|
||||
$disable = array($disable);
|
||||
}
|
||||
|
||||
// Check which installers should be disabled
|
||||
$all = array(true, "all", "*");
|
||||
$intersect = array_intersect($all, $disable);
|
||||
if (!empty($intersect)) {
|
||||
// Disable all installers
|
||||
$this->supportedTypes = array();
|
||||
} else {
|
||||
// Disable specified installers
|
||||
foreach ($disable as $key => $installer) {
|
||||
if (is_string($installer) && key_exists($installer, $this->supportedTypes)) {
|
||||
unset($this->supportedTypes[$installer]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class ItopInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'extension' => 'extensions/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class JoomlaInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'component' => 'components/{$name}/',
|
||||
'module' => 'modules/{$name}/',
|
||||
'template' => 'templates/{$name}/',
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
'library' => 'libraries/{$name}/',
|
||||
);
|
||||
|
||||
// TODO: Add inflector for mod_ and com_ names
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
/**
|
||||
*
|
||||
* Installer for kanboard plugins
|
||||
*
|
||||
* kanboard.net
|
||||
*
|
||||
* Class KanboardInstaller
|
||||
* @package Composer\Installers
|
||||
*/
|
||||
class KanboardInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class KirbyInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'site/plugins/{$name}/',
|
||||
'field' => 'site/fields/{$name}/',
|
||||
'tag' => 'site/tags/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class KnownInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'IdnoPlugins/{$name}/',
|
||||
'theme' => 'Themes/{$name}/',
|
||||
'console' => 'ConsolePlugins/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class KodiCMSInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'cms/plugins/{$name}/',
|
||||
'media' => 'cms/media/vendor/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class KohanaInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Composer\Installers;
|
||||
|
||||
class LanManagementSystemInstaller extends BaseInstaller
|
||||
{
|
||||
|
||||
protected $locations = array(
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
'template' => 'templates/{$name}/',
|
||||
'document-template' => 'documents/templates/{$name}/',
|
||||
'userpanel-module' => 'userpanel/modules/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
|
||||
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class LaravelInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'library' => 'libraries/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class LavaLiteInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'package' => 'packages/{$vendor}/{$name}/',
|
||||
'theme' => 'public/themes/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class LithiumInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'library' => 'libraries/{$name}/',
|
||||
'source' => 'libraries/_source/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MODULEWorkInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
/**
|
||||
* An installer to handle MODX Evolution specifics when installing packages.
|
||||
*/
|
||||
class MODXEvoInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'snippet' => 'assets/snippets/{$name}/',
|
||||
'plugin' => 'assets/plugins/{$name}/',
|
||||
'module' => 'assets/modules/{$name}/',
|
||||
'template' => 'assets/templates/{$name}/',
|
||||
'lib' => 'assets/lib/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MagentoInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'theme' => 'app/design/frontend/{$name}/',
|
||||
'skin' => 'skin/frontend/default/{$name}/',
|
||||
'library' => 'lib/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
/**
|
||||
* Plugin/theme installer for majima
|
||||
* @author David Neustadt
|
||||
*/
|
||||
class MajimaInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Transforms the names
|
||||
* @param array $vars
|
||||
* @return array
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
return $this->correctPluginName($vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change hyphenated names to camelcase
|
||||
* @param array $vars
|
||||
* @return array
|
||||
*/
|
||||
private function correctPluginName($vars)
|
||||
{
|
||||
$camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
|
||||
return strtoupper($matches[0][1]);
|
||||
}, $vars['name']);
|
||||
$vars['name'] = ucfirst($camelCasedName);
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MakoInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'package' => 'app/packages/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\DependencyResolver\Pool;
|
||||
|
||||
class MantisBTInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
|
||||
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MauticInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'plugin' => 'plugins/{$name}/',
|
||||
'theme' => 'themes/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name of mautic-plugins to CamelCase
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($vars['type'] == 'mautic-plugin') {
|
||||
$vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
|
||||
return strtoupper($matches[0][1]);
|
||||
}, ucfirst($vars['name']));
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MayaInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name.
|
||||
*
|
||||
* For package type maya-module, cut off a trailing '-module' if present.
|
||||
*
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($vars['type'] === 'maya-module') {
|
||||
return $this->inflectModuleVars($vars);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectModuleVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-module$/', '', $vars['name']);
|
||||
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MediaWikiInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'core' => 'core/',
|
||||
'extension' => 'extensions/{$name}/',
|
||||
'skin' => 'skins/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name.
|
||||
*
|
||||
* For package type mediawiki-extension, cut off a trailing '-extension' if present and transform
|
||||
* to CamelCase keeping existing uppercase chars.
|
||||
*
|
||||
* For package type mediawiki-skin, cut off a trailing '-skin' if present.
|
||||
*
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
|
||||
if ($vars['type'] === 'mediawiki-extension') {
|
||||
return $this->inflectExtensionVars($vars);
|
||||
}
|
||||
|
||||
if ($vars['type'] === 'mediawiki-skin') {
|
||||
return $this->inflectSkinVars($vars);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectExtensionVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-extension$/', '', $vars['name']);
|
||||
$vars['name'] = str_replace('-', ' ', $vars['name']);
|
||||
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectSkinVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MicroweberInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'userfiles/modules/{$install_item_dir}/',
|
||||
'module-skin' => 'userfiles/modules/{$install_item_dir}/templates/',
|
||||
'template' => 'userfiles/templates/{$install_item_dir}/',
|
||||
'element' => 'userfiles/elements/{$install_item_dir}/',
|
||||
'vendor' => 'vendor/{$install_item_dir}/',
|
||||
'components' => 'components/{$install_item_dir}/'
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name.
|
||||
*
|
||||
* For package type microweber-module, cut off a trailing '-module' if present
|
||||
*
|
||||
* For package type microweber-template, cut off a trailing '-template' if present.
|
||||
*
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
|
||||
|
||||
if ($this->package->getTargetDir()) {
|
||||
$vars['install_item_dir'] = $this->package->getTargetDir();
|
||||
} else {
|
||||
$vars['install_item_dir'] = $vars['name'];
|
||||
if ($vars['type'] === 'microweber-template') {
|
||||
return $this->inflectTemplateVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-templates') {
|
||||
return $this->inflectTemplatesVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-core') {
|
||||
return $this->inflectCoreVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-adapter') {
|
||||
return $this->inflectCoreVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-module') {
|
||||
return $this->inflectModuleVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-modules') {
|
||||
return $this->inflectModulesVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-skin') {
|
||||
return $this->inflectSkinVars($vars);
|
||||
}
|
||||
if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') {
|
||||
return $this->inflectElementVars($vars);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectTemplateVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-template$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/template-$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectTemplatesVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-templates$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/templates-$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectCoreVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-providers$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/-provider$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/-adapter$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectModuleVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-module$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/module-$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectModulesVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-modules$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/modules-$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectSkinVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-skin$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/skin-$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectElementVars($vars)
|
||||
{
|
||||
$vars['install_item_dir'] = preg_replace('/-elements$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/elements-$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/-element$/', '', $vars['install_item_dir']);
|
||||
$vars['install_item_dir'] = preg_replace('/element-$/', '', $vars['install_item_dir']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
/**
|
||||
* An installer to handle MODX specifics when installing packages.
|
||||
*/
|
||||
class ModxInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'extra' => 'core/packages/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class MoodleInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'mod' => 'mod/{$name}/',
|
||||
'admin_report' => 'admin/report/{$name}/',
|
||||
'atto' => 'lib/editor/atto/plugins/{$name}/',
|
||||
'tool' => 'admin/tool/{$name}/',
|
||||
'assignment' => 'mod/assignment/type/{$name}/',
|
||||
'assignsubmission' => 'mod/assign/submission/{$name}/',
|
||||
'assignfeedback' => 'mod/assign/feedback/{$name}/',
|
||||
'auth' => 'auth/{$name}/',
|
||||
'availability' => 'availability/condition/{$name}/',
|
||||
'block' => 'blocks/{$name}/',
|
||||
'booktool' => 'mod/book/tool/{$name}/',
|
||||
'cachestore' => 'cache/stores/{$name}/',
|
||||
'cachelock' => 'cache/locks/{$name}/',
|
||||
'calendartype' => 'calendar/type/{$name}/',
|
||||
'fileconverter' => 'files/converter/{$name}/',
|
||||
'format' => 'course/format/{$name}/',
|
||||
'coursereport' => 'course/report/{$name}/',
|
||||
'customcertelement' => 'mod/customcert/element/{$name}/',
|
||||
'datafield' => 'mod/data/field/{$name}/',
|
||||
'datapreset' => 'mod/data/preset/{$name}/',
|
||||
'editor' => 'lib/editor/{$name}/',
|
||||
'enrol' => 'enrol/{$name}/',
|
||||
'filter' => 'filter/{$name}/',
|
||||
'gradeexport' => 'grade/export/{$name}/',
|
||||
'gradeimport' => 'grade/import/{$name}/',
|
||||
'gradereport' => 'grade/report/{$name}/',
|
||||
'gradingform' => 'grade/grading/form/{$name}/',
|
||||
'local' => 'local/{$name}/',
|
||||
'logstore' => 'admin/tool/log/store/{$name}/',
|
||||
'ltisource' => 'mod/lti/source/{$name}/',
|
||||
'ltiservice' => 'mod/lti/service/{$name}/',
|
||||
'message' => 'message/output/{$name}/',
|
||||
'mnetservice' => 'mnet/service/{$name}/',
|
||||
'plagiarism' => 'plagiarism/{$name}/',
|
||||
'portfolio' => 'portfolio/{$name}/',
|
||||
'qbehaviour' => 'question/behaviour/{$name}/',
|
||||
'qformat' => 'question/format/{$name}/',
|
||||
'qtype' => 'question/type/{$name}/',
|
||||
'quizaccess' => 'mod/quiz/accessrule/{$name}/',
|
||||
'quiz' => 'mod/quiz/report/{$name}/',
|
||||
'report' => 'report/{$name}/',
|
||||
'repository' => 'repository/{$name}/',
|
||||
'scormreport' => 'mod/scorm/report/{$name}/',
|
||||
'search' => 'search/engine/{$name}/',
|
||||
'theme' => 'theme/{$name}/',
|
||||
'tinymce' => 'lib/editor/tinymce/plugins/{$name}/',
|
||||
'profilefield' => 'user/profile/field/{$name}/',
|
||||
'webservice' => 'webservice/{$name}/',
|
||||
'workshopallocation' => 'mod/workshop/allocation/{$name}/',
|
||||
'workshopeval' => 'mod/workshop/eval/{$name}/',
|
||||
'workshopform' => 'mod/workshop/form/{$name}/'
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class OctoberInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
'plugin' => 'plugins/{$vendor}/{$name}/',
|
||||
'theme' => 'themes/{$name}/'
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name.
|
||||
*
|
||||
* For package type october-plugin, cut off a trailing '-plugin' if present.
|
||||
*
|
||||
* For package type october-theme, cut off a trailing '-theme' if present.
|
||||
*
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
if ($vars['type'] === 'october-plugin') {
|
||||
return $this->inflectPluginVars($vars);
|
||||
}
|
||||
|
||||
if ($vars['type'] === 'october-theme') {
|
||||
return $this->inflectThemeVars($vars);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectPluginVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']);
|
||||
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function inflectThemeVars($vars)
|
||||
{
|
||||
$vars['name'] = preg_replace('/^oc-|-theme$/', '', $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class OntoWikiInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'extension' => 'extensions/{$name}/',
|
||||
'theme' => 'extensions/themes/{$name}/',
|
||||
'translation' => 'extensions/translations/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* Format package name to lower case and remove ".ontowiki" suffix
|
||||
*/
|
||||
public function inflectPackageVars($vars)
|
||||
{
|
||||
$vars['name'] = strtolower($vars['name']);
|
||||
$vars['name'] = preg_replace('/.ontowiki$/', '', $vars['name']);
|
||||
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
|
||||
$vars['name'] = preg_replace('/-translation$/', '', $vars['name']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
|
||||
class OsclassInstaller extends BaseInstaller
|
||||
{
|
||||
|
||||
protected $locations = array(
|
||||
'plugin' => 'oc-content/plugins/{$name}/',
|
||||
'theme' => 'oc-content/themes/{$name}/',
|
||||
'language' => 'oc-content/languages/{$name}/',
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
class OxidInstaller extends BaseInstaller
|
||||
{
|
||||
const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
|
||||
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
'theme' => 'application/views/{$name}/',
|
||||
'out' => 'out/{$name}/',
|
||||
);
|
||||
|
||||
/**
|
||||
* getInstallPath
|
||||
*
|
||||
* @param PackageInterface $package
|
||||
* @param string $frameworkType
|
||||
* @return string
|
||||
*/
|
||||
public function getInstallPath(PackageInterface $package, $frameworkType = '')
|
||||
{
|
||||
$installPath = parent::getInstallPath($package, $frameworkType);
|
||||
$type = $this->package->getType();
|
||||
if ($type === 'oxid-module') {
|
||||
$this->prepareVendorDirectory($installPath);
|
||||
}
|
||||
return $installPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* prepareVendorDirectory
|
||||
*
|
||||
* Makes sure there is a vendormetadata.php file inside
|
||||
* the vendor folder if there is a vendor folder.
|
||||
*
|
||||
* @param string $installPath
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareVendorDirectory($installPath)
|
||||
{
|
||||
$matches = '';
|
||||
$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
|
||||
if (!$hasVendorDirectory) {
|
||||
return;
|
||||
}
|
||||
|
||||
$vendorDirectory = $matches['vendor'];
|
||||
$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
|
||||
if (!file_exists($vendorPath)) {
|
||||
mkdir($vendorPath, 0755, true);
|
||||
}
|
||||
|
||||
$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
|
||||
touch($vendorMetaDataPath);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class PPIInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'module' => 'modules/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class PhiftyInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'bundle' => 'bundles/{$name}/',
|
||||
'library' => 'libraries/{$name}/',
|
||||
'framework' => 'frameworks/{$name}/',
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Composer\Installers;
|
||||
|
||||
class PhpBBInstaller extends BaseInstaller
|
||||
{
|
||||
protected $locations = array(
|
||||
'extension' => 'ext/{$vendor}/{$name}/',
|
||||
'language' => 'language/{$name}/',
|
||||
'style' => 'styles/{$name}/',
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue