Skip to content

Commit

Permalink
Release of v5.0.0-beta2
Browse files Browse the repository at this point in the history
First release of Sermon Distributor towards Joomla 5. Add PHP check to install/update class. Add Database check and fix to install/update class.
  • Loading branch information
aB0T committed May 3, 2024
1 parent 27a7c03 commit 60e9e3b
Show file tree
Hide file tree
Showing 144 changed files with 3,576 additions and 475 deletions.
19 changes: 11 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# v5.0.0-beta1
# v5.0.0-beta2

- First release of Sermon Distributor towards Joomla 5
- First release of Sermon Distributor towards Joomla 5
- Add PHP check to install/update class
- Add Database check and fix to install/update class

# v4.0.0-beta1
# v4.0.0-beta2

- First release of Sermon Distributor towards Joomla 4
- First release of Sermon Distributor towards Joomla 4
- Add PHP check to install/update class
- Add Database check and fix to install/update class

# v3.0.4
# v3.0.5

- Add the getDocument method call to view
- Add recall tab memory to view tabs
- Add root class calls like \JRoute
- Add PHP check to install/update class
- Add Database check and fix to install/update class
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ The best way to see all your options is to install this component on you Joomla
+ *Author*: [Llewellyn van der Merwe](mailto:[email protected])
+ *Name*: [Sermon Distributor](https://www.vdm.io/)
+ *First Build*: 22nd October, 2015
+ *Last Build*: 7th March, 2024
+ *Last Build*: 3rd May, 2024
+ *Version*: 5.0.x
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html

## Build Time :hourglass:

**245 Hours** or **31 Eight Hour Days** (actual time the author saved -
**263 Hours** or **33 Eight Hour Days** (actual time the author saved -
due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))

> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> never making one mistake or taking any coffee break.)
+ *Line count*: **87680**
+ *File count*: **574**
+ *Folder count*: **120**
+ *Line count*: **94142**
+ *File count*: **602**
+ *Folder count*: **124**

**161 Hours** or **20 Eight Hour Days** (the actual time the author spent)
**173 Hours** or **22 Eight Hour Days** (the actual time the author spent)

> (with the following break down:
> **debugging @61hours** = codingtime / 4;
> **planning @35hours** = codingtime / 7;
> **mapping @24hours** = codingtime / 10;
> **office @41hours** = codingtime / 6;)
> **debugging @66hours** = codingtime / 4;
> **planning @38hours** = codingtime / 7;
> **mapping @26hours** = codingtime / 10;
> **office @44hours** = codingtime / 6;)
**406 Hours** or **51 Eight Hour Days**
**436 Hours** or **55 Eight Hour Days**
(a total of the realistic time frame for this project)

> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)
Project duration: **10.2 weeks** or **2.1 months**
Project duration: **11 weeks** or **2.3 months**

> This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:[email protected])
185 changes: 184 additions & 1 deletion SermondistributorInstallerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\Filesystem\Folder;
use Joomla\Database\DatabaseInterface;
use TrueChristianChurch\Joomla\SermonDistributor\Table\Schema;

// No direct access to this file
defined('_JEXEC') or die;
Expand Down Expand Up @@ -300,11 +301,17 @@ public function preflight(string $type, InstallerAdapter $adapter): bool
// do any updates needed
if ($type === 'update')
{

// Check that the required configuration are set for PHP
$this->phpConfigurationCheck($this->app);
}

// do any install needed
if ($type === 'install')
{

// Check that the required configuration are set for PHP
$this->phpConfigurationCheck($this->app);
}

return true;
Expand Down Expand Up @@ -480,6 +487,10 @@ public function postflight(string $type, InstallerAdapter $adapter): bool
);



// Check that the database is up-to date
$this->databaseSchemaCheck($this->app);

echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://www.vdm.io/" title="Sermon Distributor">
<img src="components/com_sermondistributor/assets/images/vdm-component.jpg"/>
</a></div>';
Expand Down Expand Up @@ -743,10 +754,14 @@ public function postflight(string $type, InstallerAdapter $adapter): bool




// Check that the database is up-to date
$this->databaseSchemaCheck($this->app);

echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://www.vdm.io/" title="Sermon Distributor">
<img src="components/com_sermondistributor/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 5.0.0-beta1 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 5.0.0-beta2 Was Successful! Let us know if anything is not working as expected.</h3></div>';

// Add/Update component in the action logs extensions table.
$this->setActionLogsExtensions();
Expand Down Expand Up @@ -1691,6 +1706,174 @@ protected function removeDatabaseAssetsRulesFix(): void
}
}

