Server : LiteSpeed System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : alsaif ( 1057) PHP Version : 7.4.33 Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/alsaif/public_html/plugins/system/nrframework/NRFramework/Notices/Notices/ |
<?php
/**
* @author Tassos Marinos <info@tassos.gr>
* @link https://www.tassos.gr
* @copyright Copyright © 2024 Tassos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace NRFramework\Notices\Notices;
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use \NRFramework\Functions;
class Expiring extends Notice
{
protected $notice_payload = [
'type' => 'warning',
'class' => 'expiring',
'expires_in' => '',
'plan' => ''
];
public function __construct($payload = [])
{
parent::__construct($payload);
$this->payload['tooltip'] = Text::_('NR_NOTICE_EXPIRING_TOOLTIP');
$this->payload['expires_in'] = isset($this->payload['expires_in']) ? $this->payload['expires_in'] : false;
$this->payload['plan'] = isset($payload['plan']) ? $payload['plan'] : false;
}
/**
* Define the remaining days the subscription must have to display the expiring subscription notice.
*
* @var int
*/
private $expiring_notice_days = 30;
/**
* Notice title.
*
* @return string
*/
protected function getTitle()
{
return sprintf(Text::_('NR_SUBSCRIPTION_EXPIRING'), $this->extension_name);
}
/**
* Notice description.
*
* @return string
*/
protected function getDescription()
{
$title = strtolower($this->payload['plan']) === 'bundle' ? $this->payload['plan'] : $this->extension_name . ' ' . $this->payload['plan'];
return sprintf(Text::_('NR_SUBSCRIPTION_EXPIRING_DESC'), $title, Functions::applySiteTimezoneToDate($this->payload['expires_in'], 'd M o'));
}
/**
* Notice actions.
*
* @return string
*/
protected function getActions()
{
$url = 'https://www.tassos.gr/subscriptions';
return '<a href="' . Functions::getUTMURL($url, 'UserNotice', 'SubscriptionExpiring') . '" target="_blank" class="tf-notice-btn info">' . sprintf(Text::_('NR_RENEW_X_PERCENT_OFF'), 30) . '</a>';
}
/**
* Whether the notice can run.
*
* @return string
*/
protected function canRun()
{
// If cookie exists, it's already hidden
if ($this->factory->getCookie('tfNoticeHideExpiringNotice_' . $this->payload['ext_element']) === 'true')
{
return false;
}
// The date the extension expires.
if (!$this->payload['expires_in'])
{
return false;
}
// The days difference criteria must be met
if ($this->getDaysDifference(strtotime($this->payload['expires_in']), time()) > $this->expiring_notice_days)
{
return false;
}
return true;
}
}