From fdddad8f5f91821942b0f8561ab8208c6a921701 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Tue, 19 Nov 2019 18:06:17 +0530 Subject: [PATCH 01/18] Task #208 chore: Update tjlist saving and rendering logic, also added bootstrap tag input feature --- .../assets/css/bootstrap-tagsinput.css | 1 + .../assets/js/bootstrap-tagsinput.min.js | 7 ++ administrator/assets/js/tjlist.js | 20 ++++- administrator/assets/js/tjlist.min.js | 2 +- administrator/models/fields/tjlist.php | 30 +++++-- site/helpers/tjfields.php | 78 +++++++++++++++++-- 6 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 administrator/assets/css/bootstrap-tagsinput.css create mode 100644 administrator/assets/js/bootstrap-tagsinput.min.js diff --git a/administrator/assets/css/bootstrap-tagsinput.css b/administrator/assets/css/bootstrap-tagsinput.css new file mode 100644 index 00000000..55a8310b --- /dev/null +++ b/administrator/assets/css/bootstrap-tagsinput.css @@ -0,0 +1 @@ +.bootstrap-tagsinput{background-color:#fff;border:1px solid #ccc;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);display:inline-block;padding:4px 6px;color:#555;vertical-align:middle;border-radius:4px;width:100%;line-height:22px;cursor:text}.bootstrap-tagsinput input{border:none;box-shadow:none;outline:none;background-color:transparent;padding:0 6px;margin:0;width:auto;max-width:inherit}.bootstrap-tagsinput.form-control input::-moz-placeholder{color:#777;opacity:1}.bootstrap-tagsinput.form-control input:-ms-input-placeholder{color:#777}.bootstrap-tagsinput.form-control input::-webkit-input-placeholder{color:#777}.bootstrap-tagsinput input:focus{border:none;box-shadow:none}.bootstrap-tagsinput .tag{margin-right:2px;color:#fff}.bootstrap-tagsinput .tag [data-role="remove"]{margin-left:8px;cursor:pointer}.bootstrap-tagsinput .tag [data-role="remove"]:after{content:"x";padding:0 2px}.bootstrap-tagsinput .tag [data-role="remove"]:hover{box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.bootstrap-tagsinput .tag [data-role="remove"]:hover:active{box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)} diff --git a/administrator/assets/js/bootstrap-tagsinput.min.js b/administrator/assets/js/bootstrap-tagsinput.min.js new file mode 100644 index 00000000..b878bc10 --- /dev/null +++ b/administrator/assets/js/bootstrap-tagsinput.min.js @@ -0,0 +1,7 @@ +/* + * bootstrap-tagsinput v0.8.0 + * + */ + +!function(a){"use strict";function b(b,c){this.isInit=!0,this.itemsArray=[],this.$element=a(b),this.$element.hide(),this.isSelect="SELECT"===b.tagName,this.multiple=this.isSelect&&b.hasAttribute("multiple"),this.objectItems=c&&c.itemValue,this.placeholderText=b.hasAttribute("placeholder")?this.$element.attr("placeholder"):"",this.inputSize=Math.max(1,this.placeholderText.length),this.$container=a('
'),this.$input=a('').appendTo(this.$container),this.$element.before(this.$container),this.build(c),this.isInit=!1}function c(a,b){if("function"!=typeof a[b]){var c=a[b];a[b]=function(a){return a[c]}}}function d(a,b){if("function"!=typeof a[b]){var c=a[b];a[b]=function(){return c}}}function e(a){return a?i.text(a).html():""}function f(a){var b=0;if(document.selection){a.focus();var c=document.selection.createRange();c.moveStart("character",-a.value.length),b=c.text.length}else(a.selectionStart||"0"==a.selectionStart)&&(b=a.selectionStart);return b}function g(b,c){var d=!1;return a.each(c,function(a,c){if("number"==typeof c&&b.which===c)return d=!0,!1;if(b.which===c.which){var e=!c.hasOwnProperty("altKey")||b.altKey===c.altKey,f=!c.hasOwnProperty("shiftKey")||b.shiftKey===c.shiftKey,g=!c.hasOwnProperty("ctrlKey")||b.ctrlKey===c.ctrlKey;if(e&&f&&g)return d=!0,!1}}),d}var h={tagClass:function(a){return"label label-info"},focusClass:"focus",itemValue:function(a){return a?a.toString():a},itemText:function(a){return this.itemValue(a)},itemTitle:function(a){return null},freeInput:!0,addOnBlur:!0,maxTags:void 0,maxChars:void 0,confirmKeys:[13,44],delimiter:",",delimiterRegex:null,cancelConfirmKeysOnEmpty:!1,onTagExists:function(a,b){b.hide().fadeIn()},trimValue:!1,allowDuplicates:!1,triggerChange:!0};b.prototype={constructor:b,add:function(b,c,d){var f=this;if(!(f.options.maxTags&&f.itemsArray.length>=f.options.maxTags)&&(b===!1||b)){if("string"==typeof b&&f.options.trimValue&&(b=a.trim(b)),"object"==typeof b&&!f.objectItems)throw"Can't add objects when itemValue option is not set";if(!b.toString().match(/^\s*$/)){if(f.isSelect&&!f.multiple&&f.itemsArray.length>0&&f.remove(f.itemsArray[0]),"string"==typeof b&&"INPUT"===this.$element[0].tagName){var g=f.options.delimiterRegex?f.options.delimiterRegex:f.options.delimiter,h=b.split(g);if(h.length>1){for(var i=0;if.options.maxInputLength)){var o=a.Event("beforeItemAdd",{item:b,cancel:!1,options:d});if(f.$element.trigger(o),!o.cancel){f.itemsArray.push(b);var p=a(''+e(k)+'');p.data("item",b),f.findInputWrapper().before(p),p.after(" ");var q=a('option[value="'+encodeURIComponent(j)+'"]',f.$element).length||a('option[value="'+e(j)+'"]',f.$element).length;if(f.isSelect&&!q){var r=a("");r.data("item",b),r.attr("value",j),f.$element.append(r)}c||f.pushVal(f.options.triggerChange),(f.options.maxTags===f.itemsArray.length||f.items().toString().length===f.options.maxInputLength)&&f.$container.addClass("bootstrap-tagsinput-max"),a(".typeahead, .twitter-typeahead",f.$container).length&&f.$input.typeahead("val",""),this.isInit?f.$element.trigger(a.Event("itemAddedOnInit",{item:b,options:d})):f.$element.trigger(a.Event("itemAdded",{item:b,options:d}))}}}else if(f.options.onTagExists){var s=a(".tag",f.$container).filter(function(){return a(this).data("item")===n});f.options.onTagExists(b,s)}}}},remove:function(b,c,d){var e=this;if(e.objectItems&&(b="object"==typeof b?a.grep(e.itemsArray,function(a){return e.options.itemValue(a)==e.options.itemValue(b)}):a.grep(e.itemsArray,function(a){return e.options.itemValue(a)==b}),b=b[b.length-1]),b){var f=a.Event("beforeItemRemove",{item:b,cancel:!1,options:d});if(e.$element.trigger(f),f.cancel)return;a(".tag",e.$container).filter(function(){return a(this).data("item")===b}).remove(),a("option",e.$element).filter(function(){return a(this).data("item")===b}).remove(),-1!==a.inArray(b,e.itemsArray)&&e.itemsArray.splice(a.inArray(b,e.itemsArray),1)}c||e.pushVal(e.options.triggerChange),e.options.maxTags>e.itemsArray.length&&e.$container.removeClass("bootstrap-tagsinput-max"),e.$element.trigger(a.Event("itemRemoved",{item:b,options:d}))},removeAll:function(){var b=this;for(a(".tag",b.$container).remove(),a("option",b.$element).remove();b.itemsArray.length>0;)b.itemsArray.pop();b.pushVal(b.options.triggerChange)},refresh:function(){var b=this;a(".tag",b.$container).each(function(){var c=a(this),d=c.data("item"),f=b.options.itemValue(d),g=b.options.itemText(d),h=b.options.tagClass(d);if(c.attr("class",null),c.addClass("tag "+e(h)),c.contents().filter(function(){return 3==this.nodeType})[0].nodeValue=e(g),b.isSelect){var i=a("option",b.$element).filter(function(){return a(this).data("item")===d});i.attr("value",f)}})},items:function(){return this.itemsArray},pushVal:function(){var b=this,c=a.map(b.items(),function(a){return b.options.itemValue(a).toString()});b.$element.val(c,!0),b.options.triggerChange&&b.$element.trigger("change")},build:function(b){var e=this;if(e.options=a.extend({},h,b),e.objectItems&&(e.options.freeInput=!1),c(e.options,"itemValue"),c(e.options,"itemText"),d(e.options,"tagClass"),e.options.typeahead){var i=e.options.typeahead||{};d(i,"source"),e.$input.typeahead(a.extend({},i,{source:function(b,c){function d(a){for(var b=[],d=0;d$1")}}))}if(e.options.typeaheadjs){var j=null,k={},l=e.options.typeaheadjs;a.isArray(l)?(j=l[0],k=l[1]):k=l,e.$input.typeahead(j,k).on("typeahead:selected",a.proxy(function(a,b){k.valueKey?e.add(b[k.valueKey]):e.add(b),e.$input.typeahead("val","")},e))}e.$container.on("click",a.proxy(function(a){e.$element.attr("disabled")||e.$input.removeAttr("disabled"),e.$input.focus()},e)),e.options.addOnBlur&&e.options.freeInput&&e.$input.on("focusout",a.proxy(function(b){0===a(".typeahead, .twitter-typeahead",e.$container).length&&(e.add(e.$input.val()),e.$input.val(""))},e)),e.$container.on({focusin:function(){e.$container.addClass(e.options.focusClass)},focusout:function(){e.$container.removeClass(e.options.focusClass)}}),e.$container.on("keydown","input",a.proxy(function(b){var c=a(b.target),d=e.findInputWrapper();if(e.$element.attr("disabled"))return void e.$input.attr("disabled","disabled");switch(b.which){case 8:if(0===f(c[0])){var g=d.prev();g.length&&e.remove(g.data("item"))}break;case 46:if(0===f(c[0])){var h=d.next();h.length&&e.remove(h.data("item"))}break;case 37:var i=d.prev();0===c.val().length&&i[0]&&(i.before(d),c.focus());break;case 39:var j=d.next();0===c.val().length&&j[0]&&(j.after(d),c.focus())}var k=c.val().length;Math.ceil(k/5);c.attr("size",Math.max(this.inputSize,c.val().length))},e)),e.$container.on("keypress","input",a.proxy(function(b){var c=a(b.target);if(e.$element.attr("disabled"))return void e.$input.attr("disabled","disabled");var d=c.val(),f=e.options.maxChars&&d.length>=e.options.maxChars;e.options.freeInput&&(g(b,e.options.confirmKeys)||f)&&(0!==d.length&&(e.add(f?d.substr(0,e.options.maxChars):d),c.val("")),e.options.cancelConfirmKeysOnEmpty===!1&&b.preventDefault());var h=c.val().length;Math.ceil(h/5);c.attr("size",Math.max(this.inputSize,c.val().length))},e)),e.$container.on("click","[data-role=remove]",a.proxy(function(b){e.$element.attr("disabled")||e.remove(a(b.target).closest(".tag").data("item"))},e)),e.options.itemValue===h.itemValue&&("INPUT"===e.$element[0].tagName?e.add(e.$element.val()):a("option",e.$element).each(function(){e.add(a(this).attr("value"),!0)}))},destroy:function(){var a=this;a.$container.off("keypress","input"),a.$container.off("click","[role=remove]"),a.$container.remove(),a.$element.removeData("tagsinput"),a.$element.show()},focus:function(){this.$input.focus()},input:function(){return this.$input},findInputWrapper:function(){for(var b=this.$input[0],c=this.$container[0];b&&b.parentNode!==c;)b=b.parentNode;return a(b)}},a.fn.tagsinput=function(c,d,e){var f=[];return this.each(function(){var g=a(this).data("tagsinput");if(g)if(c||d){if(void 0!==g[c]){if(3===g[c].length&&void 0!==e)var h=g[c](d,null,e);else var h=g[c](d);void 0!==h&&f.push(h)}}else f.push(g);else g=new b(this,c),a(this).data("tagsinput",g),f.push(g),"SELECT"===this.tagName&&a("option",a(this)).attr("selected","selected"),a(this).val(a(this).val())}),"string"==typeof c?f.length>1?f:f[0]:f},a.fn.tagsinput.Constructor=b;var i=a("
");a(function(){a("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput()})}(window.jQuery); +//# sourceMappingURL=bootstrap-tagsinput.min.js.map diff --git a/administrator/assets/js/tjlist.js b/administrator/assets/js/tjlist.js index 96523011..fe59a766 100644 --- a/administrator/assets/js/tjlist.js +++ b/administrator/assets/js/tjlist.js @@ -6,10 +6,13 @@ * @license GNU General Public License version 2, or later */ var tjlist = { - addOtherOption: function (element) { jQuery(tjlist.getTextBox(element)).insertAfter(element.next(".chzn-container")); + + setTimeout(function() { + element.siblings('div.tjfieldTjListOtherText').children('.bootstrap-tagsinput').children().focus(); + }, 100); }, removeOtherOption: function (element) { @@ -19,9 +22,22 @@ var tjlist = { var inputName = element.attr('name'), inputId = element.attr('id'), isRequired = (element.attr('required') != undefined) ? 'required="required"' : '', + tagInput = (element.attr('multiple') != undefined) ? 'data-role="tagsinput"' : '', + requiredClass = (isRequired != '') ? 'required' : ''; - return '

