From a7c3a6e8f22a13be93402f5f00ed61937e7ec7d9 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 29 May 2018 05:45:16 +0200 Subject: [PATCH] Fixed the javascript in the new relation area. Fixed gh-294 that hade count not array errors. Added the option to over-ride the column name in the new relation area. --- README.md | 6 ++--- admin/README.txt | 6 ++--- admin/compiler/joomla_3/Helper.php | 6 ++--- admin/compiler/joomla_3/Helper_email.php | 2 +- admin/compiler/joomla_3/Helper_site.php | 6 ++--- admin/helpers/compiler/a_Get.php | 20 ++++++++++++++ admin/helpers/compiler/e_Interpretation.php | 11 ++++++++ admin/helpers/componentbuilder.php | 6 ++--- admin/helpers/componentbuilderemail.php | 2 +- .../en-GB/en-GB.com_componentbuilder.ini | 5 ++++ admin/models/ajax.php | 26 +++++++++++++++++- admin/models/forms/admin_fields_relations.js | 27 ++++++++++++++----- admin/models/forms/admin_fields_relations.xml | 15 +++++++++++ admin/sql/install.mysql.utf8.sql | 3 ++- componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 6 ++--- 16 files changed, 120 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 7beb1290a..de1256ac3 100644 --- a/README.md +++ b/README.md @@ -125,12 +125,12 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *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*: 26th May, 2018 ++ *Last Build*: 29th May, 2018 + *Version*: 2.8.0 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **185523** -+ *Field count*: **1053** ++ *Line count*: **185583** ++ *Field count*: **1054** + *File count*: **1236** + *Folder count*: **197** diff --git a/admin/README.txt b/admin/README.txt index 7beb1290a..de1256ac3 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,12 +125,12 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *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*: 26th May, 2018 ++ *Last Build*: 29th May, 2018 + *Version*: 2.8.0 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **185523** -+ *Field count*: **1053** ++ *Line count*: **185583** ++ *Field count*: **1054** + *File count*: **1236** + *Folder count*: **197** diff --git a/admin/compiler/joomla_3/Helper.php b/admin/compiler/joomla_3/Helper.php index c8cea1c53..f49a9d300 100644 --- a/admin/compiler/joomla_3/Helper.php +++ b/admin/compiler/joomla_3/Helper.php @@ -647,7 +647,7 @@ abstract class ###Component###Helper } } // check if there are any view values remaining - if (count($_result)) + if (count((array)$_result)) { $_result = json_encode($_result); $_result = array($_result); @@ -841,7 +841,7 @@ abstract class ###Component###Helper **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count($array) > 0) + if (isset($array) && is_array($array) && count((array)$array) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -944,7 +944,7 @@ abstract class ###Component###Helper { $initial = strlen($string); $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count($words); + $words_count = count((array)$words); $word_length = 0; $last_word = 0; diff --git a/admin/compiler/joomla_3/Helper_email.php b/admin/compiler/joomla_3/Helper_email.php index a0399c52b..370b827a2 100644 --- a/admin/compiler/joomla_3/Helper_email.php +++ b/admin/compiler/joomla_3/Helper_email.php @@ -232,7 +232,7 @@ abstract class ###Component###Email if (is_array($mailreply)) { $mail->ClearReplyTos(); - $numReplyTo = count($mailreply); + $numReplyTo = count((array)$mailreply); for ($i=0; $i < $numReplyTo; $i++) { $mail->addReplyTo($mailreply[$i], $replyname[$i]); diff --git a/admin/compiler/joomla_3/Helper_site.php b/admin/compiler/joomla_3/Helper_site.php index 277a746c2..0e81e73de 100644 --- a/admin/compiler/joomla_3/Helper_site.php +++ b/admin/compiler/joomla_3/Helper_site.php @@ -293,7 +293,7 @@ abstract class ###Component###Helper } } // check if there are any view values remaining - if (count($_result)) + if (count((array)$_result)) { $_result = json_encode($_result); $_result = array($_result); @@ -833,7 +833,7 @@ abstract class ###Component###Helper **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count($array) > 0) + if (isset($array) && is_array($array) && count((array)$array) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -936,7 +936,7 @@ abstract class ###Component###Helper { $initial = strlen($string); $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count($words); + $words_count = count((array)$words); $word_length = 0; $last_word = 0; diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 4084cdef4..aaef4258f 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -501,6 +501,13 @@ class Get */ public $listJoinBuilder = array(); + /** + * The list head over ride + * + * @var array + */ + public $listHeadOverRide = array(); + /** * The linked admin view tabs * @@ -1683,6 +1690,7 @@ class Get // prep the buckets $this->fieldRelations[$name_list] = array(); $this->listJoinBuilder[$name_list] = array(); + $this->listHeadOverRide[$name_list] = array(); // set the relations $view->addrelations = (isset($view->addrelations) && ComponentbuilderHelper::checkJson($view->addrelations)) ? json_decode($view->addrelations, true) : null; if (ComponentbuilderHelper::checkArray($view->addrelations)) @@ -1708,6 +1716,18 @@ class Get { $this->listJoinBuilder[$name_list][(int) $join] = (int) $join; } + // set header over-ride + if (isset($relationsValue['column_name']) && ComponentbuilderHelper::checkString($relationsValue['column_name'])) + { + $check_column_name = trim(strtolower($relationsValue['column_name'])); + // confirm it should really make the over ride + if ('default' !== $check_column_name) + { + $column_name_lang = ComponentbuilderHelper::safeString($name_list, 'U') . '_' . ComponentbuilderHelper::safeString($relationsValue['column_name'], 'U'); + $this->langContent['admin'][$column_name_lang] = trim($relationsValue['column_name']); + $this->listHeadOverRide[$name_list][(int) $relationsValue['listfield']] = $column_name_lang; + } + } } } } diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 433565260..5dee21f97 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -6886,6 +6886,12 @@ class Interpretation extends Fields // build the dynamic fields foreach ($this->listBuilder[$viewName_list] as $item) { + // check if we have an over-ride + if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']])) + { + $item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']]; + } + // set the custom code if (ComponentbuilderHelper::checkArray($item['custom'])) { $item['code'] = $item['code'] . '_' . $item['custom']['text']; @@ -7953,6 +7959,11 @@ class Interpretation extends Fields // build the dynamic fields foreach ($this->listBuilder[$viewName_list] as $item) { + // check if we have an over-ride + if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']])) + { + $item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']]; + } $setin = (2 == $this->footableVersion) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"'; if ($controller > 3) { diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 3a68c19d0..c0866db2d 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -4625,7 +4625,7 @@ abstract class ComponentbuilderHelper } } // check if there are any view values remaining - if (count($_result)) + if (count((array)$_result)) { $_result = json_encode($_result); $_result = array($_result); @@ -4819,7 +4819,7 @@ abstract class ComponentbuilderHelper **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count($array) > 0) + if (isset($array) && is_array($array) && count((array)$array) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -4922,7 +4922,7 @@ abstract class ComponentbuilderHelper { $initial = strlen($string); $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count($words); + $words_count = count((array)$words); $word_length = 0; $last_word = 0; diff --git a/admin/helpers/componentbuilderemail.php b/admin/helpers/componentbuilderemail.php index f88185156..22956ff92 100644 --- a/admin/helpers/componentbuilderemail.php +++ b/admin/helpers/componentbuilderemail.php @@ -215,7 +215,7 @@ abstract class ComponentbuilderEmail if (is_array($mailreply)) { $mail->ClearReplyTos(); - $numReplyTo = count($mailreply); + $numReplyTo = count((array)$mailreply); for ($i=0; $i < $numReplyTo; $i++) { $mail->addReplyTo($mailreply[$i], $replyname[$i]); diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index a87e8d7f9..6e5b5b4be 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -255,6 +255,9 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW="Admin View" COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW_DESCRIPTION="Select an admin view" COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ADMIN_VIEW_LABEL="View" COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_AREA_LABEL="Area" +COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_HINT="Default" +COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_LABEL="Table Column Name" +COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_COLUMN_NAME_MESSAGE="Error! Please add some text here." COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CONCATENATE_RAQUO_GLUE="Concatenate » Glue" COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CREATED_BY_DESC="The user that created this Admin Fields Relations." COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CREATED_BY_LABEL="Created By" @@ -5525,6 +5528,8 @@ COM_COMPONENTBUILDER_MAX_LENGTH_ONLY_FOUR_TEXT_FIELD="Max Length (only 4 text_fi COM_COMPONENTBUILDER_MERGE="Merge" COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT="Minify JavaScript" COM_COMPONENTBUILDER_MIN_LENGTH_ONLY_FOUR_TEXT_FIELD="Min Length (only 4 text_field)" +COM_COMPONENTBUILDER_MODEL_AFTER_MODELLING="Model (after modelling)" +COM_COMPONENTBUILDER_MODEL_BEFORE_MODELLING="Model (before modelling)" COM_COMPONENTBUILDER_NAME="Name" COM_COMPONENTBUILDER_NAME_ASC="Name (Asc)" COM_COMPONENTBUILDER_NAME_DESC="Name (Desc)" diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 9fc8aa963..0796869ff 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -413,6 +413,8 @@ class ComponentbuilderModelAjax extends JModelList 'field' => 'setItemNames', 'listfield' => 'setItemNames', 'joinfields' => 'setItemNames', + 'area' => 'setAreaName', + 'set' => 'setCode', 'join_type' => 'setJoinType', 'list' => 'setAdminBehaviour', 'title' => 'setYesNo', @@ -994,6 +996,28 @@ class ComponentbuilderModelAjax extends JModelList return JText::_('COM_COMPONENTBUILDER_DETAILS'); } + protected function setAreaName($header, $value) + { + switch ($value) + { + case 1: + return JText::_('COM_COMPONENTBUILDER_MODEL_BEFORE_MODELLING'); + break; + case 2: + return JText::_('COM_COMPONENTBUILDER_VIEW'); + break; + case 3: + return JText::_('COM_COMPONENTBUILDER_MODEL_AFTER_MODELLING'); + break; + } + return JText::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setCode($header, $value) + { + return nl2br(htmlspecialchars($value)); + } + protected function setYesNo($header, $value) { if (1 == $value) @@ -2580,7 +2604,7 @@ class ComponentbuilderModelAjax extends JModelList if ($type == 1) { // MODEL - if ($area == 1) + if ($area == 1 || $area == 3) { return ', '; } diff --git a/admin/models/forms/admin_fields_relations.js b/admin/models/forms/admin_fields_relations.js index c0d8be38e..1e7b136ed 100644 --- a/admin/models/forms/admin_fields_relations.js +++ b/admin/models/forms/admin_fields_relations.js @@ -26,12 +26,19 @@ function getCodeGlueOptions(field) { var type = jQuery('#'+subID+'__join_type').val(); // get area value var area = jQuery('#'+subID+'__area').val(); - // get codeGlueOptions - getCodeGlueOptions_server(listfield, joinfields, type, area).done(function(result) { - if(result){ - jQuery('#'+subID+'__set').val(result); - } - }); + // check that values are set + if (_isSet(listfield) && _isSet(joinfields) && _isSet(type) && _isSet(area)) { + // get codeGlueOptions + getCodeGlueOptions_server(listfield, joinfields, type, area).done(function(result) { + if(result){ + jQuery('#'+subID+'__set').val(result); + } else { + jQuery('#'+subID+'__set').val(''); + } + }); + } else { + jQuery('#'+subID+'__set').val(''); + } } function getCodeGlueOptions_server(listfield, joinfields, type, area){ @@ -48,4 +55,12 @@ function getCodeGlueOptions_server(listfield, joinfields, type, area){ }); } +// the isSet function +function _isSet(val) +{ + if ((val != undefined) && (val != null) && 0 !== val.length){ + return true; + } + return false; +} diff --git a/admin/models/forms/admin_fields_relations.xml b/admin/models/forms/admin_fields_relations.xml index d142dd62e..e250e8df8 100644 --- a/admin/models/forms/admin_fields_relations.xml +++ b/admin/models/forms/admin_fields_relations.xml @@ -119,6 +119,21 @@ onchange="getCodeGlueOptions(this)" button="false" /> + + \"}}', 54, 1, '2018-05-28 07:00:41', '2018-05-28 09:45:25', 7, '', 4); -- -- Dumping data for table `#__componentbuilder_component_admin_views` diff --git a/componentbuilder.xml b/componentbuilder.xml index c40f96bd7..cc5da0916 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 26th May, 2018 + 29th May, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index 511810fb2..ddf22f7fe 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -3911,7 +3911,7 @@ abstract class ComponentbuilderHelper } } // check if there are any view values remaining - if (count($_result)) + if (count((array)$_result)) { $_result = json_encode($_result); $_result = array($_result); @@ -4553,7 +4553,7 @@ abstract class ComponentbuilderHelper **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count($array) > 0) + if (isset($array) && is_array($array) && count((array)$array) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -4656,7 +4656,7 @@ abstract class ComponentbuilderHelper { $initial = strlen($string); $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); - $words_count = count($words); + $words_count = count((array)$words); $word_length = 0; $last_word = 0;