Skip to content

Commit

Permalink
Merge pull request #370 from ankush-maherwal/actionlogs
Browse files Browse the repository at this point in the history
Task #369 feat: Add sort functionality using fields value on to the l…
  • Loading branch information
ankush-maherwal authored Jul 24, 2020
2 parents 8d75474 + 467e8bc commit 1b17228
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 237 deletions.
182 changes: 93 additions & 89 deletions src/components/com_tjucm/site/layouts/list/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,112 +141,116 @@
<?php
}

if (!empty($item->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);
?>
<td style="word-break: break-word;" width="<?php echo (85 - $displayData['statusColumnWidth']) / count($displayData['listcolumn']) . '%';?>">
<?php
if ($canView || ($item->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);
?>
<td style="word-break: break-word;" width="<?php echo (85 - $displayData['statusColumnWidth']) / count($displayData['listcolumn']) . '%';?>">
<?php
if ($canView || ($item->created_by == $user->id))
{
$ucmSubFormData = json_decode($tjucmItemFormModel->getUcmSubFormFieldDataJson($item->id, $field));
$field->setValue($ucmSubFormData);
?>
<div>
<div class="col-xs-4"><?php echo $field->label; ?>:</div>
<div class="col-xs-8">
<?php
$count = 0;
$ucmSubFormXmlFieldSets = array();

// Call to extra fields
JLoader::import('components.com_tjucm.models.item', JPATH_SITE);
$tjucmItemModel = JModelLegacy::getInstance('Item', 'TjucmModel');

// Get Subform field data
$fieldData = $TjfieldsHelper->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);
?>
<div>
<div class="col-xs-4"><?php echo $field->label; ?>:</div>
<div class="col-xs-8">
<?php
$count = 0;
$ucmSubFormXmlFieldSets = array();

foreach ($ucmSubFormData as $subFormData)
{
$count++;
$contentIdFieldname = str_replace('.', '_', $ucmSubFormClient) . '_contentid';
// Call to extra fields
JLoader::import('components.com_tjucm.models.item', JPATH_SITE);
$tjucmItemModel = JModelLegacy::getInstance('Item', 'TjucmModel');

$ucmSubformFormObject = $tjucmItemModel->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 "<hr>";
$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 "<hr>";
}
}
}
}
?>
?>
</div>
</div>
</div>
<?php
<?php
}
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;
}
}
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;
}
}
?>
</td><?php
?>
</td>
<?php
}
}
}
?>
Expand Down
Loading

0 comments on commit 1b17228

Please sign in to comment.