Skip to content

Commit

Permalink
Actionlogs: Added parameter to disable relative timestamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmageddon committed Dec 16, 2020
1 parent fc3b3d3 commit ff32892
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
11 changes: 11 additions & 0 deletions administrator/components/com_actionlogs/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,16 @@
<option value="PUT">COM_ACTIONLOGS_FIELD_VALUE_PUT</option>
<option value="PATCH">COM_ACTIONLOGS_FIELD_VALUE_PATCH</option>
</field>
<field
name="date_relative"
type="radio"
label="COM_ACTIONLOGS_DATE_RELATIVE_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class HtmlView extends BaseHtmlView
*/
protected $showIpColumn = false;

/**
* Setting if the date should be displayed relative to the current date.
*
* @var boolean
* @since __DEPLOY_VERSION__
*/
protected $dateRelative = false;

/**
* Method to display the view.
*
Expand All @@ -100,6 +108,7 @@ public function display($tpl = null)
$this->activeFilters = $model->getActiveFilters();
$params = ComponentHelper::getParams('com_actionlogs');
$this->showIpColumn = (bool) $params->get('ip_logging', 0);
$this->dateRelative = (bool) $params->get('date_relative', 1);

if (count($errors = $model->getErrors()))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@
<?php echo $this->escape(Text::_($extension)); ?>
</td>
<td class="d-none d-md-table-cell">
<?php echo HTMLHelper::_('date.relative', $item->log_date); ?>
<div class="small">
<?php if ($this->dateRelative) : ?>
<?php echo HTMLHelper::_('date.relative', $item->log_date); ?>
<div class="small">
<?php endif; ?>
<?php echo HTMLHelper::_('date', $item->log_date, Text::_('DATE_FORMAT_LC6')); ?>
</div>
<?php if ($this->dateRelative) : ?>
</div>
<?php endif; ?>
</td>
<td class="d-md-table-cell">
<?php echo $this->escape($item->name); ?>
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_actionlogs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COM_ACTIONLOGS_COMMA="Comma"
COM_ACTIONLOGS_CONFIGURATION="User Actions Log: Options"
COM_ACTIONLOGS_CSV_DELIMITER_LABEL="CSV Delimiter"
COM_ACTIONLOGS_DATE="Date"
COM_ACTIONLOGS_DATE_RELATIVE_LABEL="Show Relative Date/Time"
COM_ACTIONLOGS_DISABLED="Disabled"
COM_ACTIONLOGS_EMAIL_DESC="This is the latest action performed by a user on your website."
COM_ACTIONLOGS_EMAIL_SUBJECT="Latest User Actions"
Expand Down

0 comments on commit ff32892

Please sign in to comment.