From 2a1a36154dacbb17a1e6e761958c85a31613a851 Mon Sep 17 00:00:00 2001 From: aB0t Date: Mon, 11 Mar 2024 18:35:14 +0200 Subject: [PATCH] Release of v2.0.0 --- componentbuilderprivacytabs.php | 18 +- componentbuilderprivacytabs.xml | 6 +- fields/joomlaplugins.php | 181 ------------------ ...lg_content_componentbuilderprivacytabs.ini | 2 +- ...ontent_componentbuilderprivacytabs.sys.ini | 2 +- rules/code.php | 56 ------ script.php | 124 ------------ 7 files changed, 13 insertions(+), 376 deletions(-) delete mode 100644 fields/joomlaplugins.php delete mode 100644 rules/code.php diff --git a/componentbuilderprivacytabs.php b/componentbuilderprivacytabs.php index 9751314..ad41a90 100644 --- a/componentbuilderprivacytabs.php +++ b/componentbuilderprivacytabs.php @@ -12,20 +12,18 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Registry\Registry; use Joomla\CMS\Form\Form; use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; - -JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - +use VDM\Joomla\Utilities\ArrayHelper; /** * Content - Componentbuilder Privacy Tabs plugin. * * @package ComponentbuilderPrivacyTabs - * @since 1.0.1 + * @since 2.0.0 */ class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin { @@ -68,7 +66,7 @@ class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin //$form->setFieldAttribute('note_select_privacy_plugin', 'showon', 'activate:1', 'params.privacy'); } // update all editors to use this components global editor - $global_editor = \JComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); // set the field editor value (with none as fallback) $form->setFieldAttribute('custom_link', 'editor', $global_editor . '|none', 'params.privacy'); } @@ -106,7 +104,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(Factory::getDbo()); + $extensionTable = new \JtableExtension(Factory::getDbo()); $extensionTable->load(array('element' => 'componentbuilderprivacytabs')); // Save the change $extensionTable->set('params', $this->params->toString()); @@ -121,7 +119,7 @@ class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin if (ArrayHelper::check($item->params)) { // Convert the params field to a string. - $params = new JRegistry; + $params = new Registry; $params->loadArray($item->params); $item->params = (string) $params; } @@ -140,10 +138,10 @@ class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin */ protected function cleanCache($group = null, $client_id = 0) { - $conf = \Factory::getConfig(); + $conf = Factory::getConfig(); $options = array( - 'defaultgroup' => $group ?: (isset($this->option) ? $this->option : \Factory::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 cea6acc..cd60b5f 100644 --- a/componentbuilderprivacytabs.xml +++ b/componentbuilderprivacytabs.xml @@ -1,13 +1,13 @@ - + PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS - 9th March, 2024 + 11th March, 2024 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 1.0.1 + 2.0.0 PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION diff --git a/fields/joomlaplugins.php b/fields/joomlaplugins.php deleted file mode 100644 index 379ca5e..0000000 --- a/fields/joomlaplugins.php +++ /dev/null @@ -1,181 +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'); - -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'); - -/** - * Joomlaplugins Form Field class for the Componentbuilder component - */ -class JFormFieldJoomlaplugins extends JFormFieldList -{ - /** - * The joomlaplugins field type. - * - * @var string - */ - public $type = 'joomlaplugins'; - - /** - * Override to add new button - * - * @return string The field input markup. - * - * @since 3.2 - */ - protected function getInput() - { - // see if we should add buttons - $set_button = $this->getAttribute('button'); - // get html - $html = parent::getInput(); - // if true set button - if ($set_button === 'true') - { - $button = array(); - $script = array(); - $button_code_name = $this->getAttribute('name'); - // get the input from url - $app = Factory::getApplication(); - $jinput = $app->input; - // get the view name & id - $values = $jinput->getArray(array( - 'id' => 'int', - 'view' => 'word' - )); - // check if new item - $ref = ''; - $refJ = ''; - if (!is_null($values['id']) && strlen($values['view'])) - { - // only load referral if not new item. - $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; - $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; - // get the return value. - $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); - $_return = urlencode(base64_encode($_uri)); - // load return value. - $ref .= '&return=' . $_return; - $refJ .= '&return=' . $_return; - } - // get button label - $button_label = trim($button_code_name); - $button_label = preg_replace('/_+/', ' ', $button_label); - $button_label = preg_replace('/\s+/', ' ', $button_label); - $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); - $button_label = ucfirst(strtolower($button_label)); - // get user object - $user = Factory::getUser(); - // only add if user allowed to create joomla_plugin - 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->isClient('administrator')) // TODO for now only in admin area. - { - // build edit button - $button[] = ''; - // build script - $script[] = " - jQuery(document).ready(function() { - jQuery('#adminForm').on('change', '#jform_".$button_code_name."',function (e) { - e.preventDefault(); - var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); - ".$button_code_name."Button(".$button_code_name."Value); - }); - var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); - ".$button_code_name."Button(".$button_code_name."Value); - }); - function ".$button_code_name."Button(value) { - if (value > 0) { - // hide the create button - jQuery('#".$button_code_name."Create').hide(); - // show edit button - jQuery('#".$button_code_name."Edit').show(); - var url = 'index.php?option=com_componentbuilder&view=joomla_plugins&task=joomla_plugin.edit&id='+value+'".$refJ."'; - jQuery('#".$button_code_name."Edit').attr('href', url); - } else { - // show the create button - jQuery('#".$button_code_name."Create').show(); - // hide edit button - jQuery('#".$button_code_name."Edit').hide(); - } - }"; - } - // check if button was created for joomla_plugin field. - if (is_array($button) && count($button) > 0) - { - // Load the needed script. - $document = Factory::getDocument(); - $document->addScriptDeclaration(implode(' ',$script)); - // return the button attached to input field. - return '
' .$html . implode('',$button).'
'; - } - } - return $html; - } - - /** - * Method to get a list of options for a list input. - * - * @return array An array of Html options. - */ - protected function getOptions() - { - // Get the user object. - $user = JFactory::getUser(); - // Get the databse object. - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.id','a.system_name','a.name','b.name','c.name'),array('id','plugin_system_name','name','class_extends_name','joomla_plugin_group_name'))); - $query->from($db->quoteName('#__componentbuilder_joomla_plugin', 'a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_class_extends', 'b') . ' ON (' . $db->quoteName('a.class_extends') . ' = ' . $db->quoteName('b.id') . ')'); - $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'c') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('c.id') . ')'); - $query->where($db->quoteName('a.published') . ' >= 1'); - $query->order('a.system_name ASC'); - // Implement View Level Access (if set in table) - if (!$user->authorise('core.options', 'com_componentbuilder')) - { - $columns = $db->getTableColumns('#__componentbuilder_joomla_plugin'); - if(isset($columns['access'])) - { - $groups = implode(',', $user->getAuthorisedViewLevels()); - $query->where('a.access IN (' . $groups . ')'); - } - } - $db->setQuery((string)$query); - $items = $db->loadObjectList(); - $options = array(); - if ($items) - { - $options[] = JHtml::_('select.option', '', 'Select a plugin'); - foreach($items as $item) - { - // set a full class name - $options[] = JHtml::_('select.option', $item->id, '( ' . $item->plugin_system_name . ' ) class Plg' . ucfirst($item->joomla_plugin_group_name) . $item->name . ' extends ' . $item->class_extends_name); - } - } - return $options; - } -} diff --git a/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.ini b/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.ini index dfe57e4..463715f 100644 --- a/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.ini +++ b/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.ini @@ -1,6 +1,6 @@ PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS="Content - Componentbuilder Privacy Tabs" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_DESCRIPTION="This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration." -PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION="

