65 lines
2.4 KiB
PHP
65 lines
2.4 KiB
PHP
<?php
|
|
/*************************************************************************************/
|
|
/* This file is part of the Thelia package. */
|
|
/* */
|
|
/* Copyright (c) OpenStudio */
|
|
/* email : dev@thelia.net */
|
|
/* web : http://www.thelia.net */
|
|
/* */
|
|
/* For the full copyright and license information, please view the LICENSE.txt */
|
|
/* file that was distributed with this source code. */
|
|
/*************************************************************************************/
|
|
|
|
namespace SliderRevolution\Smarty;
|
|
|
|
use SliderRevolution\SliderRevolution;
|
|
use TheliaSmarty\Template\AbstractSmartyPlugin;
|
|
use TheliaSmarty\Template\SmartyPluginDescriptor;
|
|
|
|
/**
|
|
* Class CartPostage
|
|
* @package Thelia\Core\Template\Smarty\Plugins
|
|
*/
|
|
class CountdownDate extends AbstractSmartyPlugin
|
|
{
|
|
/**
|
|
* Get postage amount for cart
|
|
*
|
|
* @param array $params Block parameters
|
|
* @param mixed $content Block content
|
|
* @param \Smarty_Internal_Template $template Template
|
|
* @param bool $repeat Control how many times
|
|
* the block is displayed
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getCountdownDate($params, /** @noinspection PhpUnusedParameterInspection */ $template)
|
|
{
|
|
$countdown = SliderRevolution::getConfigValue(SliderRevolution::FIN_COMPTE_A_REBOURS);
|
|
|
|
if (! empty($countdown)) {
|
|
if (false !== $date = \DateTime::createFromFormat("d/m/Y H:i:s", $countdown)) {
|
|
$today = new \DateTime();
|
|
|
|
if ($date > $today) {
|
|
return $date->getTimestamp();
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Defines the various smarty plugins handled by this class
|
|
*
|
|
* @return \TheliaSmarty\Template\SmartyPluginDescriptor[] smarty plugin descriptors
|
|
*/
|
|
public function getPluginDescriptors()
|
|
{
|
|
return array(
|
|
new SmartyPluginDescriptor('function', 'slider_revolution_countdown', $this, 'getCountdownDate')
|
|
);
|
|
}
|
|
}
|