// Adding RTL to calendar helper
This commit is contained in:
@@ -2,8 +2,13 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="datepickers-container">
|
||||
<div class="datepicker1" data-date="{$from_date}" data-date-format="{$date_format}"></div>
|
||||
<div class="datepicker2" data-date="{$to_date}" data-date-format="{$date_format}"></div>
|
||||
{if $is_rtl}
|
||||
<div class="datepicker2" data-date="{$date_to}" data-date-format="{$date_format}"></div>
|
||||
<div class="datepicker1" data-date="{$date_from}" data-date-format="{$date_format}"></div>
|
||||
{else}
|
||||
<div class="datepicker1" data-date="{$date_from}" data-date-format="{$date_format}"></div>
|
||||
<div class="datepicker2" data-date="{$date_to}" data-date-format="{$date_format}"></div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
|
||||
@@ -34,6 +34,7 @@ class HelperCalendarCore extends Helper
|
||||
private $_date_format;
|
||||
private $_date_from;
|
||||
private $_date_to;
|
||||
private $_rtl;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -62,7 +63,7 @@ class HelperCalendarCore extends Helper
|
||||
public function setCompareDateFrom($value)
|
||||
{
|
||||
if (!isset($value) || $value == '');
|
||||
$value = date('d-m-Y', strtotime("-31 days"));
|
||||
$value = date('Y-m-d', strtotime("-31 days"));
|
||||
|
||||
if (!is_string($value))
|
||||
throw new PrestaShopException('Date must be string');
|
||||
@@ -74,7 +75,7 @@ class HelperCalendarCore extends Helper
|
||||
public function getCompareDateFrom()
|
||||
{
|
||||
if (!isset($this->_compare_date_from))
|
||||
$this->_compare_date_from = date('d-m-Y', strtotime("-31 days"));
|
||||
$this->_compare_date_from = date('Y-m-d', strtotime("-31 days"));
|
||||
|
||||
return $this->_compare_date_from;
|
||||
}
|
||||
@@ -94,7 +95,7 @@ class HelperCalendarCore extends Helper
|
||||
public function getCompareDateTo()
|
||||
{
|
||||
if (!isset($this->_compare_date_to))
|
||||
$this->_compare_date_to = date('d-m-Y');
|
||||
$this->_compare_date_to = date('Y-m-d');
|
||||
|
||||
return $this->_compare_date_to;
|
||||
}
|
||||
@@ -119,7 +120,7 @@ class HelperCalendarCore extends Helper
|
||||
public function setDateFrom($value)
|
||||
{
|
||||
if (!isset($value) || $value == '')
|
||||
$value = date('d-m-Y', strtotime("-31 days"));
|
||||
$value = date('Y-m-d', strtotime("-31 days"));
|
||||
|
||||
if (!is_string($value))
|
||||
throw new PrestaShopException('Date must be string');
|
||||
@@ -131,7 +132,7 @@ class HelperCalendarCore extends Helper
|
||||
public function getDateFrom()
|
||||
{
|
||||
if (!isset($this->_date_from))
|
||||
$this->_date_from = date('d-m-Y', strtotime("-31 days"));
|
||||
$this->_date_from = date('Y-m-d', strtotime("-31 days"));
|
||||
|
||||
return $this->_date_from;
|
||||
}
|
||||
@@ -151,11 +152,17 @@ class HelperCalendarCore extends Helper
|
||||
public function getDateTo()
|
||||
{
|
||||
if (!isset($this->_date_to))
|
||||
$this->_date_to = date('d-m-Y');
|
||||
$this->_date_to = date('Y-m-d');
|
||||
|
||||
return $this->_date_to;
|
||||
}
|
||||
|
||||
public function setRTL($value)
|
||||
{
|
||||
$this->_rtl = (bool)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addAction($action)
|
||||
{
|
||||
if (!isset($this->_actions))
|
||||
@@ -195,10 +202,19 @@ class HelperCalendarCore extends Helper
|
||||
'date_to' => $this->getDateTo(),
|
||||
'compare_date_from' => $this->getCompareDateFrom(),
|
||||
'compare_date_to' => $this->getCompareDateTo(),
|
||||
'actions' => $this->getActions()
|
||||
'actions' => $this->getActions(),
|
||||
'is_rtl' => $this->isRTL()
|
||||
));
|
||||
|
||||
$html .= parent::generate();
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function isRTL()
|
||||
{
|
||||
if (!isset($this->_rtl))
|
||||
$this->_rtl = Context::getContext()->language->is_rtl;
|
||||
|
||||
return $this->_rtl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user