From db34a10e414b5bc026fc5e4ffd53f2b21d870327 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 24 Jul 2020 11:05:55 +0530 Subject: [PATCH] Task #369 feat: Add sort functionality using fields value on to the list view --- .../com_tjucm/site/layouts/list/list.php | 182 +++++++++--------- 1 file changed, 93 insertions(+), 89 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 56fd4708..47cdd2c3 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -141,112 +141,116 @@ field_values)) + if (!empty($item)) { - foreach ($item->field_values as $key => $fieldValue) + foreach ($item as $key => $fieldValue) { - $tjFieldsFieldTable = $fieldsData[$key]; - - $canView = false; - - if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) + if (array_key_exists($key, $displayData['listcolumn'])) { - $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); - } + $tjFieldsFieldTable = $fieldsData[$key]; - $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); - ?> - - created_by == $user->id)) - { - $field = $formObject->getField($tjFieldsFieldTable->name); - $field->setValue($fieldValue); + $canView = false; - if ($field->type == 'Ucmsubform' && $fieldValue) + if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) + { + $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); + } + + $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); + ?> + + created_by == $user->id)) { - $ucmSubFormData = json_decode($tjucmItemFormModel->getUcmSubFormFieldDataJson($item->id, $field)); - $field->setValue($ucmSubFormData); - ?> -
-
label; ?>:
-
- getFieldData($field->getAttribute('name')); - - $ucmSubFormFieldParams = json_decode($fieldData->params); - $ucmSubFormFormSource = explode('/', $ucmSubFormFieldParams->formsource); - $ucmSubFormClient = $ucmSubFormFormSource[1] . '.' . str_replace('form_extra.xml', '', $ucmSubFormFormSource[4]); - $view = explode('.', $ucmSubFormClient); - $ucmSubFormData = (array) $ucmSubFormData; - - if (!empty($ucmSubFormData)) - { + $field = $formObject->getField($tjFieldsFieldTable->name); + $field->setValue($fieldValue); + + if ($field->type == 'Ucmsubform' && $fieldValue) + { + $ucmSubFormData = json_decode($tjucmItemFormModel->getUcmSubFormFieldDataJson($item->id, $field)); + $field->setValue($ucmSubFormData); + ?> +
+
label; ?>:
+
+ getFormExtra( - array( - "clientComponent" => 'com_tjucm', - "client" => $ucmSubFormClient, - "view" => $view[1], - "layout" => 'default', - "content_id" => $subFormData->$contentIdFieldname) - ); + // Get Subform field data + $fieldData = $TjfieldsHelper->getFieldData($field->getAttribute('name')); - $ucmSubFormFormXml = simplexml_load_file($field->formsource); + $ucmSubFormFieldParams = json_decode($fieldData->params); + $ucmSubFormFormSource = explode('/', $ucmSubFormFieldParams->formsource); + $ucmSubFormClient = $ucmSubFormFormSource[1] . '.' . str_replace('form_extra.xml', '', $ucmSubFormFormSource[4]); + $view = explode('.', $ucmSubFormClient); + $ucmSubFormData = (array) $ucmSubFormData; - $ucmSubFormCount = 0; - - foreach ($ucmSubFormFormXml as $ucmSubFormXmlFieldSet) - { - $ucmSubFormXmlFieldSets[$ucmSubFormCount] = $ucmSubFormXmlFieldSet; - $ucmSubFormCount++; - } - - $ucmSubFormRecordData = $tjucmItemModel->getData($subFormData->$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' => $ucmSubFormRecordData, 'isSubForm' => 1)); + if (!empty($ucmSubFormData)) + { + $count = 0; - if (count($ucmSubFormData) > $count) + foreach ($ucmSubFormData as $subFormData) { - echo "
"; + $count++; + $contentIdFieldname = str_replace('.', '_', $ucmSubFormClient) . '_contentid'; + + $ucmSubformFormObject = $tjucmItemModel->getFormExtra( + array( + "clientComponent" => 'com_tjucm', + "client" => $ucmSubFormClient, + "view" => $view[1], + "layout" => 'default', + "content_id" => $subFormData->$contentIdFieldname) + ); + + $ucmSubFormFormXml = simplexml_load_file($field->formsource); + + $ucmSubFormCount = 0; + + foreach ($ucmSubFormFormXml as $ucmSubFormXmlFieldSet) + { + $ucmSubFormXmlFieldSets[$ucmSubFormCount] = $ucmSubFormXmlFieldSet; + $ucmSubFormCount++; + } + + $ucmSubFormRecordData = $tjucmItemModel->getData($subFormData->$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' => $ucmSubFormRecordData, 'isSubForm' => 1)); + + if (count($ucmSubFormData) > $count) + { + echo "
"; + } } } - } - ?> + ?> +
-
- 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)); + echo $output; + } } - else - { - $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)); - echo $output; - } - } - ?> - + +