Skip to content

Commit

Permalink
[php:plugin] add option onDropWith for plugin function iaEnabled (#2442)
Browse files Browse the repository at this point in the history
* Add option onDropWith for plugin function iaEnabled

* change to tab indent
  • Loading branch information
nmpetkov authored and nao-pon committed Mar 26, 2018
1 parent 40d556b commit f1c59f6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
21 changes: 20 additions & 1 deletion php/elFinderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,26 @@ protected function iaEnabled($opts) {
return false;
}

if (isset($opts['onDropWith']) && !is_null($opts['onDropWith'])) {
// plugin disabled by default, enabled only if given key is pressed
if (isset($_REQUEST['dropWith']) && $_REQUEST['dropWith']) {
$onDropWith = $opts['onDropWith'];
$action = (int)$_REQUEST['dropWith'];
if (!is_array($onDropWith)) {
$onDropWith = array($onDropWith);
}
foreach($onDropWith as $key) {
$key = (int)$key;
if (($action & $key) === $key) {
return true;
}
}
}
return false;
}

if (isset($opts['offDropWith']) && ! is_null($opts['offDropWith']) && isset($_REQUEST['dropWith'])) {
// plugin enabled by default, disabled only if given key is pressed
$offDropWith = $opts['offDropWith'];
$action = (int)$_REQUEST['dropWith'];
if (! is_array($offDropWith)) {
Expand Down Expand Up @@ -72,4 +91,4 @@ protected function iaEnabled($opts) {

return true;
}
}
}
10 changes: 8 additions & 2 deletions php/plugins/AutoResize/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
* 'preserveExif' => false, // Preserve EXIF data (Imagick only)
* 'forceEffect' => false, // For change quality or make progressive JPEG of small images
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
* 'offDropWith' => null // To disable it if it is dropped with pressing the meta key
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* )
Expand All @@ -41,7 +44,10 @@
* 'preserveExif' => false, // Preserve EXIF data (Imagick only)
* 'forceEffect' => false, // For change quality or make progressive JPEG of small images
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
* 'offDropWith' => null // To disable it if it is dropped with pressing the meta key
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* )
Expand Down
10 changes: 8 additions & 2 deletions php/plugins/AutoRotate/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
* 'AutoRotate' => array(
* 'enable' => true, // For control by volume driver
* 'quality' => 95, // JPEG image save quality
* 'offDropWith' => null // To disable it if it is dropped with pressing the meta key
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* )
Expand All @@ -31,7 +34,10 @@
* 'AutoRotate' => array(
* 'enable' => true, // For control by volume driver
* 'quality' => 95, // JPEG image save quality
* 'offDropWith' => null // To disable it if it is dropped with pressing the meta key
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* )
Expand Down
10 changes: 8 additions & 2 deletions php/plugins/Watermark/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
* 'targetMinPixel' => 200, // Target image minimum pixel size
* 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
* 'offDropWith' => null // To disable it if it is dropped with pressing the meta key
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* )
Expand All @@ -45,7 +48,10 @@
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
* 'targetMinPixel' => 200, // Target image minimum pixel size
* 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
* 'offDropWith' => null // To disable it if it is dropped with pressing the meta key
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
* // In case of using any key, specify it as an array
* )
Expand Down

0 comments on commit f1c59f6

Please sign in to comment.