mirror of
https://bitbucket.org/vertlach/voteny.git
synced 2024-05-01 11:29:19 +03:00
Modernization
Change-Id: Ie8dce7c0dc3feb16ac5311d1e3fb88ce5933363a
This commit is contained in:
parent
4775836933
commit
89abe6bffb
|
@ -27,8 +27,6 @@ class SpecialTopRatings extends IncludableSpecialPage {
|
|||
* @param $par Mixed: parameter passed to the special page or null
|
||||
*/
|
||||
public function execute( $par ) {
|
||||
global $wgOut, $wgScriptPath;
|
||||
|
||||
// Set the page title, robot policies, etc.
|
||||
$this->setHeaders();
|
||||
|
||||
|
@ -51,7 +49,7 @@ class SpecialTopRatings extends IncludableSpecialPage {
|
|||
|
||||
// Add JS (and CSS) -- needed so that users can vote on this page and
|
||||
// so that their browsers' consoles won't be filled with JS errors ;-)
|
||||
$wgOut->addModules( 'ext.voteNY' );
|
||||
$this->getOutput()->addModules( 'ext.voteNY' );
|
||||
|
||||
$ratings = array();
|
||||
$output = '';
|
||||
|
@ -110,8 +108,9 @@ class SpecialTopRatings extends IncludableSpecialPage {
|
|||
/* XXX dirrrrrrty hack! because when we include this page, the JS
|
||||
is not included, but we want things to work still */
|
||||
if ( $this->including() ) {
|
||||
global $wgExtensionAssetsPath;
|
||||
$output .= '<script type="text/javascript" src="' .
|
||||
$wgScriptPath . '/extensions/VoteNY/Vote.js"></script>';
|
||||
$wgExtensionAssetsPath . '/VoteNY/Vote.js"></script>';
|
||||
}
|
||||
|
||||
// yes, array_keys() is needed
|
||||
|
@ -126,8 +125,8 @@ class SpecialTopRatings extends IncludableSpecialPage {
|
|||
Linker::link(
|
||||
$titleObj,
|
||||
$titleObj->getPrefixedText() // prefixed, so that the namespace shows!
|
||||
) . wfMsg( 'word-separator' ) . // i18n overkill? ya betcha...
|
||||
wfMsg( 'parentheses', $ratings[$pageId] ) .
|
||||
) . $this->msg( 'word-separator' )->escaped() . // i18n overkill? ya betcha...
|
||||
$this->msg( 'parentheses', $ratings[$pageId] )->escaped() .
|
||||
'</div>';
|
||||
|
||||
$id = mt_rand(); // AFAIK these IDs are and originally were totally random...
|
||||
|
@ -144,11 +143,11 @@ class SpecialTopRatings extends IncludableSpecialPage {
|
|||
} else {
|
||||
// Nothing? Well, display an informative error message rather than
|
||||
// a blank page or somesuch.
|
||||
$output .= wfMsg( 'topratings-no-pages' );
|
||||
$output .= $this->msg( 'topratings-no-pages' )->escaped();
|
||||
}
|
||||
|
||||
// Output everything!
|
||||
$wgOut->addHTML( $output );
|
||||
$this->getOutput()->addHTML( $output );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -226,15 +226,15 @@ class Vote {
|
|||
$login = SpecialPage::getTitleFor( 'Userlogin' );
|
||||
$output .= '<a class="votebutton" href="' .
|
||||
htmlspecialchars( $login->getFullURL() ) . '" rel="nofollow">' .
|
||||
wfMsg( 'voteny-link' ) . '</a>';
|
||||
wfMessage( 'voteny-link' )->plain() . '</a>';
|
||||
} else {
|
||||
if( !wfReadOnly() ) {
|
||||
if( $voted == false ) {
|
||||
$output .= '<a href="javascript:void(0);" class="vote-vote-link">' .
|
||||
wfMsg( 'voteny-link' ) . '</a>';
|
||||
wfMessage( 'voteny-link' )->plain() . '</a>';
|
||||
} else {
|
||||
$output .= '<a href="javascript:void(0);" class="vote-unvote-link">' .
|
||||
wfMsg( 'voteny-unvote-link' ) . '</a>';
|
||||
wfMessage( 'voteny-unvote-link' )->plain() . '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -281,15 +281,15 @@ class VoteStars extends Vote {
|
|||
$count = $this->count();
|
||||
if( isset( $count ) ) {
|
||||
$output .= ' <span class="rating-total">(' .
|
||||
wfMsgExt( 'voteny-votes', 'parsemag', $count ) . ')</span>';
|
||||
wfMessage( 'voteny-votes', $count )->parse() . ')</span>';
|
||||
}
|
||||
$already_voted = $this->UserAlreadyVoted();
|
||||
if( $already_voted && $wgUser->isLoggedIn() ) {
|
||||
$output .= '<div class="rating-voted">' .
|
||||
wfMsgExt( 'voteny-gave-this', 'parsemag', $already_voted ) .
|
||||
wfMessage( 'voteny-gave-this', $already_voted )->parse() .
|
||||
" </div>
|
||||
<a href=\"javascript:void(0);\" class=\"vote-remove-stars-link\" data-vote-id=\"{$id}\">("
|
||||
. wfMsg( 'voteny-remove' ) .
|
||||
. wfMessage( 'voteny-remove' )->plain() .
|
||||
')</a>';
|
||||
}
|
||||
$output .= '</div>
|
||||
|
@ -308,7 +308,7 @@ class VoteStars extends Vote {
|
|||
* @return Mixed: generated <img> tag
|
||||
*/
|
||||
function displayStars( $id, $rating, $voted ) {
|
||||
global $wgScriptPath;
|
||||
global $wgExtensionAssetsPath;
|
||||
|
||||
if( !$rating ) {
|
||||
$rating = 0;
|
||||
|
@ -327,7 +327,7 @@ class VoteStars extends Vote {
|
|||
$output .= "<img class=\"vote-rating-star\" data-vote-the-vote=\"{$x}\"" .
|
||||
" data-vote-id=\"{$id}\" data-vote-action=\"{$action}\" data-vote-rating=\"{$rating}\"" .
|
||||
" data-vote-voted=\"{$voted}\" id=\"rating_{$id}_{$x}\"" .
|
||||
" src=\"{$wgScriptPath}/extensions/VoteNY/images/star_";
|
||||
" src=\"{$wgExtensionAssetsPath}/VoteNY/images/star_";
|
||||
switch( true ) {
|
||||
case $rating >= $x:
|
||||
if( $voted ) {
|
||||
|
@ -356,8 +356,8 @@ class VoteStars extends Vote {
|
|||
*/
|
||||
function displayScore() {
|
||||
$count = $this->count();
|
||||
return wfMsg( 'voteny-community-score', '<b>' . $this->getAverageVote() . '</b>' ) .
|
||||
' (' . wfMsgExt( 'voteny-ratings', 'parsemag', $count ) . ')';
|
||||
return wfMessage( 'voteny-community-score', '<b>' . $this->getAverageVote() . '</b>' )->text() .
|
||||
' (' . wfMessage( 'voteny-ratings', $count )->parse() . ')';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue