ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Carousel\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class BackButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Back'),
|
||||
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
|
||||
'class' => 'back',
|
||||
'sort_order' => 10
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL for back (reset) button
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBackUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Carousel\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class DeleteButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
$data = [];
|
||||
if ($this->getModelId()) {
|
||||
$data = [
|
||||
'label' => __('Delete Carousel'),
|
||||
'class' => 'delete',
|
||||
'on_click' => 'deleteConfirm(\'' . __(
|
||||
'Are you sure you want to do this?'
|
||||
) . '\', \'' . $this->getDeleteUrl() . '\')',
|
||||
'sort_order' => 20,
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL for delete button
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeleteUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/delete', ['carousel_id' => $this->getModelId()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Carousel\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
|
||||
|
||||
abstract class GenericButton
|
||||
{
|
||||
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
*/
|
||||
public function __construct(Context $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return model ID
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getModelId()
|
||||
{
|
||||
return $this->context->getRequest()->getParam('carousel_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate url by route and parameters
|
||||
*
|
||||
* @param string $route
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl($route = '', $params = [])
|
||||
{
|
||||
return $this->context->getUrlBuilder()->getUrl($route, $params);
|
||||
}
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Carousel\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => ['event' => 'saveAndContinueEdit'],
|
||||
],
|
||||
],
|
||||
'sort_order' => 80,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Carousel\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class SaveButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Save Carousel'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Slide\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class BackButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Back'),
|
||||
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
|
||||
'class' => 'back',
|
||||
'sort_order' => 10
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL for back (reset) button
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBackUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Slide\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class DeleteButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
$data = [];
|
||||
if ($this->getModelId()) {
|
||||
$data = [
|
||||
'label' => __('Delete Slide'),
|
||||
'class' => 'delete',
|
||||
'on_click' => 'deleteConfirm(\'' . __(
|
||||
'Are you sure you want to do this?'
|
||||
) . '\', \'' . $this->getDeleteUrl() . '\')',
|
||||
'sort_order' => 20,
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL for delete button
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeleteUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/delete', ['slide_id' => $this->getModelId()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Slide\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
|
||||
|
||||
abstract class GenericButton
|
||||
{
|
||||
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
*/
|
||||
public function __construct(Context $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return model ID
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getModelId()
|
||||
{
|
||||
return $this->context->getRequest()->getParam('slide_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate url by route and parameters
|
||||
*
|
||||
* @param string $route
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl($route = '', $params = [])
|
||||
{
|
||||
return $this->context->getUrlBuilder()->getUrl($route, $params);
|
||||
}
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Slide\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => ['event' => 'saveAndContinueEdit'],
|
||||
],
|
||||
],
|
||||
'sort_order' => 80,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Adminhtml\Slide\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
|
||||
class SaveButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Save Slide'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright (c) 2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Olegnax\Carousel\Block\Widget;
|
||||
|
||||
use Magento\Customer\Model\Context;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
use Magento\Widget\Block\BlockInterface;
|
||||
use Olegnax\Carousel\Model\CarouselFactory;
|
||||
use Olegnax\Carousel\Model\ResourceModel\Carousel\CollectionFactory;
|
||||
|
||||
|
||||
class Carousel extends Template implements BlockInterface
|
||||
{
|
||||
|
||||
protected $_template = "widget/carousel.phtml";
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Http\Context
|
||||
*/
|
||||
protected $httpContext;
|
||||
/**
|
||||
* @var Json
|
||||
*/
|
||||
protected $json;
|
||||
/**
|
||||
* @var \Olegnax\Carousel\Model\Carousel
|
||||
*/
|
||||
protected $carouselCollection;
|
||||
|
||||
/**
|
||||
* Carousel constructor.
|
||||
* @param Template\Context $context
|
||||
* @param CarouselFactory $carouselFactory
|
||||
* @param \Magento\Framework\App\Http\Context $httpContext
|
||||
* @param Json $json
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Template\Context $context,
|
||||
CollectionFactory $carouselFactory,
|
||||
\Magento\Framework\App\Http\Context $httpContext,
|
||||
Json $json,
|
||||
array $data = []
|
||||
) {
|
||||
$this->carouselCollection = $carouselFactory->create();
|
||||
$this->httpContext = $httpContext;
|
||||
$this->json = $json;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $newval
|
||||
* @return array
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getCacheKeyInfo($newval = [])
|
||||
{
|
||||
return array_merge([
|
||||
'OLEGNAX_CAROUSEL_WIDGET',
|
||||
$this->_storeManager->getStore()->getId(),
|
||||
$this->_design->getDesignTheme()->getId(),
|
||||
$this->httpContext->getValue(Context::CONTEXT_GROUP),
|
||||
$this->json->serialize($this->getData()),
|
||||
], parent::getCacheKeyInfo(), $newval);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCarouselId()
|
||||
{
|
||||
return 'ox_carousel_' . substr(md5(microtime()), -5);
|
||||
}
|
||||
|
||||
public function getSlide($store_id = null)
|
||||
{
|
||||
$carousel = $this->getCarousel();
|
||||
if ($carousel) {
|
||||
return $this->getCarousel()->getSlide($store_id);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Olegnax\Carousel\Model\Carousel
|
||||
*/
|
||||
public function getCarousel()
|
||||
{
|
||||
$carousel = $this->getData('current_carousel');
|
||||
if (empty($carousel)) {
|
||||
$carousels = $this->carouselCollection
|
||||
->addFieldToSelect('*')
|
||||
->addFieldToFilter('identifier', $this->getData('carousel'));
|
||||
if ($carousels->getSize()) {
|
||||
foreach ($carousels as $carousel) {
|
||||
$this->setData('current_carousel', $carousel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $carousel;
|
||||
}
|
||||
|
||||
protected function _construct()
|
||||
{
|
||||
$this->addData([
|
||||
'cache_lifetime' => 86400,
|
||||
]);
|
||||
if (!$this->hasData('template') && !$this->getTemplate()) {
|
||||
$this->setTemplate('Olegnax_Carousel::widget/carousel.phtml');
|
||||
}
|
||||
parent::_construct();
|
||||
}
|
||||
|
||||
public function getAutoScroll() {
|
||||
$auto_scroll = $this->getData( 'autoplay' );
|
||||
if ( empty( $auto_scroll ) ) {
|
||||
$auto_scroll = 0;
|
||||
}
|
||||
|
||||
return $auto_scroll;
|
||||
}
|
||||
|
||||
public function getResponsive( $to_string = true ) {
|
||||
$responsive = [
|
||||
'0' => [
|
||||
'items' => max(1, (int)$this->getColumnsMobile()),
|
||||
],
|
||||
'768' => [
|
||||
'items' => max(1, (int)$this->getColumnsTablet()),
|
||||
],
|
||||
'1025' => [
|
||||
'items' => max(1, (int)$this->getColumnsDesktopSmall()),
|
||||
],
|
||||
'1160' => [
|
||||
'items' => max(1, (int)$this->getColumnsDesktop()),
|
||||
],
|
||||
];
|
||||
if ( $to_string ) {
|
||||
return json_encode( $responsive );
|
||||
}
|
||||
|
||||
return $responsive;
|
||||
}
|
||||
|
||||
public function prepareStyle( array $style, string $separatorValue = ': ', string $separatorAttribute = ';' ) {
|
||||
$style = array_filter( $style );
|
||||
if ( empty( $style ) ) {
|
||||
return '';
|
||||
}
|
||||
foreach ( $style as $key => &$value ) {
|
||||
$value = $key . $separatorValue . $value;
|
||||
}
|
||||
$style = implode( $separatorAttribute, $style );
|
||||
|
||||
return $style;
|
||||
}
|
||||
public function customStyles( $slider_id, $slide ) {
|
||||
$styles = array();
|
||||
if(!empty($slide)) {
|
||||
if (!empty($slide->getData('subtitle_color'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id').' .subtitle{ color:' .$slide->getData('subtitle_color') . '}'; }
|
||||
if (!empty($slide->getData('title_color'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id').' .title{ color:' .$slide->getData('title_color') . '}'; }
|
||||
if (!empty($slide->getData('title_bg'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' .title{ background-color:' . $slide->getData('title_bg') . '}'; }
|
||||
if (!empty($slide->getData('button_color'))) {
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button{ color:' . $slide->getData('button_color') . '}';
|
||||
}
|
||||
if (!empty($slide->getData('button_color_hover'))) {
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id').' a.ox-slide__button:hover{ color:' .$slide->getData('button_color_hover') . '}';
|
||||
}
|
||||
if (!empty($slide->getData('button_bg_hover'))) {
|
||||
if($slide->getData('button_style') == 'underline'){
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button.underline:hover{ border-color:' . $slide->getData('button_bg_hover') . '}';
|
||||
} elseif($slide->getData('button_style') == 'outline'){
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button.outline:hover{ border-color:' . $slide->getData('button_bg_hover') . '}';
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button:after{ background-color:' . $slide->getData('button_bg_hover') . '}';
|
||||
} else {
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button:after{ background-color:' . $slide->getData('button_bg_hover') . '}';
|
||||
}
|
||||
}
|
||||
if (!empty($slide->getData('button_bg'))) {
|
||||
if($slide->getData('button_style') == 'underline'){
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button.underline{ border-color:' . $slide->getData('button_bg') . '}';
|
||||
} elseif($slide->getData('button_style') == 'outline'){
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button.outline{ border-color:' . $slide->getData('button_bg') . '}';
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button{ background-color:' . $slide->getData('button_bg') . '}';
|
||||
} else {
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' a.ox-slide__button{ background-color:' . $slide->getData('button_bg') . '}';
|
||||
}
|
||||
}
|
||||
if (!empty($slide->getData('content_width'))) {
|
||||
$styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id').'.slide-content-2-col .ox-carousel__col:first-child{' .
|
||||
'max-width:' .$slide->getData('content_width') . 'px;' .
|
||||
'}' .
|
||||
'#' . $slider_id. ' .slide' . $slide->getData('slide_id').' .ox-carousel__inner{ max-width:' .$slide->getData('content_width') . 'px }';
|
||||
}
|
||||
if (!empty($slide->getData('text_color'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slide_id') .' .ox-carousel__content{ color:' . $slide->getData('text_color') . '}'; }
|
||||
}
|
||||
if ( !empty($styles) ){
|
||||
return implode(' ', $styles);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
public function getBaseUrl() {
|
||||
$this->_storeManager->getStore()->getBaseUrl( UrlInterface::URL_TYPE_WEB);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user