Skip to content

Commit

Permalink
Bug techjoomla#311 fix: Frontend>>Editor field not working correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aishwarya committed Dec 19, 2019
1 parent c68c3d6 commit ace10d5
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 62 deletions.
26 changes: 21 additions & 5 deletions src/components/com_tjucm/site/layouts/detail/fields.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* @package TJ-UCM
*
* @author TechJoomla <[email protected]>
* @package TJ-UCM
*
* @author TechJoomla <[email protected]>
* @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access
Expand Down Expand Up @@ -63,6 +63,7 @@
$count++;
$fieldCount = 0;
?>
<div class="tjucm-wrapper">
<div class="row">
<?php
foreach ($formObject->getFieldset($fieldset->name) as $field)
Expand Down Expand Up @@ -178,7 +179,21 @@

$layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields');
$output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field));
echo $output;

// To align text, textarea, textareacounter and editor fields properly

if ($field->type == 'Textarea'|| $field->type == 'Textareacounter'|| $field->type == 'Text' || $field->type == 'Editor')
{
?>
<div class="tj-wordwrap">
<?php echo $output; ?>
</div>
<?php
}
else
{
echo $output;
}
?>
</div>
</div>
Expand All @@ -188,5 +203,6 @@
}
?>
</div>
</div>
<?php
}
49 changes: 38 additions & 11 deletions src/components/com_tjucm/site/layouts/list/list.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* @package TJ-UCM
* @package TJ-UCM
*
* @author TechJoomla <[email protected]>
* @author TechJoomla <[email protected]>
* @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access
Expand Down Expand Up @@ -51,7 +51,7 @@
$xmlFormObject = $displayData['xmlFormObject'];
$formObject = $displayData['formObject'];
$ucmTypeId = $displayData['ucmTypeId'];
$allowDraftSave= $displayData['ucmTypeParams']->allow_draft_save;
$allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save;

$appendUrl = '';
$csrf = "&" . Session::getFormToken() . '=1';
Expand Down Expand Up @@ -93,13 +93,16 @@
}

