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/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..477805f4 100644 --- a/administrator/assets/js/tjlist.js +++ b/administrator/assets/js/tjlist.js @@ -6,10 +6,19 @@ * @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(); + + if (element.attr('multiple') == undefined) + { + element.siblings('div.tjfieldTjListOtherText').children().focus(); + } + + }, 100); }, removeOtherOption: function (element) { @@ -21,7 +30,22 @@ var tjlist = { isRequired = (element.attr('required') != undefined) ? 'required="required"' : '', requiredClass = (isRequired != '') ? 'required' : ''; - return '

'; + 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'); + + // @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..8bb4a17d 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();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/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'; } diff --git a/administrator/models/field.php b/administrator/models/field.php index 28f0c2ab..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. @@ -288,7 +289,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; @@ -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'); 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 .= '
'; 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 .= "
" . Text::_("COM_TJFIELDS_FORM_DESC_FIELD_RELATED_ADD_RECORD") . "
"; } } 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/fields/tjlist.php b/administrator/models/fields/tjlist.php index b6b576ef..00cff908 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,9 +106,15 @@ protected function getInput() $html = parent::getInput(); - $doc = JFactory::getDocument(); + $doc = Factory::getDocument(); $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']) @@ -131,7 +138,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 +158,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 +213,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/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 @@ + +
+ +
+ +
+
+
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/site/helpers/tjfields.php b/site/helpers/tjfields.php index 1cdddcab..7de16977 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -277,6 +277,20 @@ public function saveFieldsValue($data) array_pop($ucmSubformClientTmp); $ucmSubformClient = 'com_tjucm.' . implode('_', $ucmSubformClientTmp); + // Load UCM itemform model + JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); + + // Get all the records which were previously stored for the ucmsubform field in parent form + $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); foreach ($fieldValue as $key => $ucmSubformValue) @@ -291,12 +305,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 +324,117 @@ 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') + { + // 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)) + { + if ($tjListParams->other) + { + $fieldOtherVal = $fieldOptionsVal = array(); + $postFieldValueCount = count($fieldValue); + $k = 0; + + $otherValues[] = $field->type . 'othervalue'; + + foreach ($fieldValue as $key => $listfieldVale) + { + $k++; + + // Update the last index element of other options multi values + if (strpos($listfieldVale, ',') && $postFieldValueCount > 1 && $postFieldValueCount == $k) + { + $fieldOtherVal = explode(',', $listfieldVale); + + // Add prefix for other values for tjlist field + $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); + } + + // Check options list value exist in array + if (!empty($fieldOptionsVal)) + { + $fieldValue = array_merge($fieldValue, $fieldOptionsVal); + } + } + + $this->saveMultiValuedFieldData($fieldValue, $field->client, $data['content_id'], $field->id, $fieldStoredValues); + } + elseif (!empty($fieldValue)) + { + // 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)) { @@ -354,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; @@ -368,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()) { @@ -390,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; @@ -530,8 +674,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)); @@ -1485,15 +1627,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 } } 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;?>

+ - * @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) . ''; + } +} 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 +} 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!