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
+130
View File
@@ -0,0 +1,130 @@
<?php
/**
* @author Olegnax
* @package Olegnax_HotSpotQuickview
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Olegnax\HotSpotQuickview\Block\Widget;
use Magento\Catalog\Model\ResourceModel\AbstractResource;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\Widget\Block\BlockInterface;
use Olegnax\HotSpotQuickview\Helper\Helper;
use RuntimeException;
class HotSpot extends Template implements BlockInterface
{
protected $_template = "widget/hotspot.phtml";
/**
* @var UrlFinderInterface
*/
protected $urlFinder;
/**
* @var AbstractResource|null
*/
protected $_entityResource;
/**
* @var string
*/
protected $_href;
/**
* @var UrlInterface
*/
protected $urlInterface;
/**
* @var Helper
*/
protected $helper;
/**
* HotSpot constructor.
* @param Context $context
* @param UrlInterface $urlInterface
* @param Helper $helper
* @param array $data
*/
public function __construct(
Context $context,
UrlInterface $urlInterface,
Helper $helper,
array $data = []
) {
parent::__construct($context, $data);
$this->urlInterface = $urlInterface;
$this->helper = $helper;
}
/**
* Prepare url using passed id path and return it
*
* @return string|false if path was not found in url rewrites.
* @SuppressWarnings(PHPMD.NPathComplexity)
* @throws RuntimeException
*/
public function getHref()
{
if ($this->_href === null) {
if (!$this->getData('id_path')) {
return false;
}
$rewriteData = $this->parseIdPath($this->getData('id_path'));
$href = $this->urlInterface->getUrl('ox_quickview/catalog_product/view', ['id' => $rewriteData[1]]);
$this->_href = $href;
}
return $this->_href;
}
/**
* Parse id_path
*
* @param string $idPath
* @return array
* @throws RuntimeException
*/
protected function parseIdPath($idPath)
{
$rewriteData = explode('/', $idPath);
if (!isset($rewriteData[0]) || !isset($rewriteData[1])) {
throw new RuntimeException('Wrong id_path structure.');
}
return $rewriteData;
}
/**
* @return bool
*/
public function isEnabled()
{
return $this->helper->isEnabled();
}
/**
* @return string
*/
public function getWidgetId()
{
return 'ox_hotspotquickview_' . substr(md5(microtime()), -5);
}
/**
*
*/
protected function _construct()
{
$this->setData('position_left', abs((float)$this->getData('position_left')));
$this->setData('position_top', abs((float)$this->getData('position_top')));
$this->setData('border-radius', abs((int)$this->getData('border-radius')));
$this->setData('border', abs((int)$this->getData('border')));
$this->setData('rel_nofollow', (bool)$this->getData('rel_nofollow'));
parent::_construct();
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
/**
* @author Olegnax
* @package Olegnax_HotSpotQuickview
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Olegnax\HotSpotQuickview\Helper;
use Magento\Framework\App\Helper\Context;
use Olegnax\Core\Helper\Helper as CoreHelperHelper;
class Helper extends CoreHelperHelper
{
/**
* @return bool
*/
public function isEnabled()
{
return true;
}
}
@@ -0,0 +1,47 @@
<?php
/**
* @author Olegnax
* @package Olegnax_HotSpotQuickview
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
* @noinspection PhpDeprecationInspection
*/
declare(strict_types=1);
namespace Olegnax\HotSpotQuickview\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
class Icon implements ArrayInterface
{
const ICON_NONE = '';
const ICON_PLUS = 'plus';
const ICON_PLUS_SMALL = 'plus-small';
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
$array = [];
foreach ($this->toOptionArray() as $item) {
$array[$item['value']] = $item['label'];
}
return $array;
}
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [
['value' => static::ICON_NONE, 'label' => __('None')],
['value' => static::ICON_PLUS, 'label' => __('Plus')],
['value' => static::ICON_PLUS_SMALL, 'label' => __('Plus small')],
];
}
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Olegnax_HotSpotQuickview" setup_version="1.0.1.1"/>
</config>
+121
View File
@@ -0,0 +1,121 @@
<?xml version="1.0" ?>
<!--suppress XmlDefaultAttributeValue -->
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget class="Olegnax\HotSpotQuickview\Block\Widget\HotSpot" id="olegnax_hotspotquickview_hotspot">
<label>Olegnax - Hot Spot Quickview</label>
<description></description>
<parameters>
<parameter name="id_path" xsi:type="block" visible="true" required="false" sort_order="10">
<label translate="true">Product</label>
<block class="Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser">
<data>
<item name="button" xsi:type="array">
<item name="open" xsi:type="string" translate="true">Select Product...</item>
</item>
</data>
</block>
</parameter>
<parameter name="position_left" xsi:type="text" visible="true" required="true" sort_order="20">
<label translate="true">Left Position</label>
<description translate="true">Numbers only. The position is given as a percentage, so a value of 50 will place hotspot in center.</description>
<value>50</value>
</parameter>
<parameter name="position_top" xsi:type="text" visible="true" required="true" sort_order="21">
<label translate="true">Top Position</label>
<value>50</value>
</parameter>
<parameter name="height" xsi:type="text" visible="true" sort_order="22">
<label translate="true">Hotspot Height</label>
<description translate="true">Numbers only.</description>
<value></value>
</parameter>
<parameter name="width" xsi:type="text" visible="true" sort_order="23">
<label translate="true">Hotspot Width</label>
<value></value>
</parameter>
<parameter name="label_text" xsi:type="text" visible="true" sort_order="24">
<label translate="true">Hotspot Point Text</label>
</parameter>
<parameter name="icon" sort_order="35" source_model="Olegnax\HotSpotQuickview\Model\Config\Source\Icon" visible="true" xsi:type="select">
<label translate="true">Hotspot Point Icon</label>
</parameter>
<parameter name="border_radius" xsi:type="text" visible="true" sort_order="36">
<label translate="true">Hotspot Shape Radius</label>
<description translate="true">Change hotspot shape from square to circle. Set 0 for square hotspot. Enter number only. Value set in px.</description>
<value></value>
</parameter>
<parameter name="color" xsi:type="text" visible="true" sort_order="27">
<label translate="true">Hotspot Icon/Text Color</label>
<value></value>
</parameter>
<parameter name="color_background" xsi:type="text" visible="true" sort_order="28">
<label translate="true">Hotspot Background Color</label>
<value></value>
</parameter>
<parameter name="shadow" xsi:type="select" visible="true"
source_model="Olegnax\Core\Model\Config\Source\Noyes" sort_order="28">
<label translate="true">Hotspot Shadow</label>
</parameter>
<parameter name="pulse_animation" xsi:type="select" visible="true"
source_model="Olegnax\Core\Model\Config\Source\Noyes" sort_order="30">
<label translate="true">Pulse animation</label>
</parameter>
<parameter name="pulse_animation_color" xsi:type="text" visible="true" sort_order="31">
<label translate="true">Pulse animation color</label>
<value></value>
</parameter>
<parameter name="border_color" xsi:type="text" visible="true" sort_order="32">
<label translate="true">Hotspot Border Color</label>
<value></value>
</parameter>
<parameter name="hide_mobile" xsi:type="select" visible="true"
source_model="Olegnax\Core\Model\Config\Source\Noyes" sort_order="41">
<label translate="true">Hide Hotspot on Mobile</label>
</parameter>
<parameter name="mobile_minimized" xsi:type="select" visible="true"
source_model="Olegnax\Core\Model\Config\Source\Noyes" sort_order="41">
<label translate="true">Minimize Hotspot on Mobile</label>
<description translate="true">Text will be hidden and only 20px circle will be shown.</description>
</parameter>
<parameter name="position_left_m" xsi:type="text" visible="true" sort_order="42">
<label translate="true">Hotspot Left Position Mobile</label>
<description translate="true">Numbers only. Mobile Breakpoint is 768px.</description>
<value></value>
</parameter>
<parameter name="position_top_m" xsi:type="text" visible="true" sort_order="43">
<label translate="true">Hotspot Top Position Mobile</label>
<value></value>
</parameter>
<parameter name="tooltip_content" sort_order="51" source_model="Olegnax\Core\Model\Config\Source\Noyes" visible="true" xsi:type="select">
<label translate="true">Set CMS block as Tooltip Content Source</label>
</parameter>
<parameter name="tooltip_text" xsi:type="text" visible="true" sort_order="52">
<label translate="true">Hotspot Tooltip Text</label>
<value></value>
</parameter>
<parameter name="tooltip_static" xsi:type="text" visible="true" sort_order="53">
<label translate="true">Hotspot Tooltip Static Block</label>
<description translate="true">Set static block id. Content if this static block will be shown in tooltip.</description>
<value></value>
</parameter>
<parameter name="tooltip_bold_text" sort_order="51" source_model="Olegnax\Core\Model\Config\Source\Noyes" visible="true" xsi:type="select">
<label translate="true">Tooltip Bold Text</label>
</parameter>
<parameter name="tooltip_width" xsi:type="text" visible="true" sort_order="54">
<label translate="true">Hotspot Tooltip Width</label>
<value></value>
</parameter>
<parameter name="tooltip_color" xsi:type="text" visible="true" sort_order="55">
<label translate="true">Tooltip text Color</label>
<value></value>
</parameter>
<parameter name="tooltip_color_background" xsi:type="text" visible="true" sort_order="56">
<label translate="true">Tooltip Background Color</label>
<value></value>
</parameter>
<parameter name="custom_class" xsi:type="text" visible="true" sort_order="70">
<label translate="true">Class</label>
</parameter>
</parameters>
</widget>
</widgets>
+13
View File
@@ -0,0 +1,13 @@
<?php
/**
* @author Olegnax
* @package Olegnax_HotSpotQuickview
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Olegnax_HotSpotQuickview', __DIR__);
@@ -0,0 +1,117 @@
<?php
/**
* @author Olegnax
* @package Olegnax_HotSpotQuickview
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Framework\Escaper;
use Olegnax\HotSpotQuickview\Block\Widget\HotSpot;
/** @var HotSpot $block */
/** @var Escaper $escaper */
if ($block->isEnabled()):
$mobileBreakpoint = 768;
$widgetId = $block->getWidgetId();
$hotspotHeight = $block->getHeight();
$hotspotWidth = $escaper->escapeHtmlAttr($block->getWidth());
$inlineStyles = $inlineStylesInner = $customStyles = $classes = [];
$tooltipText = $block->getTooltipText();
$iconClass = 'athlete2-icon-' . $block->getIcon();
$iconStyle = ($block->getColor() != '') ? ('style="color: ' . $block->getColor() . '"') : '';
if($block->getColorBackground()){
$inlineStylesInner[] = 'background-color: ' . $block->getColorBackground() . ';';
}
if($block->getBorderRadius() != ''){
$inlineStylesInner[] = 'border-radius: ' . $escaper->escapeHtmlAttr($block->getBorderRadius()) . 'px;';
}
if($hotspotHeight){
$inlineStyles[] = 'height: ' . $escaper->escapeHtmlAttr($hotspotHeight) . 'px;';
}
if($hotspotWidth){
$inlineStyles[] = 'min-width: ' . $hotspotWidth . 'px;';
}
$inlineStyles[] = 'left: ' . $escaper->escapeHtmlAttr($block->getPositionLeft()) . '%;';
$inlineStyles[] = 'top: ' . $escaper->escapeHtmlAttr($block->getPositionTop()) . '%;';
if($block->getBorderSize() > 0){
$inlineStylesInner[] = 'border: ' . $escaper->escapeHtmlAttr($block->getBorderSize()) . 'px solid;';
}
if( $block->getBorderColor() ){
$inlineStylesInner[] = 'border-color:' . $block->getBorderColor(). '; ';
}
if($block->getHideMobile()){
$classes[] = 'hide-on-mobile';
}
if($block->getMobileMinimized()){
$classes[] = 'mobile-minimized';
}
$classes[] = $escaper->escapeHtmlAttr($block->getCustomClass());
if($block->getPulseAnimation()){
$classes[] = '-pulse';
if($block->getPulseAnimationColor()){
$customStyles[] = '#' . $widgetId . '.ox-hotspot__item.-pulse:before{background-color:' . $block->getPulseAnimationColor() . '}';
}
}
$tooltip_color = $block->getTooltipColor();
$tooltip_color_background = $block->getTooltipColorBackground();
$tooltip_width = $escaper->escapeHtmlAttr($block->getTooltipWidth());
$mobileTop = $escaper->escapeHtmlAttr($block->getPositionTopM());
$mobileLeft = $escaper->escapeHtmlAttr($block->getPositionLeftM());
if($mobileLeft != ''){
$customStyles[] = '@media (max-width: ' . $mobileBreakpoint . 'px){#' . $widgetId . '.ox-hotspot__item{left: ' . $mobileLeft . '%!important;}}';
}
if($mobileTop != ''){
$customStyles[] = '@media (max-width: ' . $mobileBreakpoint . 'px){#' . $widgetId . '.ox-hotspot__item{top: ' . $mobileTop . '%!important;}}';
}
if( $hotspotWidth && (($block->getTooltipContent() && $block->getTooltipStatic() != '' ) || (!$block->getTooltipContent() && $tooltipText != ''))){
$customStyles[] = '#' . $widgetId . ' .ox-hotspot__tooltip{left: ' . $hotspotWidth/2 . 'px;}';
}
if($tooltip_width != ''){
$customStyles[] = '#' . $widgetId . ' .ox-hotspot__tooltip{width: ' . $tooltip_width . 'px;}';
}
if($tooltip_color_background != ''){
$customStyles[] = '#' . $widgetId . ' .ox-hotspot__tooltip{background-color: ' . $tooltip_color_background . ';}';
}
if($tooltip_color != ''){
$customStyles[] = '#' . $widgetId . ' .ox-hotspot__tooltip{color: ' . $tooltip_color . ';}';
}
if ( !empty($customStyles) ){
echo '<style>' . implode(' ', $customStyles) . '</style>';
}
if($block->getShadow()){
$classes[] = '-shadow';
}
?>
<div id="<?= $widgetId ?>"
class="ox-hotspot__item ox-quickview-button <?php if ( !empty($classes) ){ echo implode(' ', $classes); } ?>"
<?php if($block->getHref()) { ?>
data-quickview-url="<?= $escaper->escapeUrl($block->getHref()) ?>"
<?php } ?>
<?php if ( !empty($inlineStyles) ){ echo 'style="' . implode(' ', $inlineStyles) . '"'; } ?> >
<div class="inner" <?php if ( !empty($inlineStylesInner) ){ echo 'style="' . implode(' ', $inlineStylesInner) . '"';} ?>>
<?php if ( $block->getIcon() ){ ?>
<span class="ox-hotspot__icon <?= $iconClass ?>" <?= $iconStyle ?> >&nbsp;</span>
<?php } ?>
<?php $label_text = $escaper->escapeHtml($block->getLabelText()); ?>
<?php if ( $label_text != '' ){ ?>
<span class="-text hs" <?= $iconStyle ?>><?= $label_text ?></span>
<?php } ?>
<?php if ($block->getTooltipContent()){
if ( $block->getTooltipStatic() != '' ){ ?>
<div class="ox-hotspot__tooltip <?php if($block->getTooltipBoldText()) { echo '-text'; } ?>"><?= $block->getLayout()->createBlock( 'Magento\Cms\Block\Block' )->setBlockId( $block->getTooltipStatic() )->toHtml();?></div>
<?php }
} else {
if($tooltipText != '') { ?>
<div class="ox-hotspot__tooltip <?php if($block->getTooltipBoldText()) { echo '-text'; } ?>"><?= $tooltipText ?></div>
<?php }
}?>
</div>
</div>
<?php
unset($classes,$customStyles, $inlineStyles, $inlineStylesInner);
endif;
@@ -0,0 +1,167 @@
@ox-hotspot__size: 38px;
@ox-hotspot-icon__size: 17px;
@ox-hotspot-icon-smal__size: 10px;
@ox-hotspot__tooltip-width: 190px;
//
// Common
// _____________________________________________
& when (@media-common = true) {
@keyframes hs_pulse {
0% { transform:scale(1);opacity:0; }
20% { opacity:0.6; }
100% { transform:scale(3); opacity:0; }
}
.ox-hotspot__container{
position:relative;
> img{
width:100%;
display: block;
}
}
.ox-hotspot__item{
cursor:pointer;
min-width: @ox-hotspot__size;
height: @ox-hotspot__size;
margin-top: -(@ox-hotspot__size/2);
margin-left: -(@ox-hotspot__size/2);
position: absolute;
text-align: left;
top:50%;
left:50%;
&.-shadow{
.inner{
box-shadow:0px 7px 16px 0 rgba(0, 0, 0, 0.25);
}
}
&.-pulse{
&:before{
position: absolute;
display: block;
width: @ox-hotspot__size;
height: @ox-hotspot__size;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
border-radius: 50%;
content: ' '!important;
left: 50%;
top: 50%;
opacity: 0;
margin-top: -@ox-hotspot__size/2;
margin-left: -@ox-hotspot__size/2;
background-color: currentColor;
animation: hs_pulse 2s ease infinite;
}
}
.inner{
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
align-content: center;
position: relative;
border-radius: 40px;
z-index: 1;
}
.-bold,
.-text{
line-height: 1;
display: block;
font-weight: @font-weight__bold;
}
.-upper{
text-transform: uppercase;
}
&:hover{
.ox-hotspot__tooltip{
transition: all 0.3s ease;
opacity:1;
visibility:visible;
top: -10px;
}
}
}
.ox-hotspot__tooltip{
position: absolute;
top: 0;
left: @ox-hotspot__size/2;
opacity:0;
visibility:hidden;
padding: 12px 18px;
background: white;
box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.12);
width:@ox-hotspot__tooltip-width;
transform: translateY(-100%) translateX(-50%);
transition: all 0.15s ease;
line-height:1.4;
&:before{
content: '';
background: inherit;
width: 12px;
height: 12px;
transform: rotate(45deg);
display: block;
position: absolute;
bottom: -6px;
left: ~"calc(50% - 6px)";
z-index: -1;
}
}
.ox-hotspot__icon{
&.athlete2-icon-plus{
position: relative;
font-size: @ox-hotspot-icon__size;
width: @ox-hotspot-icon__size;
height: @ox-hotspot-icon__size;
line-height: @ox-hotspot-icon__size;
display: block;
overflow: hidden;
}
&.athlete2-icon-plus-small{
position: relative;
width: @ox-hotspot-icon-smal__size;
height: @ox-hotspot-icon-smal__size;
display: block;
overflow: hidden;
&:after,
&:before{
content: '';
background: currentColor;
width: @ox-hotspot-icon-smal__size;
height: 2px;
top: 4px;
display: block;
position: absolute;
}
&:after{
transform: rotate(90deg);
}
}
& + .-text.hs{
margin-left:5px;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
.ox-hotspot__item{
&.mobile-minimized{
width: 20px!important;
height: 20px!important;
min-width: 20px!important;
margin-top: -10px!important;
margin-left: -10px!important;
.ox-hotspot__icon,
.-text.hs{
display:none!important;
}
.inner{
border-radius:10px!important;
}
&:hover .ox-hotspot__tooltip{
left: 10px;
}
}
}
}