From ba63b69b069ae8a5ff6651e6e01694ef4902f9ab Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 7 Oct 2017 21:59:30 +0300 Subject: [PATCH] Fixes for MW 1.27+ and default author; fixes #3 --- S5SlideShow.class.php | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/S5SlideShow.class.php b/S5SlideShow.class.php index 6b5bf28..33edaa5 100644 --- a/S5SlideShow.class.php +++ b/S5SlideShow.class.php @@ -87,24 +87,19 @@ function setAttributes($attr) ); // Boolean value $attr['scaled'] = $attr['scaled'] == 'true' || $attr['scaled'] == 'yes' || $attr['scaled'] == 1; - // Default author = last revision's author + // Default author = first revision's author if (!isset($attr['author'])) { - $attr['author'] = $wgUser; - if ($this->sArticle){ - try{ - $u = $wgUser; - if ($this->sArticle->mRevision) { - $u = $this->sArticle->getLastNAuthors(1); - $u = $u[0]; - } - if (!is_object($u)) - $u = User::newFromName($u); - if (!is_object($u)) - $u = $wgUser; - $attr['author'] = $u->getRealName(); - } catch (Exception $e) {} - } + $rev = $this->sArticle->getOldestRevision(); + if ($rev) + { + $attr['author'] = User::newFromId($rev->getUser())->getRealName(); + } + else + { + // Not saved yet + $attr['author'] = $wgUser->getRealName(); + } } // Author and date in the subfooter by default if (!isset($attr['subfooter'])) @@ -547,7 +542,7 @@ static function slideshow_view($content, $attr, $parser, $frame = NULL, $addmsg $value ); } - $content .= "\n;" . wfMsg('s5slide-header-' . $key) . ': '. $value; + $content .= "\n;" . wfMessage('s5slide-header-' . $key)->text() . ': '. $value; } } // FIXME remove hardcoded '.png', /extensions/S5SlideShow/, "Slide Show" @@ -579,7 +574,7 @@ static function slideshow_view($content, $attr, $parser, $frame = NULL, $addmsg $html = '' . $html; } - $html = '
' . $html . '
'; + $html = '
' . $html . '
'; return $html; } @@ -595,7 +590,7 @@ function slideshow_parse($content, $attr, $parser) // - article view mode static function slides_view($content, $attr, $parser) { - if ($attr['split']) + if (!empty($attr['split'])) $slides = preg_split('/'.str_replace('/', '\\/', $attr['split']).'/', $content); else $slides = array($content); @@ -719,10 +714,10 @@ public function showMissingArticle() $oldid = $this->getOldID(); if ($oldid) { - $text = wfMsgNoTrans( + $text = wfMessage( 'missing-article', $this->mTitle->getPrefixedText(), - wfMsgNoTrans('missingarticle-rev', $oldid) - ); + wfMessage('missingarticle-rev', $oldid)->plain() + )->plain(); } else $text = $this->getContent();