Removes the custom component field from JCB. Made some filters to be multiple selection in site & component list view. Adds the combo field more correctly to JCB.

This commit is contained in:
Llewellyn van der Merwe 2021-01-15 09:13:06 +02:00
parent 12600431ca
commit bb414c980c
Signed by untrusted user: Llewellyn
GPG Key ID: EFC0C720A240551C
22 changed files with 209 additions and 158 deletions

View File

@ -143,13 +143,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 6th January, 2021
+ *Last Build*: 15th January, 2021
+ *Version*: 2.12.5
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **291576**
+ *Line count*: **291684**
+ *Field count*: **1611**
+ *File count*: **1935**
+ *File count*: **1934**
+ *Folder count*: **322**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -143,13 +143,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 6th January, 2021
+ *Last Build*: 15th January, 2021
+ *Version*: 2.12.5
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **291576**
+ *Line count*: **291684**
+ *Field count*: **1611**
+ *File count*: **1935**
+ *File count*: **1934**
+ *Folder count*: **322**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -857,9 +857,9 @@
min="1"
showon="development_method:2">
<form hidden="true" name="list_expansion_modal" repeat="true">
<!-- Component Field. Type: Component. (custom) -->
<!-- Component Field. Type: Joomlacomponent. (custom) -->
<field
type="component"
type="joomlacomponent"
name="component"
label="COM_COMPONENTBUILDER_CONFIG_COMPONENT_LABEL"
class="list_class"

View File

@ -3669,7 +3669,7 @@ abstract class ComponentbuilderHelper
protected static $fieldGroups = array(
'default' => array(
'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle',
'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB
'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components',
'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist',
'integer', 'language', 'list', 'media', 'menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition',
'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules',
@ -3681,14 +3681,14 @@ abstract class ComponentbuilderHelper
'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
),
'option' => array(
'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB
'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components',
'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql', 'groupedlist'
),
'text' => array(
'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url'
),
'list' => array(
'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist'
'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist', 'combo'
),
'dynamic' => array(
'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user'

View File

@ -1,57 +0,0 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/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');
/**
* Components Form Field class for the Componentbuilder component
*/
class JFormFieldComponents extends JFormFieldList
{
/**
* The components field type.
*
* @var string
*/
public $type = 'components';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.system_name'),array('id','components_system_name')));
$query->from($db->quoteName('#__componentbuilder_joomla_component', 'a'));
$query->where($db->quoteName('a.published') . ' >= 1');
$query->order('a.system_name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->components_system_name);
}
}
return $options;
}
}

View File

@ -17,16 +17,16 @@ jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Component Form Field class for the Componentbuilder component
* Joomlacomponent Form Field class for the Componentbuilder component
*/
class JFormFieldComponent extends JFormFieldList
class JFormFieldJoomlacomponent extends JFormFieldList
{
/**
* The component field type.
* The joomlacomponent field type.
*
* @var string
*/
public $type = 'component';
public $type = 'joomlacomponent';
/**
* Override to add new button

View File

@ -35,23 +35,23 @@ class JFormFieldJoomlacomponents extends JFormFieldList
*/
protected function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.system_name'),array('id','joomla_component_system_name')));
$query->from($db->quoteName('#__componentbuilder_joomla_component', 'a'));
$query->order('a.system_name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '', 'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->joomla_component_system_name);
}
}
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.system_name'),array('id','components_system_name')));
$query->from($db->quoteName('#__componentbuilder_joomla_component', 'a'));
$query->where($db->quoteName('a.published') . ' >= 1');
$query->order('a.system_name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->components_system_name);
}
}
return $options;
return $options;
}
}

View File

