Minor clean ups
This commit is contained in:
parent
bc4aa1495c
commit
9470259727
|
|
@ -17,7 +17,7 @@
|
||||||
<script src="<?= Backend::skinAsset('assets/js/vendor/modernizr.min.js') ?>"></script>
|
<script src="<?= Backend::skinAsset('assets/js/vendor/modernizr.min.js') ?>"></script>
|
||||||
<script src="<?= Backend::skinAsset('assets/js/vendor/vendor-min.js') ?>"></script>
|
<script src="<?= Backend::skinAsset('assets/js/vendor/vendor-min.js') ?>"></script>
|
||||||
<script src="<?= Backend::skinAsset('assets/js/october-min.js') ?>"></script>
|
<script src="<?= Backend::skinAsset('assets/js/october-min.js') ?>"></script>
|
||||||
<script src="<?= Backend::skinAsset('../cms/widgets/mediamanager/assets/js/mediamanager-global-min.js') ?>"></script>
|
<script src="<?= URL::asset('modules/cms/widgets/mediamanager/assets/js/mediamanager-global-min.js') ?>"></script>
|
||||||
|
|
||||||
<?= $this->makeAssets() ?>
|
<?= $this->makeAssets() ?>
|
||||||
<?= Block::placeholder('head') ?>
|
<?= Block::placeholder('head') ?>
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
'icon' => 'icon-picture-o',
|
'icon' => 'icon-picture-o',
|
||||||
'url' => Backend::URL('cms/themes'),
|
'url' => Backend::URL('cms/themes'),
|
||||||
'permissions' => ['system.manage_themes'],
|
'permissions' => ['system.manage_themes'],
|
||||||
'order' => 300
|
'order' => 200
|
||||||
],
|
],
|
||||||
'maintenance_settings' => [
|
'maintenance_settings' => [
|
||||||
'label' => 'cms::lang.maintenance.settings_menu',
|
'label' => 'cms::lang.maintenance.settings_menu',
|
||||||
|
|
@ -155,7 +155,7 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
'icon' => 'icon-plug',
|
'icon' => 'icon-plug',
|
||||||
'class' => 'Cms\Models\MaintenanceSettings',
|
'class' => 'Cms\Models\MaintenanceSettings',
|
||||||
'permissions' => ['system.manage_themes'],
|
'permissions' => ['system.manage_themes'],
|
||||||
'order' => 400
|
'order' => 300
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ class MediaLibrary
|
||||||
/**
|
/**
|
||||||
* Returns a list of folders and files in a Library folder.
|
* Returns a list of folders and files in a Library folder.
|
||||||
* @param string $folder Specifies the folder path relative the the Library root.
|
* @param string $folder Specifies the folder path relative the the Library root.
|
||||||
* @param string $sortBy Determines the sorting preference.
|
* @param string $sortBy Determines the sorting preference.
|
||||||
* Supported values are 'title', 'size', 'lastModified' (see SORT_BY_XXX class constants) and FALSE.
|
* Supported values are 'title', 'size', 'lastModified' (see SORT_BY_XXX class constants) and FALSE.
|
||||||
* @param string $filter Determines the document type filtering preference.
|
* @param string $filter Determines the document type filtering preference.
|
||||||
* Supported values are 'image', 'video', 'audio', 'document' (see FILE_TYPE_XXX constants of MediaLibraryItem class).
|
* Supported values are 'image', 'video', 'audio', 'document' (see FILE_TYPE_XXX constants of MediaLibraryItem class).
|
||||||
* @return array Returns an array of MediaLibraryItem objects.
|
* @return array Returns an array of MediaLibraryItem objects.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class ComponentList extends WidgetBase
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return $this->makePartial('body', [
|
return $this->makePartial('body', [
|
||||||
'data'=>$this->getData()
|
'data' => $this->getData()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,21 @@ class MediaManager extends WidgetBase
|
||||||
$this->alias = $alias;
|
$this->alias = $alias;
|
||||||
|
|
||||||
parent::__construct($controller, []);
|
parent::__construct($controller, []);
|
||||||
$this->bindToController();
|
|
||||||
|
|
||||||
$this->checkUploadPostback();
|
$this->checkUploadPostback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds widget specific asset files. Use $this->addJs() and $this->addCss()
|
||||||
|
* to register new assets to include on the page.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function loadAssets()
|
||||||
|
{
|
||||||
|
$this->addCss('css/mediamanager.css', 'core');
|
||||||
|
$this->addJs('js/mediamanager-browser-min.js', 'core');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the widget.
|
* Renders the widget.
|
||||||
* @return string
|
* @return string
|
||||||
|
|
@ -89,11 +99,13 @@ class MediaManager extends WidgetBase
|
||||||
{
|
{
|
||||||
$path = Input::get('path');
|
$path = Input::get('path');
|
||||||
|
|
||||||
if (Input::get('clearCache'))
|
if (Input::get('clearCache')) {
|
||||||
MediaLibrary::instance()->resetCache();
|
MediaLibrary::instance()->resetCache();
|
||||||
|
}
|
||||||
|
|
||||||
if (Input::get('resetSearch'))
|
if (Input::get('resetSearch')) {
|
||||||
$this->setSearchTerm(null);
|
$this->setSearchTerm(null);
|
||||||
|
}
|
||||||
|
|
||||||
$this->setCurrentFolder($path);
|
$this->setCurrentFolder($path);
|
||||||
$this->prepareVars();
|
$this->prepareVars();
|
||||||
|
|
@ -107,12 +119,14 @@ class MediaManager extends WidgetBase
|
||||||
public function onGenerateThumbnails()
|
public function onGenerateThumbnails()
|
||||||
{
|
{
|
||||||
$batch = Input::get('batch');
|
$batch = Input::get('batch');
|
||||||
if (!is_array($batch))
|
if (!is_array($batch)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($batch as $thumbnailInfo)
|
foreach ($batch as $thumbnailInfo) {
|
||||||
$result[] = $this->generateThumbnail($thumbnailInfo);
|
$result[] = $this->generateThumbnail($thumbnailInfo);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'generatedThumbnails'=>$result
|
'generatedThumbnails'=>$result
|
||||||
|
|
@ -131,19 +145,20 @@ class MediaManager extends WidgetBase
|
||||||
|
|
||||||
$path = MediaLibrary::validatePath($path);
|
$path = MediaLibrary::validatePath($path);
|
||||||
|
|
||||||
if (!is_numeric($lastModified))
|
if (!is_numeric($lastModified)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
// If the thumbnail file exists - just return the thumbnail marup,
|
// If the thumbnail file exists - just return the thumbnail marup,
|
||||||
// otherwise generate a new thumbnail.
|
// otherwise generate a new thumbnail.
|
||||||
$thumbnailPath = $this->thumbnailExists($thumbnailParams, $path, $lastModified);
|
$thumbnailPath = $this->thumbnailExists($thumbnailParams, $path, $lastModified);
|
||||||
if ($thumbnailPath) {
|
if ($thumbnailPath) {
|
||||||
return [
|
return [
|
||||||
'markup'=>$this->makePartial('thumbnail-image', [
|
'markup' => $this->makePartial('thumbnail-image', [
|
||||||
'isError' => $this->thumbnailIsError($thumbnailPath),
|
'isError' => $this->thumbnailIsError($thumbnailPath),
|
||||||
'imageUrl' => $this->getThumbnailImageUrl($thumbnailPath)
|
'imageUrl' => $this->getThumbnailImageUrl($thumbnailPath)
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumbnailInfo = $thumbnailParams;
|
$thumbnailInfo = $thumbnailParams;
|
||||||
|
|
@ -208,20 +223,24 @@ class MediaManager extends WidgetBase
|
||||||
{
|
{
|
||||||
$paths = Input::get('paths');
|
$paths = Input::get('paths');
|
||||||
|
|
||||||
if (!is_array($paths))
|
if (!is_array($paths)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$library = MediaLibrary::instance();
|
$library = MediaLibrary::instance();
|
||||||
|
|
||||||
$filesToDelete = [];
|
$filesToDelete = [];
|
||||||
foreach ($paths as $pathInfo) {
|
foreach ($paths as $pathInfo) {
|
||||||
if (!isset($pathInfo['path']) || !isset($pathInfo['type']))
|
if (!isset($pathInfo['path']) || !isset($pathInfo['type'])) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
if ($pathInfo['type'] == 'file')
|
if ($pathInfo['type'] == 'file') {
|
||||||
$filesToDelete[] = $pathInfo['path'];
|
$filesToDelete[] = $pathInfo['path'];
|
||||||
else if ($pathInfo['type'] == 'folder')
|
}
|
||||||
|
else if ($pathInfo['type'] == 'folder') {
|
||||||
$library->deleteFolder($pathInfo['path']);
|
$library->deleteFolder($pathInfo['path']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($filesToDelete) > 0)
|
if (count($filesToDelete) > 0)
|
||||||
|
|
@ -250,11 +269,13 @@ class MediaManager extends WidgetBase
|
||||||
public function onApplyName()
|
public function onApplyName()
|
||||||
{
|
{
|
||||||
$newName = trim(Input::get('name'));
|
$newName = trim(Input::get('name'));
|
||||||
if (!strlen($newName))
|
if (!strlen($newName)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
|
throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->validateFileName($newName))
|
if (!$this->validateFileName($newName)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
|
throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
|
||||||
|
}
|
||||||
|
|
||||||
$originalPath = Input::get('originalPath');
|
$originalPath = Input::get('originalPath');
|
||||||
$originalPath = MediaLibrary::validatePath($originalPath);
|
$originalPath = MediaLibrary::validatePath($originalPath);
|
||||||
|
|
@ -263,10 +284,12 @@ class MediaManager extends WidgetBase
|
||||||
|
|
||||||
$type = Input::get('type');
|
$type = Input::get('type');
|
||||||
|
|
||||||
if ($type == MediaLibraryItem::TYPE_FILE)
|
if ($type == MediaLibraryItem::TYPE_FILE) {
|
||||||
MediaLibrary::instance()->moveFile($originalPath, $newPath);
|
MediaLibrary::instance()->moveFile($originalPath, $newPath);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
MediaLibrary::instance()->moveFolder($originalPath, $newPath);
|
MediaLibrary::instance()->moveFolder($originalPath, $newPath);
|
||||||
|
}
|
||||||
|
|
||||||
MediaLibrary::instance()->resetCache();
|
MediaLibrary::instance()->resetCache();
|
||||||
}
|
}
|
||||||
|
|
@ -274,11 +297,13 @@ class MediaManager extends WidgetBase
|
||||||
public function onCreateFolder()
|
public function onCreateFolder()
|
||||||
{
|
{
|
||||||
$name = trim(Input::get('name'));
|
$name = trim(Input::get('name'));
|
||||||
if (!strlen($name))
|
if (!strlen($name)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
|
throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->validateFileName($name))
|
if (!$this->validateFileName($name)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
|
throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
|
||||||
|
}
|
||||||
|
|
||||||
$path = Input::get('path');
|
$path = Input::get('path');
|
||||||
$path = MediaLibrary::validatePath($path);
|
$path = MediaLibrary::validatePath($path);
|
||||||
|
|
@ -287,11 +312,13 @@ class MediaManager extends WidgetBase
|
||||||
|
|
||||||
$library = MediaLibrary::instance();
|
$library = MediaLibrary::instance();
|
||||||
|
|
||||||
if ($library->folderExists($newFolderPath))
|
if ($library->folderExists($newFolderPath)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.media.folder_or_file_exist'));
|
throw new ApplicationException(Lang::get('cms::lang.media.folder_or_file_exist'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!$library->makeFolder($newFolderPath))
|
if (!$library->makeFolder($newFolderPath)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.media.error_creating_folder'));
|
throw new ApplicationException(Lang::get('cms::lang.media.error_creating_folder'));
|
||||||
|
}
|
||||||
|
|
||||||
$library->resetCache();
|
$library->resetCache();
|
||||||
|
|
||||||
|
|
@ -305,8 +332,9 @@ class MediaManager extends WidgetBase
|
||||||
public function onLoadMovePopup()
|
public function onLoadMovePopup()
|
||||||
{
|
{
|
||||||
$exclude = Input::get('exclude', []);
|
$exclude = Input::get('exclude', []);
|
||||||
if (!is_array($exclude))
|
if (!is_array($exclude)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$folders = MediaLibrary::instance()->listAllDirectories($exclude);
|
$folders = MediaLibrary::instance()->listAllDirectories($exclude);
|
||||||
|
|
||||||
|
|
@ -314,8 +342,9 @@ class MediaManager extends WidgetBase
|
||||||
foreach ($folders as $folder) {
|
foreach ($folders as $folder) {
|
||||||
$path = $folder;
|
$path = $folder;
|
||||||
|
|
||||||
if ($folder == '/')
|
if ($folder == '/') {
|
||||||
$name = Lang::get('cms::lang.media.library');
|
$name = Lang::get('cms::lang.media.library');
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$segments = explode('/', $folder);
|
$segments = explode('/', $folder);
|
||||||
$name = str_repeat(' ', (count($segments)-1)*4).basename($folder);
|
$name = str_repeat(' ', (count($segments)-1)*4).basename($folder);
|
||||||
|
|
@ -333,28 +362,34 @@ class MediaManager extends WidgetBase
|
||||||
public function onMoveItems()
|
public function onMoveItems()
|
||||||
{
|
{
|
||||||
$dest = trim(Input::get('dest'));
|
$dest = trim(Input::get('dest'));
|
||||||
if (!strlen($dest))
|
if (!strlen($dest)) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.media.please_select_move_dest'));
|
throw new ApplicationException(Lang::get('cms::lang.media.please_select_move_dest'));
|
||||||
|
}
|
||||||
|
|
||||||
$dest = MediaLibrary::validatePath($dest);
|
$dest = MediaLibrary::validatePath($dest);
|
||||||
if ($dest == Input::get('originalPath'))
|
if ($dest == Input::get('originalPath')) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.media.move_dest_src_match'));
|
throw new ApplicationException(Lang::get('cms::lang.media.move_dest_src_match'));
|
||||||
|
}
|
||||||
|
|
||||||
$files = Input::get('files', []);
|
$files = Input::get('files', []);
|
||||||
if (!is_array($files))
|
if (!is_array($files)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$folders = Input::get('folders', []);
|
$folders = Input::get('folders', []);
|
||||||
if (!is_array($folders))
|
if (!is_array($folders)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$library = MediaLibrary::instance();
|
$library = MediaLibrary::instance();
|
||||||
|
|
||||||
foreach ($files as $path)
|
foreach ($files as $path) {
|
||||||
$library->moveFile($path, $dest.'/'.basename($path));
|
$library->moveFile($path, $dest.'/'.basename($path));
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($folders as $path)
|
foreach ($folders as $path) {
|
||||||
$library->moveFolder($path, $dest.'/'.basename($path));
|
$library->moveFolder($path, $dest.'/'.basename($path));
|
||||||
|
}
|
||||||
|
|
||||||
$library->resetCache();
|
$library->resetCache();
|
||||||
|
|
||||||
|
|
@ -408,8 +443,9 @@ class MediaManager extends WidgetBase
|
||||||
public function onEndCroppingSession()
|
public function onEndCroppingSession()
|
||||||
{
|
{
|
||||||
$cropSessionKey = Input::get('cropSessionKey');
|
$cropSessionKey = Input::get('cropSessionKey');
|
||||||
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey))
|
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$this->removeCropEditDir($cropSessionKey);
|
$this->removeCropEditDir($cropSessionKey);
|
||||||
}
|
}
|
||||||
|
|
@ -422,14 +458,17 @@ class MediaManager extends WidgetBase
|
||||||
$path = Input::get('path');
|
$path = Input::get('path');
|
||||||
$path = MediaLibrary::validatePath($path);
|
$path = MediaLibrary::validatePath($path);
|
||||||
|
|
||||||
if (!strlen($imageSrcPath))
|
if (!strlen($imageSrcPath)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey))
|
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_array($selectionData))
|
if (!is_array($selectionData)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->cropImage($imageSrcPath, $selectionData, $cropSessionKey, $path);
|
$result = $this->cropImage($imageSrcPath, $selectionData, $cropSessionKey, $path);
|
||||||
|
|
||||||
|
|
@ -445,16 +484,19 @@ class MediaManager extends WidgetBase
|
||||||
public function onResizeImage()
|
public function onResizeImage()
|
||||||
{
|
{
|
||||||
$cropSessionKey = Input::get('cropSessionKey');
|
$cropSessionKey = Input::get('cropSessionKey');
|
||||||
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey))
|
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$width = trim(Input::get('width'));
|
$width = trim(Input::get('width'));
|
||||||
if (!strlen($width) || !ctype_digit($width))
|
if (!strlen($width) || !ctype_digit($width)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$height = trim(Input::get('height'));
|
$height = trim(Input::get('height'));
|
||||||
if (!strlen($height) || !ctype_digit($height))
|
if (!strlen($height) || !ctype_digit($height)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
$path = Input::get('path');
|
$path = Input::get('path');
|
||||||
$path = MediaLibrary::validatePath($path);
|
$path = MediaLibrary::validatePath($path);
|
||||||
|
|
@ -530,12 +572,14 @@ class MediaManager extends WidgetBase
|
||||||
protected function setFilter($filter)
|
protected function setFilter($filter)
|
||||||
{
|
{
|
||||||
if (!in_array($filter, [
|
if (!in_array($filter, [
|
||||||
self::FILTER_EVERYTHING,
|
self::FILTER_EVERYTHING,
|
||||||
MediaLibraryItem::FILE_TYPE_IMAGE,
|
MediaLibraryItem::FILE_TYPE_IMAGE,
|
||||||
MediaLibraryItem::FILE_TYPE_AUDIO,
|
MediaLibraryItem::FILE_TYPE_AUDIO,
|
||||||
MediaLibraryItem::FILE_TYPE_DOCUMENT,
|
MediaLibraryItem::FILE_TYPE_DOCUMENT,
|
||||||
MediaLibraryItem::FILE_TYPE_VIDEO]))
|
MediaLibraryItem::FILE_TYPE_VIDEO
|
||||||
|
])) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->putSession('media_filter', $filter);
|
return $this->putSession('media_filter', $filter);
|
||||||
}
|
}
|
||||||
|
|
@ -558,10 +602,12 @@ class MediaManager extends WidgetBase
|
||||||
protected function setSortBy($sortBy)
|
protected function setSortBy($sortBy)
|
||||||
{
|
{
|
||||||
if (!in_array($sortBy, [
|
if (!in_array($sortBy, [
|
||||||
MediaLibrary::SORT_BY_TITLE,
|
MediaLibrary::SORT_BY_TITLE,
|
||||||
MediaLibrary::SORT_BY_SIZE,
|
MediaLibrary::SORT_BY_SIZE,
|
||||||
MediaLibrary::SORT_BY_MODIFIED]))
|
MediaLibrary::SORT_BY_MODIFIED
|
||||||
|
])) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->putSession('media_sort_by', $sortBy);
|
return $this->putSession('media_sort_by', $sortBy);
|
||||||
}
|
}
|
||||||
|
|
@ -576,38 +622,45 @@ class MediaManager extends WidgetBase
|
||||||
$result = $this->getSession('media_crop_selection_params');
|
$result = $this->getSession('media_crop_selection_params');
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
if (!isset($result['mode']))
|
if (!isset($result['mode'])) {
|
||||||
$result['mode'] = MediaManager::SELECTION_MODE_NORMAL;
|
$result['mode'] = MediaManager::SELECTION_MODE_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($result['width']))
|
if (!isset($result['width'])) {
|
||||||
$result['width'] = null;
|
$result['width'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($result['height']))
|
if (!isset($result['height'])) {
|
||||||
$result['height'] = null;
|
$result['height'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'mode'=>MediaManager::SELECTION_MODE_NORMAL,
|
'mode' => MediaManager::SELECTION_MODE_NORMAL,
|
||||||
'width'=>null,
|
'width' => null,
|
||||||
'height'=>null
|
'height' => null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setSelectionParams($selectionMode, $selectionWidth, $selectionHeight)
|
protected function setSelectionParams($selectionMode, $selectionWidth, $selectionHeight)
|
||||||
{
|
{
|
||||||
if (!in_array($selectionMode, [
|
if (!in_array($selectionMode, [
|
||||||
MediaManager::SELECTION_MODE_NORMAL,
|
MediaManager::SELECTION_MODE_NORMAL,
|
||||||
MediaManager::SELECTION_MODE_FIXED_RATIO,
|
MediaManager::SELECTION_MODE_FIXED_RATIO,
|
||||||
MediaManager::SELECTION_MODE_FIXED_SIZE]))
|
MediaManager::SELECTION_MODE_FIXED_SIZE
|
||||||
|
])) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($selectionWidth) && !ctype_digit($selectionWidth))
|
if (strlen($selectionWidth) && !ctype_digit($selectionWidth)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen($selectionHeight) && !ctype_digit($selectionHeight))
|
if (strlen($selectionHeight) && !ctype_digit($selectionHeight)) {
|
||||||
throw new ApplicationException('Invalid input data');
|
throw new ApplicationException('Invalid input data');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->putSession('media_crop_selection_params', [
|
return $this->putSession('media_crop_selection_params', [
|
||||||
'mode'=>$selectionMode,
|
'mode'=>$selectionMode,
|
||||||
|
|
@ -656,17 +709,6 @@ class MediaManager extends WidgetBase
|
||||||
return array_reverse($result);
|
return array_reverse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds widget specific asset files. Use $this->addJs() and $this->addCss()
|
|
||||||
* to register new assets to include on the page.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function loadAssets()
|
|
||||||
{
|
|
||||||
$this->addCss('css/mediamanager.css', 'core');
|
|
||||||
$this->addJs('js/mediamanager-browser-min.js', 'core');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setViewMode($viewMode)
|
protected function setViewMode($viewMode)
|
||||||
{
|
{
|
||||||
if (!in_array($viewMode, [self::VIEW_MODE_GRID, self::VIEW_MODE_LIST, self::VIEW_MODE_TILES]))
|
if (!in_array($viewMode, [self::VIEW_MODE_GRID, self::VIEW_MODE_LIST, self::VIEW_MODE_TILES]))
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,8 @@ class ServiceProvider extends ModuleServiceProvider
|
||||||
|
|
||||||
// Classes
|
// Classes
|
||||||
'str_*' => ['Str', '*'],
|
'str_*' => ['Str', '*'],
|
||||||
'url_*' => ['URL', '*'],
|
'url_*' => ['Url', '*'],
|
||||||
'html_*' => ['HTML', '*'],
|
'html_*' => ['Html', '*'],
|
||||||
'form_*' => ['Form', '*'],
|
'form_*' => ['Form', '*'],
|
||||||
'form_macro' => ['Form', '__call']
|
'form_macro' => ['Form', '__call']
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue