Skip to content

Commit

Permalink
pkp/pkp-lib#10328 Date to Carbon
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed Oct 1, 2024
1 parent e9fbcb1 commit 5d5b768
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
namespace APP\plugins\generic\announcementFeed;

use APP\template\TemplateManager;
use Carbon\Carbon;
use PKP\announcement\Announcement;
use PKP\core\Core;
use PKP\db\DAORegistry;
use PKP\plugins\GatewayPlugin;
use PKP\site\VersionDAO;
Expand Down Expand Up @@ -139,14 +139,14 @@ public function fetch($args, $request)
$lastDateUpdated = $this->_parentPlugin->getSetting($journal->getId(), 'dateUpdated');
if ($announcements->isEmpty()) {
if (empty($lastDateUpdated)) {
$dateUpdated = Core::getCurrentDate();
$dateUpdated = Carbon::now();
$this->_parentPlugin->updateSetting($journal->getId(), 'dateUpdated', $dateUpdated, 'string');
} else {
$dateUpdated = $lastDateUpdated;
}
} else {
$dateUpdated = $announcements->first()->getAttribute('datePosted');
if (empty($lastDateUpdated) || (strtotime($dateUpdated) > strtotime($lastDateUpdated))) {
$dateUpdated = $announcements->first()->datePosted;
if (empty($lastDateUpdated) || $dateUpdated->gt($lastDateUpdated)) {
$this->_parentPlugin->updateSetting($journal->getId(), 'dateUpdated', $dateUpdated, 'string');
}
}
Expand Down
10 changes: 5 additions & 5 deletions plugins/generic/announcementFeed/templates/atom.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@
{foreach from=$announcements item=announcement}
<entry>
{* required elements *}
<id>{url page="announcement" op="view" path=$announcement->getKey()}</id>
<id>{url page="announcement" op="view" path=$announcement->id}</id>
<title>{$announcement->getLocalizedData('fullTitle')|strip|escape:"html"}</title>
<updated>{$announcement->getAttribute('datePosted')|date_format:"%Y-%m-%dT%T%z"|regex_replace:"/00$/":":00"}</updated>
<updated>{$announcement->datePosted->format("%Y-%m-%dT%T%z")|regex_replace:"/00$/":":00"}</updated>
<author>
<name>{$journal->getLocalizedName()|strip|escape:"html"}</name>
</author>
<link rel="alternate" href="{url page="announcement" op="view" path=$announcement->getKey()}" />
<link rel="alternate" href="{url page="announcement" op="view" path=$announcement->id}" />
{if $announcement->getLocalizedData('description')}
<summary type="html" xml:base="{url page="announcement" op="view" path=$announcement->getKey()}">{$announcement->getLocalizedData('description')|strip|escape:"html"}</summary>
<summary type="html" xml:base="{url page="announcement" op="view" path=$announcement->id}">{$announcement->getLocalizedData('description')|strip|escape:"html"}</summary>
{/if}

{* optional elements *}
{* <category/> *}
{* <contributor/> *}
<published>{$announcement->getAttribute('datePosted')|date_format:"%Y-%m-%dT%T%z"|regex_replace:"/00$/":":00"}</published>
<published>{$announcement->datePosted->format("%Y-%m-%dT%T%z")|regex_replace:"/00$/":":00"}</published>
{* <source/> *}
{* <rights/> *}
</entry>
Expand Down
8 changes: 4 additions & 4 deletions plugins/generic/announcementFeed/templates/rss.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@
<items>
{foreach from=$announcements item=announcement}
<rdf:Seq>
<rdf:li rdf:resource="{url page="announcement" op="view" path=$announcement->getKey()}"/>
<rdf:li rdf:resource="{url page="announcement" op="view" path=$announcement->id}"/>
</rdf:Seq>
{/foreach}
</items>
</channel>

{foreach from=$announcements item=announcement}
<item rdf:about="{url page="announcement" op="view" path=$announcement->getKey()}">
<item rdf:about="{url page="announcement" op="view" path=$announcement->id}">
{* required elements *}
<title>{$announcement->getLocalizedData('fullTitle')|strip|escape:"html"}</title>
<link>{url page="announcement" op="view" path=$announcement->getKey()}</link>
<link>{url page="announcement" op="view" path=$announcement->id}</link>

{* optional elements *}
{if $announcement->getLocalizedData('description')}
<description>{$announcement->getLocalizedData('description')|strip|escape:"html"}</description>
{/if}
<dc:creator>{$journal->getLocalizedName()|strip|escape:"html"}</dc:creator>
<dc:date>{$announcement->getAttribute('datePosted')|date_format:"%Y-%m-%d"}</dc:date>
<dc:date>{$announcement->datePosted->format("%Y-%m-%d")}</dc:date>
</item>
{/foreach}

Expand Down

0 comments on commit 5d5b768

Please sign in to comment.