From 1f98f002acf71b7bdcd5ecd5cf5847d798f64a17 Mon Sep 17 00:00:00 2001 From: Julien Vonthron Date: Sun, 14 Jun 2020 19:52:14 +0200 Subject: [PATCH 01/11] REDCORE-588 working on J4 compatibility --- extensions/install.php | 28 +++++++++---------- .../libraries/redcore/factory/factory.php | 5 +++- .../libraries/redcore/loader/loader.php | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/extensions/install.php b/extensions/install.php index 3d5558334..9382f278e 100644 --- a/extensions/install.php +++ b/extensions/install.php @@ -253,7 +253,7 @@ public function installOrUpdate($parent) */ public function preprocessUpdates($parent) { - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; if (isset($manifest->update)) { @@ -357,7 +357,7 @@ public function preprocessUpdates($parent) */ public function phpUpdates($parent, $executeAfterUpdate) { - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; if (isset($manifest->update)) { @@ -557,7 +557,7 @@ protected function installModules($parent) { // Required objects $installer = $this->getInstaller(); - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; $src = $parent->getParent()->getPath('source'); $nodes = $manifest->modules->module; @@ -600,7 +600,7 @@ protected function installPlugins($parent) { // Required objects $installer = $this->getInstaller(); - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; $src = $parent->getParent()->getPath('source'); $nodes = $manifest->plugins->plugin; @@ -658,7 +658,7 @@ protected function installPlugins($parent) protected function installTranslations($parent) { // Required objects - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; if (method_exists('RTranslationTable', 'batchContentElements')) { @@ -795,7 +795,7 @@ private function installTemplates($parent) { // Required objects $installer = $this->getInstaller(); - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; $src = $parent->getParent()->getPath('source'); $nodes = $manifest->templates->template; @@ -836,7 +836,7 @@ private function installCli($parent) { // Required objects $installer = $this->getInstaller(); - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; $src = $parent->getParent()->getPath('source'); if (!$manifest) @@ -1010,7 +1010,7 @@ public function postflight($type, $parent) $this->installTranslations($parent); /** @var JXMLElement $manifest */ - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; if (in_array($type, array('install', 'update', 'discover_install'))) { @@ -1050,7 +1050,7 @@ public function postflight($type, $parent) */ protected function postFlightFromManifest($type, $parent) { - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; if ($tasks = $manifest->postflight->task) { @@ -1102,7 +1102,7 @@ protected function postFlightFromManifest($type, $parent) protected function deleteMenu($type, $parent, $client = null) { /** @var JXMLElement $manifest */ - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; $attributes = current($manifest->attributes()); // If it's not a component @@ -1268,7 +1268,7 @@ protected function uninstallTranslations($parent) if (method_exists('RTranslationTable', 'batchContentElements')) { // Required objects - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; $class = get_called_class(); $deleteIds = array(); $translationTables = RTranslationTable::getInstalledTranslationTables(true); @@ -1748,7 +1748,7 @@ public function getElement($parent, $manifest = null) if (null === $manifest) { - $manifest = $parent->get('manifest'); + $manifest = $parent->manifest; } if (isset($manifest->element)) @@ -1789,7 +1789,7 @@ protected function loadManifest($parent) // Type not properly detected or not a package if (count($elementParts) !== 2 || strtolower($elementParts[0]) !== 'pkg') { - $this->manifest = $parent->get('manifest'); + $this->manifest = $parent->manifest; return; } @@ -1806,7 +1806,7 @@ protected function loadManifest($parent) return; } - $this->manifest = $parent->get('manifest'); + $this->manifest = $parent->manifest; } /** diff --git a/extensions/libraries/redcore/factory/factory.php b/extensions/libraries/redcore/factory/factory.php index 0f69623f4..90aac6e42 100644 --- a/extensions/libraries/redcore/factory/factory.php +++ b/extensions/libraries/redcore/factory/factory.php @@ -98,7 +98,10 @@ protected static function createDbo() jexit('Database Error: ' . $e->getMessage()); } - $db->setDebug($debug); + if (version_compare(JVERSION, '4.0', 'lt')) + { + $db->setDebug($debug); + } return $db; } diff --git a/extensions/libraries/redcore/loader/loader.php b/extensions/libraries/redcore/loader/loader.php index e606431b6..a4cbd511f 100644 --- a/extensions/libraries/redcore/loader/loader.php +++ b/extensions/libraries/redcore/loader/loader.php @@ -508,7 +508,7 @@ public static function setup($enablePsr = true, $enablePrefixes = true, $enableC if ($enablePrefixes) { // Register the J prefix and base path for Joomla platform libraries. - self::registerPrefix('J', JPATH_PLATFORM . '/joomla'); + spl_autoload_register(array('JLoader', '_autoload'), true, true); // Register the prefix autoloader. spl_autoload_register(array('RLoader', '_autoload'), true, true); From 0e976ed5f8af838ffc58dddddb9d40c8e418381b Mon Sep 17 00:00:00 2001 From: Julien Vonthron Date: Sun, 14 Jun 2020 21:07:44 +0200 Subject: [PATCH 02/11] Installs and load the dashboard --- extensions/libraries/redcore/api/api.php | 28 +++---------------- extensions/libraries/redcore/bootstrap.php | 6 ---- extensions/plugins/system/mvcoverride | 1 - extensions/plugins/system/redcore/redcore.php | 6 ++-- extensions/redcore.xml | 1 - 5 files changed, 8 insertions(+), 34 deletions(-) delete mode 160000 extensions/plugins/system/mvcoverride diff --git a/extensions/libraries/redcore/api/api.php b/extensions/libraries/redcore/api/api.php index b40d4e641..8e6a1bf76 100644 --- a/extensions/libraries/redcore/api/api.php +++ b/extensions/libraries/redcore/api/api.php @@ -9,6 +9,7 @@ defined('JPATH_BASE') or die; +use Joomla\CMS\Factory; use Joomla\Utilities\ArrayHelper; /** @@ -431,14 +432,7 @@ public static function getHeaderVariablesFromGlobals() */ public static function clearHeaders() { - if (version_compare(JVERSION, '3') >= 0) - { - JFactory::getApplication()->clearHeaders(); - } - else - { - JResponse::clearHeaders(); - } + Factory::getApplication()->clearHeaders(); } /** @@ -448,14 +442,7 @@ public static function clearHeaders() */ public static function sendHeaders() { - if (version_compare(JVERSION, '3') >= 0) - { - JFactory::getApplication()->sendHeaders(); - } - else - { - JResponse::sendHeaders(); - } + Factory::getApplication()->sendHeaders(); } /** @@ -471,13 +458,6 @@ public static function sendHeaders() */ public static function setHeader($name, $value, $replace = false) { - if (version_compare(JVERSION, '3') >= 0) - { - JFactory::getApplication()->setHeader($name, $value, $replace); - } - else - { - JResponse::setHeader($name, $value, $replace); - } + Factory::getApplication()->setHeader($name, $value, $replace); } } diff --git a/extensions/libraries/redcore/bootstrap.php b/extensions/libraries/redcore/bootstrap.php index ce8663742..214223838 100644 --- a/extensions/libraries/redcore/bootstrap.php +++ b/extensions/libraries/redcore/bootstrap.php @@ -151,12 +151,6 @@ class_alias('JRegistry', 'Joomla\Registry\Registry'); $lang = JFactory::getLanguage(); $lang->load('lib_redcore', JPATH_REDCORE); - // For Joomla! 2.5 compatibility we add some core functions - if (version_compare(JVERSION, '3.0', '<')) - { - RLoader::registerPrefix('J', JPATH_LIBRARIES . '/redcore/joomla', false, true); - } - // Make available the fields JFormHelper::addFieldPath(JPATH_LIBRARIES . '/redcore/form/fields'); diff --git a/extensions/plugins/system/mvcoverride b/extensions/plugins/system/mvcoverride deleted file mode 160000 index d94750b01..000000000 --- a/extensions/plugins/system/mvcoverride +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d94750b01934d539e600d24a6570dd8aadca1fcc diff --git a/extensions/plugins/system/redcore/redcore.php b/extensions/plugins/system/redcore/redcore.php index 0b4ba1af4..1512f2d4d 100644 --- a/extensions/plugins/system/redcore/redcore.php +++ b/extensions/plugins/system/redcore/redcore.php @@ -7,6 +7,8 @@ * @license GNU General Public License version 2 or later, see LICENSE. */ +use Joomla\CMS\Factory; + defined('JPATH_BASE') or die; /** @@ -197,7 +199,7 @@ public function onAfterRender() } // Get the generated content - $body = JResponse::getBody(); + $body = \Joomla\CMS\Factory::getApplication()->getBody(); // Remove JCaption JS calls $pattern = "/(new JCaption\()(.*)(\);)/isU"; @@ -207,7 +209,7 @@ public function onAfterRender() // Null window.addEvent( calls $pattern = "/(window.addEvent\()(.*)(,)/isU"; $body = preg_replace($pattern, 'do_nothing(', $body); - JResponse::setBody($body); + Factory::getApplication()->setBody($body); return true; } diff --git a/extensions/redcore.xml b/extensions/redcore.xml index 1c5a8d360..b7f4dd521 100644 --- a/extensions/redcore.xml +++ b/extensions/redcore.xml @@ -96,7 +96,6 @@ - From 3f646e8af4f2a12d609917989ccb84f279da9e48 Mon Sep 17 00:00:00 2001 From: Julien Vonthron Date: Sun, 14 Jun 2020 21:22:35 +0200 Subject: [PATCH 03/11] Added dispatcher adapter --- .../libraries/redcore/factory/factory.php | 10 +-- .../libraries/redcore/helper/dispatcher.php | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 extensions/libraries/redcore/helper/dispatcher.php diff --git a/extensions/libraries/redcore/factory/factory.php b/extensions/libraries/redcore/factory/factory.php index 90aac6e42..fbc91519f 100644 --- a/extensions/libraries/redcore/factory/factory.php +++ b/extensions/libraries/redcore/factory/factory.php @@ -28,17 +28,11 @@ final class RFactory extends JFactory /** * Get the event dispatcher * - * @return JEventDispatcher + * @return RHelperDispatcher */ public static function getDispatcher() { - if (!self::$dispatcher) - { - self::$dispatcher = version_compare(JVERSION, '3.0', 'lt') ? - JDispatcher::getInstance() : JEventDispatcher::getInstance(); - } - - return self::$dispatcher; + return RHelperDispatcher::getInstance(); } /** diff --git a/extensions/libraries/redcore/helper/dispatcher.php b/extensions/libraries/redcore/helper/dispatcher.php new file mode 100644 index 000000000..57643348c --- /dev/null +++ b/extensions/libraries/redcore/helper/dispatcher.php @@ -0,0 +1,64 @@ +triggerEvent($event, $args); + } +} \ No newline at end of file From 95dc92e97640af865c0c253889800d83e7612c03 Mon Sep 17 00:00:00 2001 From: Julien Vonthron Date: Mon, 15 Jun 2020 00:15:08 +0200 Subject: [PATCH 04/11] Saving redCORE config works --- .../com_redcore/admin/models/config.php | 2 +- .../libraries/redcore/controller/form.php | 2 + extensions/libraries/redcore/form/form.php | 263 ++++++------------ extensions/libraries/redcore/html/html.php | 3 +- .../redcore/layouts/toolbar/button/modal.php | 6 +- .../layouts/toolbar/button/standard.php | 6 +- 6 files changed, 101 insertions(+), 181 deletions(-) diff --git a/extensions/components/com_redcore/admin/models/config.php b/extensions/components/com_redcore/admin/models/config.php index 3f7086c6b..4276768c6 100644 --- a/extensions/components/com_redcore/admin/models/config.php +++ b/extensions/components/com_redcore/admin/models/config.php @@ -191,7 +191,7 @@ public function save($data) } // Trigger the onConfigurationBeforeSave event. - $result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, $table, $isNew)); + $result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, $table, $isNew, [])); if (in_array(false, $result, true)) { diff --git a/extensions/libraries/redcore/controller/form.php b/extensions/libraries/redcore/controller/form.php index 60faf6202..42b247402 100644 --- a/extensions/libraries/redcore/controller/form.php +++ b/extensions/libraries/redcore/controller/form.php @@ -32,6 +32,8 @@ class RControllerForm extends JControllerForm */ public function __construct($config = array()) { + parent::__construct($config); + /** JControllerLegacy */ $this->methods = array(); $this->message = null; diff --git a/extensions/libraries/redcore/form/form.php b/extensions/libraries/redcore/form/form.php index aac671f9d..7353484b5 100644 --- a/extensions/libraries/redcore/form/form.php +++ b/extensions/libraries/redcore/form/form.php @@ -7,216 +7,127 @@ * @license GNU General Public License version 2 or later, see LICENSE. */ +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Form\FormRule; + defined('JPATH_REDCORE') or die; -if (version_compare(JVERSION, '3.0', 'lt')) +/** + * Form class. + * + * @package Redcore + * @subpackage Form + * @since 1.0 + */ +class RForm extends RFormBase { /** - * Form class. + * Method to validate a JFormField object based on field data. + * + * @param SimpleXMLElement $element The XML element object representation of the form field. + * @param string $group The optional dot-separated form group path on which to find the field. + * @param mixed $value The optional value to use as the default for the field. + * @param JRegistry $input An optional JRegistry object with the entire data set to validate + * against the entire form. * - * @package Redcore - * @subpackage Form - * @since 1.0 + * @return mixed Boolean true if field value is valid, Exception on failure. + * + * @throws InvalidArgumentException + * @throws UnexpectedValueException */ - class RForm extends RFormBase + protected function validateField(SimpleXMLElement $element, $group = null, $value = null, JRegistry $input = null) { - /** - * Method to validate a JFormField object based on field data. - * - * @param SimpleXMLElement $element The XML element object representation of the form field. - * @param string $group The optional dot-separated form group path on which to find the field. - * @param mixed $value The optional value to use as the default for the field. - * @param JRegistry $input An optional JRegistry object with the entire data set to validate - * against the entire form. - * - * @return mixed Boolean true if field value is valid, Exception on failure. - * - * @throws InvalidArgumentException - * @throws UnexpectedValueException - */ - protected function validateField($element, $group = null, $value = null, $input = null) - { - $valid = true; + $valid = true; - // Check if the field is required. - $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); + // Check if the field is required. + $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); - if ($required) + if ($required) + { + // If the field is required and the value is empty return an error message. + if (($value === '') || ($value === null)) { - // If the field is required and the value is empty return an error message. - if (($value === '') || ($value === null)) + if ($element['label']) { - if ($element['label']) - { - $message = JText::_($element['label']); - } - else - { - $message = JText::_($element['name']); - } - - $message = JText::sprintf('JLIB_FORM_VALIDATE_FIELD_REQUIRED', $message); - - return new RuntimeException($message); + $message = JText::_($element['label']); } - } - - // Get the field validation rule. - if ($type = (string) $element['validate']) - { - // Load the JFormRule object for the field. - $rule = $this->loadRuleType($type); - - // If the object could not be loaded return an error message. - if ($rule === false) + else { - throw new UnexpectedValueException(sprintf('%s::validateField() rule `%s` missing.', get_class($this), $type)); + $message = JText::_($element['name']); } - // Run the field validation rule test. - $valid = $rule->test($element, $value, $group, $input, $this); + $message = JText::sprintf('JLIB_FORM_VALIDATE_FIELD_REQUIRED', $message); - // Check for an error in the validation test. - if ($valid instanceof Exception) - { - return $valid; - } + return new RuntimeException($message); } + } - // Check if the field is valid. - if ($valid === false) - { - // Does the field have a defined error message? - $message = (string) $element['message']; - - if ($message) - { - $message = JText::_($element['message']); - - // Trick to use attributes as an array - $tags = current($element->attributes()); - $tags['value'] = $value; + // Get the field validation rule. + if ($type = (string) $element['validate']) + { + // Load the JFormRule object for the field. + $rule = $this->loadRuleType($type); - $message = RText::replace($message, $tags); + // If the object could not be loaded return an error message. + if ($rule === false) + { + throw new UnexpectedValueException(sprintf('%s::validateField() rule `%s` missing.', get_class($this), $type)); + } - return new UnexpectedValueException($message); - } - else - { - $message = JText::_($element['label']); - $message = JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $message); + // Run the field validation rule test. + $valid = $rule->test($element, $value, $group, $input, $this); - return new UnexpectedValueException($message); - } + // Check for an error in the validation test. + if ($valid instanceof Exception) + { + return $valid; } - - return true; } - } -} -else -{ - /** - * Form class. - * - * @package Redcore - * @subpackage Form - * @since 1.0 - */ - class RForm extends RFormBase - { - /** - * Method to validate a JFormField object based on field data. - * - * @param SimpleXMLElement $element The XML element object representation of the form field. - * @param string $group The optional dot-separated form group path on which to find the field. - * @param mixed $value The optional value to use as the default for the field. - * @param JRegistry $input An optional JRegistry object with the entire data set to validate - * against the entire form. - * - * @return mixed Boolean true if field value is valid, Exception on failure. - * - * @throws InvalidArgumentException - * @throws UnexpectedValueException - */ - protected function validateField(SimpleXMLElement $element, $group = null, $value = null, JRegistry $input = null) + // Check if the field is valid. + if ($valid === false) { - $valid = true; - - // Check if the field is required. - $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); - - if ($required) - { - // If the field is required and the value is empty return an error message. - if (($value === '') || ($value === null)) - { - if ($element['label']) - { - $message = JText::_($element['label']); - } - else - { - $message = JText::_($element['name']); - } - - $message = JText::sprintf('JLIB_FORM_VALIDATE_FIELD_REQUIRED', $message); - - return new RuntimeException($message); - } - } + // Does the field have a defined error message? + $message = (string) $element['message']; - // Get the field validation rule. - if ($type = (string) $element['validate']) + if ($message) { - // Load the JFormRule object for the field. - $rule = $this->loadRuleType($type); + $message = JText::_($element['message']); - // If the object could not be loaded return an error message. - if ($rule === false) - { - throw new UnexpectedValueException(sprintf('%s::validateField() rule `%s` missing.', get_class($this), $type)); - } + // Trick to use attributes as an array + $tags = current($element->attributes()); + $tags['value'] = $value; - // Run the field validation rule test. - $valid = $rule->test($element, $value, $group, $input, $this); + $message = RText::replace($message, $tags); - // Check for an error in the validation test. - if ($valid instanceof Exception) - { - return $valid; - } + return new UnexpectedValueException($message); } - - // Check if the field is valid. - if ($valid === false) + else { - // Does the field have a defined error message? - $message = (string) $element['message']; - - if ($message) - { - $message = JText::_($element['message']); - - // Trick to use attributes as an array - $tags = current($element->attributes()); - $tags['value'] = $value; + $message = JText::_($element['label']); + $message = JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $message); - $message = RText::replace($message, $tags); - - return new UnexpectedValueException($message); - } - else - { - $message = JText::_($element['label']); - $message = JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', $message); - - return new UnexpectedValueException($message); - } + return new UnexpectedValueException($message); } - - return true; } + + return true; + } + + /** + * Proxy for FormHelper::loadRuleType(). + * + * @param string $type The rule type. + * @param boolean $new Flag to toggle whether we should get a new instance of the object. + * + * @return FormRule|boolean FormRule object on success, false otherwise. + * + * @see FormHelper::loadRuleType() + * @since 1.7.0 + * @deprecated 4.0 Use FormHelper::loadRuleType() directly + */ + protected function loadRuleType($type, $new = true) + { + return FormHelper::loadRuleType($type, $new); } } diff --git a/extensions/libraries/redcore/html/html.php b/extensions/libraries/redcore/html/html.php index bf1e7a4ca..4cc9bd1d8 100644 --- a/extensions/libraries/redcore/html/html.php +++ b/extensions/libraries/redcore/html/html.php @@ -684,8 +684,7 @@ public static function stylesheet($file, $attribs = array(), $relative = false, */ public static function script($file, $framework = false, $relative = false, $path_only = false, $detect_browser = true, $detect_debug = true) { - // Include MooTools framework - if ($framework) + if ($framework && version_compare(JVERSION, '4.0.0', 'lt')) { static::_('behavior.framework'); } diff --git a/extensions/libraries/redcore/layouts/toolbar/button/modal.php b/extensions/libraries/redcore/layouts/toolbar/button/modal.php index 3c6904fd9..56da79d1a 100644 --- a/extensions/libraries/redcore/layouts/toolbar/button/modal.php +++ b/extensions/libraries/redcore/layouts/toolbar/button/modal.php @@ -56,7 +56,11 @@ if ($isList) { // Get the button command. - JHtml::_('behavior.framework'); + if (version_compare(JVERSION, '4.0.0', 'lt')) + { + JHtml::_('behavior.framework'); + } + $message = JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'); $message = addslashes($message); $cmd = "if (document.adminForm.boxchecked.value == 0) {alert('" . $message . "');jQuery('#" . $dataTarget . "').modal('hide');} diff --git a/extensions/libraries/redcore/layouts/toolbar/button/standard.php b/extensions/libraries/redcore/layouts/toolbar/button/standard.php index 8f7738698..61a6f6b5b 100644 --- a/extensions/libraries/redcore/layouts/toolbar/button/standard.php +++ b/extensions/libraries/redcore/layouts/toolbar/button/standard.php @@ -27,7 +27,11 @@ $class = $button->getClass(); // Get the button command. -JHtml::_('behavior.framework'); +if (version_compare(JVERSION, '4.0', '<')) +{ + JHtml::_('behavior.framework'); +} + $message = JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'); $message = addslashes($message); From 214f3ad32892c9e85fdad2e19910f6f504383a6f Mon Sep 17 00:00:00 2001 From: Volodymyr Shandak Date: Tue, 10 Aug 2021 12:27:47 +0300 Subject: [PATCH 05/11] fix installer --- extensions/install.php | 6 ++---- extensions/redcore.xml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/extensions/install.php b/extensions/install.php index fb5aed865..3a4f31640 100644 --- a/extensions/install.php +++ b/extensions/install.php @@ -69,10 +69,7 @@ class Com_RedcoreInstallerScript */ public function getInstaller() { - if (null === $this->installer) - { - $this->installer = new JInstaller; - } + $this->installer = new JInstaller; return $this->installer; } @@ -501,6 +498,7 @@ private function installLibraries($parent) $installer = $this->getInstaller(); $manifest = $this->getManifest($parent); $src = $parent->getParent()->getPath('source'); + $installer->setAdapter('library'); if ($nodes = $manifest->libraries->library) { diff --git a/extensions/redcore.xml b/extensions/redcore.xml index 485006088..2d36dde9b 100644 --- a/extensions/redcore.xml +++ b/extensions/redcore.xml @@ -7,7 +7,7 @@ redweb.dk Copyright (C) 2008 - 2021 redWEB.dk. All rights reserved. GNU General Public License version 2 or later, see LICENSE. - 2.2.2 + 2.2.3 beta1 COM_REDCORE_DESC install.php From 64ad251ecf9ef72097639ccb8bbecc6c8f5f498e Mon Sep 17 00:00:00 2001 From: Volodymyr Shandak Date: Tue, 26 Oct 2021 10:39:15 +0300 Subject: [PATCH 06/11] ready for J4 --- .../redcore/media/redcore/less/component.less | 3 ++ .../redcore/media/redcore/less/navbar.less | 1 + .../admin/sql/install/mysql/install.sql | 22 +++++++------- .../admin/sql/updates/mysql/1.4.7.sql | 4 +-- .../admin/sql/updates/mysql/1.5.4.sql | 8 ++--- .../admin/sql/updates/mysql/1.8.3.sql | 8 ++--- .../admin/sql/updates/mysql/1.9.0.sql | 2 +- .../admin/sql/updates/mysql/2.2.4.sql | 11 +++++++ .../admin/views/config/tmpl/edit.php | 10 +------ .../admin/views/oauth_client/tmpl/default.php | 1 + .../admin/views/oauth_clients/view.html.php | 5 +++- .../payment_configuration/tmpl/default.php | 1 + .../payment_configurations/view.html.php | 5 +++- .../admin/views/payments/view.html.php | 5 +++- .../views/translation_tables/view.html.php | 5 +++- .../admin/views/webservices/tmpl/default.php | 1 + .../admin/views/webservices/view.html.php | 5 +++- .../libraries/redcore/controller/form.php | 30 +++++++------------ .../libraries/redcore/database/driver.php | 2 +- .../libraries/redcore/factory/factory.php | 6 ++++ .../libraries/redcore/form/fields/rrules.php | 5 +++- extensions/libraries/redcore/html/html.php | 2 +- extensions/redcore.xml | 2 +- 23 files changed, 84 insertions(+), 60 deletions(-) create mode 100644 extensions/components/com_redcore/admin/sql/updates/mysql/2.2.4.sql diff --git a/build/media/libraries/redcore/media/redcore/less/component.less b/build/media/libraries/redcore/media/redcore/less/component.less index 084024770..372c88b4c 100644 --- a/build/media/libraries/redcore/media/redcore/less/component.less +++ b/build/media/libraries/redcore/media/redcore/less/component.less @@ -103,6 +103,9 @@ .redcore { padding-top: 40px; + * { + box-sizing: unset; + } .content { margin-top: 10px; padding-bottom: 40px; diff --git a/build/media/libraries/redcore/media/redcore/less/navbar.less b/build/media/libraries/redcore/media/redcore/less/navbar.less index d6102b7c9..f21da974e 100644 --- a/build/media/libraries/redcore/media/redcore/less/navbar.less +++ b/build/media/libraries/redcore/media/redcore/less/navbar.less @@ -1,4 +1,5 @@ .navbar { + padding-top: 0; a.brand, a { color: #b7b7b7; diff --git a/extensions/components/com_redcore/admin/sql/install/mysql/install.sql b/extensions/components/com_redcore/admin/sql/install/mysql/install.sql index afa9c9000..46ac6741f 100644 --- a/extensions/components/com_redcore/admin/sql/install/mysql/install.sql +++ b/extensions/components/com_redcore/admin/sql/install/mysql/install.sql @@ -174,7 +174,7 @@ CREATE TABLE IF NOT EXISTS `#__redcore_payments` ( `coupon_code` VARCHAR(255) NOT NULL DEFAULT '', `customer_note` VARCHAR(2000) NOT NULL DEFAULT '', `status` VARCHAR(32) NOT NULL DEFAULT '', - `params` TEXT NOT NULL, + `params` TEXT, `retry_counter` TINYINT(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `idx_extension_order_id` (`extension_name`, `order_id`), @@ -195,8 +195,8 @@ CREATE TABLE IF NOT EXISTS `#__redcore_payment_log` ( `ip_address` VARCHAR(100) NOT NULL DEFAULT '', `referrer` VARCHAR(2000) NOT NULL DEFAULT '', `message_uri` VARCHAR(2000) NOT NULL DEFAULT '', - `message_post` TEXT NOT NULL, - `message_text` TEXT NOT NULL, + `message_post` TEXT, + `message_text` TEXT, `status` VARCHAR(32) NOT NULL DEFAULT '', `transaction_id` VARCHAR(255) NOT NULL DEFAULT '', `customer_note` VARCHAR(2000) NOT NULL DEFAULT '', @@ -213,7 +213,7 @@ CREATE TABLE IF NOT EXISTS `#__redcore_payment_configuration` ( `extension_name` VARCHAR(255) NOT NULL DEFAULT '', `owner_name` VARCHAR(255) NOT NULL DEFAULT '', `payment_name` VARCHAR(50) NOT NULL DEFAULT '', - `params` TEXT NOT NULL, + `params` TEXT, `state` TINYINT(1) NOT NULL DEFAULT '1', `checked_out` INT(11) NULL DEFAULT NULL, `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -236,8 +236,8 @@ CREATE TABLE IF NOT EXISTS `#__redcore_webservices` ( `path` VARCHAR(255) NOT NULL DEFAULT '', `xmlFile` VARCHAR(255) NOT NULL DEFAULT '', `xmlHashed` VARCHAR(32) NOT NULL DEFAULT '', - `operations` TEXT NULL, - `scopes` TEXT NULL, + `operations` TEXT, + `scopes` TEXT, `client` VARCHAR(15) NOT NULL DEFAULT 'site', `state` TINYINT(1) NOT NULL DEFAULT '1', `checked_out` INT(11) NULL DEFAULT NULL, @@ -262,11 +262,11 @@ CREATE TABLE IF NOT EXISTS `#__redcore_translation_tables` ( `primary_columns` VARCHAR(100) NOT NULL DEFAULT 'id', `translate_columns` VARCHAR(500) NOT NULL DEFAULT '', `fallback_columns` VARCHAR(500) NOT NULL DEFAULT '', - `form_links` TEXT NULL, + `form_links` TEXT, `xml_path` VARCHAR(500) NOT NULL DEFAULT '', `xml_hashed` VARCHAR(32) NOT NULL DEFAULT '', `filter_query` VARCHAR(255) NOT NULL DEFAULT '', - `params` TEXT NOT NULL, + `params` TEXT, `state` TINYINT(1) NOT NULL DEFAULT '1', `checked_out` INT(11) NULL DEFAULT NULL, `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -290,8 +290,8 @@ CREATE TABLE IF NOT EXISTS `#__redcore_translation_columns` ( `value_type` VARCHAR(45) NOT NULL DEFAULT 'text', `fallback` TINYINT(1) NOT NULL DEFAULT '0', `filter` VARCHAR(50) NOT NULL DEFAULT 'RAW', - `description` TEXT NOT NULL, - `params` TEXT NOT NULL, + `description` TEXT, + `params` TEXT, PRIMARY KEY (`id`), UNIQUE KEY `unq_translation_columns_keys` (`translation_table_id`, `name`), KEY `idx_translation_columns_keys` (`translation_table_id`) @@ -305,7 +305,7 @@ SET FOREIGN_KEY_CHECKS = 1; CREATE TABLE IF NOT EXISTS `#__redcore_schemas` ( `asset_id` varchar(255) NOT NULL, - `fields` text NOT NULL, + `fields` text, `cached_on` datetime NOT NULL, PRIMARY KEY (`asset_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/extensions/components/com_redcore/admin/sql/updates/mysql/1.4.7.sql b/extensions/components/com_redcore/admin/sql/updates/mysql/1.4.7.sql index aba17c106..6ace15860 100644 --- a/extensions/components/com_redcore/admin/sql/updates/mysql/1.4.7.sql +++ b/extensions/components/com_redcore/admin/sql/updates/mysql/1.4.7.sql @@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS `#__redcore_webservices` ( `path` VARCHAR(255) NOT NULL DEFAULT '', `xmlFile` VARCHAR(255) NOT NULL DEFAULT '', `xmlHashed` VARCHAR(32) NOT NULL DEFAULT '', - `operations` TEXT NULL, - `scopes` TEXT NULL, + `operations` TEXT, + `scopes` TEXT, `client` VARCHAR(15) NOT NULL DEFAULT 'site', `state` TINYINT(1) NOT NULL DEFAULT '1', `checked_out` INT(11) NULL DEFAULT NULL, diff --git a/extensions/components/com_redcore/admin/sql/updates/mysql/1.5.4.sql b/extensions/components/com_redcore/admin/sql/updates/mysql/1.5.4.sql index 27a3c8680..5f3b6e5ed 100644 --- a/extensions/components/com_redcore/admin/sql/updates/mysql/1.5.4.sql +++ b/extensions/components/com_redcore/admin/sql/updates/mysql/1.5.4.sql @@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS `#__redcore_payments` ( `coupon_code` VARCHAR(255) NOT NULL DEFAULT '', `customer_note` VARCHAR(2000) NOT NULL DEFAULT '', `status` VARCHAR(32) NOT NULL DEFAULT '', - `params` TEXT NOT NULL, + `params` TEXT, `retry_counter` TINYINT(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `idx_extension_order_id` (`extension_name`, `order_id`), @@ -100,8 +100,8 @@ CREATE TABLE IF NOT EXISTS `#__redcore_payment_log` ( `ip_address` VARCHAR(100) NOT NULL DEFAULT '', `referrer` VARCHAR(2000) NOT NULL DEFAULT '', `message_uri` VARCHAR(2000) NOT NULL DEFAULT '', - `message_post` TEXT NOT NULL, - `message_text` TEXT NOT NULL, + `message_post` TEXT, + `message_text` TEXT, `status` VARCHAR(32) NOT NULL DEFAULT '', `transaction_id` VARCHAR(255) NOT NULL DEFAULT '', `customer_note` VARCHAR(2000) NOT NULL DEFAULT '', @@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS `#__redcore_payment_configuration` ( `extension_name` VARCHAR(255) NOT NULL DEFAULT '', `owner_name` VARCHAR(255) NOT NULL DEFAULT '', `payment_name` VARCHAR(50) NOT NULL DEFAULT '', - `params` TEXT NOT NULL, + `params` TEXT, `state` TINYINT(1) NOT NULL DEFAULT '1', `checked_out` INT(11) NULL DEFAULT NULL, `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', diff --git a/extensions/components/com_redcore/admin/sql/updates/mysql/1.8.3.sql b/extensions/components/com_redcore/admin/sql/updates/mysql/1.8.3.sql index a75f728d8..2f3a83b6a 100644 --- a/extensions/components/com_redcore/admin/sql/updates/mysql/1.8.3.sql +++ b/extensions/components/com_redcore/admin/sql/updates/mysql/1.8.3.sql @@ -12,11 +12,11 @@ CREATE TABLE IF NOT EXISTS `#__redcore_translation_tables` ( `primary_columns` VARCHAR(100) NOT NULL DEFAULT 'id', `translate_columns` VARCHAR(500) NOT NULL DEFAULT '', `fallback_columns` VARCHAR(500) NOT NULL DEFAULT '', - `form_links` TEXT NULL, + `form_links` TEXT, `xml_path` VARCHAR(500) NOT NULL DEFAULT '', `xml_hashed` VARCHAR(32) NOT NULL DEFAULT '', `filter_query` VARCHAR(255) NOT NULL DEFAULT '', - `params` TEXT NOT NULL, + `params` TEXT, `state` TINYINT(1) NOT NULL DEFAULT '1', `checked_out` INT(11) NULL DEFAULT NULL, `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -40,8 +40,8 @@ CREATE TABLE IF NOT EXISTS `#__redcore_translation_columns` ( `value_type` VARCHAR(45) NOT NULL DEFAULT 'text', `fallback` TINYINT(1) NOT NULL DEFAULT '0', `filter` VARCHAR(50) NOT NULL DEFAULT 'RAW', - `description` TEXT NOT NULL, - `params` TEXT NOT NULL, + `description` TEXT, + `params` TEXT, PRIMARY KEY (`id`), UNIQUE KEY `unq_translation_columns_keys` (`translation_table_id`, `name`), KEY `idx_translation_columns_keys` (`translation_table_id`) diff --git a/extensions/components/com_redcore/admin/sql/updates/mysql/1.9.0.sql b/extensions/components/com_redcore/admin/sql/updates/mysql/1.9.0.sql index 2fd451d25..4869cf920 100644 --- a/extensions/components/com_redcore/admin/sql/updates/mysql/1.9.0.sql +++ b/extensions/components/com_redcore/admin/sql/updates/mysql/1.9.0.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS `#__redcore_schemas` ( `asset_id` varchar(255) NOT NULL, - `fields` text NOT NULL, + `fields` text, `cached_on` datetime NOT NULL, PRIMARY KEY (`asset_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/extensions/components/com_redcore/admin/sql/updates/mysql/2.2.4.sql b/extensions/components/com_redcore/admin/sql/updates/mysql/2.2.4.sql new file mode 100644 index 000000000..ea07ea485 --- /dev/null +++ b/extensions/components/com_redcore/admin/sql/updates/mysql/2.2.4.sql @@ -0,0 +1,11 @@ +ALTER TABLE `#__redcore_payments` CHANGE `params` `params` TEXT; +ALTER TABLE `#__redcore_payment_log` CHANGE `message_post` `message_post` TEXT; +ALTER TABLE `#__redcore_payment_log` CHANGE `message_text` `message_text` TEXT; +ALTER TABLE `#__redcore_payment_configuration` CHANGE `params` `params` TEXT; +ALTER TABLE `#__redcore_webservices` CHANGE `operations` `operations` TEXT; +ALTER TABLE `#__redcore_webservices` CHANGE `scopes` `scopes` TEXT; +ALTER TABLE `#__redcore_translation_tables` CHANGE `form_links` `form_links` TEXT; +ALTER TABLE `#__redcore_translation_tables` CHANGE `params` `params` TEXT; +ALTER TABLE `#__redcore_translation_columns` CHANGE `description` `description` TEXT; +ALTER TABLE `#__redcore_translation_columns` CHANGE `params` `params` TEXT; +ALTER TABLE `#__redcore_schemas` CHANGE `fields` `fields` TEXT; diff --git a/extensions/components/com_redcore/admin/views/config/tmpl/edit.php b/extensions/components/com_redcore/admin/views/config/tmpl/edit.php index d4dfecd8a..70f7f70cd 100644 --- a/extensions/components/com_redcore/admin/views/config/tmpl/edit.php +++ b/extensions/components/com_redcore/admin/views/config/tmpl/edit.php @@ -22,15 +22,7 @@ JHtml::_('behavior.keepalive'); JHtml::_('rbootstrap.tooltip'); JHtml::_('rjquery.chosen', 'select'); - -if (version_compare(JVERSION, '3.4') >= 0) -{ - JHtml::_('behavior.formvalidator'); -} -else -{ - JHTML::_('behavior.formvalidation'); -} +JHtml::_('behavior.formvalidator'); JFactory::getDocument()->addScriptDeclaration( 'Joomla.submitbutton = function(task){ diff --git a/extensions/components/com_redcore/admin/views/oauth_client/tmpl/default.php b/extensions/components/com_redcore/admin/views/oauth_client/tmpl/default.php index 10dce89fc..15aea6ee6 100644 --- a/extensions/components/com_redcore/admin/views/oauth_client/tmpl/default.php +++ b/extensions/components/com_redcore/admin/views/oauth_client/tmpl/default.php @@ -14,6 +14,7 @@ JHtml::_('behavior.keepalive'); JHtml::_('rbootstrap.tooltip'); JHtml::_('rjquery.chosen', 'select'); +JHtml::_('behavior.formvalidator'); ?>
diff --git a/extensions/components/com_redcore/admin/views/oauth_clients/view.html.php b/extensions/components/com_redcore/admin/views/oauth_clients/view.html.php index 170e8f256..9ea00c528 100644 --- a/extensions/components/com_redcore/admin/views/oauth_clients/view.html.php +++ b/extensions/components/com_redcore/admin/views/oauth_clients/view.html.php @@ -132,7 +132,10 @@ public function getActions($section = 'component', $assetName = 'com_redcore') { $user = JFactory::getUser(); $result = new Registry; - $actions = JAccess::getActionsFromFile('com_redcore', $section) ?: array(); + $actions = JAccess::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_redform/access.xml', + "/access/section[@name='" . $section . "']/" + ); foreach ($actions as $action) { diff --git a/extensions/components/com_redcore/admin/views/payment_configuration/tmpl/default.php b/extensions/components/com_redcore/admin/views/payment_configuration/tmpl/default.php index 755d09b0f..f9e87d16a 100644 --- a/extensions/components/com_redcore/admin/views/payment_configuration/tmpl/default.php +++ b/extensions/components/com_redcore/admin/views/payment_configuration/tmpl/default.php @@ -14,6 +14,7 @@ JHtml::_('behavior.keepalive'); JHtml::_('rbootstrap.tooltip'); JHtml::_('rjquery.chosen', 'select'); +JHtml::_('behavior.formvalidator'); ?>