Skip to content

Commit

Permalink
0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
haihv433 committed Jun 11, 2023
1 parent fd7efa3 commit 9030897
Show file tree
Hide file tree
Showing 82 changed files with 816 additions and 7,858 deletions.
19 changes: 18 additions & 1 deletion Block/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
use Magento\Framework\Profiler;
use Magento\Framework\View\Element\Template;
use Magento\Widget\Block\BlockInterface;
use Magento\Framework\DataObject\IdentityInterface;

class Content extends Template implements BlockInterface
class Content extends Template implements BlockInterface, IdentityInterface
{
/**
* @var ContentInterface[]
Expand Down Expand Up @@ -326,4 +327,20 @@ public function __toString()
{
return $this->toHtml();
}

/**
* @inheritDoc
*/
public function getIdentities()
{
$keys = [];
if ($this->currentContentId) {
$keys[] = 'pagebuilder_content_' . $this->currentContentId;
}
if ($this->currentIdentifier) {
$keys[] = 'pagebuilder_content_' . $this->currentIdentifier;
}

return $keys;
}
}
13 changes: 0 additions & 13 deletions Builder/Base/AbstractCss.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Goomento\PageBuilder\Builder\Managers\Controls;
use Goomento\PageBuilder\Builder\Managers\Icons;
use Goomento\PageBuilder\Builder\Managers\Tags;
use Goomento\PageBuilder\Builder\Modules\Frontend;
use Goomento\PageBuilder\Builder\Modules\Stylesheet;
use Goomento\PageBuilder\Developer;
use Goomento\PageBuilder\Exception\BuilderException;
Expand Down Expand Up @@ -208,18 +207,6 @@ public function enqueue()
$frontend->enqueueFont($defaultFont);
}

if (!empty($meta['icons'])) {
$iconsTypes = Icons::getIconManagerTabs();
foreach ($meta['icons'] as $iconFont) {
if (!isset($iconsTypes[ $iconFont ])) {
continue;
}
/** @var Frontend $frontend */
$frontend = ObjectManagerHelper::get(Frontend::class);
$frontend->enqueueFont($iconFont);
}
}

$name = $this->getName();

/**
Expand Down
6 changes: 3 additions & 3 deletions Builder/Base/AbstractDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getContainerAttributes()
'class' => 'goomento gmt gmt-' . $this->getModel()->getUniqueIdentity(),
];

if (!StateHelper::isEditorPreviewMode()) {
if (!StateHelper::isCanvasMode()) {
$attributes['data-gmt-settings'] = DataHelper::encode($this->getFrontendSettings());
}

Expand Down Expand Up @@ -380,7 +380,7 @@ public function getPreviewUrl()

if (null === $url) {

$url = UrlBuilderHelper::getEditorPreviewUrl(
$url = UrlBuilderHelper::getCanvasUrl(
$this->getModel()->getOriginContent()
);

Expand Down Expand Up @@ -637,7 +637,7 @@ public function getLastEdited()
$user = $content->getLastEditorUser();
$displayName = $user ? $user->getName() : __('Automatic');

return __('Updated %1 by %2', DataHelper::timeElapsedString($content->getUpdateTime()), $displayName)->__toString();
return __('Updated by %1', $displayName)->__toString();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Builder/Base/AbstractModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class AbstractModule extends AbstractBase
*/
public function __clone()
{
throw new \Goomento\PageBuilder\Exception\BuilderException('Something went wrong');
throw new \Exception('Something went wrong');
}

/**
Expand Down
23 changes: 5 additions & 18 deletions Builder/Css/ContentCss.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,6 @@ protected function deleteMeta()
->removeFlag('direct_save');
}

/**
* Get post data.
*
* Retrieve raw post data from the database.
*
*
* @return array ContentCss data.
*/
protected function getData()
{
return $this->model->getElements();
}

