Skip to content

Commit

Permalink
Fixes for MW 1.27+ and default author; fixes mediawiki4intranet#3
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif authored and hexmode committed Jan 2, 2020
1 parent e7eef62 commit ba63b69
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions S5SlideShow.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']))
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -579,7 +574,7 @@ static function slideshow_view($content, $attr, $parser, $frame = NULL, $addmsg
$html = '<script type="text/javascript">var wgSlideViewFont = "'.
addslashes($slideShow->attr['font']).'";</script>' . $html;
}
$html = '<div id="slideshow-bundle">' . $html . '</div>';
$html = '<div id="slideshow-bundle">' . $html . '</div>';
return $html;
}

Expand All @@ -595,7 +590,7 @@ function slideshow_parse($content, $attr, $parser)
// <slides> - 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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ba63b69

Please # to comment.