diff --git a/Block/Adminhtml/Widget/Form/Field/WysiwygEditor.php b/Block/Adminhtml/Widget/Form/Field/WysiwygEditor.php
index 1c553c0..d746ef5 100644
--- a/Block/Adminhtml/Widget/Form/Field/WysiwygEditor.php
+++ b/Block/Adminhtml/Widget/Form/Field/WysiwygEditor.php
@@ -119,13 +119,9 @@ public function render(AbstractElement $element){
$html .= <<
- window.tinyMCE_GZ = window.tinyMCE_GZ || {}; window.tinyMCE_GZ.loaded = true;
require([
- "jquery",
- "mage/translate",
- "mage/adminhtml/events",
- "mage/adminhtml/wysiwyg/tiny_mce/setup",
- "mage/adminhtml/wysiwyg/widget"
+ 'jquery',
+ 'Ves_Productlist/js/wysiwyg/tiny_mce/setup'
], function(jQuery){
var config = $config,
editor;
@@ -145,7 +141,7 @@ public function render(AbstractElement $element){
config
);
- editor{$element->getHtmlId()}.toggle();
+ editor{$element->getHtmlId()}.turnOn();
varienGlobalEvents.clearEventHandlers("open_browser_callback");
varienGlobalEvents.attachEventHandler("open_browser_callback", editor{$element->getHtmlId()}.openFileBrowser);
jQuery('#{$element->getHtmlId()}')
diff --git a/Controller/Widget/Adminhtml/Widget/BuildWidget.php b/Controller/Widget/Adminhtml/Widget/BuildWidget.php
index d4c4a16..e1344cd 100644
--- a/Controller/Widget/Adminhtml/Widget/BuildWidget.php
+++ b/Controller/Widget/Adminhtml/Widget/BuildWidget.php
@@ -55,9 +55,23 @@ public function execute()
$this->getResponse()->setBody($html);
}
public function isBase64Encoded($data) {
- if(base64_encode(base64_decode($data)) === $data){
- return true;
- }
- return false;
- }
+ if(base64_encode($data) === $data) return false;
+ if(base64_encode(base64_decode($data)) === $data){
+ return true;
+ }
+ if (!preg_match('~[^0-9a-zA-Z+/=]~', $data)) {
+ $check = str_split(base64_decode($data));
+ $x = 0;
+ foreach ($check as $char) if (ord($char) > 126) $x++;
+ if ($x/count($check)*100 < 30) return true;
+ }
+ $decoded = base64_decode($data);
+ // Check if there are valid base64 characters
+ if (!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $data)) return false;
+ // if string returned contains not printable chars
+ if (0 < preg_match('/((?![[:graph:]])(?!\s)(?!\p{L}))./', $decoded, $matched)) return false;
+ if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data)) return false;
+
+ return false;
+ }
}
\ No newline at end of file
diff --git a/Model/Magento/Widget/Instance.php b/Model/Magento/Widget/Instance.php
index a67c083..e883728 100644
--- a/Model/Magento/Widget/Instance.php
+++ b/Model/Magento/Widget/Instance.php
@@ -69,9 +69,23 @@ public function getWidgetParameters()
return parent::getWidgetParameters();
}
public function isBase64Encoded($data) {
- if(base64_encode(base64_decode($data)) === $data){
- return true;
- }
- return false;
- }
+ if(base64_encode($data) === $data) return false;
+ if(base64_encode(base64_decode($data)) === $data){
+ return true;
+ }
+ if (!preg_match('~[^0-9a-zA-Z+/=]~', $data)) {
+ $check = str_split(base64_decode($data));
+ $x = 0;
+ foreach ($check as $char) if (ord($char) > 126) $x++;
+ if ($x/count($check)*100 < 30) return true;
+ }
+ $decoded = base64_decode($data);
+ // Check if there are valid base64 characters
+ if (!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $data)) return false;
+ // if string returned contains not printable chars
+ if (0 < preg_match('/((?![[:graph:]])(?!\s)(?!\p{L}))./', $decoded, $matched)) return false;
+ if (!preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data)) return false;
+
+ return false;
+ }
}
\ No newline at end of file
diff --git a/Model/Product.php b/Model/Product.php
index ac6173c..81d29ce 100644
--- a/Model/Product.php
+++ b/Model/Product.php
@@ -41,6 +41,8 @@ class Product extends \Magento\Framework\DataObject
*/
protected $_reportCollection;
+ protected $_vesreportCollection;
+
/**
* @var \Magento\Catalog\Model\Product\Visibility
*/
@@ -78,7 +80,8 @@ class Product extends \Magento\Framework\DataObject
/**
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
- * @param \Magento\Reports\Model\ResourceModel\Product\CollectionFactory $reportCollection
+ * @param \Magento\Reports\Model\ResourceModel\Product\CollectionFactory $reportCollection
+ * @param \Ves\Productlist\Model\ResourceModel\Reports\Product\CollectionFactory $vesreportCollection
* @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -93,6 +96,7 @@ class Product extends \Magento\Framework\DataObject
public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
\Magento\Reports\Model\ResourceModel\Product\CollectionFactory $reportCollection,
+ \Ves\Productlist\Model\ResourceModel\Reports\Product\CollectionFactory $vesreportCollection,
\Magento\Catalog\Model\Product\Visibility $catalogProductVisibility,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Store\Model\StoreManagerInterface $storeManager,
@@ -107,6 +111,7 @@ public function __construct(
$this->_localeDate = $localeDate;
$this->_productCollectionFactory = $productCollectionFactory;
$this->_reportCollection = $reportCollection;
+ $this->_vesreportCollection = $vesreportCollection;
$this->_catalogProductVisibility = $catalogProductVisibility;
$this->_storeManager = $storeManager;
$this->date = $date;
@@ -492,6 +497,34 @@ public function getDealsProducts($config = [])
return $collection;
}
+ public function getInterval(){
+ $interval = $this->getData("interval");
+ if(!$interval) {
+ $interval = 45;
+ }
+ return (int)$interval;
+ }
+ /**
+ * Retrieve From To Interval
+ *
+ * @return array
+ */
+ public function getFromTo()
+ {
+ $from = '';
+ $to = '';
+ $interval = (int)$this->getInterval();
+
+ if ($interval > 0) {
+ $dtTo = new \DateTime();
+ $dtFrom = clone $dtTo;
+ // last $interval day(s)
+ $dtFrom->modify("-{$interval} day");
+ $from = $dtFrom->format('Y-m-d');
+ $to = $dtTo->format('Y-m-d');
+ }
+ return [$from, $to];
+ }
/**
* Most viewed product collection
*
@@ -499,8 +532,9 @@ public function getDealsProducts($config = [])
*/
public function getMostViewedProducts($config = [])
{
- /** @var $collection \Magento\Reports\Model\ResourceModel\Product\CollectionFactory */
- $collection = $this->_reportCollection->create()->addAttributeToSelect('*')->addViewsCount();
+ list($from, $to) = $this->getFromTo();
+ /** @var $collection \Ves\Productlist\Model\ResourceModel\Reports\Product\CollectionFactory */
+ $collection = $this->_vesreportCollection->create()->addAttributeToSelect('*')->addViewsCount($from, $to);
if (isset($config['categories'])) {
if ($this->productState->isFlatEnabled()) {
$collection->joinField(
diff --git a/Model/ResourceModel/Reports/Product/Collection.php b/Model/ResourceModel/Reports/Product/Collection.php
new file mode 100644
index 0000000..0d07d45
--- /dev/null
+++ b/Model/ResourceModel/Reports/Product/Collection.php
@@ -0,0 +1,69 @@
+_eventTypeFactory->create()->getCollection();
+ foreach ($eventTypes as $eventType) {
+ if ($eventType->getEventName() == 'catalog_product_view') {
+ $productViewEvent = (int)$eventType->getId();
+ break;
+ }
+ }
+ $this->getSelect()->reset()->from(
+ ['report_table_views' => $this->getTable('report_event')],
+ ['views' => 'COUNT(report_table_views.event_id)']
+ )->join(
+ ['e' => $this->getProductEntityTableName()],
+ 'e.entity_id = report_table_views.object_id'
+ )->where(
+ 'report_table_views.event_type_id = ?',
+ $productViewEvent
+ )->group(
+ 'e.entity_id'
+ )->order(
+ 'views ' . self::SORT_ORDER_DESC
+ )->having(
+ 'COUNT(report_table_views.event_id) > ?',
+ 0
+ );
+ if ($from != '' && $to != '') {
+ $this->getSelect()->where('logged_at >= ?', $from)->where('logged_at <= ?', $to);
+ }
+ return $this;
+ }
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index a3a2a52..f4e846e 100644
--- a/composer.json
+++ b/composer.json
@@ -2,13 +2,13 @@
"name": "venustheme/magento2-product-list",
"description": "Venustheme Magento 2 Product List supports you to create a wanted list of products based on attribute, types, conditions of items.",
"require": {
- "venustheme/magento2-all": "1.*"
+ "venustheme/module-all": "1.*"
},
"type": "magento2-module",
"version": "1.0.0",
"keywords": [
- "landofcoder",
- "landofcoder product list",
+ "venustheme",
+ "venustheme product list",
"product list magento 2",
"magento 2 product list",
"product list magento 2",
@@ -20,8 +20,8 @@
],
"authors": [
{
- "name": "Landofcoder",
- "email": "landofcoder@gmail.com",
+ "name": "Venustheme",
+ "email": "venustheme@gmail.com",
"role": "Magento 2 Ves Product List"
}
],
diff --git a/view/adminhtml/templates/wysiwyg/js.phtml b/view/adminhtml/templates/wysiwyg/js.phtml
index 90522fb..5921743 100644
--- a/view/adminhtml/templates/wysiwyg/js.phtml
+++ b/view/adminhtml/templates/wysiwyg/js.phtml
@@ -11,7 +11,7 @@
require([
"jquery",
"tinymce",
- "wysiwygAdapter",
+ "prototype",
"mage/adminhtml/events"
], function(jQuery, tinyMCE){
@@ -73,7 +73,7 @@ var productlistWysiwygEditor = {
okDialogWindow : function(dialogWindow) {
if (dialogWindow.options.firedElementId) {
wysiwygObj = eval('wysiwyg'+dialogWindow.options.firedElementId+'_editor');
- wysiwygObj.toggle();
+ wysiwygObj.turnOff();
if (tinyMCE.get(wysiwygObj.id)) {
$(dialogWindow.options.firedElementId).value = tinyMCE.get(wysiwygObj.id).getContent();
} else {
diff --git a/view/adminhtml/templates/wysiwyg/wysiwyg/tiny_mce/setup.js b/view/adminhtml/templates/wysiwyg/wysiwyg/tiny_mce/setup.js
index 9d4191b..97ee9b3 100644
--- a/view/adminhtml/templates/wysiwyg/wysiwyg/tiny_mce/setup.js
+++ b/view/adminhtml/templates/wysiwyg/wysiwyg/tiny_mce/setup.js
@@ -5,7 +5,7 @@
define([
'jquery',
'underscore',
- 'wysiwygAdapter',
+ 'tinymce',
'mage/translate',
'prototype',
'mage/adminhtml/events',
diff --git a/view/adminhtml/templates/wysiwyg/wysiwyg/widget.js b/view/adminhtml/templates/wysiwyg/wysiwyg/widget.js
index 24e7a05..0d4952b 100644
--- a/view/adminhtml/templates/wysiwyg/wysiwyg/widget.js
+++ b/view/adminhtml/templates/wysiwyg/wysiwyg/widget.js
@@ -5,7 +5,7 @@
define([
"jquery",
- "wysiwygAdapter",
+ "tinymce",
'Magento_Ui/js/modal/alert',
"jquery/ui",
"mage/translate",
diff --git a/view/adminhtml/web/js/vesbrowser.js b/view/adminhtml/web/js/vesbrowser.js
index 3b6a904..def1102 100644
--- a/view/adminhtml/web/js/vesbrowser.js
+++ b/view/adminhtml/web/js/vesbrowser.js
@@ -5,7 +5,7 @@
/*jshint browser:true jquery:true*/
define([
"jquery",
- "wysiwygAdapter",
+ "tinymce",
"Magento_Ui/js/modal/prompt",
"Magento_Ui/js/modal/confirm",
"Magento_Ui/js/modal/alert",
diff --git a/view/adminhtml/web/js/wysiwyg/tiny_mce/setup.js b/view/adminhtml/web/js/wysiwyg/tiny_mce/setup.js
index e28d35d..4163218 100644
--- a/view/adminhtml/web/js/wysiwyg/tiny_mce/setup.js
+++ b/view/adminhtml/web/js/wysiwyg/tiny_mce/setup.js
@@ -5,7 +5,7 @@
define([
'jquery',
'underscore',
- 'wysiwygAdapter',
+ 'tinymce',
'mage/translate',
'prototype',
'mage/adminhtml/events',