'; + this.loadTagsinputjs(); + + return '

'; + }, + loadTagsinputjs: function() + { + var head= document.getElementsByTagName('head')[0]; + var script= document.createElement('script'); + + // @Todo - Decide right place to store below JS + script.src= Joomla.getOptions('system.paths').base +'/administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js'; + head.appendChild(script); } } diff --git a/administrator/assets/js/tjlist.min.js b/administrator/assets/js/tjlist.min.js index d3fc345a..8cb8780b 100644 --- a/administrator/assets/js/tjlist.min.js +++ b/administrator/assets/js/tjlist.min.js @@ -1 +1 @@ -var tjlist={addOtherOption:function(t){jQuery(tjlist.getTextBox(t)).insertAfter(t.next(".chzn-container"))},removeOtherOption:function(t){t.siblings("div.tjfieldTjListOtherText").remove()},getTextBox:function(t){var e=t.attr("name"),r=t.attr("id"),i=null!=t.attr("required")?'required="required"':"";return'

'}};jQuery(document).ready(function(){jQuery(document).on("change",".tjfieldTjList",function(){var t=jQuery(this).val();-1!==jQuery.inArray(Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE"),t)||t==Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE")?0==jQuery('input[name="'+jQuery(this).attr("name")+'"]').length&&tjlist.addOtherOption(jQuery(this)):tjlist.removeOtherOption(jQuery(this))})}); +var tjlist={addOtherOption:function(element){jQuery(tjlist.getTextBox(element)).insertAfter(element.next(".chzn-container"));setTimeout(function(){element.siblings("div.tjfieldTjListOtherText").children(".bootstrap-tagsinput").children().focus()},100)},removeOtherOption:function(element){element.siblings("div.tjfieldTjListOtherText").remove()},getTextBox:function(element){var inputName=element.attr("name"),inputId=element.attr("id"),isRequired=element.attr("required")!=undefined?'required="required"':"",tagInput=element.attr("multiple")!=undefined?'data-role="tagsinput"':"",requiredClass=isRequired!=""?"required":"";this.loadTagsinputjs();return'