?>
<div class="tjucm-wrapper">
<tr class="row<?php echo $item->id?>">
<?php
if (isset($item->state))
{
$class = ($canChange) ? 'active' : 'disabled'; ?>
<td class="center">
<a class="<?php echo $class; ?>" href="<?php echo ($canChange) ? 'index.php?option=com_tjucm&task=item.publish&id=' . $item->id . '&state=' . (($item->state + 1) % 2) . $appendUrl . $csrf : '#'; ?>">
<a class="<?php echo $class; ?>"
href="<?php echo ($canChange) ? 'index.php?option=com_tjucm&task=item.publish&id=' .
$item->id . '&state=' . (($item->state + 1) % 2) . $appendUrl . $csrf : '#'; ?>">
<?php
if ($item->state == 1)
{
Expand All @@ -116,16 +119,21 @@
}
?>
<td>
<a href="<?php echo Route::_('index.php?option=com_tjucm&view=item&id=' . (int) $item->id . "&client=" . $client . '&Itemid=' . $itemId, false); ?>">
<a href="<?php echo Route::_(
'index.php?option=com_tjucm&view=item&id=' .
(int) $item->id . "&client=" . $client . '&Itemid=' . $itemId, false
); ?>">
<?php echo $this->escape($item->id); ?>
</a>
</td>
<?php
if ($allowDraftSave)
{ ?>
{
?>
<td><?php echo ($item->draft) ? Text::_('COM_TJUCM_DATA_STATUS_DRAFT') : Text::_('COM_TJUCM_DATA_STATUS_SAVE'); ?></td>
<?php
}

if (!empty($item->field_values))
{
foreach ($item->field_values as $key => $fieldValue)
Expand All @@ -147,7 +155,11 @@
{
$field = $formObject->getField($tjFieldsFieldTable->name);
$field->setValue($fieldValue);
$layoutToUse = (array_key_exists(ucfirst($tjFieldsFieldTable->type), $fieldLayout)) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field';
$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;
Expand All @@ -156,22 +168,36 @@
</td><?php
}
}

if ($canEdit || $canDelete || $editown || $deleteOwn)
{
?>
<td class="center">
<a target="_blank" href="<?php echo $link; ?>" type="button" title="<?php echo Text::_('COM_TJUCM_VIEW_RECORD');?>"><i class="icon-eye-open"></i></a>
<a target="_blank" href="<?php echo $link; ?>"
type="button" title="<?php echo Text::_('COM_TJUCM_VIEW_RECORD');?>">
<i class="icon-eye-open"></i>
</a>
<?php
if ($canEdit || $editown)
{
?>
<a target="_blank" href="<?php echo 'index.php?option=com_tjucm&task=itemform.edit&id=' . $item->id . $appendUrl; ?>" type="button" title="<?php echo Text::_('COM_TJUCM_EDIT_ITEM');?>"> | <i class="icon-apply" aria-hidden="true"></i></a>
<a target="_blank"
href="<?php echo 'index.php?option=com_tjucm&task=itemform.edit&id=' . $item->id . $appendUrl; ?>"
type="button"
title="<?php echo Text::_('COM_TJUCM_EDIT_ITEM');?>"> |
<i class="icon-apply" aria-hidden="true"></i>
</a>
<?php
}

if ($canDelete || $deleteOwn)
{
?>
<a href="<?php echo 'index.php?option=com_tjucm&task=itemform.remove' . '&id=' . $item->id . $appendUrl . $csrf; ?>" class="delete-button" type="button" title="<?php echo Text::_('COM_TJUCM_DELETE_ITEM');?>"> | <i class="icon-delete" aria-hidden="true"></i></a>
<a href="<?php echo 'index.php?option=com_tjucm&task=itemform.remove' . '&id=' . $item->id . $appendUrl . $csrf; ?>"
class="delete-button" type="button"
title="<?php echo Text::_('COM_TJUCM_DELETE_ITEM');?>"> |
<i class="icon-delete" aria-hidden="true"></i>
</a>
<?php
}
?>
Expand All @@ -180,3 +206,4 @@
}
?>
</tr>
</div>
105 changes: 59 additions & 46 deletions src/components/com_tjucm/site/views/items/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@
$fieldsData = array();
$statusColumnWidth = 0;
?>
<div class="tjucm-wrapper">
<form action="<?php echo JRoute::_($link . '&Itemid=' . $itemId); ?>" method="post" name="adminForm" id="adminForm">
<?php
if (isset($this->items))
{
?>
<div class="page-header">
<h1 class="page-title">
<?php echo strtoupper($this->title) . " " . JText::_("COM_TJUCM_FORM_LIST"); ?>
<h1>
</div> <?php
}?>
<?php echo $this->loadTemplate('filters'); ?>
<div class="pull-right">
if (isset($this->items))
{
?>
<div class="page-header">
<h1 class="page-title">
<?php echo strtoupper($this->title) . " " . JText::_("COM_TJUCM_FORM_LIST"); ?>
</h1>
</div> <?php
}

echo $this->loadTemplate('filters');
?>
<div class="pull-right">
<?php
if ($this->allowedToAdd)
{
Expand Down Expand Up @@ -90,38 +93,34 @@
if (!empty($this->showList))
{
if (!empty($this->items))
{?>
<thead>
<tr>
<?php
if (isset($this->items[0]->state))
{
{
?>
<thead>
<tr>
<?php
if (isset($this->items[0]->state))
{
?>
<th class="center" width="3%">
<th class="center" width="3%">
<?php echo JHtml::_('grid.sort', 'JPUBLISHED', 'a.state', $listDirn, $listOrder); ?>
</th>
</th>
<?php
}
?>
<th width="2%">
<?php echo JHtml::_('grid.sort', 'COM_TJUCM_ITEMS_ID', 'a.id', $listDirn, $listOrder); ?>
</th>

<?php
if (!empty($this->ucmTypeParams->allow_draft_save) && $this->ucmTypeParams->allow_draft_save == 1)
{
$statusColumnWidth = 2;
?>
}
?>
<th width="2%">
<?php echo JHtml::_('grid.sort', 'COM_TJUCM_DATA_STATUS', 'a.draft', $listDirn, $listOrder); ?>
</th>
<?php
}

if (!empty($this->listcolumn))
{
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables');
$tjFieldsFieldTable = JTable::getInstance('field', 'TjfieldsTable');
if (!empty($this->ucmTypeParams->allow_draft_save) && $this->ucmTypeParams->allow_draft_save == 1)
{
$statusColumnWidth = 2;
?>
<th width="2%">
<?php echo JHtml::_('grid.sort', 'COM_TJUCM_DATA_STATUS', 'a.draft', $listDirn, $listOrder); ?>
</th>
<?php
}

foreach ($this->listcolumn as $fieldId => $col_name)
{
Expand All @@ -137,12 +136,11 @@
}
?>

<th style="word-break: break-word;" width="<?php echo (85 - $statusColumnWidth)/count($this->listcolumn).'%';?>">
<th style="word-break: break-word;" width="<?php echo (85 - $statusColumnWidth) / count($this->listcolumn) . '%';?>">
<?php echo htmlspecialchars($col_name, ENT_COMPAT, 'UTF-8'); ?>
</th>
<?php
}
}

if ($this->canEdit || $this->canDelete)
{
Expand All @@ -153,18 +151,18 @@
<?php
}
?>
</tr>
</thead>
<?php
}
}?>
</tr>
</thead>
<?php
}
}?>
<?php
if (!empty($this->items))
{
?>
<tfoot>
<tr>
<td colspan="<?php echo isset($this->items[0]) ? count($this->items[0]->field_values)+3 : 10; ?>">
<td colspan="<?php echo isset($this->items[0]) ? count($this->items[0]->field_values) + 3 : 10; ?>">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
Expand Down Expand Up @@ -197,7 +195,18 @@
{
// Call the JLayout to render the fields in the details view
$layout = new JLayoutFile('list.list', JPATH_ROOT . '/components/com_tjucm/');
echo $layout->render(array('itemsData' => $item, 'created_by' => $this->created_by, 'client' => $this->client, 'xmlFormObject' => $formXml, 'ucmTypeId' => $this->ucmTypeId, 'ucmTypeParams' => $this->ucmTypeParams, 'fieldsData' => $fieldsData, 'formObject' => $formObject));
echo $layout->render(
array(
'itemsData' => $item,
'created_by' => $this->created_by,
'client' => $this->client,
'xmlFormObject' => $formXml,
'ucmTypeId' => $this->ucmTypeId,
'ucmTypeParams' => $this->ucmTypeParams,
'fieldsData' => $fieldsData,
'formObject' => $formObject
)
);
}
}
else
Expand All @@ -223,8 +232,11 @@
if ($this->allowedToAdd)
{
?>
<a target="_blank" href="<?php echo JRoute::_('index.php?option=com_tjucm&task=itemform.edit' . $appendUrl, false); ?>" class="btn btn-success btn-small">
<i class="icon-plus"></i><?php echo JText::_('COM_TJUCM_ADD_ITEM'); ?>
<a target="_blank"
href="<?php echo JRoute::_('index.php?option=com_tjucm&task=itemform.edit' . $appendUrl, false); ?>"
class="btn btn-success btn-small">
<i class="icon-plus"></i>
<?php echo JText::_('COM_TJUCM_ADD_ITEM'); ?>
</a>
<?php
}
Expand All @@ -235,6 +247,7 @@
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>"/>
<?php echo JHtml::_('form.token'); ?>
</form>
</div>
<?php
if ($this->canDelete)
{
Expand Down

0 comments on commit ace10d5

Please sign in to comment.