/**
* Define the required limits with specific messages for success and warning scenarios
*
* @var array
* @since 3.0.5
*/
protected array $requiredPHPConfigs = [
'upload_max_filesize' => [
'value' => '64M',
'success' => 'The upload_max_filesize is appropriately set to handle large files, which is essential for uploading substantial components and media.',
'warning' => 'The current upload_max_filesize may not support large file uploads effectively, potentially causing failures during component installation.'
],
'post_max_size' => [
'value' => '128M',
'success' => 'The post_max_size setting is sufficient to manage large data submissions, ensuring smooth data processing within forms and uploads.',
'warning' => 'An insufficient post_max_size can lead to truncated data submissions, affecting form functionality and data integrity.'
],
'max_execution_time' => [
'value' => 60,
'success' => 'Max execution time is set high enough to execute complex operations without premature termination, which is crucial for lengthy operations.',
'warning' => 'A low max execution time could lead to script timeouts, especially during intensive operations, which might interrupt execution and cause failures during the compiling of a large extension.'
],
'max_input_vars' => [
'value' => 5000,
'success' => 'The max_input_vars setting supports a high number of input variables, facilitating complex forms and detailed component configurations.',
'warning' => 'Too few max_input_vars may result in lost data during processing complex forms, which can lead to incomplete configurations and operational issues.'
],
'max_input_time' => [
'value' => 60,
'success' => 'Max input time is adequate for processing inputs efficiently during high-load operations, ensuring no premature timeouts.',
'warning' => 'An insufficient max input time could result in incomplete data processing during input-heavy operations, potentially leading to errors and data loss.'
],
'memory_limit' => [
'value' => '256M',
'success' => 'The memory limit is set high to accommodate extensive operations and data processing, which enhances overall performance and stability.',
'warning' => 'A low memory limit can lead to frequent crashes and performance issues, particularly when processing large amounts of data or complex calculations.'
]
];

/**
* Helper function to convert PHP INI memory values to bytes
*
* @param string $value The value to convert
*
* @return int The bytes value
* @since 3.0.5
*/
protected function convertToBytes(string $value): int
{
$value = trim($value);
$lastChar = strtolower($value[strlen($value) - 1]);
$numValue = substr($value, 0, -1);

switch ($lastChar)
{
case 'g':
return $numValue * 1024 * 1024 * 1024;
case 'm':
return $numValue * 1024 * 1024;
case 'k':
return $numValue * 1024;
default:
return (int) $value;
}
}

