ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,66 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\Controller\Adminhtml\Slides;
use Exception;
use Magento\Backend\Model\View\Result\Redirect;
use Magento\Framework\Controller\ResultInterface;
use Olegnax\BannerSlider\Model\Slides;
class Delete extends \Olegnax\BannerSlider\Controller\Adminhtml\Slides {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_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(__('Slide has been deleted.'));
$this->messageManager->addWarningMessage(__('Banner slide has been changed. Please go to Cache Management and Flush Magento Cache.'));
// 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,73 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\Controller\Adminhtml\Slides;
use Exception;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Ui\Component\MassAction\Filter;
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
class Disable extends Action {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Edit';
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->_filter->getCollection( $this->_collectionFactory->create() );
$sliderUpdated = 0;
foreach ( $collection as $slider ) {
try {
$slider->setStatus( 0 )->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('*/*/');
}
}
@@ -0,0 +1,75 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\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\BannerSlider\Model\Slides;
class Edit extends \Olegnax\BannerSlider\Controller\Adminhtml\Slides {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_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_bannerslider_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,72 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\Controller\Adminhtml\Slides;
use Exception;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Ui\Component\MassAction\Filter;
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
class Enable extends Action {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Edit';
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->_filter->getCollection( $this->_collectionFactory->create() );
$sliderUpdated = 0;
foreach ( $collection as $slider ) {
try {
$slider->setStatus( 1 )->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( '*/*/' );
}
}
@@ -0,0 +1,48 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\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_BannerSlider::Slide_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((__('Banner Slide Manager')));
return $resultPage;
}
}
@@ -0,0 +1,65 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\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\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
class MassDelete extends Action {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_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->_filter->getCollection( $this->_collectionFactory->create() );
$delete = 0;
if ( !empty( $collection ) ) {
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( '*/*/' );
}
}
@@ -0,0 +1,59 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\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\BannerSlider\Controller\Adminhtml\Slides;
class NewAction extends Slides {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_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,177 @@
<?php
/**
* Olegnax BannerSlider
*
* 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_BannerSlider
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\BannerSlider\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\BannerSlider\Helper\Image;
use Olegnax\BannerSlider\Model\Slides;
class Save extends Action {
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Index';
const IMAGE_FOLDER = 'bannerslider/';
protected $directory;
protected $helperImage;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context, PageFactory $resultPageFactory,
Image $helperImage
) {
$this->helperImage = $helperImage;
parent::__construct( $context );
}
/**
* Save action
*
* @return ResultInterface
*/
public function execute() {
$data = $this->getRequest()->getPostValue();
$resultRedirect = $this->resultRedirectFactory->create();
$id = $this->getRequest()->getParam( 'slider_id' );
$model = $this->_objectManager->create( Slides::class );
$image_fields = [
'image',
'imageX2',
];
$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( __( 'Banner slide has been saved.' ) );
$this->messageManager->addWarningMessage( __( 'Banner slide has been changed. Please go to Cache Management and Flush Magento Cache.' ) );
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' => $id ] );
}
protected function imagePath( $subFolder = '', $prefixFolder = '' ) {
$path = self::IMAGE_FOLDER;
if ( !empty( $subFolder ) ) {
$path .= $subFolder . '/';
}
if ( !empty( $prefixFolder ) ) {
$path = $prefixFolder . $path;
}
return $path;
}
protected function mediaPath() {
if ( !$this->directory ) {
$this->directory = $this->_objectManager->get( '\Magento\Framework\Filesystem\DirectoryList' );
}
return $this->directory->getRoot() . '/pub/media/';
}
protected function saveImages( string $fieldId, $model, $currentValue = '' ) {
$saveDirectory = $this->imagePath( $model->getId(), $this->mediaPath() );
$result = null;
$filename = '';
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' ] );
$this->removeImages( $fieldId, $model );
$result = $uploader->save( $saveDirectory );
$filename = $uploader->getUploadedFileName();
} 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() ) . $filename );
} else {
$model->setData( $fieldId, $currentValue );
}
}
protected function removeImages( string $fieldId, $model, $currentValue = '' ) {
$image = $model->getData( $fieldId );
if ( !empty( $image ) ) {
$this->helperImage->removeResized( $image );
$path = $this->mediaPath() . $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_BannerSlider::Slide_New') || $this->_authorization->isAllowed('Olegnax_BannerSlider::Slide_Edit');
}
}