From 20fe9d5bb8fdcaf2efb03528c3135101707e2ac6 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Thu, 26 Sep 2024 16:54:33 +1200 Subject: [PATCH] ENH Update code to reflect changes in template layer --- code/Controller/AssetAdmin.php | 9 ++++----- code/Forms/FileHistoryFormFactory.php | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/Controller/AssetAdmin.php b/code/Controller/AssetAdmin.php index 86ac05769..3e92dc32b 100644 --- a/code/Controller/AssetAdmin.php +++ b/code/Controller/AssetAdmin.php @@ -710,8 +710,8 @@ public function apiHistory(HTTPRequest $request): HTTPResponse $output[] = array( 'versionid' => (int) $version->Version, - 'date_ago' => $version->dbObject('LastEdited')->Ago(), - 'date_formatted' => $version->dbObject('LastEdited')->Nice(), + 'date_ago' => $version->dbObject('LastEdited')?->Ago(), + 'date_formatted' => $version->dbObject('LastEdited')?->Nice(), 'status' => ($version->WasPublished) ? _t(__CLASS__.'.PUBLISHED', 'Published') : '', 'author' => ($author) ? $author->Name @@ -1604,10 +1604,9 @@ public function canView($member = null) public function PreviewPanel() { $templates = SSViewer::get_templates_by_class(get_class($this), '_PreviewPanel', __CLASS__); - $template = SSViewer::chooseTemplate($templates); // Only render preview panel if a template specifically for the asset admin has been provided - if ($template) { - return $this->renderWith($template); + if ($this->getTemplateEngine()->hasTemplate($templates)) { + return $this->renderWith($templates); } return null; } diff --git a/code/Forms/FileHistoryFormFactory.php b/code/Forms/FileHistoryFormFactory.php index 1c90b1f52..b6d2d095b 100644 --- a/code/Forms/FileHistoryFormFactory.php +++ b/code/Forms/FileHistoryFormFactory.php @@ -36,7 +36,7 @@ protected function getSpecsMarkup($record) ? _t(__CLASS__ . '.PUBLISHED', 'Published') : _t(__CLASS__ . '.SAVED', 'Saved'), Convert::raw2att($record->LastEdited), - Convert::raw2xml($record->dbObject('LastEdited')->Ago()) + Convert::raw2xml($record->dbObject('LastEdited')?->Ago()) ); return sprintf( '
%s %s, %s %s
',