/**
* Check that the required configurations are set for PHP
*
* @param $app The application
*
* @return void
* @since 3.0.5
*/
protected function phpConfigurationCheck($app): void
{
$showHelp = false;

// Check each configuration and provide detailed feedback
foreach ($this->requiredPHPConfigs as $configName => $configDetails)
{
$currentValue = ini_get($configName);
if ($currentValue === false)
{
$app->enqueueMessage("Error: Unable to retrieve current setting for '{$configName}'.", 'error');
continue;
}

$isMemoryValue = strpbrk($configDetails['value'], 'KMG') !== false;
$requiredValueBytes = $isMemoryValue ? $this->convertToBytes($configDetails['value']) : (int) $configDetails['value'];
$currentValueBytes = $isMemoryValue ? $this->convertToBytes($currentValue) : (int) $currentValue;
$conditionMet = $currentValueBytes >= $requiredValueBytes;

$messageType = $conditionMet ? 'message' : 'warning';
$messageText = $conditionMet ?
"Success: {$configName} is set to {$currentValue}. " . $configDetails['success'] :
"Warning: {$configName} configuration should be at least {$configDetails['value']} but is currently {$currentValue}. " . $configDetails['warning'];
$showHelp = ($showHelp || $messageType === 'warning') ? true : false;
$app->enqueueMessage($messageText, $messageType);
}

if ($showHelp)
{
$app->enqueueMessage('To optimize your Sermon Distributor environment, specific PHP settings must be enhanced.<br>These settings are crucial for ensuring the successful installation and stable functionality of the extension.<br>We\'ve identified that certain configurations currently do not meet the recommended standards.<br>To adjust these settings and prevent potential issues, please consult our detailed guide available at <a href="https://git.vdm.dev/christian/Joomla-Sermon-Distributor/wiki/PHP-Settings" target="_blank">Sermon Distributor PHP Settings Wiki</a>.
', 'notice');
}
}

/**
* Make sure that the sermondistributor database schema is up to date.
*
* @return void
* @since 3.0.5
*/
protected function databaseSchemaCheck($app): void
{
// try to load the schema class
try
{
// make sure the class is loaded
$this->ensureClassExists(
Schema::class
);

// instantiate the schema class and check/update the database
$messages = (new Schema())->update();
}
catch (\Exception $e)
{
$app->enqueueMessage($e->getMessage(), 'warning');
return;
}

foreach ($messages as $message)
{
$app->enqueueMessage($message, 'message');
}
}

/**
* Ensures that a class in the namespace is available.
* If the class is not already loaded, it attempts to load it via the power autoloader.
*
* @param mixed $nameClass The name::class we are looking for.
*
* @return void
* @since 3.0.5
* @throws \Exception If the class could not be loaded.
*/
protected function ensureClassExists($nameClass): void
{
if (!class_exists($nameClass, true))
{
// The power autoloader for this project admin area.
$power_autoloader = JPATH_ADMINISTRATOR . '/components/com_sermondistributor/src/Helper/PowerloaderHelper.php';
if (file_exists($power_autoloader))
{
require_once $power_autoloader;
}

// Check again if the class now exists after requiring it
if (!class_exists($nameClass, true))
{
throw new \Exception("We failed to find/load the $nameClass");
}
}
}

/**
* Method to move folders into place.
*
Expand Down
24 changes: 12 additions & 12 deletions admin/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ The best way to see all your options is to install this component on you Joomla
+ *Author*: [Llewellyn van der Merwe](mailto:[email protected])
+ *Name*: [Sermon Distributor](https://www.vdm.io/)
+ *First Build*: 22nd October, 2015
+ *Last Build*: 7th March, 2024
+ *Last Build*: 3rd May, 2024
+ *Version*: 5.0.x
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html

## Build Time :hourglass:

**245 Hours** or **31 Eight Hour Days** (actual time the author saved -
**263 Hours** or **33 Eight Hour Days** (actual time the author saved -
due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))

> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> never making one mistake or taking any coffee break.)

+ *Line count*: **87680**
+ *File count*: **574**
+ *Folder count*: **120**
+ *Line count*: **94142**
+ *File count*: **602**
+ *Folder count*: **124**

**161 Hours** or **20 Eight Hour Days** (the actual time the author spent)
**173 Hours** or **22 Eight Hour Days** (the actual time the author spent)

> (with the following break down:
> **debugging @61hours** = codingtime / 4;
> **planning @35hours** = codingtime / 7;
> **mapping @24hours** = codingtime / 10;
> **office @41hours** = codingtime / 6;)
> **debugging @66hours** = codingtime / 4;
> **planning @38hours** = codingtime / 7;
> **mapping @26hours** = codingtime / 10;
> **office @44hours** = codingtime / 6;)

**406 Hours** or **51 Eight Hour Days**
**436 Hours** or **55 Eight Hour Days**
(a total of the realistic time frame for this project)

> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)

Project duration: **10.2 weeks** or **2.1 months**
Project duration: **11 weeks** or **2.3 months**

> This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:[email protected])
3 changes: 3 additions & 0 deletions admin/forms/help_document.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
label="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_ADMIN_VIEW_LABEL"
description="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_ADMIN_VIEW_DESCRIPTION"
class="list_class"
layout="joomla.form.field.list-fancy-select"
multiple="false"
default=""
required="true"
Expand All @@ -186,6 +187,7 @@
label="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_SITE_VIEW_LABEL"
description="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_SITE_VIEW_DESCRIPTION"
class="list_class"
layout="joomla.form.field.list-fancy-select"
multiple="false"
required="true"
button="false"
Expand Down Expand Up @@ -221,6 +223,7 @@
name="article"
label="COM_SERMONDISTRIBUTOR_HELP_DOCUMENT_ARTICLE_LABEL"
class="list_class"
layout="joomla.form.field.list-fancy-select"
multiple="false"
default="0"
required="true"
Expand Down
4 changes: 2 additions & 2 deletions admin/layouts/preacher/sermons_fullwidth.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
use TrueChristianChurch\Component\Sermondistributor\Administrator\Helper\SermondistributorHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use TrueChristianChurch\Joomla\Utilities\StringHelper;
use TrueChristianChurch\Joomla\Utilities\ArrayHelper;

// No direct access to this file
defined('_JEXEC') or die;
Expand Down
Loading

0 comments on commit 60e9e3b

Please sign in to comment.