/**
* Render CSS.
*
Expand All @@ -155,10 +142,10 @@ protected function getData()
*/
protected function renderCss()
{
$data = $this->getData();
$elements = $this->getModel()->getElements();
$elementManager = ObjectManagerHelper::getElementsManager();
if (!empty($data)) {
foreach ($data as $elementData) {
if (!empty($elements)) {
foreach ($elements as $elementData) {
$element = $elementManager->createElementInstance((array) $elementData);
if (!$element) {
continue;
Expand Down Expand Up @@ -298,7 +285,7 @@ protected function renderStyles(AbstractElement $element)
*/
protected function useExternalFile()
{
$useInline = (!$this->getModel() instanceof RevisionInterface);
return $useInline && !DataHelper::useInlineCss();
$isRevision = $this->getModel() instanceof RevisionInterface;
return !$isRevision && !DataHelper::useInlineCss();
}
}
70 changes: 32 additions & 38 deletions Builder/Elements/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,25 +458,39 @@ protected function registerControls()

$this->endControlsSection();

// Popup Section
$this->startControlsSection(
'section_popup_section',
'section_type_section',
[
'label' => __('Popup'),
'label' => __('Section Type'),
'tab' => Controls::TAB_LAYOUT,
]
);

$this->addControl(
'popup_enabled',
'section_type',
[
'label' => __('Enabled'),
'type' => Controls::SWITCHER,
'label' => __('Type'),
'type' => Controls::SELECT,
'prefix_class' => 'gmt-section-type-',
'default' => '',
'prefix_class' => 'gmt-section-popup-',
'description' => __('Enable this section will hide section on storefront. Use "Call to Action" widget to show this popup.'),
'frontend_available' => true,
'return_value' => 'ok',
'options' => [
'' => __('Default'),
'popup' => __('Popup'),
],
]
);

$this->endControlsSection();

// Popup Section
$this->startControlsSection(
'section_popup_section',
[
'label' => __('Popup'),
'tab' => Controls::TAB_LAYOUT,
'condition' => [
'section_type' => 'popup'
]
]
);

Expand All @@ -486,9 +500,6 @@ protected function registerControls()
'type' => Controls::RAW_HTML,
'raw' => __('Note: CSS ID must be placed in tab Advanced > Identify > CSS ID. .'),
'content_classes' => 'gmt-panel-alert gmt-panel-alert-warning',
'condition' => [
'popup_enabled' => 'ok'
]
]
);

Expand All @@ -498,10 +509,7 @@ protected function registerControls()
'label' => __('Title'),
'type' => Controls::TEXT,
'frontend_available' => true,
'default' => __('Popup Title'),
'condition' => [
'popup_enabled' => 'ok'
]
'placeholder' => __('Popup Title'),
]
);

Expand All @@ -516,9 +524,6 @@ protected function registerControls()
'close' => __('Close Button'),
'confirm' => __('Confirm Button'),
'both' => __('Both'),
],
'condition' => [
'popup_enabled' => 'ok'
]
]
);
Expand All @@ -530,8 +535,7 @@ protected function registerControls()
'label' => __('Close Button'),
'type' => Controls::HEADING,
'condition' => [
'popup_buttons' => ['close', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['close', 'both']
]
]
);
Expand All @@ -542,11 +546,8 @@ protected function registerControls()
'label' => __('Label'),
'type' => Controls::TEXT,
'frontend_available' => true,
'default' => __('Close'),
'placeholder' => __('Close'),
'condition' => [
'popup_buttons' => ['close', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['close', 'both']
]
]
);
Expand All @@ -561,8 +562,7 @@ protected function registerControls()
'title' => __('Add your custom class WITHOUT the dot. e.g: my-class'),
'frontend_available' => true,
'condition' => [
'popup_buttons' => ['close', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['close', 'both']
]
]
);
Expand All @@ -574,8 +574,7 @@ protected function registerControls()
'label' => __('Confirm Button'),
'type' => Controls::HEADING,
'condition' => [
'popup_buttons' => ['confirm', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['confirm', 'both']
]
]
);
Expand All @@ -586,11 +585,8 @@ protected function registerControls()
'label' => __('Text'),
'type' => Controls::TEXT,
'frontend_available' => true,
'default' => __('Confirm'),
'placeholder' => __('Confirm'),
'condition' => [
'popup_buttons' => ['confirm', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['confirm', 'both']
]
]
);
Expand All @@ -603,8 +599,7 @@ protected function registerControls()
'frontend_available' => true,
'placeholder' => __('https://your-link.com'),
'condition' => [
'popup_buttons' => ['confirm', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['confirm', 'both']
]
]
);
Expand All @@ -619,8 +614,7 @@ protected function registerControls()
'prefix_class' => '',
'title' => __('Add your custom class WITHOUT the dot. e.g: my-class'),
'condition' => [
'popup_buttons' => ['confirm', 'both'],
'popup_enabled' => 'ok',
'popup_buttons' => ['confirm', 'both']
]
]
);
Expand Down
22 changes: 5 additions & 17 deletions Builder/Managers/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private static function initTabs()
'displayPrefix' => 'far',
'labelIcon' => 'fab fa-font-awesome-alt',
'ver' => '5.9.0',
'fetchJson' => self::getFaAssetUrl('regular', 'json', false),
'fetchJson' => self::getFaAssetUrl('regular'),
'native' => true,
],
'fa-solid' => [
Expand All @@ -92,7 +92,7 @@ private static function initTabs()
'displayPrefix' => 'fas',
'labelIcon' => 'fab fa-font-awesome',
'ver' => '5.9.0',
'fetchJson' => self::getFaAssetUrl('solid', 'json', false),
'fetchJson' => self::getFaAssetUrl('solid'),
'native' => true,
],
'fa-brands' => [
Expand All @@ -103,7 +103,7 @@ private static function initTabs()
'displayPrefix' => 'fab',
'labelIcon' => 'fab fa-font-awesome-flag',
'ver' => '5.9.0',
'fetchJson' => self::getFaAssetUrl('brands', 'json', false),
'fetchJson' => self::getFaAssetUrl('brands'),
'native' => true,
],
])->getResult();
Expand All @@ -124,22 +124,11 @@ public static function getIconManagerTabs()