Content - Componentbuilder Privacy Tabs (v.1.0.1)

This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration.

Created by Llewellyn van der Merwe
Development started 17th August, 2019

" +PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION="

Content - Componentbuilder Privacy Tabs (v.2.0.0)

This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration.

Created by Llewellyn van der Merwe
Development started 10th March, 2024

" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_GLOBAL_PRIVACY="Global Privacy" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN="Plugin" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PRIVACY="Privacy" diff --git a/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.sys.ini b/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.sys.ini index dfe57e4..463715f 100644 --- a/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.sys.ini +++ b/language/en-GB/en-GB.plg_content_componentbuilderprivacytabs.sys.ini @@ -1,6 +1,6 @@ PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS="Content - Componentbuilder Privacy Tabs" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_DESCRIPTION="This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration." -PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION="

Content - Componentbuilder Privacy Tabs (v.1.0.1)

This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration.

Created by Llewellyn van der Merwe
Development started 17th August, 2019

" +PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION="

Content - Componentbuilder Privacy Tabs (v.2.0.0)

This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration.

Created by Llewellyn van der Merwe
Development started 10th March, 2024

" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_GLOBAL_PRIVACY="Global Privacy" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN="Plugin" PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PRIVACY="Privacy" diff --git a/rules/code.php b/rules/code.php deleted file mode 100644 index 58a1c59..0000000 --- a/rules/code.php +++ /dev/null @@ -1,56 +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('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. - */ -class JFormRuleCode extends FormRule -{ - /** - * Method to test the value. - * - * @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, false otherwise. - */ - public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) - { - // This removes all validation (is dangerous) but needed to submit code via JCB - return true; - - /** - * My idea is to add some kind of validation to improve JCB code (per/language) - * - * So at this time this code validation is used for JavaScript,CSS,HTML and PHP. - * We can see what language is being worked on with the syntax property in the $element. (in JCB) - * What complicates things is the placeholders, of both custom code, component, and view names. - * Ideally we could strip them and then validate the code to being syntactically correct. - * But since some of the placeholders form part of the class/function names and the more, it seems like we are pressed for a much more advance solution. - * If you have any ideas to how we can go about to do this, then please open an issue on github and lets begin. (this is a nice to have, so don't break a leg...) - */ - } -} diff --git a/script.php b/script.php index aa304ab..9c7cc77 100644 --- a/script.php +++ b/script.php @@ -24,128 +24,4 @@ use Joomla\CMS\Filesystem\Folder; */ class plgContentComponentbuilderPrivacyTabsInstallerScript { - - /** - * Called before any type of action - * - * @param string $route Which action is happening (install|uninstall|discover_install|update) - * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script - * - * @return boolean True on success - */ - public function preflight($route, $adapter) - { - // get application - $app = Factory::getApplication(); - - // the default for both install and update - $jversion = new JVersion(); - if (!$jversion->isCompatible('3.8.0')) - { - $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); - return false; - } - - if ('install' === $route) - { -// needs fix - - - // check that componentbuilder is installed - $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; - if (!JFile::exists($pathToCore)) - { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', 'error'); - return false; - } - - // load the helper class - JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - - // block install - $blockInstall = true; - - // check the version of JCB - $manifest = ComponentbuilderHelper::manifest(); - if (isset($manifest->version) && strpos($manifest->version, '.') !== false) - { - // get the version - $jcbVersion = explode('.', $manifest->version); - // check that we have JCB 3.0.0 or higher installed - if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 && - ( - ($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 0) || - ($jcbVersion[0] == 3 && $jcbVersion[1] > 0) || - $jcbVersion[0] > 3) - ) - { - $blockInstall = false; - } - } - - // allow install if all conditions are met - if ($blockInstall) - { - $app->enqueueMessage('Please upgrade to JCB v3.0.0 or higher before installing this plugin.', 'error'); - return false; - } - - - // check that componentbuilder is installed - $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; - if (!JFile::exists($pathToCore)) - { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', 'error'); - return false; - } - // load the helper class - JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - // block install - $blockInstall = true; - // check the version of JCB - $manifest = ComponentbuilderHelper::manifest(); - if (isset($manifest->version) && strpos($manifest->version, '.') !== false) - { - // get the version - $jcbVersion = explode('.', $manifest->version); - // check that we have JCB 2.10.13 or higher installed - if (count($jcbVersion) == 3 && (($jcbVersion[0] == 2 && $jcbVersion[1] >= 10 && (($jcbVersion[1] == 10 && $jcbVersion[2] >= 13) || ($jcbVersion[1] > 10))) || $jcbVersion[0] >= 3)) - { - $blockInstall = false; - } - } - // allow install if all conditions are met - if ($blockInstall) - { - $app->enqueueMessage('Please upgrade to JCB 2.10.13 or higher before installing this plugin.', 'error'); - return false; - } - - // check that componentbuilder is installed - $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; - if (!JFile::exists($pathToCore)) - { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', 'error'); - return false; - } - - // check that componentbuilder is installed - $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; - if (!JFile::exists($pathToCore)) - { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', 'error'); - return false; - } - - // check that componentbuilder is installed - $pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'; - if (!JFile::exists($pathToCore)) - { - $app->enqueueMessage('Joomla Component Builder must first be installed from Joomla Component Builder.', 'error'); - return false; - } - } - - return true; - } }