Skip to content

Commit

Permalink
fix(errs): fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreimus committed Aug 30, 2024
1 parent 525b0da commit 6386c29
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 19 deletions.
3 changes: 1 addition & 2 deletions prettyblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public function hookActionFrontControllerSetVariables()
{
return [
// 'ajax_builder_url' => $this->context->link->getModuleLink($this->name,'ajax'),
'theme_settings' => PrettyBlocksModel::getThemeSettings(false, 'front'),
'id_shop' => (int) $this->context->shop->id,
'shop_name' => $this->context->shop->name,
'shop_current_url' => $this->context->shop->getBaseURL(true, true),
Expand Down Expand Up @@ -199,7 +198,7 @@ public function renderWidget($hookName = null, array $configuration = [])
return $this->fetch($template);
}
if ($vars['hookName'] !== null) {
return $this->renderZone(['zone_name' => $vars['hookName']]);
return ZonePlugin::renderZone(['zone_name' => $vars['hookName']]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"version": "1.0.0",
"scripts": {
"dev": "vite --port 3002 --host 0.0.0.0",
"dev": "vite --port 3002 --host 0.0.0.0 --mode development",
"build": "vite build",
"watch": "vite build --watch --mode development",
"preview": "vite preview",
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/editor/src/components/Iframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ onUnmounted(() => {
const reloadIframe = () => {
iframe.reloadIframe();
};
emitter.on("reloadIframe", async (id_prettyblocks) => {
let context = contextShop();
iframe.setUrl(context.href);
Expand Down Expand Up @@ -91,12 +92,13 @@ let filteredURL = computed(() => {
watch(iframe.current_url, () => {
filteredURL.value = iframe.updateFilteredURL(iframe.current_url.value);
});
</script>

<template>
<!-- animate-pulse classe to put -->
<section class="w-full h-full">
<!-- <button @click="reloadIframe()"> reload iframe </button> {{ showLoader }} -->
<!-- <button @click="reloadIframe()"> reload iframe </button> {{ showLoader }}-->
<!-- {{ classes }} -->
<iframe
id="website-iframe"
Expand Down
23 changes: 11 additions & 12 deletions src/Resources/editor/src/scripts/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ export default class Iframe {
emitter.emit('loadStateConfig', id_prettyblocks)

}
// test
if(event.data.type == 'setNewUrl')
{
// test
if(event.data.type == 'setNewUrl') {
let context = event.data.params.context
let custom_url = event.data.params.url
emitter.emit('changeUrl', context, custom_url)
Expand Down Expand Up @@ -88,7 +87,7 @@ export default class Iframe {
let id_prettyblocks = event.data.data.id_prettyblocks
let zone_name = event.data.data.zone_name
let piniaBlocks = await storedBlocks().blocks

let element = await piniaBlocks.find(b => {
return b.id_prettyblocks == id_prettyblocks
});
Expand All @@ -112,8 +111,6 @@ export default class Iframe {
this.id_shop.value = iwindow.id_shop
this.loader.value = false
emitter.emit('initStates')


}

}
Expand All @@ -125,8 +122,8 @@ export default class Iframe {
}

/**
*
* @param {*} url
*
* @param {*} url
* For set URL in input
*/
setUrl(url) {
Expand All @@ -144,8 +141,8 @@ export default class Iframe {
this.loader.value = true
let iframe = document.getElementById('website-iframe')
iframe.src = this.updateFilteredURL(this.current_url.value)
// this.loadIframe()
// this.loader.value = false
await this.loadIframe()
this.loader.value = false
}
updateFilteredURL(url) {
let hashIndex = url.indexOf('#');
Expand Down Expand Up @@ -260,13 +257,15 @@ export default class Iframe {
}
this.loadContext(e)

this.loader.value = false

}, false)
}
}

/**
* Updpate title component in Config field using Toolbar
* @param {*} newValue
* @param {*} newValue
*/
async updateTitleComponent(newValue, id_block = null, field = null, index = null) {
if (!id_block) {
Expand Down Expand Up @@ -349,4 +348,4 @@ export default class Iframe {
return responseData;
}

}
}
9 changes: 6 additions & 3 deletions src/Smarty/Plugin/ZonePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@

namespace PrestaSafe\PrettyBlocks\Smarty\Plugin;

use Context;

class ZonePlugin
{
public static function renderZone($params): bool
public static function renderZone($params): string
{
$zone_name = $params['zone_name'];

if (empty($zone_name)) {
return false;
return "";
}

$context = Context::getContext();
$id_lang = $context->language->id;
$id_shop = $context->shop->id;
$blocks = PrettyBlocksModel::getInstanceByZone($zone_name, 'front', $id_lang, $id_shop);
//$blocks = PrettyBlocksModel::getInstanceByZone($zone_name, 'front', $id_lang, $id_shop);
$blocks = [];

$context->smarty->assign([
'zone_name' => $zone_name,
Expand Down
11 changes: 11 additions & 0 deletions views/templates/front/components/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
11 changes: 11 additions & 0 deletions views/templates/front/components/title.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<{$tag} data-block-id_prettyblock='{$block.id_prettyblocks}'
data-attributes='{$attributesHTML|escape:'html'}' data-field='{$field}' class='ptb-title {$classes}
{if $attributes.bold} font-weight-bold {/if}
{if $attributes.italic} font-italic {/if}'
{if isset($index)} data-index="{$index}" {/if}
style="
{if $attributes.underline} text-decoration: underline; {/if}
{if $attributes.size && $attributes.size > 0} font-size: {$attributes.size}px; {/if}
">
{$value nofilter}
</{$tag}>
27 changes: 27 additions & 0 deletions views/templates/front/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright (c) Since 2020 PrestaSafe and contributors
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaSafe <[email protected]>
* @copyright Since 2020 PrestaSafe and contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaSafe
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
46 changes: 46 additions & 0 deletions views/templates/front/zone.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{**
* Since 2021 PrestaSafe
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaSafe <[email protected]>
* @copyright Since 2021 PrestaSafe
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaSafe
*}


<div data-prettyblocks-zone="{$zone_name}">
{if $blocks|count > 0}
{foreach from=$blocks item=block name=zoneBlocks}
<div {if $block.settings.default.load_ajax} load-ajax {/if} data-block data-instance-id="{$block.instance_id}"
data-id-prettyblocks="{$block.id_prettyblocks}">
{if !$block.settings.default.load_ajax}
{$template = 'module:prettyblocks/views/templates/blocks/welcome.tpl'}
{if isset($block.templates[$block.templateSelected])}
{$template = $block.templates[$block.templateSelected]}
{/if}

{include file=$template
instance_id=$block.instance_id
id_prettyblocks=$block.id_prettyblocks
block=$block
states=$block.states}
{else}
Chargement en cours....
{/if}
</div>
{/foreach}
{/if}
</div>
<div class="d-none blocks text-center w-100 p-5" data-zone-name="{$zone_name}"></div>


0 comments on commit 6386c29

Please sign in to comment.