update - v1.0.1

This commit is contained in:
Llewellyn van der Merwe 2022-01-06 12:04:35 +02:00
parent 40e5c4f41f
commit 7eede35961
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
5 changed files with 32 additions and 33 deletions

View File

@ -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). 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) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Dailyscripture](https://www.vdm.io/) + *Name*: [Dailyscripture](https://www.vdm.io/)
+ *First Build*: 22nd October, 2015 + *First Build*: 22nd October, 2015
+ *Last Build*: 5th January, 2022 + *Last Build*: 6th January, 2022
+ *Version*: 1.0.0 + *Version*: 1.0.1
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html

View File

@ -26,6 +26,8 @@
defined('_JEXEC') or die('Restricted access'); 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 class ModDailyScriptureHelper
{ {
@ -62,12 +64,12 @@ class ModDailyScriptureHelper
protected $telegramID = 440; protected $telegramID = 440;
/** /**
* Telegram Date = ID * Telegram Date of the telegramID
* *
* @var int * @var string
* @since 1.0 * @since 1.0
*/ */
protected $telegramDate = 1640995200; protected $telegramDate = 'Saturday 01 January, 2022';
/** /**
* Constructor. * Constructor.
@ -131,15 +133,17 @@ class ModDailyScriptureHelper
protected function setTelegram() protected function setTelegram()
{ {
// get today // get today
$today = time(); $today = $this->getTimeStamp();
// get the telegram date
$telegram_date = $this->getTimeStamp($this->telegramDate);
// get the difference // get the difference
$difference = $today - $this->telegramDate; $difference = $today - $telegram_date;
// get the number of days // get the number of days (plus one of the current date)
$days = round($difference / (60 * 60 * 24)); $days = round($difference / 86400) + 1;
// add the days // add the days
$day = $this->telegramID + $days; $id = $this->telegramID + $days;
// validate the ID // validate the ID
if (($id = $this->validateID($day)) > 0) if ($id > 0)
{ {
// get the width // get the width
$width = $this->params->get('width', 100); $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 * @since 1.0
*/ */
protected function validateID($id) protected function getTimeStamp($getDate = 'now')
{ {
// url to post // get today's date
$post_url = "https://t.me/daily_scripture/$id?embed=1"; $date = new Date($getDate);
// try to get post (painful work around because of an ugly API) // get the user time zone
if (($post = $this->getFileContents($post_url, false)) !== false && strpos($post, 'tgme_widget_message_error') === false) $timezone = Factory::getUser()->getTimezone();
{ // update the date to the users time zone
return $id; $date->setTimezone($timezone);
} // return the time stamp
// try again return $date->toUnix();
if ($id > 0)
{
return $this->validateID(--$id);
}
return 0;
} }
/** /**

View File

@ -1,6 +1,6 @@
MOD_DAILYSCRIPTURE="Dailyscripture" MOD_DAILYSCRIPTURE="Dailyscripture"
MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture." MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture."
MOD_DAILYSCRIPTURE_XML_DESCRIPTION="<h1>Dailyscripture (v.1.0.0)</h1> <div style='clear: both;'></div><p>Display the daily scripture from https://github.com/trueChristian/daily-scripture.</p><p>Created by <a href='https://www.vdm.io/' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 1st January, 2022</small></p>" MOD_DAILYSCRIPTURE_XML_DESCRIPTION="<h1>Dailyscripture (v.1.0.1)</h1> <div style='clear: both;'></div><p>Display the daily scripture from https://github.com/trueChristian/daily-scripture.</p><p>Created by <a href='https://www.vdm.io/' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 1st January, 2022</small></p>"
MOD_DAILYSCRIPTURE_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER="There was an error, please try again latter." 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_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" 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"

View File

@ -1,6 +1,6 @@
MOD_DAILYSCRIPTURE="Dailyscripture" MOD_DAILYSCRIPTURE="Dailyscripture"
MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture." MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture."
MOD_DAILYSCRIPTURE_XML_DESCRIPTION="<h1>Dailyscripture (v.1.0.0)</h1> <div style='clear: both;'></div><p>Display the daily scripture from https://github.com/trueChristian/daily-scripture.</p><p>Created by <a href='https://www.vdm.io/' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 1st January, 2022</small></p>" MOD_DAILYSCRIPTURE_XML_DESCRIPTION="<h1>Dailyscripture (v.1.0.1)</h1> <div style='clear: both;'></div><p>Display the daily scripture from https://github.com/trueChristian/daily-scripture.</p><p>Created by <a href='https://www.vdm.io/' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 1st January, 2022</small></p>"
MOD_DAILYSCRIPTURE_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER="There was an error, please try again latter." 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_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" 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"

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="4" client="site" method="upgrade"> <extension type="module" version="4" client="site" method="upgrade">
<name>MOD_DAILYSCRIPTURE</name> <name>MOD_DAILYSCRIPTURE</name>
<creationDate>5th January, 2022</creationDate> <creationDate>6th January, 2022</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://www.vdm.io/</authorUrl> <authorUrl>https://www.vdm.io/</authorUrl>
<copyright>Copyright (C) 2015. All Rights Reserved</copyright> <copyright>Copyright (C) 2015. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license> <license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>1.0.0</version> <version>1.0.1</version>
<description>MOD_DAILYSCRIPTURE_XML_DESCRIPTION</description> <description>MOD_DAILYSCRIPTURE_XML_DESCRIPTION</description>
<!-- Language files --> <!-- Language files -->