Skip to content

Commit

Permalink
Bug #17 fix: Add configuration to format date to display (#18)
Browse files Browse the repository at this point in the history
* Bug #157673 fix: Add configuration to format date to display

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.

* Bug #157673 fix: Add configuration to format date to display.
  • Loading branch information
paritshivani authored Feb 18, 2020
1 parent 3d5e634 commit 733c1fe
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 92 deletions.
77 changes: 77 additions & 0 deletions src/components/com_tc/administrator/assets/elements/dateformat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* @package Tc
* @subpackage com_tc
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2009 - 2020 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
/**
* JFormFieldDateformat class
*
* @package Tc
* @subpackage component
* @since 1.1
*/
class JFormFieldDateformat extends FormField
{
/**
* The form field type.
*
* @var string
* @since 1.1
*/
protected $type = 'dateformat';

/**
* Fiedd to decide if options are being loaded externally and from xml
*
* @var integer
* @since 1.1
*/

/**
* Method to get the field input markup.
*
* @since 1.1
*
* @return array The field input markup
*/
public function getInput ()
{
return $this->fetchElement($this->name, $this->value, $this->element, $this->options['controls']);
}

/**
* Method fetchElement
*
* @param string $name name of element
* @param string $value value of element
* @param string &$node node
* @param string $control_name control name
*
* @return array date format list
*
* @since 1.1
*/
public function fetchElement ($name, $value, &$node, $control_name)
{
$sqlGmtTimestamp = "2012-01-01 20:00:00";

$dateFormat = array("Y-m-d H:i:s", "D, M d h:i A", "F j, Y, g:i a", "m.d.y", "j, n, Y", "h-i-s, j-m-y", "H:i:s");

foreach ($dateFormat as $date)
{
$options[] = HTMLHelper::_('select.option', $date, HTMLHelper::date($sqlGmtTimestamp, $date, true));
}

$options[] = HTMLHelper::_('select.option', 'custom', JText::_('COM_TC_DATE_FORMAT_CUSTOM'));

return HTMLHelper::_('select.genericlist', $options, $name, 'class="inputbox" ', 'value', 'text', $value, $control_name . $name);
}
}
8 changes: 5 additions & 3 deletions src/components/com_tc/administrator/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<config>

</config>

<fieldset name="integration_settings" label="COM_TC_BASIC_CONFIG_SET" description="" addfieldpath="/administrator/components/com_tc/assets/elements">
<field name="date_format_show" type="dateformat" label="COM_TC_DATE_FORMAT_TO_SHOW" description="COM_TC_DATE_FORMAT_TO_SHOW_DESC" />
<field name="custom_format" class="inputbox" type="text" label="COM_TC_CUSTOM_DATE_FORMAT" showon="date_format_show:custom" description="COM_TC_CUSTOM_DATE_FORMAT_DESC" />
</fieldset>
</config>
25 changes: 9 additions & 16 deletions src/components/com_tc/administrator/models/forms/content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,34 @@
<form>
<fieldset>
<field name="tc_id" type="text" readonly="true" class="readonly" default="0" description="JGLOBAL_FIELD_ID_DESC" />
<field name="ordering" type="hidden" filter="integer"/>
<field name="ordering" type="hidden" filter="integer" />
<field name="state" default="1" type="list" label="JSTATUS" description="JFIELD_PUBLISHED_DESC" class="inputbox" size="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="checked_out" type="hidden" filter="integer"/>
<field name="checked_out" type="hidden" filter="integer" />
<field name="checked_out_time" default="0000-00-00 00:00:00" type="hidden" filter="unset" />
<field name="title" required="true" label="COM_TC_FORM_LBL_CONTENT_TITLE" description="COM_TC_FORM_DESC_CONTENT_TITLE" hint="COM_TC_FORM_LBL_CONTENT_TITLE" />

<field name="version" required="true" class="validate-version" label="COM_TC_FORM_LBL_CONTENT_VERSION" description="COM_TC_FORM_DESC_CONTENT_VERSION" hint="COM_TC_FORM_LBL_CONTENT_VERSION"/>