'},loadTagsinputjs:function(){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=Joomla.getOptions("system.paths").base+"/administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js";head.appendChild(script)}};jQuery(document).ready(function(){jQuery(document).on("change",".tjfieldTjList",function(){var selectedVal=jQuery(this).val();if(jQuery.inArray(Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE"),selectedVal)!==-1||selectedVal==Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE")){if(jQuery('input[name="'+jQuery(this).attr("name")+'"]').length==0){tjlist.addOtherOption(jQuery(this))}}else{tjlist.removeOtherOption(jQuery(this))}})}); diff --git a/administrator/models/fields/tjlist.php b/administrator/models/fields/tjlist.php index b6b576ef..ad1c3dd7 100644 --- a/administrator/models/fields/tjlist.php +++ b/administrator/models/fields/tjlist.php @@ -14,6 +14,7 @@ use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Factory; /** * Form Field class for the Joomla Platform. @@ -105,7 +106,9 @@ protected function getInput() $html = parent::getInput(); - $doc = JFactory::getDocument(); + $doc = Factory::getDocument(); + $doc->addStyleSheet(JUri::root() . 'administrator/components/com_tjfields/assets/css/bootstrap-tagsinput.css'); + $doc->addScript(JUri::root() . 'administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js'); $doc->addScript(JUri::root() . 'administrator/components/com_tjfields/assets/js/tjlist.min.js'); $options = $this->getOptions(); @@ -131,7 +134,8 @@ function ($e) { if (empty($valueFromSelectList)) { - $this->otherSelectedValue = $this->value[0]; + // Remove prefix values from other text values + $this->otherSelectedValue = str_replace($this->type . ':-', '', $this->value[0]); } } elseif ($this->multiple) @@ -150,7 +154,10 @@ function ($e) { if (!empty($otherValues)) { - $this->otherSelectedValue = $otherValues[0]; + $this->otherSelectedValue = implode(',', $otherValues); + + // Remove prefix values from other text values + $this->otherSelectedValue = str_replace($this->type . ':-', '', $this->otherSelectedValue); } } } @@ -202,8 +209,21 @@ public function getOptions() private function getInputBox() { $text = '

