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,46 @@
<?php
namespace Olegnax\BannerSlider\Model\Config\Source;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Option\ArrayInterface;
use Olegnax\Athlete2Slideshow\Helper\Helper;
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
class GroupName implements ArrayInterface {
/**
*
* @var CollectionFactory
*/
protected $group;
/**
*
* @var ObjectManager
*/
public $_objectManager;
public function __construct( Helper $helper) {
$this->_objectManager = ObjectManager::getInstance();
}
public function toOptionArray() {
$options = [];
if (!$this->group) {
$this->group = $this->_objectManager->get('\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory')->create();
}
if ($this->group && $this->group->getSize()) {
$groups = $this->group->addFieldToSelect('*')->setOrder('group_name', 'asc');
foreach ($groups as $group) {
$options[] = [
'value' => $group->getId(),
'label' => $group->getGroupName()
];
}
}
return $options;
}
}
@@ -0,0 +1,46 @@
<?php
namespace Olegnax\BannerSlider\Model\Config\Source;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Option\ArrayInterface;
use Olegnax\Athlete2Slideshow\Helper\Helper;
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
class GroupNameWidget implements ArrayInterface {
/**
*
* @var CollectionFactory
*/
protected $group;
/**
*
* @var ObjectManager
*/
public $_objectManager;
public function __construct( Helper $helper) {
$this->_objectManager = ObjectManager::getInstance();
}
public function toOptionArray() {
$options = [];
if (!$this->group) {
$this->group = $this->_objectManager->get('\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory')->create();
}
if ($this->group && $this->group->getSize()) {
$groups = $this->group->addFieldToSelect('*')->setOrder('group_name', 'asc');
foreach ($groups as $group) {
$options[] = [
'value' => $group->getIdentifier(),
'label' => $group->getGroupName()
];
}
}
return $options;
}
}
@@ -0,0 +1,34 @@
<?php
namespace Olegnax\BannerSlider\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
class Position implements ArrayInterface {
public function toOptionArray() {
return [
[
'value' => 'top-left',
'label' => __('Top Left')
],
[
'value' => 'top-right',
'label' => __('Top Right')
],
[
'value' => 'bottom-left',
'label' => __('Bottom Left')
],
[
'value' => 'bottom-right',
'label' => __('Bottom Right')
],
[
'value' => 'center',
'label' => __('Center')
],
];
}
}
+65
View File
@@ -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\Model;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Io\File;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\Context;
use Magento\Framework\Registry;
use Magento\Store\Model\StoreManagerInterface;
class Group extends AbstractModel {
protected $directoryList;
protected $io;
protected $_storeManager;
protected $_eventPrefix = 'olegnax_bannerslider_group';
public function __construct(
Context $context, Registry $registry,
StoreManagerInterface $storeManager, DirectoryList $directoryList,
File $io
) {
$this->_storeManager = $storeManager;
$this->directoryList = $directoryList;
$this->io = $io;
parent::__construct( $context, $registry );
}
/**
* @return void
*/
protected function _construct() {
$this->_init( \Olegnax\BannerSlider\Model\ResourceModel\Group::class );
}
public function getIdentities() {
return [ $this->_eventPrefix . '_' . $this->getId() ];
}
public function getIdentifier() {
return $this->getData( 'identifier' );
}
}
+79
View File
@@ -0,0 +1,79 @@
<?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\Model\Group;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Ui\DataProvider\AbstractDataProvider;
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
class DataProvider extends AbstractDataProvider {
protected $collection;
protected $dataPersistor;
protected $loadedData;
/**
* Constructor
*
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $collectionFactory
* @param DataPersistorInterface $dataPersistor
* @param array $meta
* @param array $data
*/
public function __construct(
$name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = []
) {
$this->collection = $collectionFactory->create();
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
/**
* Get data
*
* @return array
*/
public function getData() {
if (isset($this->loadedData)) {
return $this->loadedData;
}
$items = $this->collection->getItems();
foreach ($items as $model) {
$this->loadedData[$model->getId()] = $model->getData();
}
$data = $this->dataPersistor->get('olegnax_bannerslider_group');
if (!empty($data)) {
$model = $this->collection->getNewEmptyItem();
$model->setData($data);
$this->loadedData[$model->getId()] = $model->getData();
$this->dataPersistor->clear('olegnax_bannerslider_group');
}
return $this->loadedData;
}
}
@@ -0,0 +1,58 @@
<?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\Model\ResourceModel;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Group extends AbstractDb {
/**
* Define resource model
*
* @return void
*/
protected function _construct() {
$this->_init('olegnax_bannerslider_group', 'group_id');
}
protected function _beforeSave( AbstractModel $object) {
$storeId = $object->getStoreId();
if (is_array($storeId)) {
$object->setStoreId(implode(',', $storeId));
}
return parent::_beforeSave($object);
}
protected function _afterLoad( AbstractModel $object) {
$storeId = $object->getStoreId();
if (!is_array($storeId)) {
$storeId = $storeId ? explode(',', $storeId) : 0;
$object->setStoreId($storeId);
}
return parent::_afterLoad($object);
}
}
@@ -0,0 +1,126 @@
<?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\Model\ResourceModel\Group;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManagerInterface;
use Olegnax\BannerSlider\Model\ResourceModel\Group;
use Psr\Log\LoggerInterface;
class Collection extends AbstractCollection {
/**
* ID Field Name
*
* @var string
*/
protected $_idFieldName = 'group_id';
/**
* Current scope (store Id)
*
* @var int
*/
protected $_storeId;
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $_storeManager;
public function __construct(
EntityFactoryInterface $entityFactory, LoggerInterface $logger,
FetchStrategyInterface $fetchStrategy,
ManagerInterface $eventManager, StoreManagerInterface $storeManager,
AdapterInterface $connection = null,
AbstractDb $resource = null
) {
$this->_storeManager = $storeManager;
parent::__construct( $entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource );
}
/**
* Define resource model
*
* @return void
*/
protected function _construct() {
$this->_init(
\Olegnax\BannerSlider\Model\Group::class, Group::class
);
}
/**
* Set store scope
*
* @param int|string|StoreInterface $storeId
*
* @return $this
*/
public function setStoreId( $storeId ) {
if ( $storeId instanceof StoreInterface ) {
$storeId = $storeId->getId();
}
$this->_storeId = (int) $storeId;
return $this;
}
/**
* Return current store id
*
* @return int
*/
public function getStoreId() {
if ( $this->_storeId === null ) {
$this->setStoreId( $this->_storeManager->getStore()->getId() );
}
return $this->_storeId;
}
/**
* Add store availability filter. Include availability product
* for store website
*
* @param null|string|bool|int $store
* @return $this
*/
public function addStoreFilter( $store = null ) {
if ( $store === null ) {
$store = $this->getStoreId();
}
$store = $this->_storeManager->getStore( $store );
$this->getSelect()->where( "(`store_id` = 0 OR `store_id` LIKE '?,%' OR `store_id` = ? OR `store_id` LIKE '%,?' OR `store_id` LIKE '%,?,%')", $store->getId(), 'int' );
return $this;
}
}
@@ -0,0 +1,58 @@
<?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\Model\ResourceModel;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Slides extends AbstractDb {
/**
* Define resource model
*
* @return void
*/
protected function _construct() {
$this->_init('olegnax_bannerslider_slides', 'slider_id');
}
protected function _beforeSave( AbstractModel $object) {
$storeId = $object->getStoreId();
if (is_array($storeId)) {
$object->setStoreId(implode(',', $storeId));
}
return parent::_beforeSave($object);
}
protected function _afterLoad( AbstractModel $object) {
$storeId = $object->getStoreId();
if (!is_array($storeId)) {
$storeId = explode(',', $storeId);
$object->setStoreId($storeId);
}
return parent::_afterLoad($object);
}
}
@@ -0,0 +1,126 @@
<?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\Model\ResourceModel\Slides;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManagerInterface;
use Olegnax\BannerSlider\Model\ResourceModel\Slides;
use Psr\Log\LoggerInterface;
class Collection extends AbstractCollection {
/**
* ID Field Name
*
* @var string
*/
protected $_idFieldName = 'slider_id';
/**
* Current scope (store Id)
*
* @var int
*/
protected $_storeId;
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $_storeManager;
public function __construct(
EntityFactoryInterface $entityFactory, LoggerInterface $logger,
FetchStrategyInterface $fetchStrategy,
ManagerInterface $eventManager, StoreManagerInterface $storeManager,
AdapterInterface $connection = null,
AbstractDb $resource = null
) {
$this->_storeManager = $storeManager;
parent::__construct( $entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource );
}
/**
* Define resource model
*
* @return void
*/
protected function _construct() {
$this->_init(
\Olegnax\BannerSlider\Model\Slides::class, Slides::class
);
}
/**
* Set store scope
*
* @param int|string|StoreInterface $storeId
*
* @return $this
*/
public function setStoreId( $storeId ) {
if ( $storeId instanceof StoreInterface ) {
$storeId = $storeId->getId();
}
$this->_storeId = (int) $storeId;
return $this;
}
/**
* Return current store id
*
* @return int
*/
public function getStoreId() {
if ( $this->_storeId === null ) {
$this->setStoreId( $this->_storeManager->getStore()->getId() );
}
return $this->_storeId;
}
/**
* Add store availability filter. Include availability product
* for store website
*
* @param null|string|bool|int $store
* @return $this
*/
public function addStoreFilter( $store = null ) {
if ( $store === null ) {
$store = $this->getStoreId();
}
$store = $this->_storeManager->getStore( $store );
$this->getSelect()->where( "(`store_id` = 0 OR `store_id` LIKE '?,%' OR `store_id` = ? OR `store_id` LIKE '%,?' OR `store_id` LIKE '%,?,%')", $store->getId(), 'int' );
return $this;
}
}
+89
View File
@@ -0,0 +1,89 @@
<?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\Model;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Io\File;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\Context;
use Magento\Framework\Registry;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;
class Slides extends AbstractModel {
protected $directoryList;
protected $io;
protected $_storeManager;
protected $_eventPrefix = 'olegnax_bannerslider_slides';
public function __construct(
Context $context, Registry $registry, StoreManagerInterface $storeManager, DirectoryList $directoryList, File $io
) {
$this->_storeManager = $storeManager;
$this->directoryList = $directoryList;
$this->io = $io;
parent::__construct($context, $registry);
}
/**
* @return void
*/
protected function _construct() {
$this->_init(\Olegnax\BannerSlider\Model\ResourceModel\Slides::class);
}
public function getIdentities() {
return [$this->_eventPrefix . '_' . $this->getId()];
}
private function getPrefixedPath($path, $prefix = '') {
$fullPath = '';
$path = ltrim($path, '/');
if (!empty($path)) {
$fullPath = $prefix . $path;
}
return $fullPath;
}
public function getImageUrl($fieldId = 'image') {
return $this->getPrefixedPath($this->getData($fieldId),
rtrim((string)$this->_storeManager->getStore()->getBaseUrl( UrlInterface::URL_TYPE_MEDIA),
'/') . '/');
}
public function getImagePath($fieldId = 'image') {
return $this->getPrefixedPath($this->getData($fieldId),
$this->directoryList->getRoot() . '/pub/media/');
}
public function existsImage($fieldId = 'image') {
return is_file($this->getImagePath($fieldId));
}
public function hasImage($fieldId = 'image') {
return ((bool) $this->getData($fieldId) !== false && $this->existsImage());
}
}
@@ -0,0 +1,79 @@
<?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\Model\Slides;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Ui\DataProvider\AbstractDataProvider;
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
class DataProvider extends AbstractDataProvider {
protected $collection;
protected $dataPersistor;
protected $loadedData;
/**
* Constructor
*
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $collectionFactory
* @param DataPersistorInterface $dataPersistor
* @param array $meta
* @param array $data
*/
public function __construct(
$name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = []
) {
$this->collection = $collectionFactory->create();
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
/**
* Get data
*
* @return array
*/
public function getData() {
if (isset($this->loadedData)) {
return $this->loadedData;
}
$items = $this->collection->getItems();
foreach ($items as $model) {
$this->loadedData[$model->getId()] = $model->getData();
}
$data = $this->dataPersistor->get('olegnax_bannerslider_slides');
if (!empty($data)) {
$model = $this->collection->getNewEmptyItem();
$model->setData($data);
$this->loadedData[$model->getId()] = $model->getData();
$this->dataPersistor->clear('olegnax_bannerslider_slides');
}
return $this->loadedData;
}
}