diff --git a/src/components/com_tc/administrator/assets/elements/dateformat.php b/src/components/com_tc/administrator/assets/elements/dateformat.php new file mode 100644 index 0000000..f61fbfd --- /dev/null +++ b/src/components/com_tc/administrator/assets/elements/dateformat.php @@ -0,0 +1,77 @@ + + * @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); + } +} diff --git a/src/components/com_tc/administrator/config.xml b/src/components/com_tc/administrator/config.xml index 64b367d..5d44595 100755 --- a/src/components/com_tc/administrator/config.xml +++ b/src/components/com_tc/administrator/config.xml @@ -1,5 +1,7 @@ - - - +
+ + +
+ \ No newline at end of file diff --git a/src/components/com_tc/administrator/models/forms/content.xml b/src/components/com_tc/administrator/models/forms/content.xml index d65efa6..badd8e6 100755 --- a/src/components/com_tc/administrator/models/forms/content.xml +++ b/src/components/com_tc/administrator/models/forms/content.xml @@ -2,41 +2,34 @@
- + - + - - - - - + + - + - + - - + +
-
+ \ No newline at end of file diff --git a/src/components/com_tc/administrator/models/forms/filter_contents.xml b/src/components/com_tc/administrator/models/forms/filter_contents.xml index a71a9fa..d35290f 100644 --- a/src/components/com_tc/administrator/models/forms/filter_contents.xml +++ b/src/components/com_tc/administrator/models/forms/filter_contents.xml @@ -5,8 +5,8 @@ - - + + @@ -23,8 +23,8 @@ - - + + diff --git a/src/components/com_tc/administrator/models/forms/filter_usertcs.xml b/src/components/com_tc/administrator/models/forms/filter_usertcs.xml index 6ba2a1a..67eb958 100644 --- a/src/components/com_tc/administrator/models/forms/filter_usertcs.xml +++ b/src/components/com_tc/administrator/models/forms/filter_usertcs.xml @@ -2,12 +2,12 @@
- - + + -
+ diff --git a/src/components/com_tc/administrator/views/contents/tmpl/default.php b/src/components/com_tc/administrator/views/contents/tmpl/default.php index 27ada8c..be9ea9d 100755 --- a/src/components/com_tc/administrator/views/contents/tmpl/default.php +++ b/src/components/com_tc/administrator/views/contents/tmpl/default.php @@ -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'); @@ -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); ?> @@ -111,7 +114,7 @@ escape($item->client); ?> - start_date, 'Y-m-d H:i:s', true); ?> + tc_id; ?> diff --git a/src/components/com_tc/administrator/views/contents/view.html.php b/src/components/com_tc/administrator/views/contents/view.html.php index eea4548..a9d05f5 100755 --- a/src/components/com_tc/administrator/views/contents/view.html.php +++ b/src/components/com_tc/administrator/views/contents/view.html.php @@ -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. @@ -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(); diff --git a/src/components/com_tc/administrator/views/usertcs/tmpl/default.php b/src/components/com_tc/administrator/views/usertcs/tmpl/default.php index 1c967e7..8a6d37f 100755 --- a/src/components/com_tc/administrator/views/usertcs/tmpl/default.php +++ b/src/components/com_tc/administrator/views/usertcs/tmpl/default.php @@ -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'); @@ -60,64 +61,67 @@
- - - - - - - - - - - - - -
- - - - - - - - - - - -
- pagination->getListFooter(); ?> + + + + + + + + + + + + + + + + + + items as $i => $item) : + + $acceptedDate = HTMLHelper::_('date', $item->accepted_date, $this->dateFormat, true); + ?> + + + + + + + - - - items as $i => $item) : ?> - - - - - - - - - - -
+ + + + + + + + + + + +
+ pagination->getListFooter(); ?> +
+ tc_id); ?> + + escape($item->name); ?> + + escape($item->title); ?> + + client; ?> + + version; ?> + +
- tc_id); ?> - - escape($item->name); ?> - - escape($item->title); ?> - - client; ?> - - version; ?> - - accepted_date; ?> -
+ + +
diff --git a/src/components/com_tc/administrator/views/usertcs/view.html.php b/src/components/com_tc/administrator/views/usertcs/view.html.php index ab1e2fa..36405a1 100755 --- a/src/components/com_tc/administrator/views/usertcs/view.html.php +++ b/src/components/com_tc/administrator/views/usertcs/view.html.php @@ -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. * @@ -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(); diff --git a/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini b/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini index 696cfd4..91e0cc8 100755 --- a/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini +++ b/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini @@ -39,7 +39,7 @@ COM_TC_CONTENTS_CREATED_BY="Created by" COM_TC_CONTENTS_MODIFIED_BY="Modified by" COM_TC_CONTENTS_TITLE="Title" COM_TC_CONTENTS_VERSION="Version" -COM_TC_CONTENTS_CLIENT="Client" +COM_TC_CONTENTS_CLIENT="T&C code" COM_TC_CONTENTS_START_DATE="Start Date" COM_TC_CONTENTS_CONTENT="Content" COM_TC_TITLE_CONTENT="Terms and conditions" @@ -101,11 +101,17 @@ COM_TC_CONTENTS_LATEST="Latest" COM_TC_CONTENTS_ALL="All" COM_TC_CONTENTS_FILTER_PUBLISHED="Status" COM_TC_CONTENTS_FILTER_PUBLISHED_DESC="Status" -COM_TC_CONTENTS_CLIENT_FILTER="- Select Client -" -COM_TC_CONTENTS_CLIENT_FILTER_DESC="Client" +COM_TC_CONTENTS_CLIENT_FILTER="- Select T&C code -" +COM_TC_CONTENTS_CLIENT_FILTER_DESC="T&C code" COM_TC_CONTENTS_VERSION_ASC="Version ascending" COM_TC_CONTENTS_VERSION_DES="Version descending" -COM_TC_CONTENTS_CLIENT_ASC="Client ascending" -COM_TC_CONTENTS_CLIENT_DES="Client descending" +COM_TC_CONTENTS_CLIENT_ASC="T&C code ascending" +COM_TC_CONTENTS_CLIENT_DES="T&C code descending" COM_TC_CONTENTS_STARTDATE_ASC="Startdate ascending" COM_TC_CONTENTS_STARTDATE_DES="Startdate descending" +COM_TC_BASIC_CONFIG_SET="Basic configuration" +COM_TC_DATE_FORMAT_TO_SHOW="Date format to show" +COM_TC_DATE_FORMAT_TO_SHOW_DESC="You can set the format to display the date on the site" +COM_TC_CUSTOM_DATE_FORMAT="Custom date format" +COM_TC_CUSTOM_DATE_FORMAT_DESC="You can customize the date format here" +COM_TC_DATE_FORMAT_CUSTOM="custom" diff --git a/src/components/com_tc/site/views/content/tmpl/default.php b/src/components/com_tc/site/views/content/tmpl/default.php index 7fb7de3..f92c5d2 100755 --- a/src/components/com_tc/site/views/content/tmpl/default.php +++ b/src/components/com_tc/site/views/content/tmpl/default.php @@ -8,6 +8,9 @@ */ defined('_JEXEC') or die('Restricted access'); +JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/'); +use Joomla\CMS\HTML\HTMLHelper; + ?> tc_id)) - {?> + { + ?>

termsandconditions->title; ?>

termsandconditions->version; ?>   - termsandconditions->modified_on; ?> + termsandconditions->modified_on, $this->dateFormat, true); ?>

termsandconditions->content); - } ?> + } ?>
dateFormat = $comParams->get('date_format_show'); + + if ($dateFormat == "custom") + { + $this->dateFormat = $comParams->get('custom_format'); + } + // Call api to get user accepted version $model = JModelLegacy::getInstance('Content', 'TcModel');