Skip to content

Commit

Permalink
Merge branch 'develop' into feature/gdpr-auto-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jerremei committed Jul 6, 2020
2 parents a6a2e4b + a3435dd commit c02d425
Show file tree
Hide file tree
Showing 25 changed files with 1,060 additions and 657 deletions.
21 changes: 21 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,25 @@
),
),
),
'caches' => [
'melisfront_pages_file_cache' => array(
'active' => true, // activate or deactivate Melis Cache for this conf
'adapter' => array(
'name' => 'Filesystem',
'options' => array(
'ttl' => 0, // 24hrs
'namespace' => 'melisfront_pages_file_cache',
'cache_dir' => $_SERVER['DOCUMENT_ROOT'] . '/../cache'
),
),
'plugins' => array(
'exception_handler' => array('throw_exceptions' => false),
'Serializer'
),
'ttls' => array(
// add a specific ttl for a specific cache key (found via regexp)
// 'my_cache_key' => 60,
)
),
]
);
1 change: 1 addition & 0 deletions config/plugins/MelisFrontTagPlugin.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'css' => array(
),
'js' => array(
'js_melistag_custom_js' => '/MelisFront/plugins/js/plugin.related.data.js',
'js_melistag' => '/MelisFront/plugins/js/plugin.melistagHTML.init.js'
),
),
Expand Down
4 changes: 2 additions & 2 deletions public/plugins/css/plugin.melisdragdropzone.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

.melis-dragdropzone .melis-ui-outlined {
float: left;
/* revise by: Junry @ 02082019 */
margin: 0 5px 30px 0;
margin: 0;
}

