ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\Page;
|
||||
use Magento\Framework\Registry;
|
||||
|
||||
abstract class Slides extends Action {
|
||||
|
||||
protected $_coreRegistry;
|
||||
protected $_slidesFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry
|
||||
) {
|
||||
$this->_coreRegistry = $coreRegistry;
|
||||
parent::__construct( $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init page
|
||||
*
|
||||
* @param Page $resultPage
|
||||
* @return Page
|
||||
*/
|
||||
public function initPage( $resultPage ) {
|
||||
$resultPage->setActiveMenu( 'Olegnax_Core::Olegnax_Core' )
|
||||
->addBreadcrumb( __( 'Slideshow' ), __( 'Slideshow' ) )
|
||||
->addBreadcrumb( __( 'Athlete slider Slides' ), __( 'Athlete slider Slides' ) );
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Model\View\Result\Redirect;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Olegnax\Athlete2Slideshow\Model\Slides;
|
||||
|
||||
class Delete extends \Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Olegnax_Athlete2Slideshow::Slides_Delete';
|
||||
/**
|
||||
* Delete action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
// check if we know what should be deleted
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
if ($id) {
|
||||
try {
|
||||
// init model and delete
|
||||
$model = $this->_objectManager->create( Slides::class);
|
||||
$model->load($id);
|
||||
$model->delete();
|
||||
// display success message
|
||||
$this->messageManager->addSuccessMessage(__('You deleted the Slide.'));
|
||||
// go to grid
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch ( Exception $e) {
|
||||
// display error message
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
// go back to edit form
|
||||
return $resultRedirect->setPath('*/*/edit', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
// display error message
|
||||
$this->messageManager->addErrorMessage(__('We can\'t find a Slide to delete.'));
|
||||
// go to grid
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\Athlete2Slideshow\Model\Slides;
|
||||
|
||||
class Edit extends \Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides {
|
||||
const ADMIN_RESOURCE = 'Olegnax_Athlete2Slideshow::Slides_Edit';
|
||||
|
||||
protected $resultPageFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
PageFactory $resultPageFactory
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct( $context, $coreRegistry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
$id = $this->getRequest()->getParam( 'id' );
|
||||
$model = $this->_objectManager->create( Slides::class );
|
||||
|
||||
if ( $id ) {
|
||||
$model->load( $id );
|
||||
if ( !$model->getId() ) {
|
||||
$this->messageManager->addErrorMessage( __( 'This Slide no longer exists.' ) );
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
return $resultRedirect->setPath( '*/*/' );
|
||||
}
|
||||
}
|
||||
|
||||
$this->_coreRegistry->register( 'olegnax_athlete2slideshow_slide', $model );
|
||||
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$this->initPage( $resultPage )->addBreadcrumb(
|
||||
$id ? __( 'Edit Slide' ) : __( 'New Slide' ), $id ? __( 'Edit Slide' ) : __( 'New Slide' )
|
||||
);
|
||||
$resultPage->getConfig()->getTitle()->prepend( __( 'Slide' ) );
|
||||
$resultPage->getConfig()->getTitle()->prepend( $model->getId() ? __( 'Edit Slide %1', $model->getId() ) : __( 'New Slide' ) );
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_Athlete2Slideshow::Slides_Index';
|
||||
|
||||
protected $_pageFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, PageFactory $pageFactory) {
|
||||
$this->_pageFactory = $pageFactory;
|
||||
return parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$resultPage = $this->_pageFactory->create();
|
||||
$resultPage->getConfig()->getTitle()->prepend((__('Athlete Slide Manager')));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Olegnax\Athlete2Slideshow\Model\ResourceModel\Slides\CollectionFactory;
|
||||
|
||||
class MassDelete extends Action {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_Athlete2Slideshow::Slides_Delete';
|
||||
|
||||
protected $_filter;
|
||||
protected $_collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->_filter = $filter;
|
||||
$this->_collectionFactory = $collectionFactory;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$collection = $this->_collectionFactory->create();
|
||||
$collectionFilter = $this->_filter->getCollection($collection);
|
||||
$delete = 0;
|
||||
if (!empty($collectionFilter)) {
|
||||
foreach ($collection as $item) {
|
||||
$item->delete();
|
||||
$delete++;
|
||||
}
|
||||
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $delete));
|
||||
} else {
|
||||
$this->messageManager->addException(__('Nothing selected!'));
|
||||
}
|
||||
|
||||
|
||||
$resultRedirect = $this->resultFactory->create( ResultFactory::TYPE_REDIRECT);
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_Athlete2Slideshow
|
||||
* @copyright Copyright (c) 2020 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
class MassDisable extends MassEnable
|
||||
{
|
||||
const STATUS = 0;
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_Athlete2Slideshow
|
||||
* @copyright Copyright (c) 2020 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\ResponseInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Olegnax\Athlete2Slideshow\Model\ResourceModel\Slides\CollectionFactory;
|
||||
use Olegnax\Athlete2Slideshow\Model\Slides;
|
||||
|
||||
class MassEnable extends Action
|
||||
{
|
||||
const STATUS = 1;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const ADMIN_RESOURCE = 'Olegnax_Athlete2Slideshow::Slides_Edit';
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $_collectionFactory;
|
||||
/**
|
||||
* @var Filter
|
||||
*/
|
||||
protected $_filter;
|
||||
|
||||
/**
|
||||
* MassStatus constructor.
|
||||
* @param Context $context
|
||||
* @param Filter $filter
|
||||
* @param CollectionFactory $collectionFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->_filter = $filter;
|
||||
$this->_collectionFactory = $collectionFactory;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseInterface|ResultInterface
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$_collection = $this->_collectionFactory->create();
|
||||
count($_collection);
|
||||
$collection = $this->_filter->getCollection($_collection);
|
||||
$sliderUpdated = 0;
|
||||
/** @var Slides $slider */
|
||||
foreach ($collection as $slider) {
|
||||
try {
|
||||
$slider->setStatus(static::STATUS)
|
||||
->save();
|
||||
|
||||
$sliderUpdated++;
|
||||
} catch (LocalizedException $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
$this->messageManager->addErrorMessage(
|
||||
__(
|
||||
'Something went wrong while updating status for %1.',
|
||||
$slider->getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($sliderUpdated) {
|
||||
$this->messageManager->addSuccessMessage(
|
||||
__(
|
||||
'A total of %1 record(s) have been updated.',
|
||||
$sliderUpdated
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\ForwardFactory;
|
||||
use Magento\Framework\Controller\Result\Forward;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
class NewAction extends Slides
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Olegnax_Athlete2Slideshow::Slides_New';
|
||||
|
||||
protected $resultForwardFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param ForwardFactory $resultForwardFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
ForwardFactory $resultForwardFactory
|
||||
) {
|
||||
$this->resultForwardFactory = $resultForwardFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* New action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var Forward $resultForward */
|
||||
$resultForward = $this->resultForwardFactory->create();
|
||||
return $resultForward->forward('edit');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax Athlete Slideshow
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_AthleteSlideshow
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
|
||||
namespace Olegnax\Athlete2Slideshow\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\File\Uploader;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\Athlete2Slideshow\Model\Slides;
|
||||
|
||||
class Save extends Action {
|
||||
|
||||
const IMAGE_FOLDER = 'slideshow/';
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, PageFactory $resultPageFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
$data = $this->getRequest()->getPostValue();
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
$model = $this->_objectManager->create( Slides::class);
|
||||
$image_fields = [
|
||||
'image',
|
||||
'banner_1_img',
|
||||
'banner_1_imgX2',
|
||||
'banner_2_img',
|
||||
'banner_2_imgX2'];
|
||||
$need_delete = [
|
||||
];
|
||||
foreach ($image_fields as $fields) {
|
||||
if (array_key_exists($fields, $data) && is_array($data[$fields])) {
|
||||
if (isset($data[$fields]['delete'])) {
|
||||
$need_delete[$fields] = $data[$fields]['value'];
|
||||
}
|
||||
$data[$fields] = $data[$fields]['value'];
|
||||
} else {
|
||||
$data[$fields] = '';
|
||||
}
|
||||
}
|
||||
$model->setData($data);
|
||||
$model->save();
|
||||
try {
|
||||
foreach ($image_fields as $fields) {
|
||||
if (array_key_exists($fields, $need_delete)) {
|
||||
$this->removeImages($fields, $model);
|
||||
} else {
|
||||
$this->saveImages($fields, $model, $data[$fields]);
|
||||
}
|
||||
}
|
||||
$model->save();
|
||||
|
||||
$this->messageManager->addSuccess(__('Saved.'));
|
||||
if ($this->getRequest()->getParam('back')) {
|
||||
return $resultRedirect->setPath('*/*/edit', [
|
||||
'id' => $model->getId(),
|
||||
'_current' => true]);
|
||||
}
|
||||
$this->_objectManager->get('Magento\Backend\Model\Session')->setFormData(false);
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch ( Exception $e) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('%1', $e->getMessage()));
|
||||
$this->messageManager->addException($e, __('Something went wrong.'));
|
||||
}
|
||||
$this->_getSession()->setFormData($data);
|
||||
return $resultRedirect->setPath('*/*/edit', [
|
||||
'id' => $this->getRequest()->getParam('id')]);
|
||||
}
|
||||
|
||||
protected function imagePath(string $subFolder, string $prefixFolder = '') {
|
||||
return $prefixFolder . self::IMAGE_FOLDER . $subFolder . '/';
|
||||
}
|
||||
|
||||
protected function saveImages(string $fieldId, $model, $currentValue = '') {
|
||||
$directory = $this->_objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
|
||||
$saveDirectory = $this->imagePath($model->getId(), $directory->getRoot() . '/pub/media/');
|
||||
$result = null;
|
||||
$extension = '';
|
||||
try {
|
||||
$uploader = new \Magento\MediaStorage\Model\File\Uploader(
|
||||
$fieldId, $this->_objectManager->create('Magento\MediaStorage\Helper\File\Storage\Database'), $this->_objectManager->create('Magento\MediaStorage\Helper\File\Storage'), $this->_objectManager->create('Magento\MediaStorage\Model\File\Validator\NotProtectedExtension')
|
||||
);
|
||||
$uploader->setAllowCreateFolders(true);
|
||||
$uploader->setAllowRenameFiles(true);
|
||||
$uploader->setAllowedExtensions([
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'png']);
|
||||
$extension = $uploader->getFileExtension();
|
||||
$this->removeImages($fieldId, $model);
|
||||
$result = $uploader->save($saveDirectory, $fieldId . '.' . $extension);
|
||||
} catch ( Exception $e) {
|
||||
if (in_array($fieldId, [
|
||||
'image']) && $e->getCode() != Uploader::TMP_NAME_EMPTY) {
|
||||
$this->messageManager->addException($e, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$model->setData($fieldId, $this->imagePath($model->getId()) . $fieldId . '.' . $extension);
|
||||
} else {
|
||||
$model->setData($fieldId, $currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeImages(string $fieldId, $model, $currentValue = '') {
|
||||
$image = $model->getData($fieldId);
|
||||
if (!empty($image)) {
|
||||
$directory = $this->_objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
|
||||
$path = $directory->getRoot() . '/pub/media/' . $image;
|
||||
if (file_exists($path) && is_file($path)) {
|
||||
@unlink($path);
|
||||
$model->setData($fieldId, $currentValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function _isAllowed() {
|
||||
return $this->_authorization->isAllowed('Olegnax_Athlete2Slideshow::Slides_New') || $this->_authorization->isAllowed('Olegnax_Athlete2Slideshow::Slides_Edit');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user