/**
* @param $filename
* @param string $extType
* @param bool $addSuffix
* @return string
*/
private static function getFaAssetUrl($filename, $extType = 'css', $addSuffix = true)
private static function getFaAssetUrl($filename)
{
static $isTestMode = null;
if (null === $isTestMode) {
$isTestMode = !!Developer::debug();
}
$url = 'Goomento_PageBuilder/lib/font-awesome/' . $extType . '/' . $filename;
if (!$isTestMode && $addSuffix) {
$url .= '.min';
}
$url .= '.' . $extType;
return UrlBuilderHelper::urlStaticBuilder($url);
return UrlBuilderHelper::getAssetUrlWithParams(sprintf('Goomento_PageBuilder/lib/font-awesome/json/%s.json', $filename));
}

/**
Expand All @@ -159,7 +148,6 @@ public static function getIconManagerTabsConfig()
return array_values(array_merge($tabs, self::getIconManagerTabs()));
}


/**
* @param $icon
* @param array $attributes
Expand Down
20 changes: 0 additions & 20 deletions Builder/Managers/Resolvers.php

This file was deleted.

4 changes: 2 additions & 2 deletions Builder/Managers/Schemes.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ public function __construct()
{
HooksHelper::addAction('pagebuilder/ajax/register_actions', [ $this,'registerAjaxActions' ]);

$this->components = [
$this->setComponent([
Color::NAME => Color::class,
Typography::NAME => Typography::class,
ColorPicker::NAME => ColorPicker::class,
];
]);
}
}
Loading

0 comments on commit 9030897

Please sign in to comment.