.wrapper div.melis-dragdropzone:last-of-type {
margin-bottom: 35px;
}
Expand Down
4 changes: 1 addition & 3 deletions public/plugins/js/plugin.melisGdprBanner.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ window.MelisGdprBanner = (function () {
*
* src: https://zellwk.com/blog/looping-through-js-objects/
*/
options = Object.entries({...defaultOptions,...options
})
;
options = Object.entries({defaultOptions,options});
var updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);
for (const [key, value] of options) {
updatedCookie += "; " + key + "=" + value;
Expand Down
7 changes: 3 additions & 4 deletions public/plugins/js/plugin.melistagHTML.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ function melistagHTML_savePlugin(editor){
}

// run this function when you click out of the tinymce
$("body").on("blur", "div.html-editable", function(){

$("body").on("blur", "div.html-editable", function() {
// get all data-attributes from the clicked
var currentdata = $(this).data();

Expand All @@ -36,9 +35,9 @@ $("body").on("blur", "div.html-editable", function(){
tagType: currentdata.tagType,
tagId : currentdata.tagId,
tagValue : content,
};
};
melisPluginEdition.calcFrameHeight();
melisPluginEdition.savePluginUpdate(data, currentdata.siteModule);
melisPluginEdition.savePluginUpdate(data, currentdata.siteModule);
});

melistagHTML_init();
153 changes: 153 additions & 0 deletions public/plugins/js/plugin.related.data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
var pluginRelatedData = (function($, window) {
/**
* Process el from .html-editable on blur event
* Need processPluginData(toolBox, percentTotalWidth )
* */
function setPercentTotalWidth( el ) {
//setTimeout(function() {
// .melis-dragdropzone find .children(".melis-plugin-tools-box")
var $melisUI = el.closest(".melis-ui-outlined"),
melisDndZone = $melisUI.parent(),
$toolBox = $melisUI.children(".melis-plugin-tools-box"),
melisUIWidth = $melisUI.outerWidth(), // totalWidth
dragDropZoneWidth = $(melisDndZone).outerWidth(); // parentWidth

percentTotalWidth = ( 100 * dragDropZoneWidth / melisUIWidth );
percentTotalWidth = percentTotalWidth.toFixed(2);

/* console.log("melisDndZone: ", melisDndZone);
console.log("melisDndZone length: ", melisDndZone.length);
console.log("setPercentTotalWidth $toolBox: ", $toolBox);
console.log("setPercentTotalWidth $toolBox length: ", $toolBox.length); */

//if ( $toolBox.length > 0 ) {
processPluginData( $toolBox, percentTotalWidth );
//}
//}, 1000);
}

function processPluginData( el, percentTotalWidth ) {
var toolBox = el,
mobileWidth, tabletWidth, desktopWidth, currentClass, newClass,
iframe = window.parent.$("#"+ parent.activeTabId).find('iframe'),
parentOutlined = $(toolBox).closest(".melis-ui-outlined"),
classes = parentOutlined.attr("class").split(" "),
editable = parentOutlined.find(".melis-editable");

/* console.log("processPluginData toolBox: ", toolBox);
console.log("processPluginData parentOutlined: ", parentOutlined);
console.log("parentOutlined: ", parentOutlined + " classes: ", + classes); */

//console.log("toolBox length: ", toolBox.length);

if ( toolBox.length ) {
var pluginList = new Object();
// get data first load
$( toolBox ).map(function() {
var $this = $(this);

pluginList['melisIdPage'] = window.parent.$("#"+parent.activeTabId).find(".melis-iframe").data("iframe-id");
pluginList['melisModule'] = $this.data("module");
pluginList['melisPluginName'] = $this.data("plugin");
pluginList['melisPluginId'] = $this.data("plugin-id");
pluginList['melisPluginTag'] = $this.data("melis-tag");
mobileWidth = $this.attr("data-plugin-width-mobile");
tabletWidth = $this.attr("data-plugin-width-tablet");
desktopWidth = $this.attr("data-plugin-width-desktop");
});

// custom action check if plugin tags
/* if( $(editable).length ) {
// trigger focus to saveSession
var data = $(editable).data();
$(editable).focus().removeClass("mce-edit-focus");
// hide tinymce option while resizing
var inst = tinyMCE.EditorManager.get(data.pluginId);
inst.fire("blur");
iframe.blur();
$(editable).map(function() {
var $this = $(this);
pluginList['tagType'] = $this.data("tag-type");
pluginList['tagId'] = $this.data("tag-id");
pluginList['tagValue'] = tinyMCE.activeEditor.getContent({format : 'html'});
});
} */

console.log("mobileWidth: ", + mobileWidth + " tabletWidth: ", + tabletWidth + " desktopWidth: ", desktopWidth);

// check if resize in mobile
if(iframe.width() <= 480) {
mobileWidth = percentTotalWidth;
// update DOM data attribute
$(toolBox).attr("data-plugin-width-mobile", mobileWidth);
currentClass = "plugin-width-xs-";

var strPercentTotalWidth = percentTotalWidth;
// newClass = "plugin-width-xs-"+Math.floor(percentTotalWidth); // removed when css is ready
newClass = "plugin-width-xs-"+strPercentTotalWidth.replace(".", "-"); // removed when css is ready
$.each(classes, function(key, value) {
if( value.indexOf(currentClass) != -1 ) {
parentOutlined.removeClass(value).addClass(newClass);
}
});
}
// check if resize in tablet
if(iframe.width() > 490 && iframe.width() <= 980) {
tabletWidth = percentTotalWidth;
$(toolBox).attr("data-plugin-width-tablet", tabletWidth);
currentClass = "plugin-width-md-";
var strPercentTotalWidth = percentTotalWidth;
// newClass = "plugin-width-md-"+Math.floor(percentTotalWidth); // removed when css is ready
newClass = "plugin-width-lg-"+strPercentTotalWidth.replace(".", "-"); // removed when css is ready
$.each(classes, function(key, value) {
if( value.indexOf(currentClass) != -1 ) {
parentOutlined.removeClass(value).addClass(newClass);
}
});
}
// check if resize in desktop
if(iframe.width() >= 981) {
desktopWidth = percentTotalWidth;
$(toolBox).attr("data-plugin-width-desktop", desktopWidth);
currentClass = "plugin-width-lg-";
var strPercentTotalWidth = percentTotalWidth;
// newClass = "plugin-width-lg-"+Math.floor(percentTotalWidth); // removed when css is ready
newClass = "plugin-width-lg-" + strPercentTotalWidth.replace(".", "-"); // removed when css is ready
$.each(classes, function(key, value) {
if( value.indexOf(currentClass) != -1 ) {
parentOutlined.removeClass(value).addClass(newClass);
}
});
}

// set data attribute for width
pluginList['melisPluginMobileWidth'] = mobileWidth;
pluginList['melisPluginTabletWidth'] = tabletWidth;
pluginList['melisPluginDesktopWidth'] = desktopWidth;
pluginList['resize'] = true;

// recalculate frame height
melisPluginEdition.calcFrameHeight();

// pass is to savePageSession
melisPluginEdition.savePluginUpdate(pluginList, toolBox.data("site-module"));

// get plugin ID and re init
// check if owl re init
var owlCheck = $(parentOutlined).find(".owl-carousel");
if( $(owlCheck).length ) {
// setTimeout to re init, conflict with transition need to timeout
setTimeout(function() {
$(owlCheck).trigger('refresh.owl.carousel');
}, 500);
}
}
}

return {
setPercentTotalWidth : setPercentTotalWidth
}
})(jQuery, window);
26 changes: 23 additions & 3 deletions src/Controller/Plugin/MelisFrontBreadcrumbPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public function front()
{
// Get the parameters and config from $this->pluginFrontConfig (default > hardcoded > get > post)
$data = $this->getFormData();

// Retrieve cache version if front mode to avoid multiple calls
$cacheKey = 'MelisFrontBreadcrumbPlugin_' . $this->cleanString($data['id']). '_' .$this->cleanString($data['template_path']);
$cacheConfig = 'melisfront_pages_file_cache';
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig);

// Retrieving the pageId from config
$pageId = (!empty($data['pageId'])) ? $data['pageId'] : null;
$startingPage = $data['pageIdRootBreadcrumb'] ?? $data['pageIdRootBreadcrumb'];
Expand All @@ -77,7 +84,10 @@ public function front()
{
foreach ($pageBreadcrumb As $key => $val)
{
if (in_array($val->page_type, array('PAGE', 'SITE')))
if($val->page_menu == "NONE")
continue;

if (in_array($val->page_type, array('PAGE', 'FOLDER', 'SITE')))
{
// Checking if the pageId is the current viewed
$flag = ($val->page_id == $pageId) ? 1 : 0;
Expand All @@ -87,7 +97,7 @@ public function front()
$tmp = array(
'label' => $label,
'menu' => $val->page_menu,
'uri' => $treeSrv->getPageLink($val->page_id, false),
'uri' => ($val->page_menu == "LINK") ? $treeSrv->getPageLink($val->page_id, false) : null,
'idPage' => $val->page_id,
'lastEditDate' => $val->page_edit_date,
'pageStat' => $val->page_status,
Expand Down Expand Up @@ -118,6 +128,9 @@ public function front()
'pluginId' => $data['id'],
'breadcrumb' => $breadcrumb,
);

// Save cache key
$melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $viewVariables);

// return the variable array and let the view be created
return $viewVariables;
Expand Down Expand Up @@ -169,6 +182,13 @@ public function createOptionsForms()

$errors = array();
if ($form->isValid()) {

// Deleting file cache
$cacheKey = 'MelisFrontBreadcrumbPlugin_' . $this->getFormData()['id'];
$cacheConfig = 'melisfront_pages_file_cache';
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$melisEngineCacheSystem->deleteCacheByPrefix($cacheKey, $cacheConfig);

$data = $form->getData();
$success = true;
array_push($response, [
Expand Down Expand Up @@ -260,4 +280,4 @@ public function savePluginConfigToXml($parameters)
}


}
}
6 changes: 3 additions & 3 deletions src/Controller/Plugin/MelisFrontGdprBannerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function front()
$langId = empty($pageData->lang_cms_id) ? $langId : $pageData->lang_cms_id;
$locale = empty($pageData->lang_cms_locale) ? $locale : $pageData->lang_cms_locale;
if (!empty($pageData->page_tpl_id)) {
/** @var \MelisEngine\Model\Tables\MelisTemplateTable $tplTable */
$tplTable = $this->getServiceLocator()->get('MelisEngineTableTemplate');
$tplData = $tplTable->getEntryById($pageData->page_tpl_id)->toArray();
/** @var \MelisEngine\Service\MelisEngineTemplateService $tplSrv */
$tplSrv = $this->getServiceLocator()->get('MelisEngineTemplateService');
$tplData = $tplSrv->getTemplate($pageData->page_tpl_id)->toArray();
if (!empty($tplData [0]['tpl_site_id'])) {
$siteId = $tplData [0]['tpl_site_id'];
}
Expand Down
18 changes: 18 additions & 0 deletions src/Controller/Plugin/MelisFrontMenuPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ public function front()

$pageId = !empty($data['pageIdRootMenu']) ? $data['pageIdRootMenu'] : 1;

// Retrieve cache version if front mode to avoid multiple calls
$cacheKey = 'MelisFrontMenuPlugin_'.$data['pageId'].'_'.$this->cleanString($data['id']). '_' .$this->cleanString($data['template_path']);
$cacheConfig = 'melisfront_pages_file_cache';
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig);

if (!is_null($results))
return $results;

// Getting the Site Menu from MelisFrontNavigator
$site = new MelisFrontNavigation($this->getServiceLocator(), $pageId, $this->renderMode);

Expand All @@ -77,6 +86,9 @@ public function front()
'menu' => $siteMenu
);

// Save cache key
$melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $viewVariables);

// return the variable array and let the view be created
return $viewVariables;
}
Expand Down Expand Up @@ -126,6 +138,12 @@ public function createOptionsForms()

$errors = array();
if ($form->isValid()) {

$cacheKey = 'MelisFrontMenuPlugin_' . $this->getFormData()['id'];
$cacheConfig = 'melisfront_pages_file_cache';
$melisEngineCacheSystem = $this->getServiceLocator()->get('MelisEngineCacheSystem');
$melisEngineCacheSystem->deleteCacheByPrefix($cacheKey, $cacheConfig);

$data = $form->getData();
$success = true;
array_push($response, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function front()

foreach ($pages as $key => $val)
{
$val = (object) $val;
/**
* Page content has a values of XML type
* so need to parse to make the content of the page easy to manage
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/StyleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getPagePluginWidthCssAction()
->addHeaderLine('Pragma' , 'no-cache')
->addHeaderLine('Content-Type' , 'text/css;charset=UTF-8');

$css = '[class^="plugin-width"] {float: left;margin: 0 0px 30px;}';
$css = '[class^="plugin-width"] {float: left;margin: 0;}';
$pageId = (int) $this->params()->fromQuery('idpage');

$pageSvc = $this->getServiceLocator()->get('MelisEnginePage');
Expand Down
Loading

0 comments on commit c02d425

Please sign in to comment.