diff --git a/README.md b/README.md index ab4431ce6..917344af2 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.7.1 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **188511** ++ *Line count*: **188537** + *Field count*: **1011** + *File count*: **1197** + *Folder count*: **193** diff --git a/admin/README.txt b/admin/README.txt index ab4431ce6..917344af2 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.7.1 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **188511** ++ *Line count*: **188537** + *Field count*: **1011** + *File count*: **1197** + *Folder count*: **193** diff --git a/admin/models/import_joomla_components.php b/admin/models/import_joomla_components.php index aa7e25183..f51ccd933 100644 --- a/admin/models/import_joomla_components.php +++ b/admin/models/import_joomla_components.php @@ -697,7 +697,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy $this->today = JFactory::getDate()->toSql(); // the array of tables to store $tables = array( - 'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view', + 'validation_rule', 'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view', 'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code', 'admin_fields', 'admin_fields_conditions', 'component_admin_views', 'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks', @@ -2336,6 +2336,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy $this->specialValue['admin_view'] = $this->newID['admin_view'][(int) $item->admin_view]; } break; + case 'validation_rule': case 'fieldtype': // get by name (since there should only be one of each name) $getter = 'name'; diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index 41675dda2..5ce685ea9 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -302,13 +302,17 @@ class ComponentbuilderModelJoomla_components extends JModelList { $this->setData($table, $pks, $field); } - // add fields and conditions if (isset($this->exportIDs['admin_view']) && ComponentbuilderHelper::checkArray($this->exportIDs['admin_view'])) { $this->setData('admin_fields', array_values($this->exportIDs['admin_view']), 'admin_view'); $this->setData('admin_fields_conditions', array_values($this->exportIDs['admin_view']), 'admin_view'); } + // add validation rules + if (isset($this->exportIDs['validation_rule']) && ComponentbuilderHelper::checkArray($this->exportIDs['validation_rule'])) + { + $this->setData('validation_rule', array_values($this->exportIDs['validation_rule']), 'name'); + } // add field types if (isset($this->exportIDs['fieldtype']) && ComponentbuilderHelper::checkArray($this->exportIDs['fieldtype'])) { @@ -357,7 +361,7 @@ class ComponentbuilderModelJoomla_components extends JModelList * * @return void. */ - protected function setExportIDs($value, $table) + protected function setExportIDs($value, $table, $int = true) { // check if table has been set if (!isset($this->exportIDs[$table])) @@ -374,16 +378,24 @@ class ComponentbuilderModelJoomla_components extends JModelList { foreach ($value as $id) { - if ((ComponentbuilderHelper::checkString($id) || is_numeric($id)) && 0 !== (int) $id) + if ($int && (ComponentbuilderHelper::checkString($id) || is_numeric($id)) && 0 !== (int) $id) { $this->exportIDs[$table][(int) $id] = (int) $id; } + elseif (!$int && ComponentbuilderHelper::checkString($id)) + { + $this->exportIDs[$table][$id] = $this->_db->quote($id); + } } } - elseif ((ComponentbuilderHelper::checkString($value) || is_numeric($value)) && 0 !== (int) $value) + elseif ($int && (ComponentbuilderHelper::checkString($value) || is_numeric($value)) && 0 !== (int) $value) { $this->exportIDs[$table][(int) $value] = (int) $value; } + elseif (!$int && ComponentbuilderHelper::checkString($value)) + { + $this->exportIDs[$table][$value] = $this->_db->quote($value); + } } /** @@ -467,7 +479,7 @@ class ComponentbuilderModelJoomla_components extends JModelList * * @return mixed An array of data items on success, false on failure. */ - protected function setData($table, $values, $key) + protected function setData($table, $values, $key, $string = false) { // make sure we have an array of values if (!ComponentbuilderHelper::checkArray($values) || !ComponentbuilderHelper::checkString($table) || !ComponentbuilderHelper::checkString($key)) @@ -476,10 +488,8 @@ class ComponentbuilderModelJoomla_components extends JModelList } // start the query $query = $this->_db->getQuery(true); - // Select some fields $query->select(array('a.*')); - // From the componentbuilder_ANY table $query->from($this->_db->quoteName('#__componentbuilder_'. $table, 'a')); // set the where query @@ -490,10 +500,8 @@ class ComponentbuilderModelJoomla_components extends JModelList $groups = implode(',', $this->user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ')'); } - // Order the results by ordering $query->order('a.ordering ASC'); - // Load the items $this->_db->setQuery($query); $this->_db->execute(); @@ -653,6 +661,23 @@ class ComponentbuilderModelJoomla_components extends JModelList $this->setData('field', $fieldsSets, 'id'); } } + // check if validation rule is found + $validationRule = ComponentbuilderHelper::getBetween(json_decode($item->xml), 'validate="', '"'); + if (ComponentbuilderHelper::checkString($validationRule)) + { + // make sure it is lowercase + $validationRule = ComponentbuilderHelper::safeString($validationRule); + // get core validation rules + if ($coreValidationRules = ComponentbuilderHelper::getExistingValidationRuleNames(true)) + { + // make sure this rule is not a core validation rule + if (!in_array($validationRule, (array) $coreValidationRules)) + { + // okay load the rule + $this->setExportIDs($validationRule, 'validation_rule', false); + } + } + } } // actions to take if table is site_view and custom_admin_view if ('site_view' === $table || 'custom_admin_view' === $table) diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index 009ae20d6..e21eeac69 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -1287,7 +1287,7 @@ INSERT INTO `#__componentbuilder_joomla_component` (`id`, `add_license`, `licens -- INSERT INTO `#__componentbuilder_admin_view` (`id`, `add_css_view`, `add_css_views`, `add_custom_button`, `add_custom_import`, `add_fadein`, `add_javascript_view_file`, `add_javascript_view_footer`, `add_javascript_views_file`, `add_javascript_views_footer`, `add_php_ajax`, `add_php_allowedit`, `add_php_batchcopy`, `add_php_batchmove`, `add_php_getitem`, `add_php_getitems`, `add_php_getitems_after_all`, `add_php_getlistquery`, `add_php_postsavehook`, `add_php_save`, `add_sql`, `addlinked_views`, `addpermissions`, `addtables`, `addtabs`, `add_php_before_delete`, `add_php_before_publish`, `add_php_document`, `add_php_after_delete`, `add_php_after_publish`, `php_before_delete`, `php_before_publish`, `php_controller`, `php_document`, `php_after_delete`, `php_after_publish`, `ajax_input`, `css_view`, `css_views`, `custom_button`, `description`, `html_import_view`, `icon`, `icon_add`, `icon_category`, `javascript_view_file`, `javascript_view_footer`, `javascript_views_file`, `javascript_views_footer`, `name_list`, `system_name`, `name_single`, `not_required`, `php_ajaxmethod`, `php_allowedit`, `php_batchcopy`, `php_batchmove`, `php_getitem`, `php_getitems`, `php_getitems_after_all`, `php_getlistquery`, `php_import`, `php_import_display`, `php_import_save`, `php_import_setdata`, `php_model`, `php_postsavehook`, `php_save`, `short_description`, `source`, `sql`, `type`, `params`, `published`, `created`, `modified`, `version`, `hits`, `ordering`) VALUES -(109, '', '', '', '', 1, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '{\"addpermissions0\":{\"action\":\"view.edit\",\"implementation\":\"3\"},\"addpermissions1\":{\"action\":\"view.edit.own\",\"implementation\":\"3\"},\"addpermissions2\":{\"action\":\"view.edit.state\",\"implementation\":\"3\"},\"addpermissions3\":{\"action\":\"view.edit.created_by\",\"implementation\":\"3\"},\"addpermissions4\":{\"action\":\"view.edit.created\",\"implementation\":\"3\"},\"addpermissions5\":{\"action\":\"view.create\",\"implementation\":\"3\"},\"addpermissions6\":{\"action\":\"view.delete\",\"implementation\":\"3\"},\"addpermissions7\":{\"action\":\"view.access\",\"implementation\":\"3\"}}', '', '{\"addtabs0\":{\"name\":\"Details\"},\"addtabs1\":{\"name\":\"More\"}}', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'images/WoodMannequin-icon.png', 'images/WoodMannequin-icon-plus.png', '', '', '', '', '', 'Looks', 'Look', 'Look', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'The demo view', '', '', 1, '', 1, '2016-10-18 11:44:46', '2016-10-20 19:23:57', 12, '', 16); +(109, '', '', '', '', 1, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '{\"addpermissions0\":{\"action\":\"view.edit\",\"implementation\":\"3\"},\"addpermissions1\":{\"action\":\"view.edit.own\",\"implementation\":\"3\"},\"addpermissions2\":{\"action\":\"view.edit.state\",\"implementation\":\"3\"},\"addpermissions3\":{\"action\":\"view.edit.created_by\",\"implementation\":\"3\"},\"addpermissions4\":{\"action\":\"view.edit.created\",\"implementation\":\"3\"},\"addpermissions5\":{\"action\":\"view.create\",\"implementation\":\"3\"},\"addpermissions6\":{\"action\":\"view.delete\",\"implementation\":\"3\"},\"addpermissions7\":{\"action\":\"view.access\",\"implementation\":\"3\"}}', '', '{\"addtabs0\":{\"name\":\"Details\"},\"addtabs1\":{\"name\":\"More\"}}', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'images/WoodMannequin-icon.png', 'images/WoodMannequin-icon-plus.png', '', '', '', '', '', 'Looks', 'Look', 'Look', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'The demo view', '', '', 1, '', 1, '2016-10-18 11:44:46', '2018-03-30 09:30:48', 14, '', 16); @@ -1485,7 +1485,7 @@ INSERT INTO `#__componentbuilder_field` (`id`, `add_css_view`, `add_css_views`, (199, '', '', '', '', '', '', '', '', '', 255, '', 'VARCHAR', 2, '', '', 'Name', 'NOT NULL', '', 24, '\"\"', 1, '2015-03-19 17:30:59', '2017-10-25 20:26:02', 8, '', 4), (203, '', '', '', '', '', '', '', '', '', 1, '', 'INT', '', '', '', 'Not Required', 'NOT NULL', '', 9, '\"\"', 1, '2015-05-08 16:19:16', '2015-08-25 21:15:22', 1, '', 19), (280, '', '', '', '', '', '', '', '', '', 255, '', 'VARCHAR', '', '', '', 'Website', 'NOT NULL', '', 27, '\"\"', 1, '2015-04-08 00:36:16', '2015-08-25 21:15:22', 1, '', 105), -(682, '', '', '', '', '', '', '', '', '', 1, '', 'TINYINT', 2, '', '', 'Add More', 'NOT NULL', '', 17, '\"\"', 1, '2015-08-05 01:18:20', '2016-10-18 12:16:27', 2, '', 196), +(682, '', '', '', '', '', '', '', '', '', 1, '', 'TINYINT', 2, '', '', 'Add More', 'NOT NULL', '', 17, '\"\"', 1, '2015-08-05 01:18:20', '2018-03-30 09:30:45', 4, '', 196), (1011, '', '', '', '', '', '', '', 'Other', '0000-00-00', '', '', 'DATE', '', '', '', 'Date of Birth', 'NOT NULL', '', 1, '\"\"', 1, '2015-12-07 01:47:32', '2015-12-07 02:15:24', 3, '', 649); --