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); + } + ?> +