@ -51,7 +51,6 @@ class JFormFieldJoomlacomponentsfilterauthor extends JFormFieldList
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_AUTHOR') . ' -');
if ($results)
{

View File

@ -51,7 +51,6 @@ class JFormFieldJoomlacomponentsfiltercompanyname extends JFormFieldList
$results = $db->loadColumn();
$_filter = array();
$_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_COMPANYNAME') . ' -');
if ($results)
{

View File

@ -93,9 +93,9 @@
default="componentbuilder custom_code"
/>
<!-- Dynamic Fields. -->
<!-- Component Field. Type: Component. (custom) -->
<!-- Component Field. Type: Joomlacomponent. (custom) -->
<field
type="component"
type="joomlacomponent"
name="component"
label="COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL"
class="list_class"

View File

@ -31,7 +31,7 @@
onchange="this.form.submit();"
/>
<field
type="component"
type="joomlacomponent"
name="component"
label="COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL"
multiple="false"

View File

@ -34,14 +34,16 @@
type="joomlacomponentsfiltercompanyname"
name="companyname"
label="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_LABEL"
multiple="false"
class="multipleJoomlacomponentsfiltercompanyname"
multiple="true"
onchange="this.form.submit();"
/>
<field
type="joomlacomponentsfilterauthor"
name="author"
label="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL"
multiple="false"
class="multipleJoomlacomponentsfilterauthor"
multiple="true"
onchange="this.form.submit();"
/>
<input type="hidden" name="form_submited" value="1"/>

View File

@ -34,7 +34,8 @@
type="maingets"
name="main_get"
label="COM_COMPONENTBUILDER_SITE_VIEW_MAIN_GET_LABEL"
multiple="false"
class="multipleMaingets"
multiple="true"
onchange="this.form.submit();"
/>
<field

View File

@ -127,9 +127,9 @@
default="0"
button="true"
/>
<!-- Components Field. Type: Components. (custom) -->
<!-- Components Field. Type: Joomlacomponents. (custom) -->
<field
type="components"
type="joomlacomponents"
name="components"
label="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_COMPONENTS_LABEL"
class="list_class span12"

View File

@ -2284,6 +2284,29 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
$query->where('a.companyname = ' . $db->quote($db->escape($_companyname)));
}
elseif (ComponentbuilderHelper::checkArray($_companyname))
{
// Secure the array for the query
$_companyname = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (ComponentbuilderHelper::checkString($val))
{
return $db->quote($db->escape($val));
}
}, $_companyname);
// Filter by the Companyname Array.
$query->where('a.companyname IN (' . implode(',', $_companyname) . ')');
}
// Filter by Author.
$_author = $this->getState('filter.author');
if (is_numeric($_author))
@ -2301,6 +2324,29 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
$query->where('a.author = ' . $db->quote($db->escape($_author)));
}
elseif (ComponentbuilderHelper::checkArray($_author))
{
// Secure the array for the query
$_author = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (ComponentbuilderHelper::checkString($val))
{
return $db->quote($db->escape($val));
}
}, $_author);
// Filter by the Author Array.
$query->where('a.author IN (' . implode(',', $_author) . ')');
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.id');
@ -2526,8 +2572,30 @@ class ComponentbuilderModelJoomla_components extends JModelList
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.companyname');
$id .= ':' . $this->getState('filter.author');
// Check if the value is an array
$_companyname = $this->getState('filter.companyname');
if (ComponentbuilderHelper::checkArray($_companyname))
{
$id .= ':' . implode(':', $_companyname);
}
// Check if this is only an number or string
elseif (is_numeric($_companyname)
|| ComponentbuilderHelper::checkString($_companyname))
{
$id .= ':' . $_companyname;
}
// Check if the value is an array
$_author = $this->getState('filter.author');
if (ComponentbuilderHelper::checkArray($_author))
{
$id .= ':' . implode(':', $_author);
}
// Check if this is only an number or string
elseif (is_numeric($_author)
|| ComponentbuilderHelper::checkString($_author))
{
$id .= ':' . $_author;
}
$id .= ':' . $this->getState('filter.system_name');
$id .= ':' . $this->getState('filter.name_code');
$id .= ':' . $this->getState('filter.short_description');

View File

@ -317,6 +317,29 @@ class ComponentbuilderModelSite_views extends JModelList
{
$query->where('a.main_get = ' . $db->quote($db->escape($_main_get)));
}
elseif (ComponentbuilderHelper::checkArray($_main_get))
{
// Secure the array for the query
$_main_get = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (ComponentbuilderHelper::checkString($val))
{
return $db->quote($db->escape($val));
}
}, $_main_get);
// Filter by the Main_get Array.
$query->where('a.main_get IN (' . implode(',', $_main_get) . ')');
}
// Filter by Add_php_ajax.
$_add_php_ajax = $this->getState('filter.add_php_ajax');
if (is_numeric($_add_php_ajax))
@ -536,7 +559,18 @@ class ComponentbuilderModelSite_views extends JModelList
$id .= ':' . $this->getState('filter.ordering');
$id .= ':' . $this->getState('filter.created_by');
$id .= ':' . $this->getState('filter.modified_by');
$id .= ':' . $this->getState('filter.main_get');
// Check if the value is an array
$_main_get = $this->getState('filter.main_get');
if (ComponentbuilderHelper::checkArray($_main_get))
{
$id .= ':' . implode(':', $_main_get);
}
// Check if this is only an number or string
elseif (is_numeric($_main_get)
|| ComponentbuilderHelper::checkString($_main_get))
{
$id .= ':' . $_main_get;
}
$id .= ':' . $this->getState('filter.add_php_ajax');
$id .= ':' . $this->getState('filter.add_custom_button');
$id .= ':' . $this->getState('filter.system_name');

File diff suppressed because one or more lines are too long

View File

@ -187,7 +187,7 @@ class ComponentbuilderViewCustom_codes extends JViewLegacy
if ($this->canBatch && $this->canCreate && $this->canEdit)
{
// Set Component System Name Selection
$this->componentSystem_nameOptions = JFormHelper::loadFieldType('Component')->options;
$this->componentSystem_nameOptions = JFormHelper::loadFieldType('Joomlacomponent')->options;
// We do some sanitation for Component System Name filter
if (ComponentbuilderHelper::checkArray($this->componentSystem_nameOptions) &&
isset($this->componentSystem_nameOptions[0]->value) &&

View File

@ -15,6 +15,8 @@ defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', '.multipleJoomlacomponentsfiltercompanyname', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_COMPANYNAME') . ' -'));
JHtml::_('formbehavior.chosen', '.multipleJoomlacomponentsfilterauthor', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_AUTHOR') . ' -'));
JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -'));
JHtml::_('formbehavior.chosen', 'select');
if ($this->saveOrder)

View File

@ -15,6 +15,7 @@ defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', '.multipleMaingets', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_MAIN_GET') . ' -'));
JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -'));
JHtml::_('formbehavior.chosen', 'select');
if ($this->saveOrder)

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>6th January, 2021</creationDate>
<creationDate>15th January, 2021</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -3666,7 +3666,7 @@ abstract class ComponentbuilderHelper
protected static $fieldGroups = array(
'default' => array(
'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle',
'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB
'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components',
'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist',
'integer', 'language', 'list', 'media', 'menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition',
'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules',
@ -3678,14 +3678,14 @@ abstract class ComponentbuilderHelper
'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
),
'option' => array(
'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', // 'components', (TODO) must be added but still in use as a custom field in JCB
'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components',
'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql', 'groupedlist'
),
'text' => array(
'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url'
),
'list' => array(
'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist'
'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist', 'combo'
),
'dynamic' => array(
'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user'