Adds better linking to Telegram post. Adds comment display options. Adds more detailed information about how this works.

This commit is contained in:
Llewellyn van der Merwe 2023-04-06 01:22:46 +02:00
parent b898ffccae
commit bd4a3197cd
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
8 changed files with 349 additions and 126 deletions

View File

@ -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)
> This **module** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)

View File

@ -10,7 +10,7 @@
/------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x
@version 2.1.x
@created 22nd October, 2015
@package Sermon Distributor
@subpackage helper.php
@ -26,8 +26,6 @@
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
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
{
$this->setTelegram();
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->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 = "<script async src=\"https://telegram.org/js/telegram-widget.js?15\" data-telegram-post=\"daily_scripture/$id\" data-width=\"$width%\"${color}${userpic}${dark}></script>";
$this->telegram = "<script async src=\"https://telegram.org/js/telegram-widget.js?22\" data-telegram-post=\"daily_scripture/$id\" data-width=\"$width%\"${color}${userpic}${dark}></script>";
}
}
/**
* 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 = "<script async src=\"https://telegram.org/js/telegram-widget.js?22\" data-telegram-discussion=\"daily_scripture/$id\" data-comments-limit=\"$limit\"${colorful}${height}${color}${dark}></script>";
}
}
/**
* 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;
}
/**

View File

@ -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="<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_DESCRIPTION="A Joomla Module to Display the Daily Scripture."
MOD_DAILYSCRIPTURE_XML_DESCRIPTION="<h1>Dailyscripture (v.1.1.4)</h1> <div style='clear: both;'></div><p>A Joomla Module to Display the 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_LOADING_THE_DAILY_SCRIPTURE_PLEASE_TRY_AGAIN_LATTER="There was an error loading the Daily Scripture, please try again latter."
MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE="Daily Scripture"
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_DIRECT_FROM_GITHUB="Direct from gitHub"
MOD_DAILYSCRIPTURE_DIRECT_FROM_TELEGRAM="Direct from Telegram"
MOD_DAILYSCRIPTURE_LINK_LABEL="Show Link"
MOD_DAILYSCRIPTURE_LINK_DESCRIPTION="Should we show the link to the daily scripture channel on Telegram."
MOD_DAILYSCRIPTURE_SHOW_COMMENTS_LABEL="Show Comments"
MOD_DAILYSCRIPTURE_SHOW_COMMENTS_DESCRIPTION="The option to load comment below the post"
MOD_DAILYSCRIPTURE_YES="Yes"
MOD_DAILYSCRIPTURE_NO="No"
MOD_DAILYSCRIPTURE_COMMENTS_LIMIT_LABEL="Comments limit"
MOD_DAILYSCRIPTURE_COMMENTS_COLORFUL_LABEL="Use different colors for names"
MOD_DAILYSCRIPTURE_COMMENTS_HEIGHT_LABEL="Comments Height"
MOD_DAILYSCRIPTURE_COMMENTS_HEIGHT_DESCRIPTION="Use 300 for auto height. Any higher value to set custom height, since 300 is the smallest height available."
MOD_DAILYSCRIPTURE_LINK_LABEL="Show Link"
MOD_DAILYSCRIPTURE_LINK_DESCRIPTION="Should we show the link to the daily scripture channel on Telegram."
MOD_DAILYSCRIPTURE_WIDTH_LABEL="Width"
MOD_DAILYSCRIPTURE_AUTHOR_PHOTO_LABEL="Author Photo"
MOD_DAILYSCRIPTURE_AUTO="Auto"
@ -27,3 +34,5 @@ MOD_DAILYSCRIPTURE_CUSTOM_COLOR_LABEL="Custom Color"
MOD_DAILYSCRIPTURE_THEME_LABEL="Theme"
MOD_DAILYSCRIPTURE_LIGHT_THEME="Light Theme"
MOD_DAILYSCRIPTURE_DARK_THEME="Dark Theme"
MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE_NOTE_LABEL="Details"
MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE_NOTE_DESCRIPTION="<h5>Relevant Links:</h5><ul><li><b>Daily scripture</b>: <a href='https://github.com/trueChristian/daily-scripture' target='_blank'>https://github.com/trueChristian/daily-scripture</a>.</li><li><b>Telegram channel</b>: <a href='https://t.me/daily_scripture' target='_blank'>https://t.me/daily_scripture</a>.</li><li><b>Module repository</b>: <a href='https://git.vdm.dev/christian/mod_dailyscripture' target='_blank'>https://git.vdm.dev/christian/mod_dailyscripture</a>.</li></ul><h5>How it works</h5><p>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.</p><ol><li>Shuffling the verses: The script first reads the entire list of verses from a file called &quot;SCRIPTURE&quot; and then shuffles this list using a random sorting algorithm. This ensures that the order of the verses in the list is entirely random and unpredictable. This randomness is crucial, as it eliminates any potential human bias or control over the selection process.</li><li>Choosing the first verse from the shuffled list: Once the list of verses has been randomly shuffled, the script selects the very first verse from this shuffled list. Because the order of the verses is random, the selected verse is also random and unbiased. This chosen verse is then considered the verse of the day.</li><li>Updating the list of used verses: To ensure that the same verse isn't selected again within a short period, the script maintains a separate list of recently used verses, stored in a file called &quot;SCRIPTURE_USED.&quot; After selecting the verse of the day, the script removes it from the main &quot;SCRIPTURE&quot; list and adds it to the &quot;SCRIPTURE_USED&quot; list. Additionally, to prevent the &quot;SCRIPTURE_USED&quot; list from growing indefinitely, the script retains only the last 182 used verses (approximately six months). If the &quot;SCRIPTURE_USED&quot; list grows beyond this limit, the oldest verse in the list is removed and added back to the main &quot;SCRIPTURE&quot; list, making it eligible for selection again.</li></ol><p>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.</p>"

View File

@ -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="<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_DESCRIPTION="A Joomla Module to Display the Daily Scripture."
MOD_DAILYSCRIPTURE_XML_DESCRIPTION="<h1>Dailyscripture (v.1.1.4)</h1> <div style='clear: both;'></div><p>A Joomla Module to Display the 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_LOADING_THE_DAILY_SCRIPTURE_PLEASE_TRY_AGAIN_LATTER="There was an error loading the Daily Scripture, please try again latter."
MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE="Daily Scripture"
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_DIRECT_FROM_GITHUB="Direct from gitHub"
MOD_DAILYSCRIPTURE_DIRECT_FROM_TELEGRAM="Direct from Telegram"
MOD_DAILYSCRIPTURE_LINK_LABEL="Show Link"
MOD_DAILYSCRIPTURE_LINK_DESCRIPTION="Should we show the link to the daily scripture channel on Telegram."
MOD_DAILYSCRIPTURE_SHOW_COMMENTS_LABEL="Show Comments"
MOD_DAILYSCRIPTURE_SHOW_COMMENTS_DESCRIPTION="The option to load comment below the post"
MOD_DAILYSCRIPTURE_YES="Yes"
MOD_DAILYSCRIPTURE_NO="No"
MOD_DAILYSCRIPTURE_COMMENTS_LIMIT_LABEL="Comments limit"
MOD_DAILYSCRIPTURE_COMMENTS_COLORFUL_LABEL="Use different colors for names"
MOD_DAILYSCRIPTURE_COMMENTS_HEIGHT_LABEL="Comments Height"
MOD_DAILYSCRIPTURE_COMMENTS_HEIGHT_DESCRIPTION="Use 300 for auto height. Any higher value to set custom height, since 300 is the smallest height available."
MOD_DAILYSCRIPTURE_LINK_LABEL="Show Link"
MOD_DAILYSCRIPTURE_LINK_DESCRIPTION="Should we show the link to the daily scripture channel on Telegram."
MOD_DAILYSCRIPTURE_WIDTH_LABEL="Width"
MOD_DAILYSCRIPTURE_AUTHOR_PHOTO_LABEL="Author Photo"
MOD_DAILYSCRIPTURE_AUTO="Auto"
@ -27,3 +34,5 @@ MOD_DAILYSCRIPTURE_CUSTOM_COLOR_LABEL="Custom Color"
MOD_DAILYSCRIPTURE_THEME_LABEL="Theme"
MOD_DAILYSCRIPTURE_LIGHT_THEME="Light Theme"
MOD_DAILYSCRIPTURE_DARK_THEME="Dark Theme"
MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE_NOTE_LABEL="Details"
MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE_NOTE_DESCRIPTION="<h5>Relevant Links:</h5><ul><li><b>Daily scripture</b>: <a href='https://github.com/trueChristian/daily-scripture' target='_blank'>https://github.com/trueChristian/daily-scripture</a>.</li><li><b>Telegram channel</b>: <a href='https://t.me/daily_scripture' target='_blank'>https://t.me/daily_scripture</a>.</li><li><b>Module repository</b>: <a href='https://git.vdm.dev/christian/mod_dailyscripture' target='_blank'>https://git.vdm.dev/christian/mod_dailyscripture</a>.</li></ul><h5>How it works</h5><p>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.</p><ol><li>Shuffling the verses: The script first reads the entire list of verses from a file called &quot;SCRIPTURE&quot; and then shuffles this list using a random sorting algorithm. This ensures that the order of the verses in the list is entirely random and unpredictable. This randomness is crucial, as it eliminates any potential human bias or control over the selection process.</li><li>Choosing the first verse from the shuffled list: Once the list of verses has been randomly shuffled, the script selects the very first verse from this shuffled list. Because the order of the verses is random, the selected verse is also random and unbiased. This chosen verse is then considered the verse of the day.</li><li>Updating the list of used verses: To ensure that the same verse isn't selected again within a short period, the script maintains a separate list of recently used verses, stored in a file called &quot;SCRIPTURE_USED.&quot; After selecting the verse of the day, the script removes it from the main &quot;SCRIPTURE&quot; list and adds it to the &quot;SCRIPTURE_USED&quot; list. Additionally, to prevent the &quot;SCRIPTURE_USED&quot; list from growing indefinitely, the script retains only the last 182 used verses (approximately six months). If the &quot;SCRIPTURE_USED&quot; list grows beyond this limit, the oldest verse in the list is removed and added back to the main &quot;SCRIPTURE&quot; list, making it eligible for selection again.</li></ol><p>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.</p>"

View File

@ -10,7 +10,7 @@
/------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x
@version 2.1.x
@created 22nd October, 2015
@package Sermon Distributor
@subpackage mod_dailyscripture.php

View File

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="4" client="site" method="upgrade">
<name>MOD_DAILYSCRIPTURE</name>
<creationDate>7th January, 2022</creationDate>
<creationDate>5th April, 2023</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://www.vdm.io/</authorUrl>
<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>
<version>1.0.1</version>
<version>1.1.4</version>
<description>MOD_DAILYSCRIPTURE_XML_DESCRIPTION</description>
<!-- Scripts to run on installation -->
<scriptfile>script.php</scriptfile>
<!-- Language files -->
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.mod_dailyscripture.ini</language>
@ -29,7 +32,10 @@
</files>
<!-- Config parameter -->
<config>
<config
addrulepath="/administrator/components/com_sermondistributor/models/rules"
addfieldpath="/administrator/components/com_sermondistributor/models/fields"
>
<fields name="params">
<!-- default paths of basic fieldset points to the module -->
<fieldset name="basic" label="basic"
@ -51,6 +57,57 @@
<option value="2">
MOD_DAILYSCRIPTURE_DIRECT_FROM_TELEGRAM</option>
</field>
<!-- Show_comments Field. Type: Radio. (joomla) -->
<field
type="radio"
name="show_comments"
label="MOD_DAILYSCRIPTURE_SHOW_COMMENTS_LABEL"
description="MOD_DAILYSCRIPTURE_SHOW_COMMENTS_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0">
<!-- Option Set. -->
<option value="1">
MOD_DAILYSCRIPTURE_YES</option>
<option value="0">
MOD_DAILYSCRIPTURE_NO</option>
</field>
<!-- Comments_limit Field. Type: Number. (joomla) -->
<field
type="number"
name="comments_limit"
label="MOD_DAILYSCRIPTURE_COMMENTS_LIMIT_LABEL"
class="text_area"
min="1"
max="20"
step="1"
showon="show_comments:1"
/>
<!-- Comments_colorful Field. Type: Radio. (joomla) -->
<field
type="radio"
name="comments_colorful"
label="MOD_DAILYSCRIPTURE_COMMENTS_COLORFUL_LABEL"
class="btn-group btn-group-yesno"
default="0"
showon="show_comments:1">
<!-- Option Set. -->
<option value="1">
MOD_DAILYSCRIPTURE_YES</option>
<option value="0">
MOD_DAILYSCRIPTURE_NO</option>
</field>
<!-- Comments_height Field. Type: Number. (joomla) -->
<field
type="number"
name="comments_height"
label="MOD_DAILYSCRIPTURE_COMMENTS_HEIGHT_LABEL"
description="MOD_DAILYSCRIPTURE_COMMENTS_HEIGHT_DESCRIPTION"
class="text_area"
min="300"
max="2000"
step="10"
showon="show_comments:1"
/>
<!-- Link Field. Type: Radio. (joomla) -->
<field
type="radio"
@ -71,7 +128,6 @@
type="number"
name="width"
label="MOD_DAILYSCRIPTURE_WIDTH_LABEL"
default="100"
class="text_area"
min="10"
max="100"
@ -103,7 +159,7 @@
class="list_class"
multiple="false"
default="1"
showon="type:2">
showon="type:2[OR]show_comments:1">
<!-- Option Set. -->
<option value="1">
MOD_DAILYSCRIPTURE_DEFAULT</option>
@ -126,7 +182,7 @@
name="custom_color"
default="1"
label="MOD_DAILYSCRIPTURE_CUSTOM_COLOR_LABEL"
showon="type:2[AND]color:7"
showon="type:2[AND]color:7[OR]show_comments:1[AND]color:7"
/>
<!-- Theme Field. Type: Radio. (joomla) -->
<field
@ -135,7 +191,7 @@
label="MOD_DAILYSCRIPTURE_THEME_LABEL"
class="btn-group btn-group-yesno"
default="1"
showon="type:2">
showon="type:2[OR]show_comments:1">
<!-- Option Set. -->
<option value="1">
MOD_DAILYSCRIPTURE_LIGHT_THEME</option>
@ -143,6 +199,10 @@
MOD_DAILYSCRIPTURE_DARK_THEME</option>
</field>
</fieldset>
<fieldset name="info" label="MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE">
<!-- Daily_scripture_note Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="daily_scripture_note" label="MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE_NOTE_LABEL" description="MOD_DAILYSCRIPTURE_DAILY_SCRIPTURE_NOTE_DESCRIPTION" heading="h4" class="alert alert-success daily_scripture_note" />
</fieldset>
</fields>
</config>
</extension>

64
script.php Normal file
View File

@ -0,0 +1,64 @@
<?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/
@version 2.1.x
@created 22nd October, 2015
@package Sermon Distributor
@subpackage script.php
@author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Dailyscripture script file.
*
* @package DailyScripture
*/
class mod_DailyScriptureInstallerScript
{
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($route, $adapter)
{
// get application
$app = JFactory::getApplication();
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.8.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
return false;
}
if ('install' === $route)
{
//
}
return true;
}
}

View File

@ -10,7 +10,7 @@
/------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x
@version 2.1.x
@created 22nd October, 2015
@package Sermon Distributor
@subpackage default.php
@ -37,11 +37,16 @@ defined('_JEXEC') or die('Restricted access');
<?php if ($params->get('link', 1) == 1): ?>
<a href="https://t.me/s/<?php echo $today->telegram; ?>" target="_blank"><?php echo $today->date; ?></a>
<?php else: ?>
<br />
<?php echo $today->date; ?>
<p><?php echo $today->date; ?></p>
<?php endif; ?>
<?php if ($today->comments): ?>
<?php echo $today->comments; ?>
<?php endif; ?>
<?php elseif ($params->get('type', 1) == 2 && $today->telegram): ?>
<?php echo $today->telegram; ?>
<?php else: ?>
<?php echo JText::_('MOD_DAILYSCRIPTURE_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER'); ?>
<?php if ($today->comments): ?>
<?php echo $today->comments; ?>
<?php endif; ?>
<?php else: ?>
<?php echo JText::_('MOD_DAILYSCRIPTURE_THERE_WAS_AN_ERROR_LOADING_THE_DAILY_SCRIPTURE_PLEASE_TRY_AGAIN_LATTER'); ?>
<?php endif; ?>