diff --git a/fields/Layouts/Helper/LayoutPathsHelper.php b/fields/Layouts/Helper/LayoutPathsHelper.php index eb3373f..916718f 100644 --- a/fields/Layouts/Helper/LayoutPathsHelper.php +++ b/fields/Layouts/Helper/LayoutPathsHelper.php @@ -1,6 +1,8 @@ -paths; } - protected function set($paths = []) { $this->paths = $paths; } - protected function add($path) { if (in_array($path['path'], $this->cache_paths)) @@ -149,5 +146,4 @@ protected function add($path) return true; } - } \ No newline at end of file diff --git a/fields/Layouts/LayoutsField.php b/fields/Layouts/LayoutsField.php index c56675c..0d9bfcc 100644 --- a/fields/Layouts/LayoutsField.php +++ b/fields/Layouts/LayoutsField.php @@ -1,6 +1,8 @@ -element['template']; $template = preg_replace('#\W#', '', $template); @@ -57,11 +59,11 @@ protected function getInput() $template_style_id = preg_replace('#\W#', '', $template_style_id); } - $lang = Factory::getLanguage(); + $lang = Factory::getApplication()->getLanguage(); $lang->load($module . '.sys', $client->path, null, false, true) || $lang->load($module . '.sys', $client->path . '/modules/' . $module, null, false, true); - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseDriver::class); $query = $db->getQuery(true); $query diff --git a/fields/Layouts/LayoutspluginField.php b/fields/Layouts/LayoutspluginField.php index 8220fb2..a49df40 100644 --- a/fields/Layouts/LayoutspluginField.php +++ b/fields/Layouts/LayoutspluginField.php @@ -1,6 +1,8 @@ -element['template']; $template = preg_replace('#\W#', '', $template); @@ -66,11 +66,12 @@ protected function getInput() $template_style_id = preg_replace('#\W#', '', $template_style_id); } - $lang = Factory::getLanguage(); + $lang = Factory::getApplication()->getLanguage(); $lang->load($plugin . '.sys', $client->path, null, false, true) || $lang->load($plugin . '.sys', $client->path . '/plugins/' . $folder . '/' . $plugin, null, false, true); - $db = Factory::getDbo(); + /** @var DatabaseDriver $db */ + $db = Factory::getContainer()->get(DatabaseDriver::class); $query = $db->getQuery(true); $query diff --git a/fields/ListArticles/ListarticlesField.php b/fields/ListArticles/ListarticlesField.php index 5a0fb65..3f321c5 100644 --- a/fields/ListArticles/ListarticlesField.php +++ b/fields/ListArticles/ListarticlesField.php @@ -20,7 +20,7 @@ class ListarticlesField extends ListField * @var string * @since 1.6 */ - public $type = 'ListArticles'; + public $type = 'Listarticles'; /** * diff --git a/fields/ListArticles/helpers/articles.php b/fields/ListArticles/helpers/articles.php index 5273a4b..120f611 100644 --- a/fields/ListArticles/helpers/articles.php +++ b/fields/ListArticles/helpers/articles.php @@ -2,6 +2,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; +use Joomla\Database\DatabaseDriver; use Joomla\Utilities\ArrayHelper; /** @@ -35,20 +36,22 @@ public static function options($config = []) $config = array_merge($config, [ 'filter.published' => [0, 1] ]); - $hash = md5('lib_fields' . '.' . serialize($config)); + $hash = md5('lib_fields' . '.' . serialize($config)); if (!isset(static::$items[$hash])) { $config = (array) $config; - $db = Factory::getDbo(); - $user = Factory::getUser(); + /** @var DatabaseDriver $db */ + $db = Factory::getContainer()->get(DatabaseDriver::class); + $user = Factory::getApplication()->getIdentity(); $groups = implode(',', $user->getAuthorisedViewLevels()); $query = $db->getQuery(true) ->select("con.id, REPLACE(con.title, '\"', '') as title, con.language") ->from('#__content AS con'); - if(isset($config['filter.category'])) { + if (isset($config['filter.category'])) + { $category = (int) $config['filter.category']; $query->innerJoin("(SELECT node.id FROM #__categories AS node, #__categories AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND (parent.parent_id = " . $category . " OR parent.id = " . $category . ") ORDER BY node.lft) AS cat ON (con.catid = cat.id)"); } @@ -88,7 +91,7 @@ public static function options($config = []) // Filter on the language if (isset($config['filter.q'])) { - $search = $db->Quote( '%' . $db->escape( $config['filter.q'], true ) . '%' ); + $search = $db->Quote('%' . $db->escape($config['filter.q'], true) . '%'); $query->where("title LIKE " . $search); } @@ -96,13 +99,13 @@ public static function options($config = []) // Filter on the language if (isset($config['filter.limit'])) { - $query->setLimit((int)$config['filter.limit']); + $query->setLimit((int) $config['filter.limit']); } // Filter on the language if (isset($config['filter.ids'])) { - $ids = $db->escape( implode(',', $config['filter.ids']), true ); + $ids = $db->escape(implode(',', $config['filter.ids']), true); $query->where("con.id in (" . $ids . ')'); } diff --git a/fields/ListComponents/ListcomponentsField.php b/fields/ListComponents/ListcomponentsField.php index 0daea47..315414e 100644 --- a/fields/ListComponents/ListcomponentsField.php +++ b/fields/ListComponents/ListcomponentsField.php @@ -1,4 +1,6 @@ -_options === null) { - // Get components - $db = Factory::getDbo(); + /** @var DatabaseDriver $db */ + $db = Factory::getContainer()->get(DatabaseDriver::class); $query = $db->getQuery(true) ->select(['e.element']) ->from($db->quoteName('#__extensions', 'e')) @@ -98,7 +76,6 @@ protected function getOptions() } } - // Convert options $options = parent::getOptions(); foreach ($options as $key => $option) @@ -133,9 +110,8 @@ protected function getOptions() } - // Prepare options $pluginConstant = 'LIB_FIELDS_FIELD_LIST_COMPONENTS'; - $language = Factory::getLanguage(); + $language = Factory::getApplication()->getLanguage(); $language_tag = $language->getTag(); $language->load('lib_fields', JPATH_SITE, $language_tag, true); foreach ($components as $component => $views) @@ -145,7 +121,6 @@ protected function getOptions() $componentText = ($language->hasKey($componentConstant)) ? Text::_($componentConstant) : ucfirst(str_replace('com_', '', $component)); - // Add views foreach ($views as $view => $layouts) { $viewValue = $componentValue . '.' . $view; @@ -158,7 +133,6 @@ protected function getOptions() $option->text = $viewText; $options[] = $option; - // Add layouts foreach ($layouts as $layout) { $layoutValue = $viewValue . ':' . $layout; @@ -181,14 +155,6 @@ protected function getOptions() return $this->_options; } - /** - * Check if relevant folder exists with different paths for J3 and J4 - * - * @param string $component - * @param string $rootComponents - * - * @return string|bool - */ private static function checkFolder(string $component, string $rootComponents = JPATH_ROOT) { $jversion = new Version(); @@ -209,14 +175,6 @@ private static function checkFolder(string $component, string $rootComponents = return false; } - /** - * Check if there is an edit option in views for J4 - * - * @param string $folder - * @param string $view - * - * @return bool - */ private static function checkEditOption(string $folder, string $view) { $editFile = $folder . DIRECTORY_SEPARATOR . $view . DIRECTORY_SEPARATOR . 'edit.php'; diff --git a/fields/Modal/ModuleidField.php b/fields/Modal/ModuleidField.php index 8007183..5eba6b2 100644 --- a/fields/Modal/ModuleidField.php +++ b/fields/Modal/ModuleidField.php @@ -1,11 +1,15 @@ -get(DatabaseDriver::class); $db->setQuery('SELECT id, title FROM #__modules'); try @@ -37,7 +42,6 @@ public function getInput() if (self::$declareScriptFlag) { - // Build the script. $script = array(); $script[] = ' function jInsertEditorText(text, elementId) {'; $script[] = ' var moduleData = ' . json_encode($data) . ';'; @@ -47,8 +51,10 @@ public function getInput() $script[] = ' SqueezeBox.close();'; $script[] = ' }'; - // Add the script to the document head. - Factory::getDocument()->addScriptDeclaration(implode("\n", $script)); + /** @var WebAssetManager $wa */ + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); + $wa->addInlineScript(implode("\n", $script)); + self::$declareScriptFlag = false; } @@ -68,8 +74,8 @@ public function getInput() $html[] = ''; $html[] = ' - - ' . JText::_(self::BTN_VALUE) . ' + + ' . Text::_(self::BTN_VALUE) . ' '; $html[] = ''; $html[] = ''; diff --git a/fields/QuantumAccessibleMedia/QuantumaccessiblemediaField.php b/fields/QuantumAccessibleMedia/QuantumaccessiblemediaField.php index 6d21cea..66506fa 100644 --- a/fields/QuantumAccessibleMedia/QuantumaccessiblemediaField.php +++ b/fields/QuantumAccessibleMedia/QuantumaccessiblemediaField.php @@ -1,44 +1,26 @@ -load('com_modules'); + Factory::getApplication()->getLanguage()->load('com_modules'); + return parent::getLayoutData(); } - public function getInput() { HTMLHelper::_('stylesheet', 'lib_fields/selectmenuitem/selectmenuitem.css', [ - 'version' => filemtime(__FILE__), + 'version' => filemtime(__FILE__), 'relative' => true ]); HTMLHelper::_('script', 'lib_fields/selectmenuitem/selectmenuitem.js', [ - 'version' => filemtime(__FILE__), + 'version' => filemtime(__FILE__), 'relative' => true ]); return parent::getInput(); } - } \ No newline at end of file diff --git a/fields/SelectMenuItem/layouts/selectmenuitem.php b/fields/SelectMenuItem/layouts/selectmenuitem.php index 9c7f7e0..3d6d878 100644 --- a/fields/SelectMenuItem/layouts/selectmenuitem.php +++ b/fields/SelectMenuItem/layouts/selectmenuitem.php @@ -1,117 +1,129 @@ 'auto', 'relative' => true)); +HTMLHelper::_('script', 'jui/treeselectmenu.jquery.min.js', array('version' => 'auto', 'relative' => true)); extract($displayData); -if(!is_array($value)) +if (!is_array($value)) { - $value = []; + $value = []; } ?>