From fe9d3cc1da2f44f4acc0980c55e5fd03d26249e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Thu, 1 Aug 2019 10:36:28 +0530 Subject: [PATCH 01/20] Feature #148433 chore: Display field values with using specific layout in items view --- .../com_tjucm/site/layouts/detail/list.php | 175 ++++++++++++++++++ .../site/views/items/tmpl/default.php | 132 +------------ 2 files changed, 183 insertions(+), 124 deletions(-) create mode 100644 src/components/com_tjucm/site/layouts/detail/list.php diff --git a/src/components/com_tjucm/site/layouts/detail/list.php b/src/components/com_tjucm/site/layouts/detail/list.php new file mode 100644 index 00000000..d171e546 --- /dev/null +++ b/src/components/com_tjucm/site/layouts/detail/list.php @@ -0,0 +1,175 @@ + + * @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('itemsData', $displayData)) +{ + return; +} + +$app = JFactory::getApplication(); +$user = JFactory::getUser(); + +// Layout for field types +$fieldLayout = array(); +$fieldLayout['File'] = $fieldLayout['Image'] = "file"; +$fieldLayout['Checkbox'] = "checkbox"; +$fieldLayout['Radio'] = $fieldLayout['List'] = "list"; +$fieldLayout['Itemcategory'] = "itemcategory"; +$fieldLayout['Video'] = $fieldLayout['Audio'] = $fieldLayout['Url'] = "link"; +$fieldLayout['Calendar'] = "calendar"; + +// Load the tj-fields helper +JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); +$TjfieldsHelper = new TjfieldsHelper; + +// Get JLayout data +$item = $displayData['itemsData']; +$created_by = $displayData['created_by']; +$client = $displayData['client']; +$xmlFieldSet = $displayData['xmlFormObject']; +$ucmTypeId = $displayData['ucmTypeId']; + +// Get Field table +$fieldTableData = new stdClass; +JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); +$fieldTableData->tjFieldFieldTable = JTable::getInstance('field', 'TjfieldsTable'); +$appendUrl = ''; +$csrf = "&" . JSession::getFormToken() . '=1'; + +$canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmTypeId); +$canDeleteOwn = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $ucmTypeId); +$canChange = $user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $ucmTypeId); +$canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmTypeId); +$canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $ucmTypeId); + +if (!empty($created_by)) +{ + $appendUrl .= "&created_by=" . $created_by; +} + +if (!empty($client)) +{ + $appendUrl .= "&client=" . $client; +} + +$link = 'index.php?option=com_tjucm&view=items' . $appendUrl; +$tjUcmFrontendHelper = new TjucmHelpersTjucm; +$itemId = $tjUcmFrontendHelper->getItemId($link); + + $link = JRoute::_('index.php?option=com_tjucm&view=item&id=' . $item->id . "&client=" . $client . '&Itemid=' . $itemId, false); + + $editown = false; + + if ($canEditOwn) + { + $editown = (JFactory::getUser()->id == $item->created_by ? true : false); + } + + $deleteOwn = false; + if ($canDeleteOwn) + { + $deleteOwn = (JFactory::getUser()->id == $item->created_by ? true : false); + } + ?> + + state)) + { + $class = ($canChange) ? 'active' : 'disabled'; ?> + + + state == 1) + { + ?> + + + + + checked_out) && $item->checked_out) + { + echo JHtml::_('jgrid.checkedout', $i, $item->uEditor, $item->checked_out_time, 'items.', $canCheckin); + } + ?> + + escape($item->id); ?> + + + field_values)) + { + $fieldCount = 0; + foreach ($item->field_values as $key => $field_values) + { + $fieldTableData->tjFieldFieldTable->load(array('id' => $key)); + $type = $fieldTableData->tjFieldFieldTable->type; + + // Get xml for the field + $xmlField = $xmlFieldSet->fieldset->field[$fieldCount]; + $fieldCount++; + + if($xmlField['type'][0] == 'ucmsubform') + { + $xmlField = $xmlFieldSet->fieldset->field[$fieldCount]; + $fieldCount++; + } + ?> + + type] : 'field'; + $field = new stdClass; + $field->value = $field_values; + + $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); + $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); + echo $output; + ?> + + + + + + + + + + + + + + diff --git a/src/components/com_tjucm/site/views/items/tmpl/default.php b/src/components/com_tjucm/site/views/items/tmpl/default.php index 69cbbdd4..5f065125 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -35,6 +35,7 @@ $link = 'index.php?option=com_tjucm&view=items' . $appendUrl; $itemId = $tjUcmFrontendHelper->getItemId($link); + ?>
@@ -71,16 +72,10 @@ canEdit || $this->canDelete) - { ?> - items)) { + $xmlFileName = explode(".", $this->client); + $xmlFilePath = JPATH_SITE . "/administrator/components/com_tjucm/models/forms/" . $xmlFileName[1] . "_extra" . ".xml"; + $formXml = simplexml_load_file($xmlFilePath); + foreach ($this->items as $i => $item) { - $link = JRoute::_('index.php?option=com_tjucm&view=item&id=' . $item->id . "&client=" . $this->client . '&Itemid=' . $itemId, false); - - $editown = false; - if ($this->canEditOwn) - { - $editown = (JFactory::getUser()->id == $item->created_by ? true : false); - } - - $deleteOwn = false; - if ($this->canDeleteOwn) - { - $deleteOwn = (JFactory::getUser()->id == $item->created_by ? true : false); - } - - ?> - - items[0]->state)) - { - $class = ($this->canChange) ? 'active' : 'disabled'; ?> - - - - field_values)) - { - foreach ($item->field_values as $field_values) - { - ?> - - canEdit || $this->canDelete || $editown || $deleteOwn) - { - ?> - - - - render(array('itemsData' => $item, 'created_by' => $this->created_by, 'client' => $this->client, 'xmlFormObject' => $formXml, 'ucmTypeId' => $this->ucmTypeId)); } } else From fd013c3afa9633b2a5df77990906e8ed6eb638f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Thu, 1 Aug 2019 18:15:44 +0530 Subject: [PATCH 02/20] Feature #148433 chore: Display field values with using specific layout in items view --- src/components/com_tjucm/site/layouts/list/index.html | 1 + src/components/com_tjucm/site/layouts/{detail => list}/list.php | 0 src/components/com_tjucm/site/views/items/tmpl/default.php | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/components/com_tjucm/site/layouts/list/index.html rename src/components/com_tjucm/site/layouts/{detail => list}/list.php (100%) diff --git a/src/components/com_tjucm/site/layouts/list/index.html b/src/components/com_tjucm/site/layouts/list/index.html new file mode 100644 index 00000000..42682b47 --- /dev/null +++ b/src/components/com_tjucm/site/layouts/list/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/com_tjucm/site/layouts/detail/list.php b/src/components/com_tjucm/site/layouts/list/list.php similarity index 100% rename from src/components/com_tjucm/site/layouts/detail/list.php rename to src/components/com_tjucm/site/layouts/list/list.php diff --git a/src/components/com_tjucm/site/views/items/tmpl/default.php b/src/components/com_tjucm/site/views/items/tmpl/default.php index 5f065125..8de98f75 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -108,7 +108,7 @@ foreach ($this->items as $i => $item) { // Call the JLayout to render the fields in the details view - $layout = new JLayoutFile('list', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); + $layout = new JLayoutFile('list', JPATH_ROOT . '/components/com_tjucm/layouts/list'); echo $layout->render(array('itemsData' => $item, 'created_by' => $this->created_by, 'client' => $this->client, 'xmlFormObject' => $formXml, 'ucmTypeId' => $this->ucmTypeId)); } } From fc0379ee22190dabcfd3a676655c48fcfb960c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 9 Aug 2019 15:32:27 +0530 Subject: [PATCH 03/20] Feature #148971 chore: Display subform field values on item view --- .../com_tjucm/site/layouts/detail/fields.php | 21 +++- .../com_tjucm/site/layouts/detail/subform.php | 97 +++++++++++++++++++ 2 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 src/components/com_tjucm/site/layouts/detail/subform.php diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index fe5b0f90..92f9c780 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -110,6 +110,7 @@ if (!empty($ucmSubFormFieldValue)) { + foreach ($ucmSubFormFieldValue as $ucmSubFormData) { $contentIdFieldname = str_replace('.', '_', $ucmSubFormClient) . '_contentid'; @@ -132,11 +133,21 @@ $ucmSubFormXmlFieldSets[$ucmSubFormCount] = $ucmSubFormXmlFieldSet; $ucmSubFormCount++; } - - // Call the JLayout recursively to render fields of ucmsubform - $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); - echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $this->item, 'isSubForm' => 1)); - echo "
"; + + if($field->type == 'Subform') + { + // Call the JLayout recursively to render fields of ucmsubform + $layout = new JLayoutFile('subform', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); + echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'ucmSubFormData' => $ucmSubFormData, 'isSubForm' => 1)); + echo "
"; + } + else + { + // Call the JLayout recursively to render fields of ucmsubform + $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); + echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $this->item, 'isSubForm' => 1)); + echo "
"; + } } } ?> diff --git a/src/components/com_tjucm/site/layouts/detail/subform.php b/src/components/com_tjucm/site/layouts/detail/subform.php new file mode 100644 index 00000000..fab31618 --- /dev/null +++ b/src/components/com_tjucm/site/layouts/detail/subform.php @@ -0,0 +1,97 @@ + + * @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('ucmSubFormData', $displayData) || !key_exists('xmlFormObject', $displayData)) +{ + return; +} + +$user = JFactory::getUser(); + +// Layout for field types +$fieldLayout = array(); +$fieldLayout['File'] = $fieldLayout['Image'] = "file"; +$fieldLayout['Checkbox'] = "checkbox"; +$fieldLayout['Radio'] = $fieldLayout['List'] = "list"; +$fieldLayout['Itemcategory'] = "itemcategory"; +$fieldLayout['Video'] = $fieldLayout['Audio'] = $fieldLayout['Url'] = "link"; +$fieldLayout['Calendar'] = "calendar"; + +// Load the tj-fields helper +JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); +$TjfieldsHelper = new TjfieldsHelper; + +// Get JLayout data +$xmlFormObject = $displayData['xmlFormObject']; +$ucmSubFormData = $displayData['ucmSubFormData']; +$isSubForm = $displayData['isSubForm']; + +// Define the classes for subform and normal form rendering +$controlGroupDivClass = ($isSubForm) ? 'col-xs-12' : 'col-xs-12 col-md-6'; +$labelDivClass = ($isSubForm) ? 'col-xs-6' : 'col-xs-4'; +$controlDivClass = ($isSubForm) ? 'col-xs-6' : 'col-xs-8'; + +// Get Field table +$fieldTableData = new stdClass; +JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); +$fieldTableData->tjFieldFieldTable = JTable::getInstance('field', 'TjfieldsTable'); + +$count = 0; +$fieldCount = 0; +$xmlFieldSet = $xmlFormObject[$count]; + +?> +
+ $fieldValue) + { + // Get the field data by field name to check the field type + $fieldTableData->tjFieldFieldTable->load(array('name' => $fieldName)); + $canView = false; + + if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $fieldTableData->tjFieldFieldTable->group_id)) + { + $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $fieldTableData->tjFieldFieldTable->id); + } + + if ($canView || ($itemData->created_by == $user->id)) + { + // Get xml for the field + $xmlField = $xmlFieldSet->field[$fieldCount]; + $fieldCount++; + + if ($fieldTableData->tjFieldFieldTable->type == 'hidden') + { + continue; + } + else + { + $layoutToUse = (array_key_exists($fieldTableData->tjFieldFieldTable->type, $fieldLayout)) ? $fieldLayout[$field->type] : 'field'; + ?> +
+
tjFieldFieldTable->label; ?>:
+
+ value = $fieldValue; + $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); + $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); + echo $output; + ?> +
+
+ +
From 457c7e6937284913522bdabd99eb9f7f293d3375 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 4 Sep 2019 16:22:37 +0530 Subject: [PATCH 04/20] Task #193 chore: Rename cluster ACL name and changes made in model file --- src/components/com_tjucm/site/models/itemform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 3203a535..1eb9ab17 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -862,7 +862,7 @@ public function setClusterData(&$validData, $data) $ClusterModel->setState('filter.published', 1); $ClusterModel->setState('filter.cluster_id', (int) $data[$clusterField]); - if (!$isSuperUser && !$user->authorise('core.manageall.cluster', 'com_cluster')) + if (!$isSuperUser && !$user->authorise('core.manageall', 'com_cluster')) { $ClusterModel->setState('filter.user_id', $user->id); } From fabaf2a340e52ec5226e8c5c4390b06f7157e2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Mon, 14 Oct 2019 13:00:22 +0530 Subject: [PATCH 05/20] Task #151909 chore: Issue is vom_tjucm layout overriding --- src/components/com_tjucm/site/views/item/tmpl/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/views/item/tmpl/default.php b/src/components/com_tjucm/site/views/item/tmpl/default.php index ea0782e9..00fc4663 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -24,7 +24,7 @@ } // Call the JLayout to render the fields in the details view - $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); + $layout = new JLayoutFile('detail.fields', JPATH_ROOT . '/components/com_tjucm'); echo $layout->render(array('xmlFormObject' => $xmlFieldSets, 'formObject' => $this->form_extra, 'itemData' => $this->item)); } else From e53e4544c25eafe9cd642155c34e06ccea063be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Tue, 15 Oct 2019 12:23:11 +0530 Subject: [PATCH 06/20] Bug #203 fix: While saving form progress the form gives error for required fields which should not be given as the form is being stored in draft mode --- .../administrator/assets/js/itemform.js | 254 +++++------------- .../site/controllers/itemform.json.php | 24 +- .../com_tjucm/site/models/itemform.php | 15 ++ .../site/views/itemform/tmpl/default.php | 4 +- 4 files changed, 111 insertions(+), 186 deletions(-) diff --git a/src/components/com_tjucm/administrator/assets/js/itemform.js b/src/components/com_tjucm/administrator/assets/js/itemform.js index ef50ae9b..ac7248fe 100644 --- a/src/components/com_tjucm/administrator/assets/js/itemform.js +++ b/src/components/com_tjucm/administrator/assets/js/itemform.js @@ -244,10 +244,7 @@ jQuery(window).load(function() }); var tjUcmItemForm = { - onUcmFormChange: function (fieldObj){ - /* Disable the action buttons before performing the action*/ - jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); - + getUcmParentRecordId: function (draft, callback){ var tjUcmParentClient = jQuery('#item-form').find("input[name='jform[client]']").val(); var getParentRecordid = new Promise(function(resolve, reject) { @@ -268,6 +265,8 @@ var tjUcmItemForm = { /* Callback function after creating the parent UCM record */ var afterCreateParentUcmRecord = function (error, response){ + response = JSON.parse(response); + if (error == null) { if (response.data !== null && jQuery.isNumeric(response.data.id)) @@ -297,7 +296,7 @@ var tjUcmItemForm = { }; /* Create the record in draft mode*/ - tjUcmItemFormData.append('draft', 1); + tjUcmItemFormData.append('draft', draft); /* Add new UCM parent record for UCM type if its not created yet*/ com_tjucm.Services.Item.create(tjUcmItemFormData, afterCreateParentUcmRecord); @@ -310,14 +309,21 @@ var tjUcmItemForm = { // Action on after creating the parent UCM record getParentRecordid.then(function (response){ - /* Save the field value which was added/changed */ - tjUcmItemForm.initUcmFormFieldDataSave(fieldObj, tjUcmParentClient, response); + callback(response); }).catch(function (error){ console.log(error); - return false; }); }, + onUcmFormChange: function (fieldObj){ + /* Disable the action buttons before performing the action*/ + jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); + + tjUcmItemForm.getUcmParentRecordId(1, function (tjucmParentRecordId){ + var tjUcmParentClient = jQuery('#item-form').find("input[name='jform[client]']").val(); + tjUcmItemForm.initUcmFormFieldDataSave(fieldObj, tjUcmParentClient, tjucmParentRecordId); + }); + }, initUcmFormFieldDataSave: function (fieldObj, tjUcmParentClient, tjUcmParentRecordId){ /* Disable the action buttons before performing the action*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); @@ -350,6 +356,8 @@ var tjUcmItemForm = { { /* Callback function after creating the UCM subform record */ var afterCreateUcmSubFormRecord = function (error, response){ + response = JSON.parse(response); + if (error == null) { if (response.data !== null && jQuery.isNumeric(response.data.id)) @@ -429,6 +437,7 @@ var tjUcmItemForm = { return true; }, afterDataSave: function (error, response){ + response = JSON.parse(response); /* Remove the dirty class fromt the form once the field data is saved*/ jQuery('#item-form').removeClass('dirty'); @@ -520,6 +529,7 @@ var tjUcmItemForm = { var tjUcmItemFormData = new FormData(); var tjUcmUpdateRelatedFieldsOptions = function (error, response){ + response = JSON.parse(response); tjucmRelatedFieldUpdatedOptions = response.data; if(tjucmRelatedFieldUpdatedOptions == '') @@ -552,6 +562,7 @@ var tjUcmItemForm = { /* Disable the action buttons before performing the action*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); var tjUcmFormSubmitCallingButtonId = event.target.id; + var tjUcmSaveRecordAsDraft = 1; if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionFinalSave') { @@ -561,125 +572,64 @@ var tjUcmItemForm = { return false; } - } - - if (document.formvalidator.isValid(document.getElementById('item-form'))) - { - /* Clear the error messages first if any before processing the data*/ - jQuery("#system-message-container").html(""); - - /* Disable the save button till the record is saved*/ - jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); - - /* For AJAX save need to assign values to the editor field containers*/ - jQuery("#item-form .toggle-editor a").each(function(index) { - this.click(); - }); - - var tjUcmParentClient = jQuery('#item-form').find("input[name='jform[client]']").val(); - var getParentRecordid = new Promise(function(resolve, reject) { - var tjucmParentRecordId = jQuery('#item-form').find("input[name='jform[id]']").val(); - - if (tjucmParentRecordId == '') - { - var tjUcmItemFormData = new FormData(); - /* Set parent client in the data form*/ - if (tjUcmParentClient != '') - { - tjUcmItemFormData.append('client', tjUcmParentClient); - } - - /* Add CSRF token to the form*/ - tjUcmItemFormData.append(Joomla.getOptions('csrf.token'), 1); - - /* Callback function after creating the parent UCM record */ - var afterCreateParentUcmRecord = function (error, response){ - if (error == null) - { - if (response.data !== null && jQuery.isNumeric(response.data.id)) - { - /* Set parent record id in the form*/ - jQuery('#item-form').find("input[name='jform[id]']").val(response.data.id); - - /* Update parent record id in the URL if the parent record is created successfully*/ - var tjucmUrl = window.location.href.split('#')[0]; - var tjucmUrlSeparator = (tjucmUrl.indexOf("?")===-1)?"?":"&"; - var tjucmNewParam = "id=" + response.data.id; - - if (!(tjucmUrl.indexOf(tjucmNewParam) >= 0)) - { - tjucmUrl+=tjucmUrlSeparator+tjucmNewParam; - } - - history.pushState(null, null, tjucmUrl); - - resolve(response.data.id); - } - else - { - reject(response); - } - } - }; - - /* Add new UCM parent record for UCM type if its not created yet*/ - com_tjucm.Services.Item.create(tjUcmItemFormData, afterCreateParentUcmRecord); - } - else if (jQuery.isNumeric(tjucmParentRecordId) && tjucmParentRecordId != 0) - { - resolve(tjucmParentRecordId); - } - }); - - /* Once data is assigned to the textarea toggle the editors*/ - jQuery("#item-form .toggle-editor a").each(function(index) { - this.click(); - }); - - // Action on after creating the parent UCM record - getParentRecordid.then(function (response){ - var myForm = document.getElementById('item-form'); - var tjUcmItemFormData = new FormData(myForm); - tjUcmItemFormData.delete('task'); - tjUcmItemFormData.delete('option'); - tjUcmItemFormData.delete('view'); - tjUcmItemFormData.delete('layout'); - var tjUcmClient = jQuery('#item-form').find("input[name='jform[client]']").val(); - var tjUcmRecordId = jQuery('#item-form').find("input[name='jform[id]']").val(); - - /* Add CSRF token to the form*/ - tjUcmItemFormData.append(Joomla.getOptions('csrf.token'), 1); - tjUcmItemFormData.append('client', tjUcmClient); - tjUcmItemFormData.append('recordid', tjUcmRecordId); + if (document.formvalidator.isValid(document.getElementById('item-form'))) + { + /* Clear the error messages first if any before processing the data*/ + jQuery("#system-message-container").html(""); + + /* Disable the save button till the record is saved*/ + jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); + } + else + { + tjUcmItemForm.setVisibilityOfNavigationButtons(); + jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', false); + jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow"); + + return false; + } - if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionDraftSave') - { - tjUcmItemFormData.append('draft', 1); - } + tjUcmSaveRecordAsDraft = 0; + } - if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionFinalSave') - { - tjUcmFormFinalSave = 1; - } + /* For AJAX save need to assign values to the editor field containers*/ + jQuery("#item-form .toggle-editor a").each(function(index) { + this.click(); + }); - com_tjucm.Services.Item.saveFormData(tjUcmItemFormData, tjUcmItemForm.afterDataSave); + tjUcmItemForm.getUcmParentRecordId(tjUcmSaveRecordAsDraft, function (){ + var tjUcmForm = document.getElementById('item-form'); + var tjUcmItemFormData = new FormData(tjUcmForm); + tjUcmItemFormData.delete('task'); + tjUcmItemFormData.delete('option'); + tjUcmItemFormData.delete('view'); + tjUcmItemFormData.delete('layout'); + var tjUcmClient = jQuery('#item-form').find("input[name='jform[client]']").val(); + var tjUcmRecordId = jQuery('#item-form').find("input[name='jform[id]']").val(); + + /* Add CSRF token to the form*/ + tjUcmItemFormData.append(Joomla.getOptions('csrf.token'), 1); + tjUcmItemFormData.append('client', tjUcmClient); + tjUcmItemFormData.append('recordid', tjUcmRecordId); + + if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionDraftSave') + { + tjUcmItemFormData.append('draft', 1); + } - return true; - }).catch(function (error){ - console.log(error); + if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionFinalSave') + { + tjUcmFormFinalSave = 1; + } - return false; - }); - } - else - { - tjUcmItemForm.setVisibilityOfNavigationButtons(); - jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', false); - jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow"); + com_tjucm.Services.Item.saveFormData(tjUcmItemFormData, tjUcmItemForm.afterDataSave); + }); - return false; - } + /* Once data is assigned to the textarea toggle the editors*/ + jQuery("#item-form .toggle-editor a").each(function(index) { + this.click(); + }); }, saveSectionData: function (tabId){ /* Disable the action buttons before performing the action*/ @@ -721,64 +671,8 @@ var tjUcmItemForm = { /* Disable the save button till the record is saved*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); - var tjUcmParentClient = jQuery('#item-form').find("input[name='jform[client]']").val(); - var getParentRecordid = new Promise(function(resolve, reject) { - var tjucmParentRecordId = jQuery('#item-form').find("input[name='jform[id]']").val(); - - if (tjucmParentRecordId == '') - { - var tjUcmItemFormData = new FormData(); - - /* Set parent client in the data form*/ - if (tjUcmParentClient != '') - { - tjUcmItemFormData.append('client', tjUcmParentClient); - } - - /* Add CSRF token to the form*/ - tjUcmItemFormData.append(Joomla.getOptions('csrf.token'), 1); - - /* Callback function after creating the parent UCM record */ - var afterCreateParentUcmRecord = function (error, response){ - if (error == null) - { - if (response.data !== null && jQuery.isNumeric(response.data.id)) - { - /* Set parent record id in the form*/ - jQuery('#item-form').find("input[name='jform[id]']").val(response.data.id); - - /* Update parent record id in the URL if the parent record is created successfully*/ - var tjucmUrl = window.location.href.split('#')[0]; - var tjucmUrlSeparator = (tjucmUrl.indexOf("?")===-1)?"?":"&"; - var tjucmNewParam = "id=" + response.data.id; - - if (!(tjucmUrl.indexOf(tjucmNewParam) >= 0)) - { - tjucmUrl+=tjucmUrlSeparator+tjucmNewParam; - } - history.pushState(null, null, tjucmUrl); - - resolve(response.data.id); - } - else - { - reject(response); - } - } - }; - - /* Add new UCM parent record for UCM type if its not created yet*/ - com_tjucm.Services.Item.create(tjUcmItemFormData, afterCreateParentUcmRecord); - } - else if (jQuery.isNumeric(tjucmParentRecordId) && tjucmParentRecordId != 0) - { - resolve(tjucmParentRecordId); - } - }); - - // Action on after creating the parent UCM record - getParentRecordid.then(function (response){ + tjUcmItemForm.getUcmParentRecordId(1, function (){ tjUcmSectionFormData.delete('task'); tjUcmSectionFormData.delete('option'); tjUcmSectionFormData.delete('view'); @@ -793,12 +687,6 @@ var tjUcmItemForm = { tjUcmSectionFormData.append('tjUcmFormSection', jQuery("a[href='"+tabId+"']").html()); com_tjucm.Services.Item.saveFormData(tjUcmSectionFormData, tjUcmItemForm.afterDataSave); - - return true; - }).catch(function (error){ - console.log(error); - - return false; }); } else diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 25401ab7..f5f3a285 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -123,7 +123,8 @@ public function save($key = null, $urlVar = null) { JSession::checkToken() or jexit(Text::_('JINVALID_TOKEN')); - $post = Factory::getApplication()->input->post; + $app = Factory::getApplication(); + $post = $app->input->post; $model = $this->getModel('itemform'); $data = array(); @@ -137,6 +138,7 @@ public function save($key = null, $urlVar = null) if ($client == '' || empty($this->typeId)) { echo new JResponseJson('', Text::_('COM_TJUCM_FORM_SAVE_FAILED_CLIENT_REQUIRED'), true); + $app->close(); } // Set the state of record as per UCM type config @@ -162,6 +164,7 @@ public function save($key = null, $urlVar = null) $this->processErrors($errors); echo new JResponseJson('', Text::_('COM_TJUCM_FORM_VALIDATATION_FAILED'), true); + $app->close(); } if ($model->save($data)) @@ -169,17 +172,20 @@ public function save($key = null, $urlVar = null) $result['id'] = $model->getState($model->getName() . '.id'); echo new JResponseJson($result, Text::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY')); + $app->close(); } else { $errors = $model->getErrors(); $this->processErrors($errors); echo new JResponseJson('', Text::_('COM_TJUCM_FORM_SAVE_FAILED'), true); + $app->close(); } } catch (Exception $e) { echo new JResponseJson($e); + $app->close(); } } @@ -211,6 +217,7 @@ public function saveFieldData() { $app->enqueueMessage(Text::_('COM_TJUCM_FORM_VALIDATATION_FAILED'), 'error'); echo new JResponseJson(null); + $app->close(); } try @@ -227,6 +234,7 @@ public function saveFieldData() $this->processErrors($errors); echo new JResponseJson(null); + $app->close(); } $table = $model->getTable(); @@ -242,10 +250,12 @@ public function saveFieldData() $response = $model->saveExtraFields($fieldData); echo new JResponseJson($response); + $app->close(); } catch (Exception $e) { echo new JResponseJson($e); + $app->close(); } } @@ -274,6 +284,7 @@ public function saveFormData() { $app->enqueueMessage(Text::_('COM_TJUCM_FORM_VALIDATATION_FAILED'), 'error'); echo new JResponseJson(null); + $app->close(); } try @@ -290,6 +301,7 @@ public function saveFormData() } else { + $formData['draft'] = $draft; $form = $model->getTypeForm($formData); } @@ -302,6 +314,7 @@ public function saveFormData() $this->processErrors($errors); echo new JResponseJson(null); + $app->close(); } $table = $model->getTable(); @@ -334,10 +347,12 @@ public function saveFormData() } echo new JResponseJson($response, $msg); + $app->close(); } catch (Exception $e) { echo new JResponseJson($e); + $app->close(); } } @@ -369,6 +384,7 @@ public function saveItemFieldData($key = null, $urlVar = null) if ($client == '') { echo new JResponseJson('', Text::_('COM_TJUCM_FORM_SAVE_FAILED'), true); + $app->close(); } $data['created_by'] = Factory::getUser()->id; @@ -395,6 +411,7 @@ public function saveItemFieldData($key = null, $urlVar = null) $this->processErrors($errors); echo new JResponseJson('', Text::_('COM_TJUCM_FORM_VALIDATATION_FAILED'), true); + $app->close(); } if ($model->save($data)) @@ -402,17 +419,20 @@ public function saveItemFieldData($key = null, $urlVar = null) $result['id'] = $model->getState($model->getName() . '.id'); echo new JResponseJson($result, Text::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY')); + $app->close(); } else { $errors = $model->getErrors(); $this->processErrors($errors); echo new JResponseJson('', Text::_('COM_TJUCM_FORM_SAVE_FAILED'), true); + $app->close(); } } catch (Exception $e) { echo new JResponseJson($e); + $app->close(); } } @@ -466,11 +486,13 @@ public function getRelatedFieldOptions() if (empty($client) || empty($contentId)) { echo new JResponseJson(null); + $app->close(); } $app->input->set('id', $contentId); $updatedOptionsForRelatedField = $model->getUdatedRelatedFieldOptions($client, $contentId); echo new JResponseJson($updatedOptionsForRelatedField); + $app->close(); } } diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 7bf2f97a..0b8cf7c6 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -432,6 +432,7 @@ public function getFieldForm($data = array(), $loadData = true) public function getTypeForm($data = array(), $loadData = true) { + $draft = $data['draft']; $clientPart = explode(".", $data['client']); // Path of empty form XML to create form object dynamically @@ -445,6 +446,20 @@ public function getTypeForm($data = array(), $loadData = true) ) ); + // If data is being saved in draft mode then dont check if the fields are required + if ($draft) + { + $fieldSets = $form->getFieldsets(); + + foreach ($fieldSets as $fieldset) + { + foreach ($form->getFieldset($fieldset->name) as $field) + { + $form->setFieldAttribute($field->fieldname, 'required', false); + } + } + } + if (empty($form)) { return false; diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default.php b/src/components/com_tjucm/site/views/itemform/tmpl/default.php index 980f18bd..d3ae87e4 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -47,7 +47,7 @@ if ($this->item->id) { - $itemState = ($this->item->draft && $this->allow_auto_save) ? 1 : 0; + $itemState = ($this->item->draft && ($this->allow_auto_save || $this->allow_draft_save)) ? 1 : 0; } else { @@ -182,7 +182,7 @@ if ($calledFrom == 'frontend') { - if (($this->allow_auto_save || $this->allow_draft_save) && !empty($itemState)) + if (($this->allow_auto_save || $this->allow_draft_save) && $itemState) { ?> Date: Thu, 17 Oct 2019 18:12:23 +0530 Subject: [PATCH 07/20] Bug #205 fix: For list type of field, value is shown on list and details view instead of label --- .../com_tjucm/site/layouts/detail/fields.php | 41 ++-- .../com_tjucm/site/layouts/detail/subform.php | 97 -------- .../com_tjucm/site/layouts/list/list.php | 190 ++++++++-------- .../com_tjucm/site/models/itemform.php | 6 +- .../site/views/items/tmpl/default.php | 215 ++++++------------ 5 files changed, 177 insertions(+), 372 deletions(-) delete mode 100644 src/components/com_tjucm/site/layouts/detail/subform.php diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index 9f94b104..0dbb04b7 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -22,11 +22,14 @@ $fieldLayout = array(); $fieldLayout['File'] = $fieldLayout['Image'] = "file"; $fieldLayout['Checkbox'] = "checkbox"; -$fieldLayout['Radio'] = $fieldLayout['List'] = "list"; +$fieldLayout['multi_select'] = $fieldLayout['single_select'] = $fieldLayout['Radio'] = $fieldLayout['List'] = $fieldLayout['tjlist'] = "list"; $fieldLayout['Itemcategory'] = "itemcategory"; $fieldLayout['Video'] = $fieldLayout['Audio'] = $fieldLayout['Url'] = "link"; $fieldLayout['Calendar'] = "calendar"; $fieldLayout['Cluster'] = "cluster"; +$fieldLayout['Related'] = $fieldLayout['SQL'] = "sql"; +$fieldLayout['Subform'] = "subform"; +$fieldLayout['Ownership'] = "ownership"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); @@ -44,15 +47,14 @@ $controlDivClass = ($isSubForm) ? 'col-xs-6' : 'col-xs-8'; // Get Field table -$fieldTableData = new stdClass; JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); -$fieldTableData->tjFieldFieldTable = JTable::getInstance('field', 'TjfieldsTable'); +$tjFieldsFieldTable = JTable::getInstance('field', 'TjfieldsTable'); $fieldSets = $formObject->getFieldsets(); $count = 0; // Iterate through the normal form fieldsets and display each one -foreach ($fieldSets as $fieldName => $fieldset) +foreach ($fieldSets as $fieldset) { $xmlFieldSet = $xmlFormObject[$count]; $count++; @@ -64,14 +66,14 @@ { // No need to show tooltip/description for field on details view $field->description = ''; - + // Get the field data by field name to check the field type - $fieldTableData->tjFieldFieldTable->load(array('name' => $field->__get("fieldname"))); + $tjFieldsFieldTable->load(array('name' => $field->__get("fieldname"))); $canView = false; - if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $fieldTableData->tjFieldFieldTable->group_id)) + if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) { - $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $fieldTableData->tjFieldFieldTable->id); + $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); } if ($canView || ($itemData->created_by == $user->id)) @@ -86,7 +88,7 @@ continue; } - if ($field->type == 'Subform' || $field->type == 'Ucmsubform') + if ($field->type == 'Ucmsubform') { ?>
@@ -111,7 +113,6 @@ if (!empty($ucmSubFormFieldValue)) { - foreach ($ucmSubFormFieldValue as $ucmSubFormData) { $contentIdFieldname = str_replace('.', '_', $ucmSubFormClient) . '_contentid'; @@ -134,21 +135,11 @@ $ucmSubFormXmlFieldSets[$ucmSubFormCount] = $ucmSubFormXmlFieldSet; $ucmSubFormCount++; } - - if($field->type == 'Subform') - { - // Call the JLayout recursively to render fields of ucmsubform - $layout = new JLayoutFile('subform', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); - echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'ucmSubFormData' => $ucmSubFormData, 'isSubForm' => 1)); - echo "
"; - } - else - { - // Call the JLayout recursively to render fields of ucmsubform - $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); - echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $this->item, 'isSubForm' => 1)); - echo "
"; - } + + // Call the JLayout recursively to render fields of ucmsubform + $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); + echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $this->item, 'isSubForm' => 1)); + echo "
"; } } ?> diff --git a/src/components/com_tjucm/site/layouts/detail/subform.php b/src/components/com_tjucm/site/layouts/detail/subform.php deleted file mode 100644 index fab31618..00000000 --- a/src/components/com_tjucm/site/layouts/detail/subform.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @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('ucmSubFormData', $displayData) || !key_exists('xmlFormObject', $displayData)) -{ - return; -} - -$user = JFactory::getUser(); - -// Layout for field types -$fieldLayout = array(); -$fieldLayout['File'] = $fieldLayout['Image'] = "file"; -$fieldLayout['Checkbox'] = "checkbox"; -$fieldLayout['Radio'] = $fieldLayout['List'] = "list"; -$fieldLayout['Itemcategory'] = "itemcategory"; -$fieldLayout['Video'] = $fieldLayout['Audio'] = $fieldLayout['Url'] = "link"; -$fieldLayout['Calendar'] = "calendar"; - -// Load the tj-fields helper -JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); -$TjfieldsHelper = new TjfieldsHelper; - -// Get JLayout data -$xmlFormObject = $displayData['xmlFormObject']; -$ucmSubFormData = $displayData['ucmSubFormData']; -$isSubForm = $displayData['isSubForm']; - -// Define the classes for subform and normal form rendering -$controlGroupDivClass = ($isSubForm) ? 'col-xs-12' : 'col-xs-12 col-md-6'; -$labelDivClass = ($isSubForm) ? 'col-xs-6' : 'col-xs-4'; -$controlDivClass = ($isSubForm) ? 'col-xs-6' : 'col-xs-8'; - -// Get Field table -$fieldTableData = new stdClass; -JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); -$fieldTableData->tjFieldFieldTable = JTable::getInstance('field', 'TjfieldsTable'); - -$count = 0; -$fieldCount = 0; -$xmlFieldSet = $xmlFormObject[$count]; - -?> -
- $fieldValue) - { - // Get the field data by field name to check the field type - $fieldTableData->tjFieldFieldTable->load(array('name' => $fieldName)); - $canView = false; - - if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $fieldTableData->tjFieldFieldTable->group_id)) - { - $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $fieldTableData->tjFieldFieldTable->id); - } - - if ($canView || ($itemData->created_by == $user->id)) - { - // Get xml for the field - $xmlField = $xmlFieldSet->field[$fieldCount]; - $fieldCount++; - - if ($fieldTableData->tjFieldFieldTable->type == 'hidden') - { - continue; - } - else - { - $layoutToUse = (array_key_exists($fieldTableData->tjFieldFieldTable->type, $fieldLayout)) ? $fieldLayout[$field->type] : 'field'; - ?> -
-
tjFieldFieldTable->label; ?>:
-
- value = $fieldValue; - $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); - $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); - echo $output; - ?> -
-
- -
diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index d171e546..691fdc94 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -15,6 +15,8 @@ return; } +$fieldsData = $displayData['fieldsData']; + $app = JFactory::getApplication(); $user = JFactory::getUser(); @@ -22,26 +24,26 @@ $fieldLayout = array(); $fieldLayout['File'] = $fieldLayout['Image'] = "file"; $fieldLayout['Checkbox'] = "checkbox"; -$fieldLayout['Radio'] = $fieldLayout['List'] = "list"; +$fieldLayout['tjlist'] = $fieldLayout['Radio'] = $fieldLayout['List'] = $fieldLayout['Single_select'] = $fieldLayout['Multi_select'] = "list"; $fieldLayout['Itemcategory'] = "itemcategory"; $fieldLayout['Video'] = $fieldLayout['Audio'] = $fieldLayout['Url'] = "link"; $fieldLayout['Calendar'] = "calendar"; +$fieldLayout['Cluster'] = "cluster"; +$fieldLayout['Related'] = $fieldLayout['Sql'] = "sql"; +$fieldLayout['Ownership'] = "ownership"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); $TjfieldsHelper = new TjfieldsHelper; // Get JLayout data -$item = $displayData['itemsData']; -$created_by = $displayData['created_by']; -$client = $displayData['client']; -$xmlFieldSet = $displayData['xmlFormObject']; -$ucmTypeId = $displayData['ucmTypeId']; - -// Get Field table -$fieldTableData = new stdClass; -JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); -$fieldTableData->tjFieldFieldTable = JTable::getInstance('field', 'TjfieldsTable'); +$item = $displayData['itemsData']; +$created_by = $displayData['created_by']; +$client = $displayData['client']; +$xmlFormObject = $displayData['xmlFormObject']; +$formObject = $displayData['formObject']; +$ucmTypeId = $displayData['ucmTypeId']; + $appendUrl = ''; $csrf = "&" . JSession::getFormToken() . '=1'; @@ -65,111 +67,101 @@ $tjUcmFrontendHelper = new TjucmHelpersTjucm; $itemId = $tjUcmFrontendHelper->getItemId($link); - $link = JRoute::_('index.php?option=com_tjucm&view=item&id=' . $item->id . "&client=" . $client . '&Itemid=' . $itemId, false); - - $editown = false; - - if ($canEditOwn) - { - $editown = (JFactory::getUser()->id == $item->created_by ? true : false); - } +$link = JRoute::_('index.php?option=com_tjucm&view=item&id=' . $item->id . "&client=" . $client . '&Itemid=' . $itemId, false); + +$editown = false; + +if ($canEditOwn) +{ + $editown = (JFactory::getUser()->id == $item->created_by ? true : false); +} + +$deleteOwn = false; - $deleteOwn = false; - if ($canDeleteOwn) +if ($canDeleteOwn) +{ + $deleteOwn = (JFactory::getUser()->id == $item->created_by ? true : false); +} +?> +
+ state)) { - $deleteOwn = (JFactory::getUser()->id == $item->created_by ? true : false); - } - ?> - - state)) - { - $class = ($canChange) ? 'active' : 'disabled'; ?> - - - - field_values)) + + + field_values)) + { + foreach ($item->field_values as $key => $fieldValue) { - $fieldCount = 0; - foreach ($item->field_values as $key => $field_values) + $tjFieldsFieldTable = $fieldsData[$key]; + + $canView = false; + + if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) { - $fieldTableData->tjFieldFieldTable->load(array('id' => $key)); - $type = $fieldTableData->tjFieldFieldTable->type; - - // Get xml for the field - $xmlField = $xmlFieldSet->fieldset->field[$fieldCount]; - $fieldCount++; - - if($xmlField['type'][0] == 'ucmsubform') - { - $xmlField = $xmlFieldSet->fieldset->field[$fieldCount]; - $fieldCount++; - } - ?> - + + - id . $appendUrl . $csrf; ?>" class="btn btn-mini delete-button" type="button"> + - - - + + + diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 0b8cf7c6..32175e0a 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -432,7 +432,7 @@ public function getFieldForm($data = array(), $loadData = true) public function getTypeForm($data = array(), $loadData = true) { - $draft = $data['draft']; + $draft = isset($data['draft']) ? $data['draft'] : 0; $clientPart = explode(".", $data['client']); // Path of empty form XML to create form object dynamically @@ -973,13 +973,13 @@ public function duplicate(&$pks) /** * Method to delete data * - * @param array $contentId Data to be deleted + * @param array &$contentId Data to be deleted * * @return bool|int If success returns the id of the deleted item, if not false * * @throws Exception */ - public function delete($contentId) + public function delete(&$contentId) { $ucmTypeId = $this->getState('ucmType.id'); $user = JFactory::getUser(); diff --git a/src/components/com_tjucm/site/views/items/tmpl/default.php b/src/components/com_tjucm/site/views/items/tmpl/default.php index e9724cf2..47084072 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -39,7 +39,7 @@ $link = 'index.php?option=com_tjucm&view=items' . $appendUrl; $itemId = $tjUcmFrontendHelper->getItemId($link); - +$fieldsData = array(); ?> loadTemplate('filters'); ?> @@ -66,11 +66,23 @@ listcolumn)) { - foreach ($this->listcolumn as $col_name) + JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); + $tjFieldsFieldTable = JTable::getInstance('field', 'TjfieldsTable'); + + foreach ($this->listcolumn as $fieldId => $col_name) { + if (isset($fieldsData[$fieldId])) + { + $tjFieldsFieldTable = $fieldsData[$fieldId]; + } + else + { + $tjFieldsFieldTable = JTable::getInstance('field', 'TjfieldsTable'); + $tjFieldsFieldTable->load($fieldId); + $fieldsData[$fieldId] = $tjFieldsFieldTable; + } ?> - - - items)) - { - ?> - - - - - - + + - - showList)) + }?> + items)) + { + ?> + + + + + + + + showList)) + { + if (!empty($this->items)) { - if (!empty($this->items)) - { - foreach ($this->items as $i => $item) - { - $editown = false; - if ($this->canEditOwn) - { - $editown = (JFactory::getUser()->id == $item->created_by ? true : false); - } + $xmlFileName = explode(".", $this->client); + $xmlFilePath = JPATH_SITE . "/administrator/components/com_tjucm/models/forms/" . $xmlFileName[1] . "_extra" . ".xml"; + $formXml = simplexml_load_file($xmlFilePath); - $deleteOwn = false; - if ($this->canDeleteOwn) - { - $deleteOwn = (JFactory::getUser()->id == $item->created_by ? true : false); - } - ?> - - items[0]->state)) - { - $class = ($this->canChange) ? 'active' : 'disabled'; ?> - - - - field_values)) - { - foreach ($item->field_values as $field_values) - { - ?> - - client); + JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); + $itemFormModel = JModelLegacy::getInstance('ItemForm', 'TjucmModel'); + $formObject = $itemFormModel->getFormExtra( + array( + "clientComponent" => 'com_tjucm', + "client" => $this->client, + "view" => $view[1], + "layout" => 'edit') + ); - if ($this->canEdit || $this->canDelete || $editown || $deleteOwn) - { - ?> - - - - items as $i => $item) { - ?> -
- render(array('itemsData' => $item, 'created_by' => $this->created_by, 'client' => $this->client, 'xmlFormObject' => $formXml, 'ucmTypeId' => $this->ucmTypeId, 'fieldsData' => $fieldsData, 'formObject' => $formObject)); } } else { - ?> + ?>
- -
- - state == 1) - { - ?> - - - checked_out) && $item->checked_out) - { - echo JHtml::_('jgrid.checkedout', $i, $item->uEditor, $item->checked_out_time, 'items.', $canCheckin); - } - ?> - - escape($item->id); ?> - - - - - $subFormDataColumn) - { - ?> - - ' . $key . '' : ''; - ?> - - -
' . $subFormDataColumn . '
- - - - - -
- canEdit || $editown) - { - ?> - - canDelete || $deleteOwn) - { - ?> - - -
- - state == 1) - { - ?> - - + $class = ($canChange) ? 'active' : 'disabled'; ?> + + checked_out) && $item->checked_out) + if ($item->state == 1) + { + ?>uEditor, $item->checked_out_time, 'items.', $canCheckin); + ?> - - escape($item->id); ?> + + escape($item->id); ?> + + - type] : 'field'; - $field = new stdClass; - $field->value = $field_values; + $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); + } + $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); + ?> + + created_by == $user->id)) + { + $field = $formObject->getField($tjFieldsFieldTable->name); + $field->value = $fieldValue; + $layoutToUse = (array_key_exists(ucfirst($tjFieldsFieldTable->type), $fieldLayout)) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); - $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); + $output = $layout->render(array('fieldXml' => $fieldXml, 'field' => $field)); echo $output; - ?> - - + + - - + - - - - -
@@ -88,163 +100,70 @@ -
- pagination->getListFooter(); ?> -
+ pagination->getListFooter(); ?> +
- - state == 1) - { - ?> - - - checked_out) && $item->checked_out) - { - echo JHtml::_('jgrid.checkedout', $i, $item->uEditor, $item->checked_out_time, 'items.', $canCheckin); - } - ?> - - escape($item->id); ?> - - - - - $subFormDataColumn) - { - ?> - - ' . $key . '' : ''; - ?> - - -
' . $subFormDataColumn . '
- -
- canEdit || $editown) - { - ?> - - canDelete || $deleteOwn) - { - ?> - - -
- + } + else + { + ?> +
+ + + + allowedToAdd) { From 90f2ac4073eac8d41945deff7ef8cfb55c3f0bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 18 Oct 2019 12:55:07 +0530 Subject: [PATCH 08/20] Bug #205 fix: For list type of field, value is shown on list and details view instead of label --- .../com_tjucm/site/layouts/list/list.php | 2 +- src/components/com_tjucm/site/models/items.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 691fdc94..91ac31b4 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -131,7 +131,7 @@ if ($canView || ($item->created_by == $user->id)) { $field = $formObject->getField($tjFieldsFieldTable->name); - $field->value = $fieldValue; + $field->setValue($fieldValue); $layoutToUse = (array_key_exists(ucfirst($tjFieldsFieldTable->type), $fieldLayout)) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); $output = $layout->render(array('fieldXml' => $fieldXml, 'field' => $field)); diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 62a62ecf..bcda4f90 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -479,7 +479,22 @@ public function getItems() { if ($item->id == $fieldValue->content_id) { - $item->field_values[$fieldValue->field_id] = $fieldValue->value; + if (isset($item->field_values[$fieldValue->field_id])) + { + if (is_array($item->field_values[$fieldValue->field_id])) + { + $item->field_values[$fieldValue->field_id] = array_merge($item->field_values[$fieldValue->field_id], array($fieldValue->value)); + } + else + { + $item->field_values[$fieldValue->field_id] = array_merge(array($item->field_values[$fieldValue->field_id]), array($fieldValue->value)); + } + } + else + { + $item->field_values[$fieldValue->field_id] = $fieldValue->value; + } + unset($fieldValues[$key]); } } From 72963f2256b1c65d3035e8affc8b8a023d3280cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 18 Oct 2019 15:42:51 +0530 Subject: [PATCH 09/20] Bug #205 fix: For list type of field, value is shown on list and details view instead of label --- src/components/com_tjucm/site/layouts/detail/fields.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index 0dbb04b7..ab76f420 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -39,7 +39,7 @@ $xmlFormObject = $displayData['xmlFormObject']; $formObject = $displayData['formObject']; $itemData = $displayData['itemData']; -$isSubForm = $displayData['isSubForm']; +$isSubForm = isset($displayData['isSubForm']) ? $displayData['isSubForm'] : ''; // Define the classes for subform and normal form rendering $controlGroupDivClass = ($isSubForm) ? 'col-xs-12' : 'col-xs-12 col-md-6'; @@ -136,9 +136,11 @@ $ucmSubFormCount++; } + $ucmSubFormRecordData = $tjucmItemModel->getData($ucmSubFormData->$contentIdFieldname); + // Call the JLayout recursively to render fields of ucmsubform $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); - echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $this->item, 'isSubForm' => 1)); + echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $ucmSubFormRecordData, 'isSubForm' => 1)); echo "
"; } } From 16dd6f9f4e9e2fe8a9961c355f69f9f4f1922fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 23 Oct 2019 17:30:58 +0530 Subject: [PATCH 10/20] Bug #151675 fix: Multi-select and radio button value did no display in view page --- .../com_tjucm/site/layouts/detail/fields.php | 19 ++++++++++++++++++- .../com_tjucm/site/views/item/view.html.php | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index ab76f420..38b6dfda 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -40,6 +40,7 @@ $formObject = $displayData['formObject']; $itemData = $displayData['itemData']; $isSubForm = isset($displayData['isSubForm']) ? $displayData['isSubForm'] : ''; +$data = $TjfieldsHelper->FetchDatavalue(array('content_id' => $itemData->id, 'client' => $itemData->client)); // Define the classes for subform and normal form rendering $controlGroupDivClass = ($isSubForm) ? 'col-xs-12' : 'col-xs-12 col-md-6'; @@ -123,7 +124,7 @@ "client" => $ucmSubFormClient, "view" => $view[1], "layout" => 'default', - "content_id" => $ucmSubFormData->$contentIdFieldname, ) + "content_id" => $ucmSubFormData->$contentIdFieldname) ); $ucmSubFormFormXml = simplexml_load_file($field->formsource); @@ -157,6 +158,22 @@
label; ?>:
getAttribute('name') == $fieldData->name) + { + $valueFound = 1; + break; + } + } + + if (empty($valueFound)) + { + $field->setValue(''); + } + $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); echo $output; diff --git a/src/components/com_tjucm/site/views/item/view.html.php b/src/components/com_tjucm/site/views/item/view.html.php index b68b5514..8cc78723 100644 --- a/src/components/com_tjucm/site/views/item/view.html.php +++ b/src/components/com_tjucm/site/views/item/view.html.php @@ -105,8 +105,8 @@ public function display($tpl = null) "clientComponent" => 'com_tjucm', "client" => $this->client, "view" => $view[1], - "layout" => 'default', - "content_id" => $this->id, ) + "layout" => 'edit', + "content_id" => $this->id) ); // Check for errors. From 1d1f4087ffd2e954dec638e274745d70bacb2d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 25 Oct 2019 11:03:15 +0530 Subject: [PATCH 11/20] Bug #152428 fix: ForntEnd>> Tool tip is missing on actions button. --- .../com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini | 1 + src/components/com_tjucm/site/layouts/list/list.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini index f2c102ea..811f4bea 100644 --- a/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini @@ -5,6 +5,7 @@ COM_TJUCM_ITEM_DELETED_SUCCESSFULLY="Item deleted successfully" COM_TJUCM_ITEM_DOESNT_EXIST="Item does not exist" COM_TJUCM_ITEM_NOT_LOADED="Could not load the item" COM_TJUCM_VIEW_FILE="[View File]" +COM_TJUCM_VIEW_RECORD="View" COM_TJUCM_ADD_ITEM="Add" COM_TJUCM_EDIT_ITEM="Edit" COM_TJUCM_DELETE_ITEM="Delete" diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 91ac31b4..7e6c7de6 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -93,11 +93,11 @@ state == 1) { - ?> @@ -145,18 +145,18 @@ { ?> - + - + - + From 90eb919295a3806d51a1b24d36fce1bf773abf61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 25 Oct 2019 11:57:59 +0530 Subject: [PATCH 12/20] Bug #152427 fix: Front End >> UI distortion at the list view of the form if user enter long text in textarea. --- src/components/com_tjucm/site/layouts/list/list.php | 2 +- .../com_tjucm/site/views/items/tmpl/default.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 7e6c7de6..22506057 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -126,7 +126,7 @@ $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); ?> - + created_by == $user->id)) { diff --git a/src/components/com_tjucm/site/views/items/tmpl/default.php b/src/components/com_tjucm/site/views/items/tmpl/default.php index 47084072..2db9ffdb 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -43,7 +43,7 @@ ?> loadTemplate('filters'); ?> -
+
showList)) @@ -56,13 +56,13 @@ if (isset($this->items[0]->state)) { ?> - - - canEdit || $this->canDelete) { ?> - Date: Fri, 25 Oct 2019 12:37:48 +0530 Subject: [PATCH 13/20] Bug #152425 fix: Field>> Checkbox column is blank once user not selected the checkbox. --- .../administrator/assets/js/itemform.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/com_tjucm/administrator/assets/js/itemform.js b/src/components/com_tjucm/administrator/assets/js/itemform.js index ac7248fe..81c91a3c 100644 --- a/src/components/com_tjucm/administrator/assets/js/itemform.js +++ b/src/components/com_tjucm/administrator/assets/js/itemform.js @@ -623,6 +623,17 @@ var tjUcmItemForm = { tjUcmFormFinalSave = 1; } + jQuery('input[type="checkbox"]').each(function (){ + if (jQuery(this).prop('checked') == true) + { + tjUcmItemFormData.append(jQuery(this).attr('name'), 1); + } + else + { + tjUcmItemFormData.append(jQuery(this).attr('name'), 0); + } + }); + com_tjucm.Services.Item.saveFormData(tjUcmItemFormData, tjUcmItemForm.afterDataSave); }); @@ -658,6 +669,17 @@ var tjUcmItemForm = { tjUcmSectionFormData.append(jQuery(this).attr('name'), jQuery(this)[0].files[0]); } } + else if(jQuery(this).attr('type') == 'checkbox') + { + if (jQuery(this).prop('checked') == true) + { + jQuery(this).val(1); + } + else + { + jQuery(this).val(0); + } + } else { if (jQuery(this).val() != undefined) From 3ea5e6abf1c5eda1294041a1e4efe9dcb02ff349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 25 Oct 2019 15:59:42 +0530 Subject: [PATCH 14/20] Issue #123 chore: Merge upstream/master --- src/components/com_tjucm/tjucm.xml | 4 ++-- src/pkg_tjucm.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/com_tjucm/tjucm.xml b/src/components/com_tjucm/tjucm.xml index 9b21c573..6adf1a51 100644 --- a/src/components/com_tjucm/tjucm.xml +++ b/src/components/com_tjucm/tjucm.xml @@ -6,8 +6,8 @@ Techjoomla extensions@techjoomla.com https://techjoomla.com - 4th Oct 2019 - 1.2.1 + 25th Oct 2019 + 1.2.2 TJ-UCM - Universal Content Manager]]> script.php diff --git a/src/pkg_tjucm.xml b/src/pkg_tjucm.xml index 586170a3..b326c6a7 100644 --- a/src/pkg_tjucm.xml +++ b/src/pkg_tjucm.xml @@ -6,9 +6,9 @@ TJUCM - Universal Content Manager Package Copyright (c) 2009-2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 4th Oct 2019 + 25th Oct 2019 ucm - 1.2.1 + 1.2.2 Techjoomla Team script.pkg_tjucm.php From 72b0b0604e56b15f9d014b8fe339afdee550f07a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 25 Oct 2019 18:16:02 +0530 Subject: [PATCH 15/20] Issue #123 chore: Merge upstream/master --- .../administrator/assets/js/itemform.js | 14 ++++++++++- .../site/views/itemform/tmpl/default.php | 25 ++++++++----------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/components/com_tjucm/administrator/assets/js/itemform.js b/src/components/com_tjucm/administrator/assets/js/itemform.js index 81c91a3c..2ff9bb56 100644 --- a/src/components/com_tjucm/administrator/assets/js/itemform.js +++ b/src/components/com_tjucm/administrator/assets/js/itemform.js @@ -423,7 +423,19 @@ var tjUcmItemForm = { tjUcmItemFieldFormData.append('client', tjUcmClient); tjUcmItemFieldFormData.append('recordid', tjUcmRecordId); - if (jQuery(fieldObj).attr('type') != 'file') + + if (jQuery(fieldObj).attr('type') == 'checkbox') + { + if (jQuery(fieldObj).prop('checked') == true) + { + tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), 1); + } + else + { + tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), 0); + } + } + else if (jQuery(fieldObj).attr('type') != 'file') { tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj).val()); } diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default.php b/src/components/com_tjucm/site/views/itemform/tmpl/default.php index d3ae87e4..89f2358d 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -53,40 +53,37 @@ { $itemState = ($this->allow_auto_save || $this->allow_draft_save) ? 1 : 0; } -?> - + }; +'); +?> allow_auto_save == '1') From 20e0bab048d6cb6ebfcc7bebe9a590f01ed3059d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 31 Oct 2019 17:18:04 +0530 Subject: [PATCH 16/20] Bug #152494 fix: If there is some error in the migration script then the script is executed multiplke times --- .../administrator/assets/js/itemform.js | 1 - .../houseKeeping/1.1.0/ucmSubformData.php | 198 ++++++++++-------- 2 files changed, 106 insertions(+), 93 deletions(-) diff --git a/src/components/com_tjucm/administrator/assets/js/itemform.js b/src/components/com_tjucm/administrator/assets/js/itemform.js index 2ff9bb56..7fdae20f 100644 --- a/src/components/com_tjucm/administrator/assets/js/itemform.js +++ b/src/components/com_tjucm/administrator/assets/js/itemform.js @@ -423,7 +423,6 @@ var tjUcmItemForm = { tjUcmItemFieldFormData.append('client', tjUcmClient); tjUcmItemFieldFormData.append('recordid', tjUcmRecordId); - if (jQuery(fieldObj).attr('type') == 'checkbox') { if (jQuery(fieldObj).prop('checked') == true) diff --git a/src/components/com_tjucm/administrator/houseKeeping/1.1.0/ucmSubformData.php b/src/components/com_tjucm/administrator/houseKeeping/1.1.0/ucmSubformData.php index 1d78ad05..dcdc6725 100644 --- a/src/components/com_tjucm/administrator/houseKeeping/1.1.0/ucmSubformData.php +++ b/src/components/com_tjucm/administrator/houseKeeping/1.1.0/ucmSubformData.php @@ -35,118 +35,132 @@ class TjHouseKeepingUcmSubformData extends TjModelHouseKeeping */ public function migrate() { - $db = Factory::getDbo(); - $query = $db->getQuery(true); - $query->select('ud.*, fv.id AS fieldValueId, fv.field_id, fv.client AS sub_client, fv.value, f.name'); - $query->from($db->qn('#__tjfields_fields_value', 'fv')); - $query->join('INNER', $db->qn('#__tjfields_fields', 'f') . ' ON (' . - $db->qn('f.id') . ' = ' . $db->qn('fv.field_id') . ' AND ' . $db->qn('f.type') . ' = "ucmsubform")'); - $query->join('INNER', $db->qn('#__tj_ucm_data', 'ud') . ' ON (' . - $db->qn('fv.content_id') . ' = ' . $db->qn('ud.id') . ')'); - $db->setQuery($query); - - $data = $db->loadObjectlist(); - - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); - BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_tjucm/models'); - - // Get UCM type id from uniquue identifier - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models'); - $tjUcmModelType = BaseDatabaseModel::getInstance('Type', 'TjucmModel', array('ignore_request' => true)); - - // Process all ucm subform records - foreach ($data as $ucmSubFormData) - { - if (json_decode($ucmSubFormData->value) === null) - { - continue; - } + $result = array(); - // Create Main table data - $validData = array(); - $validData['id'] = 0; - $validData['parent_id'] = $ucmSubFormData->id; - $validData['cluster_id'] = $ucmSubFormData->cluster_id; - $validData['state'] = $ucmSubFormData->state; - $validData['created_by'] = $ucmSubFormData->created_by; - $validData['created_date'] = $ucmSubFormData->created_date; - $validData['modified_by'] = $ucmSubFormData->modified_by; - $validData['modified_date'] = $ucmSubFormData->modified_date; - - $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); - $tjFieldsFieldsModel->setState('filter.client', $ucmSubFormData->client); - $tjFieldsFieldsModel->setState('filter.type', 'ucmsubform'); - $tjFieldsFieldsModel->setState('filter.search', 'id:' . $ucmSubFormData->field_id); - - // Get ucmsubform field data - $ucmSubFormFields = $tjFieldsFieldsModel->getItems(); - - // Initialize ucmsubform data variable - $ucmSubFormDataSet = array(); - $ucmSubFormClient = ''; - - // Sort all the ucmsubform records as per client - foreach ($ucmSubFormFields as $ucmSubFormField) + try + { + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $query->select('ud.*, fv.id AS fieldValueId, fv.field_id, fv.client AS sub_client, fv.value, f.name'); + $query->from($db->qn('#__tjfields_fields_value', 'fv')); + $query->join('INNER', $db->qn('#__tjfields_fields', 'f') . ' ON (' . + $db->qn('f.id') . ' = ' . $db->qn('fv.field_id') . ' AND ' . $db->qn('f.type') . ' = "ucmsubform")'); + $query->join('INNER', $db->qn('#__tj_ucm_data', 'ud') . ' ON (' . + $db->qn('fv.content_id') . ' = ' . $db->qn('ud.id') . ')'); + $db->setQuery($query); + + $data = $db->loadObjectlist(); + + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); + BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_tjucm/models'); + + // Get UCM type id from uniquue identifier + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models'); + $tjUcmModelType = BaseDatabaseModel::getInstance('Type', 'TjucmModel', array('ignore_request' => true)); + + // Process all ucm subform records + foreach ($data as $ucmSubFormData) { - // Get decoded data object - Convert subform JSON data into an Array - $subformRecords = new Registry($ucmSubFormData->value); + if (json_decode($ucmSubFormData->value) === null) + { + continue; + } - if (!empty($subformRecords)) + // Create Main table data + $validData = array(); + $validData['id'] = 0; + $validData['parent_id'] = $ucmSubFormData->id; + $validData['cluster_id'] = $ucmSubFormData->cluster_id; + $validData['state'] = $ucmSubFormData->state; + $validData['created_by'] = $ucmSubFormData->created_by; + $validData['created_date'] = $ucmSubFormData->created_date; + $validData['modified_by'] = $ucmSubFormData->modified_by; + $validData['modified_date'] = $ucmSubFormData->modified_date; + + $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $tjFieldsFieldsModel->setState('filter.client', $ucmSubFormData->client); + $tjFieldsFieldsModel->setState('filter.type', 'ucmsubform'); + $tjFieldsFieldsModel->setState('filter.search', 'id:' . $ucmSubFormData->field_id); + + // Get ucmsubform field data + $ucmSubFormFields = $tjFieldsFieldsModel->getItems(); + + // Initialize ucmsubform data variable + $ucmSubFormDataSet = array(); + $ucmSubFormClient = ''; + + // Sort all the ucmsubform records as per client + foreach ($ucmSubFormFields as $ucmSubFormField) { - // Initialize subform data variables - $subFormData = $ucmSubFormDataSet = array(); + // Get decoded data object - Convert subform JSON data into an Array + $subformRecords = new Registry($ucmSubFormData->value); - foreach ($subformRecords as $key => $subformRecord) + if (!empty($subformRecords)) { - // Type cast subform records - $subformRecord = (array) $subformRecord; + // Initialize subform data variables + $subFormData = $ucmSubFormDataSet = array(); - if (!empty($subformRecord)) + foreach ($subformRecords as $key => $subformRecord) { - // Add ucmSubFormFieldName in the data to pass data to JS - $subformRecord['ucmSubformFieldName'] = $ucmSubFormData->name; - $subFormData[] = $subformRecord; + // Type cast subform records + $subformRecord = (array) $subformRecord; + + if (!empty($subformRecord)) + { + // Add ucmSubFormFieldName in the data to pass data to JS + $subformRecord['ucmSubformFieldName'] = $ucmSubFormData->name; + $subFormData[] = $subformRecord; + } } - } - if (!empty($subFormData)) - { - // Format subform data to save entry as a new UCM type data - $ucmSubFormFieldParams = new Registry($ucmSubFormField->params); - $ucmSubFormFormSource = explode('/', $ucmSubFormFieldParams->get('formsource')); - $ucmSubFormClient = $ucmSubFormFormSource[1] . '.' . str_replace('form_extra.xml', '', $ucmSubFormFormSource[4]); - $ucmSubFormDataSet[$ucmSubFormClient] = $subFormData; - $ucmSubFormData->value = $ucmSubFormClient; + if (!empty($subFormData)) + { + // Format subform data to save entry as a new UCM type data + $ucmSubFormFieldParams = new Registry($ucmSubFormField->params); + $ucmSubFormFormSource = explode('/', $ucmSubFormFieldParams->get('formsource')); + $ucmSubFormClient = $ucmSubFormFormSource[1] . '.' . str_replace('form_extra.xml', '', $ucmSubFormFormSource[4]); + $ucmSubFormDataSet[$ucmSubFormClient] = $subFormData; + $ucmSubFormData->value = $ucmSubFormClient; + } } } - } - // Save ucmSubForm records - if (!empty($ucmSubFormDataSet)) - { - $itemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel', array('ignore_request' => true)); + // Save ucmSubForm records + if (!empty($ucmSubFormDataSet)) + { + $itemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel', array('ignore_request' => true)); - // Set ucm type id to check permission in Item form model save() for logged-in user - $ucmTypeId = $tjUcmModelType->getTypeId($ucmSubFormClient); - $itemFormModel->setState('ucmType.id', $ucmTypeId); + // Set ucm type id to check permission in Item form model save() for logged-in user + $ucmTypeId = $tjUcmModelType->getTypeId($ucmSubFormClient); + $itemFormModel->setState('ucmType.id', $ucmTypeId); - // Call method to save ucmsubform data into new UCM data - $subFormContentIds = $itemFormModel->saveUcmSubFormRecords($validData, $ucmSubFormDataSet); + // Call method to save ucmsubform data into new UCM data + $subFormContentIds = $itemFormModel->saveUcmSubFormRecords($validData, $ucmSubFormDataSet); - // To update existing ucm subform field value from JSON to subform ucm type name - if ($subFormContentIds) - { - $obj = new stdClass; - $obj->id = $ucmSubFormData->fieldValueId; - $obj->field_id = $ucmSubFormData->field_id; - $obj->content_id = $ucmSubFormData->id; - $obj->value = $ucmSubFormClient; + // To update existing ucm subform field value from JSON to subform ucm type name + if ($subFormContentIds) + { + $obj = new stdClass; + $obj->id = $ucmSubFormData->fieldValueId; + $obj->field_id = $ucmSubFormData->field_id; + $obj->content_id = $ucmSubFormData->id; + $obj->value = $ucmSubFormClient; - $db->updateObject('#__tjfields_fields_value', $obj, 'id'); + $db->updateObject('#__tjfields_fields_value', $obj, 'id'); + } } } + + $result['status'] = true; + $result['message'] = "Migration successful"; + } + catch (Exception $e) + { + $result['err_code'] = ''; + $result['status'] = false; + $result['message'] = $e->getMessage(); } - return true; + return $result; } } From e4f64e57c6f6334dde14dfa3a2e84d9c502aa6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 1 Nov 2019 11:42:20 +0530 Subject: [PATCH 17/20] Bug #152480 fix: Front end >> User should get general message if category not added under the menu. --- src/components/com_tjucm/site/views/itemform/view.html.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/views/itemform/view.html.php b/src/components/com_tjucm/site/views/itemform/view.html.php index 98292ec6..693e3754 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -239,7 +239,12 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors)); + foreach ($errors as $error) + { + $app->enqueueMessage($error, 'error'); + } + + return false; } // Ucm triggger before item form display From 0360d04b979cee621de87edc5df4481286fdd397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 4 Nov 2019 12:52:36 +0530 Subject: [PATCH 18/20] Bug #218 fix: Editor field do not shows formated text in the list and details view --- src/components/com_tjucm/site/layouts/detail/fields.php | 1 + src/components/com_tjucm/site/layouts/list/list.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index 38b6dfda..634b9502 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -30,6 +30,7 @@ $fieldLayout['Related'] = $fieldLayout['SQL'] = "sql"; $fieldLayout['Subform'] = "subform"; $fieldLayout['Ownership'] = "ownership"; +$fieldLayout['Editor'] = "editor"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 22506057..3589eaa5 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -31,6 +31,7 @@ $fieldLayout['Cluster'] = "cluster"; $fieldLayout['Related'] = $fieldLayout['Sql'] = "sql"; $fieldLayout['Ownership'] = "ownership"; +$fieldLayout['Editor'] = "editor"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); From 8832cb3429a23de7dcea16b433518b4d3b22c808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 4 Nov 2019 16:36:51 +0530 Subject: [PATCH 19/20] Bug #218 fix: Editor field do not shows formated text in the list and details view --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 3 +++ src/components/com_tjucm/site/router.php | 13 ++++++++----- .../com_tjucm/site/views/itemform/view.html.php | 5 +---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini index 811f4bea..eb9f7ded 100644 --- a/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini @@ -179,3 +179,6 @@ COM_TJUCM_FORM_SAVE_FAILED_CLIENT_REQUIRED="Unable to process the request as cli COM_TJUCM_FORM_SAVE_FAILED_RECORD_ID_REQUIRED="Unable to process the request as record id is not provided" COM_TJUCM_FORM_SAVE_FAILED_FIELD_DATA_REQUIRED="Unable to process the request as field data is not provided" COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR="You are not authorized to perform this operation." + +; Since 1.2.2 +COM_TJUCM_SOMETHING_WENT_WRONG="Something went wrong" diff --git a/src/components/com_tjucm/site/router.php b/src/components/com_tjucm/site/router.php index 0eb0898f..f1fc2a97 100644 --- a/src/components/com_tjucm/site/router.php +++ b/src/components/com_tjucm/site/router.php @@ -148,12 +148,15 @@ public function parse(&$segments) if ($count >= 1) { - $ucmTypeTable = Table::getInstance('Type', 'TjucmTable', array('dbo', $db)); - $ucmTypeTable->load(array('alias' => $segments[1])); - - if ($ucmTypeTable->id) + if (isset($segments[1])) { - $vars['client'] = $ucmTypeTable->unique_identifier; + $ucmTypeTable = Table::getInstance('Type', 'TjucmTable', array('dbo', $db)); + $ucmTypeTable->load(array('alias' => $segments[1])); + + if ($ucmTypeTable->id) + { + $vars['client'] = $ucmTypeTable->unique_identifier; + } } } diff --git a/src/components/com_tjucm/site/views/itemform/view.html.php b/src/components/com_tjucm/site/views/itemform/view.html.php index 693e3754..c782dc44 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -239,10 +239,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - foreach ($errors as $error) - { - $app->enqueueMessage($error, 'error'); - } + $app->enqueueMessage(Text::_("COM_TJUCM_SOMETHING_WENT_WRONG"), 'error'); return false; } From 55a5c6a2ee3f8a460d2f3ee64e1cde53fae4a90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 4 Nov 2019 16:45:52 +0530 Subject: [PATCH 20/20] Bug #218 fix: Editor field do not shows formated text in the list and details view --- src/components/com_tjucm/tjucm.xml | 2 +- src/pkg_tjucm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/tjucm.xml b/src/components/com_tjucm/tjucm.xml index 6adf1a51..876a72f3 100644 --- a/src/components/com_tjucm/tjucm.xml +++ b/src/components/com_tjucm/tjucm.xml @@ -6,7 +6,7 @@ Techjoomla extensions@techjoomla.com https://techjoomla.com - 25th Oct 2019 + 4th Nov 2019 1.2.2 TJ-UCM - Universal Content Manager]]> script.php diff --git a/src/pkg_tjucm.xml b/src/pkg_tjucm.xml index b326c6a7..fbaaf95c 100644 --- a/src/pkg_tjucm.xml +++ b/src/pkg_tjucm.xml @@ -6,7 +6,7 @@ TJUCM - Universal Content Manager Package Copyright (c) 2009-2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 25th Oct 2019 + 4th Nov 2019 ucm 1.2.2 Techjoomla Team
+ + + +