diff --git a/README.md b/README.md index 735c767..6718102 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Dailyscripture (1.0.1) +# Dailyscripture (1.1.4) Display the daily scripture from [https://github.com/trueChristian/daily-scripture](https://github.com/trueChristian/daily-scripture). @@ -8,46 +8,10 @@ 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*: 7th January, 2022 -+ *Version*: 1.0.1 ++ *Last Build*: 5th April, 2023 ++ *Version*: 1.1.4 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -> This **module** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com). -> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) - - -## Contributors -This project exists thanks to all the people who contribute to the [Joomla Component Builder Project](https://github.com/vdm-io/Joomla-Component-Builder). - -[![Contributors](https://opencollective.com/Joomla-Component-Builder/contributors.svg?width=890&button=false)](https://github.com/vdm-io/Joomla-Component-Builder/graphs/contributors) - -### Backers -Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/Joomla-Component-Builder#backer)] - -[![Our Backers on opencollective](https://opencollective.com/Joomla-Component-Builder/backers.svg?width=890)](https://opencollective.com/Joomla-Component-Builder#backers) - -### Sponsors -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/Joomla-Component-Builder#sponsor)] - -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/0/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/0/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/1/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/1/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/2/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/2/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/3/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/3/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/4/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/4/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/5/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/5/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/6/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/6/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/7/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/7/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/8/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/8/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/9/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/9/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/10/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/10/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/11/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/11/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/12/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/12/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/13/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/13/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/14/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/14/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/15/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/15/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/16/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/16/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/17/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/17/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/18/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/18/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/19/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/19/website) -[![Sponsor](https://opencollective.com/Joomla-Component-Builder/sponsor/20/avatar.svg)](https://opencollective.com/Joomla-Component-Builder/sponsor/20/website) \ No newline at end of file +> This **module** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com). +> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) \ No newline at end of file diff --git a/helper.php b/helper.php index 7544329..3da771d 100644 --- a/helper.php +++ b/helper.php @@ -10,7 +10,7 @@ /------------------------------------------------------------------------------------------------------------------------------------/ - @version 2.0.x + @version 2.1.x @created 22nd October, 2015 @package Sermon Distributor @subpackage helper.php @@ -25,9 +25,7 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -use Joomla\Registry\Registry; -use Joomla\CMS\Date\Date; -use Joomla\CMS\Factory; +use Joomla\Registry\Registry; class ModDailyScriptureHelper { @@ -37,7 +35,15 @@ class ModDailyScriptureHelper * @var Registry * @since 1.0 */ - protected $params; + protected Registry $params; + + /** + * The Translation Version + * + * @var string + * @since 1.1 + */ + protected string $version; /** * Scripture @@ -47,29 +53,37 @@ class ModDailyScriptureHelper */ protected $scripture = null; + /** + * Telegram Scripture + * + * @var string + * @since 1.1 + */ + protected string $telegram = ''; + + /** + * Telegram Comments + * + * @var string + * @since 1.1 + */ + protected string $comments = ''; + /** * Type * * @var int * @since 1.0 */ - protected $type; + protected int $type; /** - * Telegram ID = Date + * The Telegram Post ID * * @var int - * @since 1.0 + * @since 1.1 */ - protected $telegramID = 440; - - /** - * Telegram Date of the telegramID - * - * @var string - * @since 1.0 - */ - protected $telegramDate = 'Saturday 01 January, 2022'; + protected int $id = 0; /** * Constructor. @@ -87,22 +101,43 @@ class ModDailyScriptureHelper $this->params = $params; // get the version $this->type = $params->get('type', 1); + // get the version + $this->version = $params->get('version', 'kjv'); + // implementation type = 1 = gitHub if ($this->type == 1) { - // get the version - $version = $params->get('version', 'kjv'); // the link to the scripture for the day - $path = "https://raw.githubusercontent.com/trueChristian/daily-scripture/master/scripture/$version/README.json"; + $path = "https://raw.githubusercontent.com/trueChristian/daily-scripture/master/scripture/{$this->version}/README.json"; // get the scripture object $this->scripture = $this->getFileContents($path); } - // implementation type = 2 = Telegram - elseif ($this->type == 2) + } + } + + /** + * get the Telegram Post ID + * + * @return int + * @since 1.1 + */ + protected function getId(): int + { + if ($this->id == 0) + { + // the link to the scripture for the day + $path = "https://raw.githubusercontent.com/trueChristian/daily-scripture/master/scripture/{$this->version}/README.tg.id"; + // get the scripture object + $id = trim($this->getFileContents($path, false)); + + // make sure we have a number here + if (is_numeric($id)) { - $this->setTelegram(); + $this->id = (int) $id; } } + + return $this->id; } /** @@ -111,76 +146,152 @@ class ModDailyScriptureHelper * @param mixed $name Name of the value to retrieve. * * @return mixed The request value - * * @since 1.0 */ - public function __get($name) + public function __get($key) { - if ($this->type == 1 && $this->checkScripture($name)) + if ($this->type == 1 && $this->checkScripture($key)) { - return $this->scripture->{$name}; + return $this->scripture->{$key}; } - elseif ($this->type == 2 && $name === 'telegram' && isset($this->telegram)) + elseif ($this->type == 2 && $key === 'telegram') { - return $this->telegram; + return $this->getTelegram(); } + elseif ($key === 'comments') + { + return $this->getComments(); + } + return null; } /** * get the Telegram script * + * @return string|null + * + * @since 1.1 + */ + protected function getTelegram(): ?string + { + if (empty($this->telegram)) + { + $this->setTelegram(); + } + + return $this->checkString($this->telegram) ? $this->telegram : null; + } + + /** + * set the Telegram script + * * @return void * * @since 1.0 */ protected function setTelegram() { - // get today - $today = $this->getTimeStamp(); - // get the telegram date - $telegram_date = $this->getTimeStamp($this->telegramDate); - // get the difference - $difference = $today - $telegram_date; - // get the number of days (plus one of the current date) - $days = round($difference / 86400) + 1; - // add the days - $id = $this->telegramID + $days; // validate the ID - if ($id > 0) + if (($id = $this->getId()) > 0) { - // get the width - $width = $this->params->get('width', 100); // get the color $color = $this->getColor(); - // get the userpic - $userpic = $this->getUserPic(); + // get the dark theme $dark = $this->getDarkTheme(); + + // get the width + $width = $this->params->get('width', 100); + + // get the userpic + $userpic = $this->getUserPic(); + // set the script - $this->telegram = ""; + $this->telegram = ""; } } /** - * get today's time stamp based on user + * get the Telegram Comment script * - * @param string $getDate the string to get the time stamp for + * @return string|null * - * @return int the timestamp - * - * @since 1.0 + * @since 1.1 */ - protected function getTimeStamp($getDate = 'now') + protected function getComments(): ?string { - // 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(); + if (empty($this->comments)) + { + $this->setComments(); + } + + return $this->checkString($this->comments) ? $this->comments : null; + } + + /** + * set the Telegram script + * + * @return void + * + * @since 1.1 + */ + protected function setComments() + { + // should we add comments + if (($id = $this->getId()) > 0 && $this->params->get('show_comments', 0) == 1) + { + // get the color + $color = $this->getColor(); + + // get the dark theme + $dark = $this->getDarkTheme(); + + // get comment limit + $limit = $this->params->get('comments_limit', 5); + + // get comment Height + $height = $this->getCommentHeight(); + + // get color ful switch + $colorful = $this->getCommentColorful(); + + // set the script + $this->comments = ""; + } + } + + /** + * get the comment height + * + * @return string height value + * + * @since 1.1 + */ + protected function getCommentHeight() + { + if (($height = $this->params->get('comments_height')) > 300) + { + return " data-height=\"$height\""; + } + + return ''; + } + + /** + * get the comment color ful switch + * + * @return string height value + * + * @since 1.1 + */ + protected function getCommentColorful() + { + if (($colorful = $this->params->get('comments_colorful', 0)) == 1) + { + return " data-colorful=\"1\""; + } + return ''; } /** @@ -307,7 +418,7 @@ class ModDailyScriptureHelper * * @input string $path The path to get remotely * - * @returns object on success + * @returns mixed on success * * @since 1.0 */ @@ -359,7 +470,8 @@ class ModDailyScriptureHelper return $content; } } - return false; + + return null; } /** diff --git a/language/en-GB/en-GB.mod_dailyscripture.ini b/language/en-GB/en-GB.mod_dailyscripture.ini index 2dde901..3e36613 100644 --- a/language/en-GB/en-GB.mod_dailyscripture.ini +++ b/language/en-GB/en-GB.mod_dailyscripture.ini @@ -1,15 +1,22 @@ MOD_DAILYSCRIPTURE="Dailyscripture" -MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture." -MOD_DAILYSCRIPTURE_XML_DESCRIPTION="
Display the daily scripture from https://github.com/trueChristian/daily-scripture.
Created by Llewellyn van der Merwe
Development started 1st January, 2022
A Joomla Module to Display the Daily Scripture.
Created by Llewellyn van der Merwe
Development started 1st January, 2022
The daily scripture architecture is designed to automatically select a random verse from a collection of scripture without any human intervention. The core process of selecting a random verse can be broken down into three main steps: shuffling the verses, choosing the first verse from the shuffled list, and updating the list of used verses.
In summary, the random verse generation process implemented in this script is entirely automated and unbiased, relying on a random sorting algorithm to shuffle the list of verses before selecting one. The system also maintains a list of recently used verses to prevent repetition within a six-month period. This approach ensures a truly unexpected and random selection of verses, free from any human intervention or influence.
" \ No newline at end of file diff --git a/language/en-GB/en-GB.mod_dailyscripture.sys.ini b/language/en-GB/en-GB.mod_dailyscripture.sys.ini index 2dde901..3e36613 100644 --- a/language/en-GB/en-GB.mod_dailyscripture.sys.ini +++ b/language/en-GB/en-GB.mod_dailyscripture.sys.ini @@ -1,15 +1,22 @@ MOD_DAILYSCRIPTURE="Dailyscripture" -MOD_DAILYSCRIPTURE_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture." -MOD_DAILYSCRIPTURE_XML_DESCRIPTION="Display the daily scripture from https://github.com/trueChristian/daily-scripture.
Created by Llewellyn van der Merwe
Development started 1st January, 2022
A Joomla Module to Display the Daily Scripture.
Created by Llewellyn van der Merwe
Development started 1st January, 2022
The daily scripture architecture is designed to automatically select a random verse from a collection of scripture without any human intervention. The core process of selecting a random verse can be broken down into three main steps: shuffling the verses, choosing the first verse from the shuffled list, and updating the list of used verses.
In summary, the random verse generation process implemented in this script is entirely automated and unbiased, relying on a random sorting algorithm to shuffle the list of verses before selecting one. The system also maintains a list of recently used verses to prevent repetition within a six-month period. This approach ensures a truly unexpected and random selection of verses, free from any human intervention or influence.
" \ No newline at end of file diff --git a/mod_dailyscripture.php b/mod_dailyscripture.php index fc6b03a..4667088 100644 --- a/mod_dailyscripture.php +++ b/mod_dailyscripture.php @@ -10,7 +10,7 @@ /------------------------------------------------------------------------------------------------------------------------------------/ - @version 2.0.x + @version 2.1.x @created 22nd October, 2015 @package Sermon Distributor @subpackage mod_dailyscripture.php diff --git a/mod_dailyscripture.xml b/mod_dailyscripture.xml index 10d6c59..d760b06 100644 --- a/mod_dailyscripture.xml +++ b/mod_dailyscripture.xml @@ -1,15 +1,18 @@date; ?>
+ + comments): ?> + comments; ?> get('type', 1) == 2 && $today->telegram): ?> telegram; ?> + comments): ?> + comments; ?> + - +