From 95f02e1bff8f9f54ebe2628b6ac151aea16b8261 Mon Sep 17 00:00:00 2001 From: Giuseppe Di Terlizzi Date: Mon, 30 Mar 2015 10:32:15 +0200 Subject: [PATCH] Fixed some issue * Fixed PHP Warning when the wiki page is not created * Fixed the author and description method --- action.php | 26 ++++++++++++++++++-------- plugin.info.txt | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/action.php b/action.php index b74db1f..f071053 100644 --- a/action.php +++ b/action.php @@ -28,7 +28,7 @@ class action_plugin_semantic extends DokuWiki_Action_Plugin { $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'json_ld'); } - if ($this->getConf('useDescription')) { + if ($this->getConf('useMetaDescription')) { $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'meta_description'); } @@ -64,7 +64,7 @@ class action_plugin_semantic extends DokuWiki_Action_Plugin { return false; } - if (isset($meta['date'])) { + if (isset($meta['date']) && $meta['date'] !== '') { $type = ((isset($meta['semantic']['schema.org']['type'])) ? $meta['semantic']['schema.org']['type'] @@ -161,10 +161,14 @@ class action_plugin_semantic extends DokuWiki_Action_Plugin { $meta = $INFO['meta']; - if ($meta['date'] && $meta['semantic']['enabled']) { + if (isset($meta['semantic']['enabled']) && ! $meta['semantic']['enabled']) { + return false; + } + + if (isset($meta['date']) && $meta['date'] !== '') { $description = str_replace("\n", ' ', trim(ltrim($meta['description']['abstract'], $meta['title']))); - + $event->data['meta'][] = array( 'name' => 'description', 'content' => $description, @@ -186,12 +190,18 @@ class action_plugin_semantic extends DokuWiki_Action_Plugin { return false; } - if ($this->getConf('useMetaAuthor') && $INFO['perm'] > 0) { - - if ($meta['date'] && $meta['semantic']['enabled']) { + if ($INFO['perm'] > 0) { + + $meta = $INFO['meta']; + + if (isset($meta['semantic']['enabled']) && ! $meta['semantic']['enabled']) { + return false; + } + + if ((isset($meta['date']) && $meta['date'] !== '')) { $meta = $INFO['meta']; - + $event->data['meta'][] = array( 'name' => 'author', 'content' => $meta['creator'], diff --git a/plugin.info.txt b/plugin.info.txt index 6304763..a51e2d0 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base semantic author Giuseppe Di Terlizzi email giuseppe.diterlizzi@gmail.com -date 2015-03-26 +date 2015-03-30 name Semantic Plugin desc Add Semantic Data in Dokuwiki url http://www.dokuwiki.org/plugin:semantic