<field name="client" required="true" id="client_id" class="validate-client" label="COM_TC_FORM_LBL_CONTENT_TC_CODE" description="COM_TC_FORM_DESC_CONTENT_CLIENT" hint="COM_TC_FORM_LBL_CONTENT_TC_CODE" />

<field name="version" required="true" class="validate-version" label="COM_TC_FORM_LBL_CONTENT_VERSION" description="COM_TC_FORM_DESC_CONTENT_VERSION" hint="COM_TC_FORM_LBL_CONTENT_VERSION" />
<field name="client" required="true" id="client_id" class="validate-client" label="COM_TC_FORM_LBL_CONTENT_TC_CODE" description="COM_TC_FORM_DESC_CONTENT_TC_CODE" hint="COM_TC_FORM_LBL_CONTENT_TC_CODE" />
<field name= "url_pattern" id="url_pattern_id" description= "COM_TC_FORM_LBL_CONTENT_URL_PATTERN_DESC" type= "subform" label= "COM_TC_FORM_LBL_CONTENT_URL_PATTERN" min= "1" max= "1000" formsource= "/administrator/components/com_tc/models/forms/url_pattern.xml" multiple= "true" buttons= "add,remove" layout="joomla.form.field.subform.repeatable-table" groupByFieldset="false" />
<field name="start_date"
type="calendar"
default="now"
showtime="true"
class="inputbox" format="%Y-%m-%d %H:%M:%S" required="true" label="COM_TC_FORM_LBL_CONTENT_START_DATE" description="COM_TC_FORM_DESC_CONTENT_START_DATE" hint="COM_TC_FORM_LBL_CONTENT_START_DATE" filter="user_utc"/>
<field name="start_date" type="calendar" default="now" showtime="true" class="inputbox" format="%Y-%m-%d %H:%M:%S" required="true" label="COM_TC_FORM_LBL_CONTENT_START_DATE" description="COM_TC_FORM_DESC_CONTENT_START_DATE" hint="COM_TC_FORM_LBL_CONTENT_START_DATE" filter="user_utc" />
<field name="content" type="editor" filter="raw" label="COM_TC_FORM_LBL_CONTENT_CONTENT" buttons="true" description="COM_TC_FORM_DESC_CONTENT_CONTENT" hint="COM_TC_FORM_LBL_CONTENT_CONTENT" />
<field name="global" type="radio" class="btn-group" id="global_id" label="COM_TC_FORM_LBL_CONTENT_GLOBAL" description="COM_TC_FORM_LBL_CONTENT_GLOBLA_DESC" default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="groups" type="usergrouplist" multiple="true" default="0" label="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP" description="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP_DESC" showon="global:0"/>
<field name="groups" type="usergrouplist" multiple="true" default="0" label="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP" description="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP_DESC" showon="global:0" />
<field name="is_blacklist" type="radio" class="btn-group" label="COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR" description="COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_DESC" default="1" showon="global:0">
<option value="1">COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_YES</option>
<option value="0">COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_NO</option>
</field>
<field name="enforce_delay_days" type="hidden" required="" label="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY" description="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY_DESC" hint="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY" />
<field name="created_by" type="hidden" default="0" filter="integer"/>
<field name="modified_by" type="hidden" default="0" filter="integer"/>
<field name="created_by" type="hidden" default="0" filter="integer" />
<field name="modified_by" type="hidden" default="0" filter="integer" />
<field name="created_on" type="hidden" filter="unset" />
<field name="modified_on" type="hidden" filter="unset" />
</fieldset>
</form>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<field name="state" type="status" label="COM_TC_CONTENTS_FILTER_PUBLISHED" description="COM_TC_CONTENTS_FILTER_PUBLISHED_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field name="client" type="sql" query="SELECT DISTINCT (`client`) FROM `#__tc_content` ORDER BY client ASC" key_field="client" value_field="client" filter="safehtml" label="COM_TC_CONTENTS_CLIENT" description="COM_TC_CONTENTS_CLIENT_FILTER_DESC" onchange="this.form.submit();">
<option value="">COM_TC_CONTENTS_CLIENT_FILTER</option>
<field name="client" type="sql" query="SELECT DISTINCT (`client`) FROM `#__tc_content` ORDER BY client ASC" key_field="client" value_field="client" filter="safehtml" label="COM_TC_CONTENTS_TC_CODE" description="COM_TC_CONTENTS_TC_CODE_FILTER_DESC" onchange="this.form.submit();">
<option value="">COM_TC_CONTENTS_TC_CODE_FILTER</option>
</field>
<input type="hidden" name="form_submited" value="1" />
</fields>
Expand All @@ -23,8 +23,8 @@
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.version ASC">COM_TC_CONTENTS_VERSION_ASC</option>
<option value="a.version DESC">COM_TC_CONTENTS_VERSION_ASC</option>
<option value="a.client ASC">COM_TC_CONTENTS_CLIENT_ASC</option>
<option value="a.client DESC">COM_TC_CONTENTS_CLIENT_DES</option>
<option value="a.client ASC">COM_TC_CONTENTS_TC_CODE_ASC</option>
<option value="a.client DESC">COM_TC_CONTENTS_TC_CODE_DES</option>
<option value="a.start_date DESC">COM_TC_CONTENTS_STARTDATE_ASC</option>
<option value="a.start_date DESC">COM_TC_CONTENTS_STARTDATE_DES</option>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<form>
<fields name="filter">
<field name="search" type="text" filter="string" label="JSEARCH_FILTER" description="JSEARCH_FILTER_DESC" hint="JSEARCH_FILTER" />
<field name="client" type="sql" query="SELECT DISTINCT (`client`) FROM `#__tc_content` ORDER BY client ASC" key_field="client" value_field="client" filter="safehtml" label="COM_TC_CONTENTS_CLIENT" description="COM_TC_CONTENTS_CLIENT_FILTER_DESC" onchange="this.form.submit();">
<option value="">COM_TC_CONTENTS_CLIENT_FILTER</option>
<field name="client" type="sql" query="SELECT DISTINCT (`client`) FROM `#__tc_content` ORDER BY client ASC" key_field="client" value_field="client" filter="safehtml" label="COM_TC_CONTENTS_TC_CODE" description="COM_TC_CONTENTS_TC_CODE_FILTER_DESC" onchange="this.form.submit();">
<option value="">COM_TC_CONTENTS_TC_CODE_FILTER</option>
</field>
<input type="hidden" name="form_submited" value="1" />
</fields>
<fields name="list">
<field name="limit" type="limitbox" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</form>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/');
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Layout\LayoutHelper;

