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,119 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreFactory;
use Magento\Store\Model\StoreManagerInterface;
use Plumrocket\CookieConsent\Api\CookieRepositoryInterface;
use Plumrocket\CookieConsent\Model\Cookie;
use Plumrocket\CookieConsent\Model\CookieFactory;
use Plumrocket\CookieConsent\Ui\Locator\CookieLocatorInterface;
/**
* @since 1.0.0
*/
class Builder
{
/**
* @var \Plumrocket\CookieConsent\Model\CookieFactory
*/
private $cookieFactory;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Magento\Store\Model\StoreFactory
*/
private $storeFactory;
/**
* @var \Plumrocket\CookieConsent\Ui\Locator\CookieLocatorInterface
*/
private $cookieLocator;
/**
* @var \Plumrocket\CookieConsent\Api\CookieRepositoryInterface
*/
private $cookieRepository;
/**
* @param \Plumrocket\CookieConsent\Model\CookieFactory $cookieFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Store\Model\StoreFactory $storeFactory
* @param \Plumrocket\CookieConsent\Ui\Locator\CookieLocatorInterface $cookieLocator
* @param \Plumrocket\CookieConsent\Api\CookieRepositoryInterface $cookieRepository
*/
public function __construct(
CookieFactory $cookieFactory,
StoreManagerInterface $storeManager,
StoreFactory $storeFactory,
CookieLocatorInterface $cookieLocator,
CookieRepositoryInterface $cookieRepository
) {
$this->cookieFactory = $cookieFactory;
$this->storeManager = $storeManager;
$this->storeFactory = $storeFactory;
$this->cookieLocator = $cookieLocator;
$this->cookieRepository = $cookieRepository;
}
/**
* Build cookie item based on user request
*
* @param RequestInterface $request
* @return \Plumrocket\CookieConsent\Model\Cookie
*/
public function build(RequestInterface $request): Cookie
{
$storeId = (int) $request->getParam('store', 0);
$cookieId = (int) $request->getParam('id');
$store = $this->storeManager->getStore($storeId);
$this->storeManager->setCurrentStore($store->getCode());
if ($cookieId) {
try {
$cookie = $this->cookieRepository->getById($cookieId, $storeId);
} catch (NoSuchEntityException $e) {
/** @var \Plumrocket\CookieConsent\Model\Cookie $cookie */
$cookie = $this->cookieFactory->create();
}
} else {
/** @var \Plumrocket\CookieConsent\Model\Cookie $cookie */
$cookie = $this->cookieFactory->create();
}
/** @var \Magento\Store\Model\Store $store */
$store = $this->storeFactory->create();
$store->load($storeId);
$cookie->setStoreId(null !== $store->getId() ? (int) $store->getId() : null);
$this->cookieLocator->setStore($store);
$this->cookieLocator->setCookie($cookie);
return $cookie;
}
}
@@ -0,0 +1,72 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Backend\App\Action\Context;
use Plumrocket\CookieConsent\Api\CookieRepositoryInterface;
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
/**
* @since 1.0.0
*/
class Delete extends AbstractItem
{
/**
* @var \Plumrocket\CookieConsent\Api\CookieRepositoryInterface
*/
private $cookieRepository;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Plumrocket\CookieConsent\Api\CookieRepositoryInterface $cookieRepository
*/
public function __construct(
Context $context,
CookieRepositoryInterface $cookieRepository
) {
parent::__construct($context);
$this->cookieRepository = $cookieRepository;
}
/**
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$id = (int) $this->getRequest()->getParam('id');
if ($id) {
try {
$this->cookieRepository->deleteById($id);
$this->messageManager->addSuccessMessage(__('You deleted the cookie.'));
return $resultRedirect->setPath('*/*/');
} catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
return $resultRedirect->setPath('*/*/edit', ['id' => $id]);
}
}
$this->messageManager->addErrorMessage(__('We can\'t find a cookie to delete.'));
return $resultRedirect->setPath('*/*/');
}
}
@@ -0,0 +1,96 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Store\Model\StoreManagerInterface;
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
/**
* @since 1.0.0
*/
class Edit extends AbstractItem
{
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
private $storeManager;
/**
* @var \Plumrocket\CookieConsent\Controller\Adminhtml\Item\Builder
*/
private $cookieBuilder;
/**
* Edit constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Plumrocket\CookieConsent\Controller\Adminhtml\Item\Builder $cookieBuilder
*/
public function __construct(
Context $context,
StoreManagerInterface $storeManager,
Builder $cookieBuilder
) {
parent::__construct($context);
$this->storeManager = $storeManager;
$this->cookieBuilder = $cookieBuilder;
}
/**
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$storeId = (int) $this->getRequest()->getParam('store', 0);
$id = (int) $this->getRequest()->getParam('id');
$store = $this->storeManager->getStore($storeId);
$this->storeManager->setCurrentStore($store->getCode());
$cookie = $this->cookieBuilder->build($this->getRequest());
if ($id && ! $cookie->getId()) {
$this->messageManager->addErrorMessage(__('This cookie cookie no longer exists.'));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('*/*/');
}
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$this->initBreadcrumbAndMenu($resultPage)->addBreadcrumb(
$id ? __('Edit Cookie') : __('New Cookie'),
$id ? __('Edit Cookie') : __('New Cookie')
);
$title = $resultPage->getConfig()->getTitle();
$title->prepend(__('Cookie Category'));
$title->prepend($cookie->getId() ? __('Edit Cookie "%1"', $cookie->getName()) : __('New Cookie'));
return $resultPage;
}
}
@@ -0,0 +1,59 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Controller\ResultFactory;
use Plumrocket\CookieConsent\Api\Data\CookieInterface;
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
/**
* @since 1.0.0
*/
class Index extends AbstractItem
{
/**
* @var \Magento\Framework\App\Request\DataPersistorInterface
*/
private $dataPersistor;
/**
* Index constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
*/
public function __construct(
Context $context,
DataPersistorInterface $dataPersistor
) {
parent::__construct($context);
$this->dataPersistor = $dataPersistor;
}
public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$this->initBreadcrumbAndMenu($resultPage)->getConfig()->getTitle()->prepend(__('Manage Cookies'));
$this->dataPersistor->clear(CookieInterface::DATA_PERSISTOR_KEY);
return $resultPage;
}
}
@@ -0,0 +1,77 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Ui\Component\MassAction\Filter;
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
use Plumrocket\CookieConsent\Model\ResourceModel\Cookie\CollectionFactory;
/**
* @since 1.0.0
*/
class MassDelete extends AbstractItem
{
/**
* @var \Magento\Ui\Component\MassAction\Filter
*/
private $filter;
/**
* @var \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\CollectionFactory
*/
private $collectionFactory;
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Ui\Component\MassAction\Filter $filter
* @param \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\CollectionFactory $collectionFactory
*/
public function __construct(
Context $context,
Filter $filter,
CollectionFactory $collectionFactory
) {
parent::__construct($context);
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;
}
/**
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
/** @var \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\Collection $collection */
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
foreach ($collection->getItems() as $cookie) {
$cookie->delete();
}
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath('*/*/');
}
}
@@ -0,0 +1,40 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Framework\Controller\ResultFactory;
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractItem;
/**
* @since 1.0.0
*/
class NewAction extends AbstractItem
{
/**
* @inheritDoc
*/
public function execute()
{
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
return $resultForward->forward('edit');
}
}
@@ -0,0 +1,139 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\CookieConsent\Controller\Adminhtml\Item;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Store\Model\StoreManagerInterface;
use Plumrocket\CookieConsent\Api\CookieRepositoryInterface;
use Plumrocket\CookieConsent\Api\Data\CookieInterface;
use Plumrocket\CookieConsent\Controller\Adminhtml\AbstractEavSave;
use Plumrocket\CookieConsent\Model\Cookie\Attribute\DurationDecorator;
class Save extends AbstractEavSave
{
public const ADMIN_RESOURCE = 'Plumrocket_CookieConsent::cookies';
/**
* @var Builder
*/
private $cookieBuilder;
/**
* @var \Magento\Framework\App\Request\DataPersistorInterface
*/
private $dataPersistor;
/**
* @var \Plumrocket\CookieConsent\Api\CategoryRepositoryInterface
*/
private $cookieRepository;
/**
* @var \Plumrocket\CookieConsent\Model\Cookie\Attribute\DurationDecorator
*/
private $durationDecorator;
/**
* Save constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Plumrocket\CookieConsent\Controller\Adminhtml\Item\Builder $cookieBuilder
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor
* @param \Plumrocket\CookieConsent\Api\CookieRepositoryInterface $cookieRepository
* @param \Plumrocket\CookieConsent\Model\Cookie\Attribute\DurationDecorator $durationDecorator
*/
public function __construct(
Context $context,
Builder $cookieBuilder,
StoreManagerInterface $storeManager,
DataPersistorInterface $dataPersistor,
CookieRepositoryInterface $cookieRepository,
DurationDecorator $durationDecorator
) {
parent::__construct($context, $storeManager);
$this->cookieBuilder = $cookieBuilder;
$this->dataPersistor = $dataPersistor;
$this->cookieRepository = $cookieRepository;
$this->durationDecorator = $durationDecorator;
}
/**
* @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Framework\App\ResponseInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function execute()
{
$storeId = $this->initCurrentStore();
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$postData = $this->getRequest()->getPostValue();
$id = (int) $this->getRequest()->getParam('id');
if ($postData) {
$cookie = $this->cookieBuilder->build($this->getRequest());
$this->dataPersistor->set(CookieInterface::DATA_PERSISTOR_KEY, $postData);
if ($id && ! $cookie->getId()) {
$this->messageManager->addErrorMessage(__('This cookie no longer exists.'));
return $resultRedirect->setPath('*/*/');
}
try {
$postData = $this->durationDecorator->serializeParams($postData);
$cookie->addData($postData);
$this->prepareUseDefault($postData, $cookie);
$this->cookieRepository->save($cookie);
$this->messageManager->addSuccessMessage(__('You saved the cookie.'));
$this->dataPersistor->clear(CookieInterface::DATA_PERSISTOR_KEY);
if ($this->getRequest()->getParam('back')) {
return $resultRedirect->setPath(
'*/*/edit',
['id' => $cookie->getId(), '_current' => true]
);
}
return $resultRedirect->setPath('*/*/');
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addExceptionMessage(
$e,
__('Something went wrong while saving the cookie.')
);
}
$this->dataPersistor->set(CookieInterface::DATA_PERSISTOR_KEY, $postData);
return $resultRedirect->setPath('*/*/edit', [
'id' => $this->getRequest()->getParam('id'),
'store' => $storeId,
]);
}
return $resultRedirect->setPath('*/*/');
}
}