'; - $text .= 'otherInputRequired . ' - name="' . $this->name . '" id="' . $this->id . '" value="' . $this->otherSelectedValue . '" aria-invalid="false">
'; + + // Check multiple select option true or not + if ($this->multiple) + { + // Enable the bootstrap taging input + $text .= 'otherInputRequired . ' name="' . $this->name . '" id="' . $this->id . '" value="' . $this->otherSelectedValue . '" aria-invalid="false">'; + } + else + { + $text .= 'otherInputRequired . ' + name="' . $this->name . '" id="' . $this->id . '" value="' . $this->otherSelectedValue . '" aria-invalid="false">'; + } + + $text .= '
'; return $text; } diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 1cdddcab..12c1d8e9 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -307,6 +307,68 @@ public function saveFieldsValue($data) } } } + elseif ($field->type == 'tjlist') + { + // Check for Tjlist - start + $tjListParams = json_decode($field->params); + + if ($tjListParams->other) + { + // Get all the fields of the specified client + JLoader::import('components.com_tjfields.models.options', JPATH_ADMINISTRATOR); + $tjFieldOptionsModel = JModelLegacy::getInstance('Options', 'TjfieldsModel', array('ignore_request' => true)); + $tjFieldOptionsModel->setState('filter.field_id', $field->id); + $optionsValue = $tjFieldOptionsModel->getItems(); + + // Get array of dropdown values + $otherValues = array_column($optionsValue, 'value'); + } + + if (is_array($fieldValue)) + { + $fieldVal = array(); + + if ($tjListParams->other) + { + $otherValues[] = $field->type . 'othervalue'; + + foreach ($fieldValue as $key => $listfieldVale) + { + if (strpos($listfieldVale, ',')) + { + $fieldVal = explode(',', $listfieldVale); + + // Add prefix for other values for tjlist field + $fieldVal = preg_filter('/^/', $field->type . ':-', $fieldVal); + unset($fieldValue[$key]); + } + elseif (!in_array($listfieldVale, $otherValues)) + { + $fieldValue[$key] = $field->type . ':-' . $listfieldVale; + } + } + + if (!empty($fieldVal)) + { + $fieldValue = array_merge($fieldValue, $fieldVal); + } + } + + $this->saveMultiValuedFieldData($fieldValue, $field->client, $data['content_id'], $field->id, $fieldStoredValues); + } + else + { + // Check other option enable for tjlist field + + if ($tjListParams->other && !in_array($fieldValue, $otherValues)) + { + // Add prefix for other values for tjlist field + $fieldValue = $field->type . ':-' . $fieldValue; + } + + $this->saveSingleValuedFieldData($fieldValue, $field->client, $data['content_id'], $field->id, $fieldStoredValues); + } + } elseif (is_array($fieldValue)) { if (strpos($fieldValue[0], ',')) @@ -1485,15 +1547,17 @@ public function getOptions($field_id, $option_value = '') if (!empty($otherValues)) { - $tjListOtherObj = new stdClass; - - $tjListOtherObj->options = $otherValues[0]; - $tjListOtherObj->default_option = ''; - $tjListOtherObj->value = $otherValues[0]; - - $extra_options[] = $tjListOtherObj; + foreach ($otherValues as $othervalue) + { + $tjListOtherObj = new stdClass; + $tjListOtherObj->default_option = ''; + $tjListOtherObj->options = $othervalue; + $tjListOtherObj->value = $othervalue; + $extra_options[] = $tjListOtherObj; + } } } + // Check for Tjlist - end } } From b7fed3811f293c3ae4a1118a216212e81551a3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyour?= Date: Tue, 19 Nov 2019 18:40:15 +0530 Subject: [PATCH 02/18] Add Support for Color Picker field #210 --- admin_language/en-GB/en-GB.com_tjfields.ini | 2 ++ administrator/models/fields/tjfieldfields.php | 1 + administrator/models/forms/types/forms/color.xml | 8 ++++++++ 3 files changed, 11 insertions(+) create mode 100644 administrator/models/forms/types/forms/color.xml diff --git a/admin_language/en-GB/en-GB.com_tjfields.ini b/admin_language/en-GB/en-GB.com_tjfields.ini index 8820d0e6..ce7d994c 100755 --- a/admin_language/en-GB/en-GB.com_tjfields.ini +++ b/admin_language/en-GB/en-GB.com_tjfields.ini @@ -224,6 +224,8 @@ COM_TJFIELDS_YES="Yes" COMTJFILEDS_FIELD_CREATED_SUCCESSFULLY="Field saved successfully" COMTJFILEDS_GROUP_CREATED_SUCCESSFULLY="Group saved successfully" COM_TJFIELDS_NUMBER="Number" +COM_TJFIELDS_COLOR="Colour(color)" + ; Since 1.1 - Aug 2014 ; Countries list diff --git a/administrator/models/fields/tjfieldfields.php b/administrator/models/fields/tjfieldfields.php index 8b4cb181..38feccd6 100644 --- a/administrator/models/fields/tjfieldfields.php +++ b/administrator/models/fields/tjfieldfields.php @@ -92,6 +92,7 @@ protected function getInput() } $options[] = JHtml::_('select.option', 'ownership', JText::_('COM_TJFIELDS_OWNERSHIP')); + $options[] = JHtml::_('select.option', 'color', JText::_('COM_TJFIELDS_COLOR')); $options = array_merge(parent::getOptions(), $options); diff --git a/administrator/models/forms/types/forms/color.xml b/administrator/models/forms/types/forms/color.xml new file mode 100644 index 00000000..a767e5cd --- /dev/null +++ b/administrator/models/forms/types/forms/color.xml @@ -0,0 +1,8 @@ + +
+ +
+ +
+
+
From 3fb2fe07b6cccb16654a0bb9bc0ecbb381a56a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 20 Nov 2019 11:59:49 +0530 Subject: [PATCH 03/18] Bug #242 fix: If any field in subform contain special character in its name then the data for that field is not saved in DB --- administrator/models/field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/models/field.php b/administrator/models/field.php index 28f0c2ab..5255b4bd 100755 --- a/administrator/models/field.php +++ b/administrator/models/field.php @@ -288,7 +288,7 @@ public function save($data) if ($data['id'] == 0) { // Escape apostraphe - $data_name = trim(preg_replace('/[^A-Za-z0-9\-\']/', '', $data['name'])); + $data_name = trim(preg_replace('/[^a-zA-Z0-9]/', '', $data['name'])); $client = explode('.', $data['client']); $client = $client[0]; $data_unique_name = $client . '_' . $data['client_type'] . '_' . $data_name; From 9d974cfe47f8de0e6c204f8a61fc88ac6a4cf712 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 20 Nov 2019 13:07:26 +0530 Subject: [PATCH 04/18] Task #208 chore: Changes made for tagInputs --- administrator/assets/js/tjlist.js | 14 +++++++++++--- administrator/assets/js/tjlist.min.js | 2 +- administrator/models/fields/tjlist.php | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/administrator/assets/js/tjlist.js b/administrator/assets/js/tjlist.js index fe59a766..477805f4 100644 --- a/administrator/assets/js/tjlist.js +++ b/administrator/assets/js/tjlist.js @@ -12,6 +12,12 @@ var tjlist = { setTimeout(function() { element.siblings('div.tjfieldTjListOtherText').children('.bootstrap-tagsinput').children().focus(); + + if (element.attr('multiple') == undefined) + { + element.siblings('div.tjfieldTjListOtherText').children().focus(); + } + }, 100); }, removeOtherOption: function (element) { @@ -22,11 +28,13 @@ var tjlist = { var inputName = element.attr('name'), inputId = element.attr('id'), isRequired = (element.attr('required') != undefined) ? 'required="required"' : '', - tagInput = (element.attr('multiple') != undefined) ? 'data-role="tagsinput"' : '', - requiredClass = (isRequired != '') ? 'required' : ''; - this.loadTagsinputjs(); + if (element.attr('multiple') != undefined) + { + this.loadTagsinputjs(); + var tagInput = (element.attr('multiple') != undefined) ? 'data-role="tagsinput"' : ''; + } return '

'; }, diff --git a/administrator/assets/js/tjlist.min.js b/administrator/assets/js/tjlist.min.js index 8cb8780b..8bb4a17d 100644 --- a/administrator/assets/js/tjlist.min.js +++ b/administrator/assets/js/tjlist.min.js @@ -1 +1 @@ -var tjlist={addOtherOption:function(element){jQuery(tjlist.getTextBox(element)).insertAfter(element.next(".chzn-container"));setTimeout(function(){element.siblings("div.tjfieldTjListOtherText").children(".bootstrap-tagsinput").children().focus()},100)},removeOtherOption:function(element){element.siblings("div.tjfieldTjListOtherText").remove()},getTextBox:function(element){var inputName=element.attr("name"),inputId=element.attr("id"),isRequired=element.attr("required")!=undefined?'required="required"':"",tagInput=element.attr("multiple")!=undefined?'data-role="tagsinput"':"",requiredClass=isRequired!=""?"required":"";this.loadTagsinputjs();return'

'},loadTagsinputjs:function(){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=Joomla.getOptions("system.paths").base+"/administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js";head.appendChild(script)}};jQuery(document).ready(function(){jQuery(document).on("change",".tjfieldTjList",function(){var selectedVal=jQuery(this).val();if(jQuery.inArray(Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE"),selectedVal)!==-1||selectedVal==Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE")){if(jQuery('input[name="'+jQuery(this).attr("name")+'"]').length==0){tjlist.addOtherOption(jQuery(this))}}else{tjlist.removeOtherOption(jQuery(this))}})}); +var tjlist={addOtherOption:function(element){jQuery(tjlist.getTextBox(element)).insertAfter(element.next(".chzn-container"));setTimeout(function(){element.siblings("div.tjfieldTjListOtherText").children(".bootstrap-tagsinput").children().focus();if(element.attr("multiple")==undefined){element.siblings("div.tjfieldTjListOtherText").children().focus()}},100)},removeOtherOption:function(element){element.siblings("div.tjfieldTjListOtherText").remove()},getTextBox:function(element){var inputName=element.attr("name"),inputId=element.attr("id"),isRequired=element.attr("required")!=undefined?'required="required"':"",requiredClass=isRequired!=""?"required":"";if(element.attr("multiple")!=undefined){this.loadTagsinputjs();var tagInput=element.attr("multiple")!=undefined?'data-role="tagsinput"':""}return'

'},loadTagsinputjs:function(){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=Joomla.getOptions("system.paths").base+"/administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js";head.appendChild(script)}};jQuery(document).ready(function(){jQuery(document).on("change",".tjfieldTjList",function(){var selectedVal=jQuery(this).val();if(jQuery.inArray(Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE"),selectedVal)!==-1||selectedVal==Joomla.JText._("COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE")){if(jQuery('input[name="'+jQuery(this).attr("name")+'"]').length==0){tjlist.addOtherOption(jQuery(this))}}else{tjlist.removeOtherOption(jQuery(this))}})}); diff --git a/administrator/models/fields/tjlist.php b/administrator/models/fields/tjlist.php index ad1c3dd7..00cff908 100644 --- a/administrator/models/fields/tjlist.php +++ b/administrator/models/fields/tjlist.php @@ -107,10 +107,14 @@ protected function getInput() $html = parent::getInput(); $doc = Factory::getDocument(); - $doc->addStyleSheet(JUri::root() . 'administrator/components/com_tjfields/assets/css/bootstrap-tagsinput.css'); - $doc->addScript(JUri::root() . 'administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js'); $doc->addScript(JUri::root() . 'administrator/components/com_tjfields/assets/js/tjlist.min.js'); + if ($this->multiple) + { + $doc->addStyleSheet(JUri::root() . 'administrator/components/com_tjfields/assets/css/bootstrap-tagsinput.css'); + $doc->addScript(JUri::root() . 'administrator/components/com_tjfields/assets/js/bootstrap-tagsinput.min.js'); + } + $options = $this->getOptions(); if ($this->element['other']) From e3ca0ee1fece4b3dd319cd3bd29fcd1b5ca15d03 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 20 Nov 2019 15:54:41 +0530 Subject: [PATCH 05/18] Task #208 chore: made changes in list field layout --- site/layouts/fields/list.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/site/layouts/fields/list.php b/site/layouts/fields/list.php index 910ad1a1..39c69ff8 100644 --- a/site/layouts/fields/list.php +++ b/site/layouts/fields/list.php @@ -9,6 +9,8 @@ // No direct access defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Language\Text; + if (!key_exists('field', $displayData) || !key_exists('fieldXml', $displayData)) { return; @@ -40,7 +42,12 @@ if (isset($options[$field->value])) { $options[$field->value] = htmlspecialchars($options[$field->value], ENT_COMPAT, 'UTF-8'); - echo JText::_(ucfirst($options[$field->value])); + echo Text::_(ucfirst($options[$field->value])); + } + elseif ($field->value != Text::_('COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE')) + { + echo Text::_(ucfirst(str_replace($field->type . ':-', '', $field->value))); + echo "
"; } } else @@ -51,9 +58,14 @@ if (isset($options[$value])) { $options[$value] = htmlspecialchars($options[$value], ENT_COMPAT, 'UTF-8'); - echo JText::_(ucfirst($options[$value])); + echo Text::_(ucfirst($options[$value])); + echo "
"; + } + elseif ($value != Text::_('COM_TJFIELDS_TJLIST_OTHER_OPTION_VALUE')) + { + echo Text::_(ucfirst(str_replace($field->type . ':-', '', $value))); echo "
"; } } } -} \ No newline at end of file +} From 5d2fde5db9825a0d431220c7162b6f699cc1bda3 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 20 Nov 2019 16:21:51 +0530 Subject: [PATCH 06/18] Task #208 chore: prevent to store blank value --- site/helpers/tjfields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 12c1d8e9..16800f25 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -356,7 +356,7 @@ public function saveFieldsValue($data) $this->saveMultiValuedFieldData($fieldValue, $field->client, $data['content_id'], $field->id, $fieldStoredValues); } - else + elseif (!empty($fieldValue)) { // Check other option enable for tjlist field From f0c8b590bc656d27f4db61c8ce7bf94f08f470f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 21 Nov 2019 15:16:32 +0530 Subject: [PATCH 07/18] Bug #242 fix: If any field in subform contain special character in its name then the data for that field is not saved in DB --- administrator/helpers/tjfields.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/helpers/tjfields.php b/administrator/helpers/tjfields.php index 405f2e14..5abdc72d 100755 --- a/administrator/helpers/tjfields.php +++ b/administrator/helpers/tjfields.php @@ -239,13 +239,13 @@ public function createXml($data, $fields, $category = null) // Get backend XML file path if (!empty($category['category_id'])) { - $filePathBackend = JPATH_SITE . DS . 'administrator/components/' . + $filePathBackend = JPATH_ADMINISTRATOR . '/components/' . $explodeForCom[0] . '/models/forms/' . $category['category_id'] . $data['client_type'] . '_extra.xml'; } else { - $filePathBackend = JPATH_SITE . DS . 'administrator/components/' . + $filePathBackend = JPATH_ADMINISTRATOR . '/components/' . $explodeForCom[0] . '/models/forms/' . $data['client_type'] . '_extra.xml'; } From 348bf72d45f5a00c8b2c8241a978035b89da965f Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Fri, 22 Nov 2019 12:39:16 +0530 Subject: [PATCH 08/18] Task#208 chore: update tjlist saving logic for other options multiple values --- site/helpers/tjfields.php | 55 ++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 16800f25..b8a0700f 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -326,31 +326,72 @@ public function saveFieldsValue($data) if (is_array($fieldValue)) { - $fieldVal = array(); - if ($tjListParams->other) { + $fieldOtherVal = $fieldOptionsVal = array(); + $postFieldValueCount = count($fieldValue); + $k = 0; + $otherValues[] = $field->type . 'othervalue'; foreach ($fieldValue as $key => $listfieldVale) { - if (strpos($listfieldVale, ',')) + $k++; + + // Update the last index element of other options multi values + if (strpos($listfieldVale, ',') && $postFieldValueCount > 1 && $postFieldValueCount == $k) { - $fieldVal = explode(',', $listfieldVale); + $fieldOtherVal = explode(',', $listfieldVale); // Add prefix for other values for tjlist field - $fieldVal = preg_filter('/^/', $field->type . ':-', $fieldVal); + $fieldOtherVal = preg_filter('/^/', $field->type . ':-', $fieldOtherVal); + unset($fieldValue[$key]); + } + elseif (strpos($listfieldVale, ',')) + { + // Check its actual option list values + $fieldOptionsVal = explode(',', $listfieldVale); + + if ($postFieldValueCount == 1) + { + $fieldOptionsVal = array_filter( + $fieldOptionsVal, + function($val) + { + return $val != 'tjlistothervalue'; + } + ); + } + unset($fieldValue[$key]); } elseif (!in_array($listfieldVale, $otherValues)) { + // Check its other options values not a actual option list values $fieldValue[$key] = $field->type . ':-' . $listfieldVale; } + else + { + $fieldValue = array_filter( + $fieldValue, + function($val) + { + return $val != 'tjlistothervalue'; + } + ); + } + } + + // Check other options multiple values exist in array + if (!empty($fieldOtherVal)) + { + $fieldValue = array_merge($fieldValue, $fieldOtherVal); } - if (!empty($fieldVal)) + // Check options list value exist in array + if (!empty($fieldOptionsVal)) { - $fieldValue = array_merge($fieldValue, $fieldVal); + $fieldValue = array_merge($fieldValue, $fieldOptionsVal); } } From edcbf45074f1afa68ef112ddf6af9b77a14fc735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyour?= Date: Fri, 22 Nov 2019 18:28:37 +0530 Subject: [PATCH 09/18] Issue #210: Color Field Layout --- site/layouts/fields/color.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 site/layouts/fields/color.php diff --git a/site/layouts/fields/color.php b/site/layouts/fields/color.php new file mode 100644 index 00000000..8903d73d --- /dev/null +++ b/site/layouts/fields/color.php @@ -0,0 +1,23 @@ + + * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access +defined('_JEXEC') or die('Restricted access'); + +if (!key_exists('field', $displayData)) +{ + return; +} + +$field = $displayData['field']; + +if ($field->value != '') +{ ?> +

value;?>

+ Date: Mon, 25 Nov 2019 16:58:51 +0530 Subject: [PATCH 10/18] Task#216 Fix: File name should be display in edit and detail view --- administrator/models/fields/file.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/administrator/models/fields/file.php b/administrator/models/fields/file.php index 7467915f..ff613b75 100644 --- a/administrator/models/fields/file.php +++ b/administrator/models/fields/file.php @@ -142,10 +142,23 @@ protected function getInput() $data = $this->buildData($layoutData); $html .= $data->html; + // To get the file name from URL + $substrString = substr($data->mediaLink, strlen('fpht=') + strpos($data->mediaLink, 'fpht=')); + $substrString = substr($substrString, 0, strpos($substrString, '&')); + + // Decode the filename + $fileName = base64_decode($substrString); + if (!empty($data->mediaLink)) { $html .= $this->canDownloadFile($data, $layoutData); $html .= $this->canDeleteFile($data, $layoutData); + + // To display the file name if exist and skip the prepended file name value + if (!empty($fileName)) + { + $html .= ' ' . substr($fileName, strpos($fileName, '_', 12) + 1) . ''; + } } $html .= ''; From b26eed48f17f0cc53ce6f432cdf0c4650977354c Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Mon, 25 Nov 2019 17:00:26 +0530 Subject: [PATCH 11/18] Task#216 Fix: File name should be display in edit and detail view --- site/layouts/fields/file.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/site/layouts/fields/file.php b/site/layouts/fields/file.php index 896857e7..fc1af06e 100644 --- a/site/layouts/fields/file.php +++ b/site/layouts/fields/file.php @@ -1,9 +1,10 @@ - * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package TJ-Fields + * @subpackage Form + * author TechJoomla + * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE */ // No direct access @@ -38,5 +39,19 @@ $tjFieldHelper = new TjfieldsHelper; $mediaLink = $tjFieldHelper->getMediaUrl($field->value, $extraParamArray); + + // To get the file name from URL + $substrString = substr($mediaLink, strlen('fpht=') + strpos($mediaLink, 'fpht=')); + $substrString = substr($substrString, 0, strpos($substrString, '=')); + + // Decode the filename + $fileName = base64_decode($substrString); + echo "" . JText::_("COM_TJFIELDS_FILE_DOWNLOAD") . ""; -} \ No newline at end of file + + // To display the file name if exist and skip the prepended file name value + if (!empty($fileName)) + { + echo ' ' . substr($fileName, strpos($fileName, '_', 12) + 1) . ''; + } +} From f5ffe940734dd6720617c7270901018235bbc261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 25 Nov 2019 18:38:39 +0530 Subject: [PATCH 12/18] Bug #153600 fix: Chrome,Edge>> Record is still visible even user remove it and saved the changes --- site/helpers/tjfields.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index b8a0700f..f10d0fd1 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -277,6 +277,17 @@ public function saveFieldsValue($data) array_pop($ucmSubformClientTmp); $ucmSubformClient = 'com_tjucm.' . implode('_', $ucmSubformClientTmp); + // Load UCM models + JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); + JLoader::import('components.com_tjucm.models.items', JPATH_SITE); + + // Get all the records which were previously stored for the ucmsubform field in parent form + $tjucmItemsModel = JModelLegacy::getInstance('Items', 'TjucmModel', array('ignore_request' => true)); + $tjucmItemsModel->setState('parent_id', TJUCM_PARENT_CONTENT_ID); + $tjucmItemsModel->setState('ucm.client', $ucmSubformClient); + $ucmSubformRecords = $tjucmItemsModel->getItems(); + $ucmSubformRecordIds = array_column($ucmSubformRecords, 'id'); + $this->saveSingleValuedFieldData($ucmSubformClient, TJUCM_PARENT_CLIENT, TJUCM_PARENT_CONTENT_ID, $field->id, $fieldStoredValues); foreach ($fieldValue as $key => $ucmSubformValue) @@ -291,12 +302,16 @@ public function saveFieldsValue($data) { $tjUcmSubFormItemData = array('id' => '', 'parent_id' => $data['content_id'], 'client' => $ucmSubformClient); - JLoader::import('component.com_tjucm.models.itemform', JPATH_SITE); $tjUcmItemFormModel = JModelLegacy::getInstance('ItemForm', 'TjucmModel'); $tjUcmItemFormModel->save($tjUcmSubFormItemData); $ucmSubFormContentId = $tjUcmItemFormModel->getState($tjUcmItemFormModel->getName() . '.id'); } + if (array_search($ucmSubFormContentId, $ucmSubformRecordIds) !== false) + { + unset($ucmSubformRecordIds[array_search($ucmSubFormContentId, $ucmSubformRecordIds)]); + } + $tjUcmSubFormContentId['childContentIds'][$ucmSubformContentIdFieldElementId] = (INT) $ucmSubFormContentId; $ucmSubFormData = array(); $ucmSubFormData['content_id'] = $ucmSubFormContentId; @@ -306,6 +321,14 @@ public function saveFieldsValue($data) $this->saveFieldsValue($ucmSubFormData); } } + + // Delete the records which are removed from the ucmsubform + $tjUcmItemFormModel = JModelLegacy::getInstance('ItemForm', 'TjucmModel'); + + foreach ($ucmSubformRecordIds as $ucmSubformRecordId) + { + $tjUcmItemFormModel->delete($ucmSubformRecordId); + } } elseif ($field->type == 'tjlist') { From e376681174d40606e360f92265e1a3ddcf4aeab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Tue, 26 Nov 2019 17:07:23 +0530 Subject: [PATCH 13/18] Bug #256 fix: If related field is cluster aware then we should only show the options of records belonging to the clusters of the logged in user --- administrator/models/field.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/administrator/models/field.php b/administrator/models/field.php index 5255b4bd..3a398458 100755 --- a/administrator/models/field.php +++ b/administrator/models/field.php @@ -12,6 +12,7 @@ jimport('joomla.application.component.modeladmin'); use Joomla\Registry\Registry; +use Joomla\CMS\Form\FormHelper; /** * Tjfields model. @@ -692,6 +693,32 @@ public function getRelatedFieldOptions($fieldId) { $query->where($db->quoteName('cluster_id') . ' = ' . $clusterId); } + else + { + FormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models/fields/'); + $cluster = FormHelper::loadFieldType('cluster', false); + $clusterList = $cluster->getOptionsExternally(); + $usersClusters = array(); + + if (!empty($clusterList)) + { + foreach ($clusterList as $clusterList) + { + if (!empty($clusterList->value)) + { + $usersClusters[] = $clusterList->value; + } + } + } + + // If cluster array empty then we set 0 in whereclause query + if (empty($usersClusters)) + { + $usersClusters[] = 0; + } + + $query->where($db->quoteName('cluster_id') . ' IN (' . implode(",", $usersClusters) . ')'); + } } $parentContentId = $jInput->get('id', 0, 'INT'); From 43ba5205dfa8f7ed8c8e62c9e12d0a5143bbc753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 27 Nov 2019 13:02:12 +0530 Subject: [PATCH 14/18] Bug #256 fix: If related field is cluster aware then we should only show the options of records belonging to the clusters of the logged in user --- administrator/models/fields/related.php | 13 +++++++++++++ site/helpers/tjfields.php | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/administrator/models/fields/related.php b/administrator/models/fields/related.php index 47e71d3c..3cb0e980 100644 --- a/administrator/models/fields/related.php +++ b/administrator/models/fields/related.php @@ -109,12 +109,25 @@ protected function getInput() // UCM fields and field value to get $showAddNewRecordLink = $fieldParams->get('showAddNewRecordLink'); + $clusterAware = $fieldParams->get('clusterAware'); if ($canCreate && !empty($showAddNewRecordLink)) { $tjUcmFrontendHelper = new TjucmHelpersTjucm; $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=itemform&client=' . $ucmTypeTable->unique_identifier); $masterUcmLink = Route::_('index.php?option=com_tjucm&view=itemform&Itemid=' . $itemId, false); + + if ($clusterAware) + { + $input = JFactory::getApplication()->input; + $clusterId = $input->get("cluster_id", 0, "INT"); + + if ($clusterId) + { + $masterUcmLink .= (strpos($masterUcmLink, '?')) ? '&cluster_id=' . $clusterId : '?cluster_id=' . $clusterId; + } + } + $html .= ""; } } diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index f10d0fd1..37ca40d4 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -656,8 +656,6 @@ private function saveMediaFieldData($fieldValue, $client, $contentId, $fieldId, // Configure allowed extensions for media library if (!empty($mimeTypes)) { - $mimeTypes = explode(',', $mimeTypes); - foreach ($mimeTypes as $j => $allowedType) { $mimeTypes[$j] = trim(str_replace('.', '', $allowedType)); From 39fb1c94787382dd3ff215fe68290eeb3c1ca6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 27 Nov 2019 16:46:09 +0530 Subject: [PATCH 15/18] Bug #242 fix: If any field in subform contain special character in its name then the data for that field is not saved in DB --- site/helpers/tjfields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 37ca40d4..a5bb3ad7 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -286,7 +286,7 @@ public function saveFieldsValue($data) $tjucmItemsModel->setState('parent_id', TJUCM_PARENT_CONTENT_ID); $tjucmItemsModel->setState('ucm.client', $ucmSubformClient); $ucmSubformRecords = $tjucmItemsModel->getItems(); - $ucmSubformRecordIds = array_column($ucmSubformRecords, 'id'); + $ucmSubformRecordIds = (!empty($ucmSubformRecords)) ? array_column($ucmSubformRecords, 'id') : array(); $this->saveSingleValuedFieldData($ucmSubformClient, TJUCM_PARENT_CLIENT, TJUCM_PARENT_CONTENT_ID, $field->id, $fieldStoredValues); From 607466e9285a3033af1145d931341773befd89fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 27 Nov 2019 18:49:09 +0530 Subject: [PATCH 16/18] Bug #153557 fix: Frontend>> Removed record from UCM subform is still visible if user check it from edit mode --- site/helpers/tjfields.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index a5bb3ad7..5c72b9a4 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -277,16 +277,19 @@ public function saveFieldsValue($data) array_pop($ucmSubformClientTmp); $ucmSubformClient = 'com_tjucm.' . implode('_', $ucmSubformClientTmp); - // Load UCM models + // Load UCM itemform model JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); - JLoader::import('components.com_tjucm.models.items', JPATH_SITE); // Get all the records which were previously stored for the ucmsubform field in parent form - $tjucmItemsModel = JModelLegacy::getInstance('Items', 'TjucmModel', array('ignore_request' => true)); - $tjucmItemsModel->setState('parent_id', TJUCM_PARENT_CONTENT_ID); - $tjucmItemsModel->setState('ucm.client', $ucmSubformClient); - $ucmSubformRecords = $tjucmItemsModel->getItems(); - $ucmSubformRecordIds = (!empty($ucmSubformRecords)) ? array_column($ucmSubformRecords, 'id') : array(); + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select('id'); + $query->from($db->quoteName('#__tj_ucm_data')); + $query->where($db->quoteName('parent_id') . '=' . TJUCM_PARENT_CONTENT_ID); + $query->where($db->quoteName('client') . '=' . $db->quote($ucmSubformClient)); + $db->setQuery($query); + $ucmSubformRecordIds = $db->loadColumn(); + $ucmSubformRecordIds = (!empty($ucmSubformRecordIds)) ? $ucmSubformRecordIds : array(); $this->saveSingleValuedFieldData($ucmSubformClient, TJUCM_PARENT_CLIENT, TJUCM_PARENT_CONTENT_ID, $field->id, $fieldStoredValues); From 820593b933c09424bd1646850a7441d60fd3ad47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 28 Nov 2019 11:51:13 +0530 Subject: [PATCH 17/18] Bug #152905 fix: Front end>> Radio button under UCM sub form is not working properly --- site/helpers/tjfields.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 5c72b9a4..7de16977 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -483,7 +483,9 @@ private function saveSingleValuedFieldData($fieldValue, $client, $contentId, $fi } JLoader::import('components.com_tjfields.tables.fieldsvalue', JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjfields.tables.option', JPATH_ADMINISTRATOR); $fieldsValueTable = JTable::getInstance('FieldsValue', 'TjfieldsTable', array('dbo', JFactory::getDbo())); + $fieldOptionTable = JTable::getInstance('Option', 'TjfieldsTable', array('dbo', JFactory::getDbo())); // Set currently logged in users id as user_id $fieldsValueTable->user_id = JFactory::getUser()->id; @@ -497,6 +499,12 @@ private function saveSingleValuedFieldData($fieldValue, $client, $contentId, $fi if ($fieldValue != '') { $fieldsValueTable->value = $fieldValue; + $fieldOptionTable->load(array('field_id' => $fieldId, 'value' => $fieldValue)); + + if ($fieldOptionTable->id) + { + $fieldsValueTable->option_id = $fieldOptionTable->id; + } if ($fieldsValueTable->store()) { @@ -519,6 +527,13 @@ private function saveSingleValuedFieldData($fieldValue, $client, $contentId, $fi $fieldsValueTable->value = $fieldValue; $fieldsValueTable->client = $client; + $fieldOptionTable->load(array('field_id' => $fieldId, 'value' => $fieldValue)); + + if ($fieldOptionTable->id) + { + $fieldsValueTable->option_id = $fieldOptionTable->id; + } + if ($fieldsValueTable->store()) { return true; From 7e45f27e7f25282044b26bd0b1f562f7da44d437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 2 Dec 2019 16:30:13 +0530 Subject: [PATCH 18/18] Task #123 feat: version update --- modules/mod_tjfields_search/mod_tjfields_search.xml | 4 ++-- tjfields.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/mod_tjfields_search/mod_tjfields_search.xml b/modules/mod_tjfields_search/mod_tjfields_search.xml index bb260307..964fbf0d 100755 --- a/modules/mod_tjfields_search/mod_tjfields_search.xml +++ b/modules/mod_tjfields_search/mod_tjfields_search.xml @@ -6,8 +6,8 @@ www.techjoomla.com Copyright(C)2012-16 TechJoomla http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 4th Nov 2019 - 1.4.3 + 2nd Dec 2019 + 1.4.4 MOD_TJFIELDS_SEARCH_XML_DESCRIPTION mod_tjfields_search.php diff --git a/tjfields.xml b/tjfields.xml index 8c282a6d..7ffa1e40 100644 --- a/tjfields.xml +++ b/tjfields.xml @@ -6,8 +6,8 @@ www.techjoomla.com Copyright(C)2012-19 TechJoomla http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 4th Nov 2019 - 1.4.3 + 2nd Dec 2019 + 1.4.4 TJFields - Common code for TJ Fields Manager and TJ Geo Manager!