Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shows stash timemodified if exists #16

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class local_amos_stash implements renderable {
public $name;
/** @var int timestamp of when the stash was created */
public $timecreated;
/** @var int timestamp of when the stash was modified */
public $timemodified;
/** @var stdClass the owner of the stash */
public $owner;
/** @var array of language names */
Expand Down Expand Up @@ -71,6 +73,7 @@ public static function instance_from_mlang_stash(mlang_stash $stash, stdClass $o
$new->id = $stash->id;
$new->name = $stash->name;
$new->timecreated = $stash->timecreated;
$new->timemodified = $stash->timemodified;

$stage = new mlang_stage();
$stash->apply($stage);
Expand Down Expand Up @@ -109,6 +112,7 @@ public static function instance_from_record(stdClass $record, stdClass $owner) {
$new->id = $record->id;
$new->name = $record->name;
$new->timecreated = $record->timecreated;
$new->timemodified = $record->timemodified;
$new->strings = $record->strings;
$new->components = explode('/', trim($record->components, '/'));
$new->languages = explode('/', trim($record->languages, '/'));
Expand Down
19 changes: 16 additions & 3 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,14 @@ protected function render_local_amos_stash(local_amos_stash $stash) {
'class' => 'my-2 mr-2 d-inline-block',
'size' => 21,
]);
$output .= html_writer::tag('div', userdate($stash->timecreated, get_string('strftimedaydatetime', 'langconfig')),
['class' => 'timecreated']);

if ($stash->timemodified) {
$output .= html_writer::tag('div', userdate($stash->timemodified, get_string('strftimedaydatetime', 'langconfig')),
['class' => 'timemodified']);
} else {
$output .= html_writer::tag('div', userdate($stash->timecreated, get_string('strftimedaydatetime', 'langconfig')),
['class' => 'timecreated']);
}
$output .= html_writer::tag('div', get_string('stashstrings', 'local_amos', $stash->strings),
['class' => 'strings']);
$output .= html_writer::tag('div', get_string('stashlanguages', 'local_amos', s(implode(', ', $stash->languages))),
Expand Down Expand Up @@ -372,8 +378,15 @@ protected function render_local_amos_contribution(local_amos_contribution $contr
$output = '';
$output .= $this->output->heading('#'.$contrib->info->id.' '.s($contrib->info->subject), 3, 'subject');
$output .= $this->output->container($this->output->user_picture($contrib->author) . fullname($contrib->author), 'author');
$output .= $this->output->container(userdate($contrib->info->timecreated,

if ($contrib->info->timemodified) {
$output .= $this->output->container(userdate($contrib->info->timemodified,
get_string('strftimedaydatetime', 'langconfig')), 'timemodified');
} else {
$output .= $this->output->container(userdate($contrib->info->timecreated,
get_string('strftimedaydatetime', 'langconfig')), 'timecreated');
}

$output .= $this->output->container(format_text($contrib->info->message), 'message');
$output = $this->box($output, 'generalbox source');

Expand Down
Loading