Skip to content

Commit

Permalink
Merge pull request #327 from JoomShaper/prakash/dev
Browse files Browse the repository at this point in the history
Fixed Coming soon validation, HFWU-139 & HFWU-151
  • Loading branch information
mi-prakash authored May 16, 2023
2 parents 4f100bb + 539170d commit 854db9b
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 11 deletions.
18 changes: 13 additions & 5 deletions plugins/system/helixultimate/assets/js/admin/helix-ultimate.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,25 @@ jQuery(function ($) {
if (data.status) {
let $previewFrame = document.getElementById('hu-template-preview');
$previewFrame.contentWindow.location.reload(true);

Joomla.HelixToaster.success('Changes have been successfully saved!', 'Success');
$('.hu-loading-msg').hide();
$('.hu-done-msg').hide();
$('.action-reset-drafts').hide();
showSaveLoader(false);
} else {
Joomla.HelixToaster.error(data.message, 'Failed');
$('.hu-loading-msg').hide();
$('.hu-done-msg').hide();
$('.action-reset-drafts').hide();
showSaveLoader(false);
}

// Update the setvalues.
updateSetvalue();

},
complete() {
Joomla.HelixToaster.success('Changes have been successfully saved!', 'Success');
$('.hu-loading-msg').hide();
$('.hu-done-msg').hide();
$('.action-reset-drafts').hide();
showSaveLoader(false);
},
error: function (err) {
console.error('error', err);
Expand Down
4 changes: 3 additions & 1 deletion plugins/system/helixultimate/helixultimate.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class PlgSystemHelixultimate extends CMSPlugin
*/
public function onAfterInitialise()
{

if (JVERSION < 4) {
$this->registerBootstrap();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
use Joomla\CMS\Language\Text;


if(JVERSION < 4)
if (JVERSION < 4)
{
HTMLHelper::_('behavior.core');
HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html');

HTMLHelper::_('stylesheet', 'com_finder/finder.css', array('version' => 'auto', 'relative' => true));
HTMLHelper::_('stylesheet', 'vendor/awesomplete/awesomplete.css', array('version' => 'auto', 'relative' => true));

Text::script('MOD_FINDER_SEARCH_VALUE', true);

HTMLHelper::_('script', 'com_finder/finder.js', array('version' => 'auto', 'relative' => true));
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@

$route = $this->result->route;

$showImage = $this->params->get('show_image', 0);
$imageClass = $this->params->get('image_class', '');
$extraAttr = [];

if ($showImage && !empty($this->result->imageUrl) && $imageClass !== '') {
$extraAttr['class'] = $imageClass;
}

// Get the route with highlighting information.
if (!empty($this->query->highlight)
&& empty($this->result->mime)
Expand All @@ -51,6 +59,25 @@

?>
<li>
<?php if ($showImage && isset($this->result->imageUrl)) : ?>
<?php
$imageUrl = $this->result->imageUrl;
$imageAlt = $this->result->imageAlt;
if (!empty($this->result->params->get('helix_ultimate_image'))) {
$imageUrl = $this->result->params->get('helix_ultimate_image');
$imageAlt = $this->result->title;
}
?>
<figure class="<?php echo htmlspecialchars($imageClass, ENT_COMPAT, 'UTF-8'); ?> result__image">
<?php if ($this->params->get('link_image') && $this->result->route) : ?>
<a href="<?php echo Route::_($this->result->route); ?>">
<?php echo HTMLHelper::_('image', $imageUrl, $imageAlt, $extraAttr); ?>
</a>
<?php else : ?>
<?php echo HTMLHelper::_('image', $imageUrl, $imageAlt, $extraAttr); ?>
<?php endif; ?>
</figure>
<?php endif; ?>
<h4 class="result-title <?php echo $mime; ?>">
<a href="<?php echo Route::_($route); ?>">
<?php echo $this->result->title; ?>
Expand Down
20 changes: 20 additions & 0 deletions plugins/system/helixultimate/src/Platform/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

defined('_JEXEC') or die();

use DateTime;
use Exception;
use HelixUltimate\Framework\HttpResponse\Response;
use HelixUltimate\Framework\Platform\Blog;
use HelixUltimate\Framework\Platform\Helper;
Expand Down Expand Up @@ -228,6 +230,17 @@ private function saveTemplateStyle()
Session::checkToken() or die(json_encode($this->report));

$data = $_POST;

$data['comingsoon_date'] = date('Y-m-d', strtotime($data['comingsoon_date']));
$dateStatus = $this->validateDate($data['comingsoon_date']);

if (!$dateStatus) {
$this->report['status'] = false;
$this->report['message'] = 'Coming Soon Date for Countdown is invalid';
$this->report['isDrafted'] = Helper::isDrafted();
return;
}

$inputs = $this->filterInputs($data);

if (!$this->id || !is_int($this->id))
Expand Down Expand Up @@ -260,6 +273,13 @@ private function saveTemplateStyle()
}
}

private function validateDate($date, $format = 'Y-m-d')
{
$d = DateTime::createFromFormat($format, $date);
// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
return $d && $d->format($format) === $date;
}

private function draftTemplateStyle()
{
$this->report['status'] = false;
Expand Down
2 changes: 1 addition & 1 deletion templates/shaper_helixultimate/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"contact_time": "",
"comingsoon_title": "Coming Soon Title",
"comingsoon_content": "Coming soon content",
"comingsoon_date": "1-1-2025",
"comingsoon_date": "2025-01-01",
"comingsoon_logo": "",
"comingsoon_bg_image": "",
"error_logo": "",
Expand Down

0 comments on commit 854db9b

Please sign in to comment.