HTMLHelper::_('behavior.tooltip');
HTMLHelper::_('behavior.multiselect');
HTMLHelper::_('formbehavior.chosen', 'select');
Expand Down Expand Up @@ -81,6 +82,8 @@
$canEdit = $this->user->authorise('core.edit', 'com_tc');
$canCheckin = $this->user->authorise('core.manage', 'com_tc');
$canChange = $this->user->authorise('core.edit.state', 'com_tc');

$startDate = HTMLHelper::_('date', $item->start_date, $this->dateFormat, true);
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="hidden-phone">
Expand Down Expand Up @@ -111,7 +114,7 @@
<?php echo $this->escape($item->client); ?>
</td>
<td>
<?php echo JHtml::date($item->start_date, 'Y-m-d H:i:s', true); ?>
<?php echo $startDate; ?>
</td>
<td>
<?php echo $item->tc_id; ?>
Expand Down
10 changes: 10 additions & 0 deletions src/components/com_tc/administrator/views/contents/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

jimport('joomla.application.component.view');
use Joomla\CMS\Factory;
use \Joomla\CMS\Component\ComponentHelper;

/**
* View class for a list of Tc.
Expand Down Expand Up @@ -63,6 +64,15 @@ public function display($tpl = null)

TcHelpersTc::addSubmenu('contents');

// To get the foematted date
$comParams = ComponentHelper::getParams('com_tc');
$this->dateFormat = $comParams->get('date_format_show');

if ($dateFormat == "custom")
{
$this->dateFormat = $comParams->get('custom_format');
}

$this->addToolbar();

$this->sidebar = JHtmlSidebar::render();
Expand Down
116 changes: 60 additions & 56 deletions src/components/com_tc/administrator/views/usertcs/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/');
use Joomla\CMS\HTML\HTMLHelper;
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
Expand Down Expand Up @@ -60,64 +61,67 @@
<?php
else : ?>
<div class="clearfix"></div>
<table class="table table-striped" id="contentList">
<thead>
<tr>
<th width="1%" class="hidden-phone">
<input type="checkbox" name="checkall-toggle" value=""
title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)"/>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_NAME', 'uc.`name`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_TITLE', 'c.`title`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_TC_CODE', 'c.`client`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_CONTENTS_VERSION', 'c.`version`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_ACCEPTED_DATE', 'a.`accepted_date`', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="<?php echo isset($this->items[0]) ? count(get_object_vars($this->items[0])) : 10; ?>">
<?php echo $this->pagination->getListFooter(); ?>
<table class="table table-striped" id="contentList">
<thead>
<tr>
<th width="1%" class="hidden-phone">
<input type="checkbox" name="checkall-toggle" value=""
title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)"/>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_NAME', 'uc.`name`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_TITLE', 'c.`title`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_TC_CODE', 'c.`client`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_CONTENTS_VERSION', 'c.`version`', $listDirn, $listOrder); ?>
</th>
<th class='left'>
<?php echo JHtml::_('grid.sort', 'COM_TC_USERTCS_ACCEPTED_DATE', 'a.`accepted_date`', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="<?php echo isset($this->items[0]) ? count(get_object_vars($this->items[0])) : 10; ?>">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
foreach ($this->items as $i => $item) :

$acceptedDate = HTMLHelper::_('date', $item->accepted_date, $this->dateFormat, true);
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="hidden-phone">
<?php echo JHtml::_('grid.id', $i, $item->tc_id); ?>
</td>
<td>
<?php echo $this->escape($item->name); ?>
</td>
<td>
<?php echo $this->escape($item->title); ?>
</td>
<td>
<?php echo $item->client; ?>
</td>
<td>
<?php echo $item->version; ?>
</td>
<td>
<?php echo $acceptedDate; ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
foreach ($this->items as $i => $item) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="hidden-phone">
<?php echo JHtml::_('grid.id', $i, $item->tc_id); ?>
</td>
<td>
<?php echo $this->escape($item->name); ?>
</td>
<td>
<?php echo $this->escape($item->title); ?>
</td>
<td>
<?php echo $item->client; ?>
</td>
<td>
<?php echo $item->version; ?>
</td>
<td>
<?php echo $item->accepted_date; ?>
</td>
</tr>
<?php
endforeach; ?>
</tbody>
</table>
<?php
endforeach; ?>
</tbody>
</table>
<?php
endif; ?>
<input type="hidden" name="task" value=""/>
Expand Down
11 changes: 10 additions & 1 deletion src/components/com_tc/administrator/views/usertcs/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

use \Joomla\CMS\Component\ComponentHelper;
/**
* View class for a list of Tc.
*
Expand Down Expand Up @@ -57,6 +57,15 @@ public function display($tpl = null)

TcHelpersTc::addSubmenu('usertcs');

// To get the foematted date
$comParams = ComponentHelper::getParams('com_tc');
$this->dateFormat = $comParams->get('date_format_show');

if ($dateFormat == "custom")
{
$this->dateFormat = $comParams->get('custom_format');
}

$this->addToolbar();

$this->sidebar = JHtmlSidebar::render();
Expand Down
Loading

0 comments on commit 733c1fe

Please sign in to comment.