diff --git a/README.md b/README.md index f2d2e77..2283e3d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Dailyscripture (1.0.0) +# Dailyscripture (1.0.1) Display the daily scripture from [https://github.com/trueChristian/daily-scripture](https://github.com/trueChristian/daily-scripture). @@ -8,8 +8,8 @@ Display the daily scripture from [https://github.com/trueChristian/daily-scriptu + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Dailyscripture](https://www.vdm.io/) + *First Build*: 22nd October, 2015 -+ *Last Build*: 5th January, 2022 -+ *Version*: 1.0.0 ++ *Last Build*: 6th January, 2022 ++ *Version*: 1.0.1 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html diff --git a/helper.php b/helper.php index 769c386..6565b41 100644 --- a/helper.php +++ b/helper.php @@ -25,7 +25,9 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Registry\Registry; +use Joomla\Registry\Registry; +use Joomla\CMS\Date\Date; +use Joomla\CMS\Factory; class ModDailyScriptureHelper { @@ -62,12 +64,12 @@ class ModDailyScriptureHelper protected $telegramID = 440; /** - * Telegram Date = ID + * Telegram Date of the telegramID * - * @var int + * @var string * @since 1.0 */ - protected $telegramDate = 1640995200; + protected $telegramDate = 'Saturday 01 January, 2022'; /** * Constructor. @@ -131,15 +133,17 @@ class ModDailyScriptureHelper protected function setTelegram() { // get today - $today = time(); + $today = $this->getTimeStamp(); + // get the telegram date + $telegram_date = $this->getTimeStamp($this->telegramDate); // get the difference - $difference = $today - $this->telegramDate; - // get the number of days - $days = round($difference / (60 * 60 * 24)); + $difference = $today - $telegram_date; + // get the number of days (plus one of the current date) + $days = round($difference / 86400) + 1; // add the days - $day = $this->telegramID + $days; + $id = $this->telegramID + $days; // validate the ID - if (($id = $this->validateID($day)) > 0) + if ($id > 0) { // get the width $width = $this->params->get('width', 100); @@ -155,27 +159,22 @@ class ModDailyScriptureHelper } /** - * validate the current ID of the post + * get today's time stamp based on user * - * @return int the post ID + * @return int the timestamp * * @since 1.0 */ - protected function validateID($id) + protected function getTimeStamp($getDate = 'now') { - // url to post - $post_url = "https://t.me/daily_scripture/$id?embed=1"; - // try to get post (painful work around because of an ugly API) - if (($post = $this->getFileContents($post_url, false)) !== false && strpos($post, 'tgme_widget_message_error') === false) - { - return $id; - } - // try again - if ($id > 0) - { - return $this->validateID(--$id); - } - return 0; + // get today's date + $date = new Date($getDate); + // get the user time zone + $timezone = Factory::getUser()->getTimezone(); + // update the date to the users time zone + $date->setTimezone($timezone); + // return the time stamp + return $date->toUnix(); } /** diff --git a/language/en-GB/en-GB.mod_dailyscripture.ini b/language/en-GB/en-GB.mod_dailyscripture.ini index b160dc3..2dde901 100644 --- a/language/en-GB/en-GB.mod_dailyscripture.ini +++ b/language/en-GB/en-GB.mod_dailyscripture.ini @@ -1,6 +1,6 @@ MOD_DAILYSCRIPTURE="Dailyscripture" MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture." -MOD_DAILYSCRIPTURE_XML_DESCRIPTION="

Dailyscripture (v.1.0.0)

Display the daily scripture from https://github.com/trueChristian/daily-scripture.

Created by Llewellyn van der Merwe
Development started 1st January, 2022

" +MOD_DAILYSCRIPTURE_XML_DESCRIPTION="

Dailyscripture (v.1.0.1)

Display the daily scripture from https://github.com/trueChristian/daily-scripture.

Created by Llewellyn van der Merwe
Development started 1st January, 2022

" MOD_DAILYSCRIPTURE_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER="There was an error, please try again latter." MOD_DAILYSCRIPTURE_TYPE_LABEL="Implementation Type" MOD_DAILYSCRIPTURE_TYPE_DESCRIPTION="What kind of implementation would you like to use. Direct from gitHub the main source, or directly from Telegram its official channel" diff --git a/language/en-GB/en-GB.mod_dailyscripture.sys.ini b/language/en-GB/en-GB.mod_dailyscripture.sys.ini index b160dc3..2dde901 100644 --- a/language/en-GB/en-GB.mod_dailyscripture.sys.ini +++ b/language/en-GB/en-GB.mod_dailyscripture.sys.ini @@ -1,6 +1,6 @@ MOD_DAILYSCRIPTURE="Dailyscripture" MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture." -MOD_DAILYSCRIPTURE_XML_DESCRIPTION="

Dailyscripture (v.1.0.0)

Display the daily scripture from https://github.com/trueChristian/daily-scripture.

Created by Llewellyn van der Merwe
Development started 1st January, 2022

" +MOD_DAILYSCRIPTURE_XML_DESCRIPTION="

Dailyscripture (v.1.0.1)

Display the daily scripture from https://github.com/trueChristian/daily-scripture.

Created by Llewellyn van der Merwe
Development started 1st January, 2022

" MOD_DAILYSCRIPTURE_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER="There was an error, please try again latter." MOD_DAILYSCRIPTURE_TYPE_LABEL="Implementation Type" MOD_DAILYSCRIPTURE_TYPE_DESCRIPTION="What kind of implementation would you like to use. Direct from gitHub the main source, or directly from Telegram its official channel" diff --git a/mod_dailyscripture.xml b/mod_dailyscripture.xml index d0a63ea..f36f7af 100644 --- a/mod_dailyscripture.xml +++ b/mod_dailyscripture.xml @@ -1,13 +1,13 @@ MOD_DAILYSCRIPTURE - 5th January, 2022 + 6th January, 2022 Llewellyn van der Merwe joomla@vdm.io https://www.vdm.io/ Copyright (C) 2015. All Rights Reserved GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - 1.0.0 + 1.0.1 MOD_DAILYSCRIPTURE_XML_DESCRIPTION