From ab2a9f0aecd6996f48109a99bc9a6d0c932670ce Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 4 Jan 2022 17:41:07 +0200 Subject: [PATCH] first commit - v1.0.0 --- fields/index.html | 1 + helper.php | 176 ++++++++++++++++++ index.html | 1 + language/en-GB/en-GB.mod_dailyscripture.ini | 8 + .../en-GB/en-GB.mod_dailyscripture.sys.ini | 8 + language/en-GB/index.html | 1 + language/index.html | 1 + mod_dailyscripture.php | 38 ++++ mod_dailyscripture.xml | 55 ++++++ rules/index.html | 1 + tmpl/default.php | 44 +++++ tmpl/index.html | 1 + 12 files changed, 335 insertions(+) create mode 100644 fields/index.html create mode 100644 helper.php create mode 100644 index.html create mode 100644 language/en-GB/en-GB.mod_dailyscripture.ini create mode 100644 language/en-GB/en-GB.mod_dailyscripture.sys.ini create mode 100644 language/en-GB/index.html create mode 100644 language/index.html create mode 100644 mod_dailyscripture.php create mode 100644 mod_dailyscripture.xml create mode 100644 rules/index.html create mode 100644 tmpl/default.php create mode 100644 tmpl/index.html diff --git a/fields/index.html b/fields/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/fields/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/helper.php b/helper.php new file mode 100644 index 0000000..9e2fbc0 --- /dev/null +++ b/helper.php @@ -0,0 +1,176 @@ + + @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'); + +use Joomla\Registry\Registry; + +class ModDailyScriptureHelper +{ + /** + * Scripture + * + * @var array + * @since 1.0 + */ + protected $scripture; + + /** + * Constructor. + * + * @param Registry $params the module settings + * + * @since 1.0 + */ + public function __construct(Registry $params = null) + { + // 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"; + // get the scripture object + $this->scripture = $this->getFileContents($path); + } + + /** + * Waco method to get an scripture value + * + * @param mixed $name Name of the value to retrieve. + * + * @return mixed The request value + * + * @since 1.0 + */ + public function __get($name) + { + if ($this->checkScripture($name)) + { + return $this->scripture->{$name}; + } + return null; + } + + /** + * get the file content + * + * @input string $path The path to get remotely + * + * @returns object on success + * + * @since 1.0 + */ + protected function getFileContents($path) + { + // use basic file get content for now + if (($content = @file_get_contents($path)) !== FALSE) + { + // return if found + if ($this->checkJson($content)) + { + return json_decode($content); + } + } + // use curl if available + elseif (function_exists('curl_version')) + { + // start curl + $ch = curl_init(); + // set the options + $options = array(); + $options[CURLOPT_URL] = $path; + $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; + $options[CURLOPT_RETURNTRANSFER] = TRUE; + $options[CURLOPT_SSL_VERIFYPEER] = FALSE; + // load the options + curl_setopt_array($ch, $options); + // get the content + $content = curl_exec($ch); + // close the connection + curl_close($ch); + // return if found + if ($this->checkJson($content)) + { + return json_decode($content); + } + } + return false; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + * + * @since 1.0 + */ + protected function checkJson($string) + { + if ($this->checkString($string)) + { + json_decode($string); + return (json_last_error() === JSON_ERROR_NONE); + } + return false; + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + * + * @since 1.0 + */ + protected function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } + + /** + * Check if we have an scripture object with value + * + * @input key The key being requested + * + * @returns bool true on success + * + * @since 1.0 + */ + protected function checkScripture($key) + { + if (isset($this->scripture) && is_object($this->scripture) && isset($this->scripture->{$key})) + { + return true; + } + return false; + } + +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/en-GB/en-GB.mod_dailyscripture.ini b/language/en-GB/en-GB.mod_dailyscripture.ini new file mode 100644 index 0000000..4b5b6dd --- /dev/null +++ b/language/en-GB/en-GB.mod_dailyscripture.ini @@ -0,0 +1,8 @@ +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_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER="There was an error, please try again latter." +MOD_DAILYSCRIPTURE_LINK_LABEL="Show Link" +MOD_DAILYSCRIPTURE_LINK_DESCRIPTION="Should we show the link to the daily scripture channel on Telegram." +MOD_DAILYSCRIPTURE_YES="Yes" +MOD_DAILYSCRIPTURE_NO="No" \ 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 new file mode 100644 index 0000000..4b5b6dd --- /dev/null +++ b/language/en-GB/en-GB.mod_dailyscripture.sys.ini @@ -0,0 +1,8 @@ +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_THERE_WAS_AN_ERROR_PLEASE_TRY_AGAIN_LATTER="There was an error, please try again latter." +MOD_DAILYSCRIPTURE_LINK_LABEL="Show Link" +MOD_DAILYSCRIPTURE_LINK_DESCRIPTION="Should we show the link to the daily scripture channel on Telegram." +MOD_DAILYSCRIPTURE_YES="Yes" +MOD_DAILYSCRIPTURE_NO="No" \ No newline at end of file diff --git a/language/en-GB/index.html b/language/en-GB/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/language/en-GB/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/language/index.html b/language/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/language/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/mod_dailyscripture.php b/mod_dailyscripture.php new file mode 100644 index 0000000..e6de29e --- /dev/null +++ b/mod_dailyscripture.php @@ -0,0 +1,38 @@ + + @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'); + +// Include the helper functions only once +JLoader::register('ModDailyScriptureHelper', __DIR__ . '/helper.php'); + +// get the daily scripture +$today = new ModDailyScriptureHelper($params); + +// get the module class sfx (local) +$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8'); + +// load the default Tmpl +require JModuleHelper::getLayoutPath('mod_dailyscripture', $params->get('layout', 'default')); diff --git a/mod_dailyscripture.xml b/mod_dailyscripture.xml new file mode 100644 index 0000000..810196f --- /dev/null +++ b/mod_dailyscripture.xml @@ -0,0 +1,55 @@ + + + MOD_DAILYSCRIPTURE + 4th January, 2022 + Llewellyn van der Merwe + info+joomla@truechristian.church + https://truechristian.church/ + Copyright (C) 2015. All Rights Reserved + GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + 1.0.0 + MOD_DAILYSCRIPTURE_XML_DESCRIPTION + + + + en-GB/en-GB.mod_dailyscripture.ini + en-GB/en-GB.mod_dailyscripture.sys.ini + + + + + mod_dailyscripture.php + helper.php + index.html + language + fields + rules + tmpl + + + + + + +
+ + + + + + +
+
+
+
\ No newline at end of file diff --git a/rules/index.html b/rules/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/rules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tmpl/default.php b/tmpl/default.php new file mode 100644 index 0000000..2597036 --- /dev/null +++ b/tmpl/default.php @@ -0,0 +1,44 @@ + + @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'); + + +?> +scripture): ?> + <get('name_header', 'h3'); ?>>name; ?>get('name_header', 'h3'); ?>> + + get('link', 1) == 1): ?> + date; ?> + + date; ?> + + + + diff --git a/tmpl/index.html b/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file