Fixed missing date field in frontmatter. Removed auto-date dependency

This commit is contained in:
Jeremy Gonyea
2021-01-24 02:16:41 -05:00
parent 5a36021864
commit 44c85620e0
4 changed files with 20 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ You should now have all the plugin files under
> NOTE: This plugin is a modular component for Grav which requires the following to operate:
* [Grav Core](http://github.com/getgrav/grav)
* [Admin](https://github.com/getgrav/grav-plugin-admin)
* [Auto Date](https://github.com/getgrav/grav-plugin-auto-date)
* [Breadcrumbs](https://github.com/getgrav/grav-plugin-breadcrumbs)
* [Feed](https://github.com/getgrav/grav-plugin-feed)
* [GetId3](https://github.com/jgonyea/grav-plugin-get-id3), along with its accompanying [getID3 php library](http://www.getid3.org/)

View File

@@ -13,7 +13,7 @@ license: MIT
dependencies:
- admin
- auto-date
- breadcrumbs
- feed
- get-id3

View File

@@ -5,6 +5,9 @@ en:
MAX_UPLOAD_HELP: 'Set "upload_max_filesize" and "post_max_size" in php.ini to at least this value or higher.'
PODCAST: Podcast Channel
SERIES: Podcast Series
SERIES_CONTENT:
HEADER: Series Description
EPISODE_CONTENT:
HEADER: Episode Content
DOWNLOAD: Download Audio

View File

@@ -82,13 +82,26 @@ class PodcastPlugin extends Plugin
public function onAdminSave($event)
{
$obj = $event['object'];
// Process only podcast episodes page types.
// Process only podcast-* page types.
$obj_class = get_class($obj);
if (($obj_class != 'Grav\Common\Page\Page' && $obj_class != 'Grav\Common\Flex\Types\Pages\PageObject') || $obj->template() != 'podcast-episode') {
if (($obj_class != 'Grav\Common\Page\Page' && $obj_class != 'Grav\Common\Flex\Types\Pages\PageObject')){
return;
}
$header = $obj->header();
// Set auto dates on all podcast-* page types.
if ( str_starts_with($obj->template(), 'podcast-') && !isset($header->date)) {
$date = date($this->grav['config']->get('system.pages.dateformat.default', 'H:i d-m-Y'));
$header['date'] = $date;
}
// Return with just auto-date updated field if not podcast-episode.
if ($obj->template() != 'podcast-episode') {
$new_header = $header->toArray();
$obj->header($new_header);
return;
}
// Use local file for meta calculations, if present.
// Else, use remote file for meta, if present.
// Else, cleanup media entry in markdown header.