diff --git a/componentbuilderprivacytabs.php b/componentbuilderprivacytabs.php index 9a44094..84e1838 100644 --- a/componentbuilderprivacytabs.php +++ b/componentbuilderprivacytabs.php @@ -106,7 +106,7 @@ class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin // first set new params $this->params->set('plugin', (int) $item->params['plugin']); // update the global plugin settings - $extensionTable = new JtableExtension(JFactory::getDbo()); + $extensionTable = new JtableExtension(Factory::getDbo()); $extensionTable->load(array('element' => 'componentbuilderprivacytabs')); // Save the change $extensionTable->set('params', $this->params->toString()); @@ -140,10 +140,10 @@ class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin */ protected function cleanCache($group = null, $client_id = 0) { - $conf = \JFactory::getConfig(); + $conf = \Factory::getConfig(); $options = array( - 'defaultgroup' => $group ?: (isset($this->option) ? $this->option : \JFactory::getApplication()->input->get('option')), + 'defaultgroup' => $group ?: (isset($this->option) ? $this->option : \Factory::getApplication()->input->get('option')), 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'), 'result' => true, ); diff --git a/componentbuilderprivacytabs.xml b/componentbuilderprivacytabs.xml index 1ec6a90..99a04e3 100644 --- a/componentbuilderprivacytabs.xml +++ b/componentbuilderprivacytabs.xml @@ -1,7 +1,7 @@ - + PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS - 24th October, 2023 + 2nd March, 2024 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io diff --git a/fields/joomlaplugins.php b/fields/joomlaplugins.php index 16462c0..379ca5e 100644 --- a/fields/joomlaplugins.php +++ b/fields/joomlaplugins.php @@ -12,6 +12,10 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); @@ -24,7 +28,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList /** * The joomlaplugins field type. * - * @var string + * @var string */ public $type = 'joomlaplugins'; @@ -48,7 +52,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList $script = array(); $button_code_name = $this->getAttribute('name'); // get the input from url - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $jinput = $app->input; // get the view name & id $values = $jinput->getArray(array( @@ -64,7 +68,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; // get the return value. - $_uri = (string) JUri::getInstance(); + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); $_return = urlencode(base64_encode($_uri)); // load return value. $ref .= '&return=' . $_return; @@ -77,20 +81,20 @@ class JFormFieldJoomlaplugins extends JFormFieldList $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); $button_label = ucfirst(strtolower($button_label)); // get user object - $user = JFactory::getUser(); + $user = Factory::getUser(); // only add if user allowed to create joomla_plugin - if ($user->authorise('joomla_plugin.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + if ($user->authorise('joomla_plugin.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. { // build Create button - $button[] = ' '; } // only add if user allowed to edit joomla_plugin - if ($user->authorise('joomla_plugin.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + if ($user->authorise('joomla_plugin.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. { // build edit button - $button[] = ''; // build script $script[] = " @@ -123,7 +127,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList if (is_array($button) && count($button) > 0) { // Load the needed script. - $document = JFactory::getDocument(); + $document = Factory::getDocument(); $document->addScriptDeclaration(implode(' ',$script)); // return the button attached to input field. return '
' .$html . implode('',$button).'
'; @@ -135,7 +139,7 @@ class JFormFieldJoomlaplugins extends JFormFieldList /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. */ protected function getOptions() { diff --git a/fields/targetfields.php b/fields/targetfields.php deleted file mode 100644 index 3ad0d16..0000000 --- a/fields/targetfields.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @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 - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); - -/** - * Targetfields Form Field class for the Componentbuilder component - */ -class JFormFieldTargetfields extends JFormFieldList -{ - /** - * The targetfields field type. - * - * @var string - */ - public $type = 'targetfields'; - - /** - * Method to get a list of options for a list input. - * - * @return array An array of JHtml options. - */ - protected function getOptions() - { - // load the db opbject - $db = JFactory::getDBO(); - // get the input from url - $jinput = JFactory::getApplication()->input; - // get the id - $ID = $jinput->getInt('id', 0); - // get the view name - $VIEW = $jinput->get('view', null, 'WORD'); - // rest the fields ids - $fieldIds = array(); - // if this is an actual admin view then we are done - if ('admin_view' === $VIEW && is_numeric($ID) && $ID >= 1) - { - $adminView = $ID; - } - elseif (is_numeric($ID) && $ID >= 1) - { - // get the admin view ID - $adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view'); - } - elseif ('admin_view' !== $VIEW) - { - // get the admin view ID - $adminView = $jinput->getInt('refid', 0); - } - if (isset($adminView) && is_numeric($adminView) && $adminView >= 1) - { - // get all the fields linked to the admin view - if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) - { - if (ComponentbuilderHelper::checkJson($addFields)) - { - $addFields = json_decode($addFields, true); - if (ComponentbuilderHelper::checkArray($addFields)) - { - foreach($addFields as $addField) - { - if (isset($addField['field'])) - { - $fieldIds[] = (int) $addField['field']; - } - } - } - } - } - } - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.id','a.name','t.name'),array('id','name','type'))); - $query->from($db->quoteName('#__componentbuilder_field', 'a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 't') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('t.id') . ')'); - $query->where($db->quoteName('a.published') . ' >= 1'); - // filter by fields linked - if (ComponentbuilderHelper::checkArray($fieldIds)) - { - // only load these fields - $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); - } - $query->order('a.name ASC'); - $db->setQuery((string)$query); - $items = $db->loadObjectList(); - $options = array(); - if ($items) - { - foreach($items as $item) - { - $options[] = JHtml::_('select.option', $item->id, $item->name . ' [' . $item->type . ']'); - } - } - - return $options; - } -} diff --git a/rules/code.php b/rules/code.php index 192d4dc..58a1c59 100644 --- a/rules/code.php +++ b/rules/code.php @@ -12,9 +12,12 @@ // No direct access to this file defined('JPATH_PLATFORM') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; use Joomla\CMS\Form\Form; use Joomla\CMS\Form\FormRule; use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; /** * Form Rule (Code) class for the Joomla Platform. diff --git a/script.php b/script.php index 8208721..aa304ab 100644 --- a/script.php +++ b/script.php @@ -12,6 +12,11 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; + /** * Content - Componentbuilder Privacy Tabs script file. * @@ -31,7 +36,7 @@ class plgContentComponentbuilderPrivacyTabsInstallerScript public function preflight($route, $adapter) { // get application - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // the default for both install and update $jversion = new JVersion();