From 908fd6a45a6ca4cc9ff1f499d097463627a8d7a8 Mon Sep 17 00:00:00 2001 From: aB0t Date: Thu, 10 Aug 2023 06:49:04 +0200 Subject: [PATCH] Update on v1.0.5 (beta for next version) Here's an update on the current version, which includes changes towards the next release still in beta. --- README.md | 8 +- admin/README.txt | 8 +- admin/helpers/release_checking.php | 43 +++++++ admin/models/ajax.php | 3 +- admin/models/fields/actionsfiltername.php | 8 +- admin/models/fields/contextsfiltername.php | 8 +- .../fields/releasechecksfiltercreatedby.php | 8 +- .../fields/releasechecksfilteroutcome.php | 14 +-- admin/models/import.php | 2 +- admin/models/rules/int.php | 55 --------- admin/release_checking.php | 43 +++++++ libraries/jcb_powers/.htaccess | 9 ++ .../jcb_powers/VDM.Joomla/index.html | 0 .../VDM.Joomla/src/Utilities/ArrayHelper.php | 107 ++++++++++++++++++ .../VDM.Joomla/src/Utilities/index.html | 1 + libraries/jcb_powers/htaccess.txt | 9 ++ libraries/jcb_powers/index.html | 1 + libraries/jcb_powers/web.config | 7 ++ release_checking.xml | 2 +- 19 files changed, 251 insertions(+), 85 deletions(-) delete mode 100644 admin/models/rules/int.php create mode 100644 libraries/jcb_powers/.htaccess rename index.html => libraries/jcb_powers/VDM.Joomla/index.html (100%) create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Utilities/index.html create mode 100644 libraries/jcb_powers/htaccess.txt create mode 100644 libraries/jcb_powers/index.html create mode 100644 libraries/jcb_powers/web.config diff --git a/README.md b/README.md index fc7f16d..727566b 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ A component to keep track of release checking. + *Author*: [Joomla! Project](mailto:admin@joomla.org) + *Name*: [Track Release Checking](http://www.joomla.org) + *First Build*: 29th July, 2020 -+ *Last Build*: 21st September, 2022 ++ *Last Build*: 10th August, 2023 + *Version*: 1.0.x + *Copyright*: (C) 2020 Open Source Matters, Inc. + *License*: GNU General Public License version 2 or later; see LICENSE.txt ## Some Fun Numbers -+ *Line count*: **22248** -+ *File count*: **213** -+ *Folder count*: **62** \ No newline at end of file ++ *Line count*: **23163** ++ *File count*: **226** ++ *Folder count*: **64** \ No newline at end of file diff --git a/admin/README.txt b/admin/README.txt index fc7f16d..727566b 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -8,13 +8,13 @@ A component to keep track of release checking. + *Author*: [Joomla! Project](mailto:admin@joomla.org) + *Name*: [Track Release Checking](http://www.joomla.org) + *First Build*: 29th July, 2020 -+ *Last Build*: 21st September, 2022 ++ *Last Build*: 10th August, 2023 + *Version*: 1.0.x + *Copyright*: (C) 2020 Open Source Matters, Inc. + *License*: GNU General Public License version 2 or later; see LICENSE.txt ## Some Fun Numbers -+ *Line count*: **22248** -+ *File count*: **213** -+ *Folder count*: **62** \ No newline at end of file ++ *Line count*: **23163** ++ *File count*: **226** ++ *Folder count*: **64** \ No newline at end of file diff --git a/admin/helpers/release_checking.php b/admin/helpers/release_checking.php index 6a35b5b..1d42904 100644 --- a/admin/helpers/release_checking.php +++ b/admin/helpers/release_checking.php @@ -11,6 +11,49 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +// register this component namespace +spl_autoload_register(function ($class) { + // project-specific base directories and namespace prefix + $search = [ + 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla' + ]; + // Start the search and load if found + $found = false; + $found_base_dir = ""; + $found_len = 0; + foreach ($search as $base_dir => $prefix) + { + // does the class use the namespace prefix? + $len = strlen($prefix); + if (strncmp($prefix, $class, $len) === 0) + { + // we have a match so load the values + $found = true; + $found_base_dir = $base_dir; + $found_len = $len; + // done here + break; + } + } + // check if we found a match + if (!$found) + { + // not found so move to the next registered autoloader + return; + } + // get the relative class name + $relative_class = substr($class, $found_len); + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; + // if the file exists, require it + if (file_exists($file)) + { + require $file; + } +}); + use Joomla\CMS\Filesystem\File; use Joomla\CMS\Language\Language; use Joomla\Registry\Registry; diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 51d08f7..9f468fa 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -13,6 +13,7 @@ defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\MVC\Model\ListModel; use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Release_checking Ajax List Model @@ -61,7 +62,7 @@ class Release_checkingModelAjax extends ListModel $query->select($db->quoteName( array('a.id') )); $query->from($db->quoteName('#__release_checking_action', 'a')); // we also filter out the actions this user already did on this context - if (Release_checkingHelper::checkArray($result['removed_ids'])) + if (UtilitiesArrayHelper::check($result['removed_ids'])) { $query->where($db->quoteName('a.id') . ' NOT IN (' . implode(', ', $result['removed_ids']) . ')'); } diff --git a/admin/models/fields/actionsfiltername.php b/admin/models/fields/actionsfiltername.php index d5fb949..27dafcd 100644 --- a/admin/models/fields/actionsfiltername.php +++ b/admin/models/fields/actionsfiltername.php @@ -48,14 +48,14 @@ class JFormFieldActionsfiltername extends JFormFieldList // Reset the query using our newly populated query object. $db->setQuery($query); - $results = $db->loadColumn(); + $_results = $db->loadColumn(); $_filter = array(); $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_NAME') . ' -'); - if ($results) + if ($_results) { - $results = array_unique($results); - foreach ($results as $name) + $_results = array_unique($_results); + foreach ($_results as $name) { // Now add the name and its text to the options array $_filter[] = JHtml::_('select.option', $name, $name); diff --git a/admin/models/fields/contextsfiltername.php b/admin/models/fields/contextsfiltername.php index c68995f..0f9e1a3 100644 --- a/admin/models/fields/contextsfiltername.php +++ b/admin/models/fields/contextsfiltername.php @@ -48,14 +48,14 @@ class JFormFieldContextsfiltername extends JFormFieldList // Reset the query using our newly populated query object. $db->setQuery($query); - $results = $db->loadColumn(); + $_results = $db->loadColumn(); $_filter = array(); $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_RELEASE_CHECKING_FILTER_SELECT_NAME') . ' -'); - if ($results) + if ($_results) { - $results = array_unique($results); - foreach ($results as $name) + $_results = array_unique($_results); + foreach ($_results as $name) { // Now add the name and its text to the options array $_filter[] = JHtml::_('select.option', $name, $name); diff --git a/admin/models/fields/releasechecksfiltercreatedby.php b/admin/models/fields/releasechecksfiltercreatedby.php index d2d9a95..8154702 100644 --- a/admin/models/fields/releasechecksfiltercreatedby.php +++ b/admin/models/fields/releasechecksfiltercreatedby.php @@ -48,13 +48,13 @@ class JFormFieldReleasechecksfiltercreatedby extends JFormFieldList // Reset the query using our newly populated query object. $db->setQuery($query); - $results = $db->loadColumn(); + $_results = $db->loadColumn(); $_filter = array(); - if ($results) + if ($_results) { - $results = array_unique($results); - foreach ($results as $created_by) + $_results = array_unique($_results); + foreach ($_results as $created_by) { // Now add the created_by and its text to the options array $_filter[] = JHtml::_('select.option', $created_by, JFactory::getUser($created_by)->name); diff --git a/admin/models/fields/releasechecksfilteroutcome.php b/admin/models/fields/releasechecksfilteroutcome.php index 8a230b0..0b1ab88 100644 --- a/admin/models/fields/releasechecksfilteroutcome.php +++ b/admin/models/fields/releasechecksfilteroutcome.php @@ -48,20 +48,20 @@ class JFormFieldReleasechecksfilteroutcome extends JFormFieldList // Reset the query using our newly populated query object. $db->setQuery($query); - $results = $db->loadColumn(); + $_results = $db->loadColumn(); $_filter = array(); - if ($results) + if ($_results) { // get release_checksmodel - $model = Release_checkingHelper::getModel('release_checks'); - $results = array_unique($results); - foreach ($results as $outcome) + $_model = Release_checkingHelper::getModel('release_checks'); + $_results = array_unique($_results); + foreach ($_results as $outcome) { // Translate the outcome selection - $text = $model->selectionTranslation($outcome,'outcome'); + $_text = $_model->selectionTranslation($outcome,'outcome'); // Now add the outcome and its text to the options array - $_filter[] = JHtml::_('select.option', $outcome, JText::_($text)); + $_filter[] = JHtml::_('select.option', $outcome, JText::_($_text)); } } return $_filter; diff --git a/admin/models/import.php b/admin/models/import.php index e5934d8..be7b1cb 100644 --- a/admin/models/import.php +++ b/admin/models/import.php @@ -17,7 +17,7 @@ use Joomla\CMS\Filesystem\Folder; use Joomla\Utilities\ArrayHelper; use PhpOffice\PhpSpreadsheet\IOFactory; -/** +/*** * Release_checking Import Base Database Model */ class Release_checkingModelImport extends BaseDatabaseModel diff --git a/admin/models/rules/int.php b/admin/models/rules/int.php deleted file mode 100644 index f6229e1..0000000 --- a/admin/models/rules/int.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * @created 29th July, 2020 - * @copyright (C) 2020 Open Source Matters, Inc. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('JPATH_PLATFORM') or die; - -use Joomla\CMS\Form\Form; -use Joomla\CMS\Form\FormRule; -use Joomla\Registry\Registry; - -/** - * Form Rule (Int) class for the Joomla Platform. - */ -class JFormRuleInt extends FormRule -{ - /** - * Method to test that an integer value was added. - * - * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. - * @param mixed $value The form field value to validate. - * @param string $group The field name group control value. This acts as an array container for the field. - * For example if the field has name="foo" and the group value is set to "bar" then the - * full field name would end up being "bar[foo]". - * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. - * @param Form $form The form object for which the field is being tested. - * - * @return boolean True if the value is valid integer, false otherwise. - * - */ - public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) - { - // Check if the field is required. - $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); - - // If the value is empty and the field is not required return True. - if (($value === '' || $value === null) && ! $required) - { - return true; - } - - // now validate the value to be an integer - // we need to validate a string with the integer in it - // since this is how Joomla passes the value to the test method - // so we use type coercion along with is_numeric - return is_numeric($value) && is_int(+$value); - // if you have a better idea... lets hear it. - } -} diff --git a/admin/release_checking.php b/admin/release_checking.php index 01d3255..acbd8a1 100644 --- a/admin/release_checking.php +++ b/admin/release_checking.php @@ -11,6 +11,49 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +// register this component namespace +spl_autoload_register(function ($class) { + // project-specific base directories and namespace prefix + $search = [ + 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla' + ]; + // Start the search and load if found + $found = false; + $found_base_dir = ""; + $found_len = 0; + foreach ($search as $base_dir => $prefix) + { + // does the class use the namespace prefix? + $len = strlen($prefix); + if (strncmp($prefix, $class, $len) === 0) + { + // we have a match so load the values + $found = true; + $found_base_dir = $base_dir; + $found_len = $len; + // done here + break; + } + } + // check if we found a match + if (!$found) + { + // not found so move to the next registered autoloader + return; + } + // get the relative class name + $relative_class = substr($class, $found_len); + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; + // if the file exists, require it + if (file_exists($file)) + { + require $file; + } +}); + // Access check. diff --git a/libraries/jcb_powers/.htaccess b/libraries/jcb_powers/.htaccess new file mode 100644 index 0000000..9afb1a1 --- /dev/null +++ b/libraries/jcb_powers/.htaccess @@ -0,0 +1,9 @@ +# Apache 2.4+ + + Require all denied + + +# Apache 2.0-2.2 + + Deny from all + diff --git a/index.html b/libraries/jcb_powers/VDM.Joomla/index.html similarity index 100% rename from index.html rename to libraries/jcb_powers/VDM.Joomla/index.html diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php new file mode 100644 index 0000000..70cc939 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php @@ -0,0 +1,107 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +/** + * Some array tricks helper + * + * @since 3.0.9 + */ +abstract class ArrayHelper +{ + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns int|false number of items in array on success + * + * @since 3.2.0 + */ + public static function check($array, $removeEmptyString = false) + { + if (is_array($array) && ($nr = count((array) $array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + $array = array_filter($array); + + if ($array === []) + { + return false; + } + + return count($array); + } + + return $nr; + } + + return false; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array|null merged array on success + * + * @since 3.0.9 + */ + public static function merge($arrays): ?array + { + if(self::check($arrays)) + { + $merged = []; + foreach ($arrays as $array) + { + if (self::check($array)) + { + $merged = array_merge($merged, $array); + } + } + return $merged; + } + return null; + } + + /** + * Check if arrays intersect + * + * @input array The first array + * @input array The second array + * + * @returns bool true if intersect else false + * + * @since 3.1.1 + */ + public static function intersect($a_array, $b_array): bool + { + // flip the second array + $b_array = array_flip($b_array); + + // loop the first array + foreach ($a_array as $v) + { + if (isset($b_array[$v])) + { + return true; + } + } + return false; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/index.html b/libraries/jcb_powers/VDM.Joomla/src/Utilities/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/htaccess.txt b/libraries/jcb_powers/htaccess.txt new file mode 100644 index 0000000..9afb1a1 --- /dev/null +++ b/libraries/jcb_powers/htaccess.txt @@ -0,0 +1,9 @@ +# Apache 2.4+ + + Require all denied + + +# Apache 2.0-2.2 + + Deny from all + diff --git a/libraries/jcb_powers/index.html b/libraries/jcb_powers/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/web.config b/libraries/jcb_powers/web.config new file mode 100644 index 0000000..47b6d6d --- /dev/null +++ b/libraries/jcb_powers/web.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/release_checking.xml b/release_checking.xml index 22fdb1a..f7b0819 100644 --- a/release_checking.xml +++ b/release_checking.xml @@ -1,7 +1,7 @@ COM_RELEASE_CHECKING - 21st September, 2022 + 10th August, 2023 Joomla! Project admin@joomla.org http://www.joomla.org