jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/363768 )
Change subject: Reorganize directory structure + file renaming ...................................................................... Reorganize directory structure + file renaming Also split VoteClass.php into: - includes/Vote.class.php - includes/VoteStars.class.php Bug: T160849 Change-Id: Icb51972383d6342f292fe62d9ec93a189d4dbeca --- M extension.json R includes/Vote.class.php R includes/VoteNY.alias.php R includes/VoteNY.hooks.php R includes/VoteNY.i18n.magic.php A includes/VoteStars.class.php R includes/api/ApiVoteNY.php R includes/specials/SpecialTopRatings.php R resources/css/Vote.css R resources/images/star_half.gif R resources/images/star_off.gif R resources/images/star_on.gif R resources/images/star_voted.gif R resources/js/Vote.js R sql/vote.mysql R sql/vote.postgres 16 files changed, 136 insertions(+), 136 deletions(-) Approvals: Jack Phoenix: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index a2e26bf..a39a648 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "VoteNY", - "version": "2.8.1", + "version": "2.9.0", "author": [ "Aaron Wright", "David Pean", @@ -22,15 +22,15 @@ "voteny": "ApiVoteNY" }, "ExtensionMessagesFiles": { - "VoteNYAlias": "VoteNY.alias.php", - "VoteNYMagic": "VoteNY.i18n.magic.php" + "VoteNYAlias": "includes/VoteNY.alias.php", + "VoteNYMagic": "includes/VoteNY.i18n.magic.php" }, "AutoloadClasses": { - "ApiVoteNY": "ApiVoteNY.php", - "Vote": "VoteClass.php", - "VoteStars": "VoteClass.php", - "SpecialTopRatings": "SpecialTopRatings.php", - "VoteHooks": "VoteHooks.php" + "ApiVoteNY": "includes/api/ApiVoteNY.php", + "Vote": "includes/Vote.class.php", + "VoteStars": "includes/VoteStars.class.php", + "SpecialTopRatings": "includes/specials/SpecialTopRatings.php", + "VoteHooks": "includes/VoteNY.hooks.php" }, "Hooks": { "ParserFirstCallInit": [ @@ -56,7 +56,7 @@ }, "ResourceModules": { "ext.voteNY.scripts": { - "scripts": "Vote.js", + "scripts": "resources/js/Vote.js", "messages": [ "voteny-link", "voteny-unvote-link" @@ -65,7 +65,7 @@ "position": "bottom" }, "ext.voteNY.styles": { - "styles": "Vote.css", + "styles": "resources/css/Vote.css", "position": "top" } }, diff --git a/VoteClass.php b/includes/Vote.class.php similarity index 64% rename from VoteClass.php rename to includes/Vote.class.php index 1b44378..8ead420 100644 --- a/VoteClass.php +++ b/includes/Vote.class.php @@ -242,126 +242,3 @@ return $output; } } - -/** - * Class for generating star rating stars. - */ -class VoteStars extends Vote { - - public $maxRating = 5; - - /** - * Displays voting stars - * - * @param bool $voted Has the user already voted? False by default - * @return string HTML output - */ - function display( $voted = false ) { - global $wgUser; - - $overall_rating = $this->getAverageVote(); - - if ( $voted ) { - $display_stars_rating = $voted; - } else { - $display_stars_rating = $this->getAverageVote(); - } - - $id = ''; - - // Should probably be $this->PageID or something? - // 'cause we define $id just above as an empty string...duh - $output = '<div id="rating_' . $id . '">'; - $output .= '<div class="rating-score">'; - $output .= '<div class="voteboxrate">' . $overall_rating . '</div>'; - $output .= '</div>'; - $output .= '<div class="rating-section">'; - $output .= $this->displayStars( $id, $display_stars_rating, $voted ); - $count = $this->count(); - if ( isset( $count ) ) { - $output .= ' <span class="rating-total">(' . - wfMessage( 'voteny-votes', $count )->parse() . ')</span>'; - } - $already_voted = $this->UserAlreadyVoted(); - if ( $already_voted && $wgUser->isLoggedIn() ) { - $output .= '<div class="rating-voted">' . - wfMessage( 'voteny-gave-this', $already_voted )->parse() . - " </div> - <a href=\"javascript:void(0);\" class=\"vote-remove-stars-link\" data-page-id=\"{$this->PageID}\" data-vote-id=\"{$id}\">(" - . wfMessage( 'voteny-remove' )->plain() . - ')</a>'; - } - $output .= '</div> - <div class="rating-clear"> - </div>'; - - $output .= '</div>'; - return $output; - } - - /** - * Displays the actual star images, depending on the state of the user's mouse - * - * @param int $id ID of the rating (div) element - * @param int $rating Average rating - * @param int $voted - * @return string Generated <img> tag - */ - function displayStars( $id, $rating, $voted ) { - global $wgExtensionAssetsPath; - - if ( !$rating ) { - $rating = 0; - } - if ( !$voted ) { - $voted = 0; - } - $output = ''; - - for ( $x = 1; $x <= $this->maxRating; $x++ ) { - if ( !$id ) { - $action = 3; - } else { - $action = 5; - } - $output .= "<img class=\"vote-rating-star\" data-vote-the-vote=\"{$x}\"" . - " data-page-id=\"{$this->PageID}\"" . - " data-vote-id=\"{$id}\" data-vote-action=\"{$action}\" data-vote-rating=\"{$rating}\"" . - " data-vote-voted=\"{$voted}\" id=\"rating_{$id}_{$x}\"" . - " src=\"{$wgExtensionAssetsPath}/VoteNY/images/star_"; - switch ( true ) { - case $rating >= $x: - if ( $voted ) { - $output .= 'voted'; - } else { - $output .= 'on'; - } - break; - case ( $rating > 0 && $rating < $x && $rating > ( $x - 1 ) ): - $output .= 'half'; - break; - case ( $rating < $x ): - $output .= 'off'; - break; - } - - $output .= '.gif" alt="" />'; - } - - return $output; - } - - /** - * Displays the average score for the current page - * and the total amount of votes. - * - * @return string - */ - function displayScore() { - $count = $this->count(); - return wfMessage( 'voteny-community-score', '<b>' . $this->getAverageVote() . '</b>' ) - ->numParams( $count )->text() . - ' (' . wfMessage( 'voteny-ratings' )->numParams( $count )->parse() . ')'; - } - -} diff --git a/VoteNY.alias.php b/includes/VoteNY.alias.php similarity index 100% rename from VoteNY.alias.php rename to includes/VoteNY.alias.php diff --git a/VoteHooks.php b/includes/VoteNY.hooks.php similarity index 98% rename from VoteHooks.php rename to includes/VoteNY.hooks.php index b27e675..415ecc3 100644 --- a/VoteHooks.php +++ b/includes/VoteNY.hooks.php @@ -218,7 +218,7 @@ if ( $dbt === 'sqlite' ) { $dbt = 'mysql'; } - $file = __DIR__ . "/vote.$dbt"; + $file = __DIR__ . "/../sql/vote.$dbt"; if ( file_exists( $file ) ) { $updater->addExtensionUpdate( array( 'addTable', 'Vote', $file, true ) ); } else { diff --git a/VoteNY.i18n.magic.php b/includes/VoteNY.i18n.magic.php similarity index 100% rename from VoteNY.i18n.magic.php rename to includes/VoteNY.i18n.magic.php diff --git a/includes/VoteStars.class.php b/includes/VoteStars.class.php new file mode 100644 index 0000000..c89f899 --- /dev/null +++ b/includes/VoteStars.class.php @@ -0,0 +1,123 @@ +<?php +/** + * Class for generating star rating stars. + */ +class VoteStars extends Vote { + + public $maxRating = 5; + + /** + * Displays voting stars + * + * @param bool $voted Has the user already voted? False by default + * @return string HTML output + */ + function display( $voted = false ) { + global $wgUser; + + $overall_rating = $this->getAverageVote(); + + if ( $voted ) { + $display_stars_rating = $voted; + } else { + $display_stars_rating = $this->getAverageVote(); + } + + $id = ''; + + // Should probably be $this->PageID or something? + // 'cause we define $id just above as an empty string...duh + $output = '<div id="rating_' . $id . '">'; + $output .= '<div class="rating-score">'; + $output .= '<div class="voteboxrate">' . $overall_rating . '</div>'; + $output .= '</div>'; + $output .= '<div class="rating-section">'; + $output .= $this->displayStars( $id, $display_stars_rating, $voted ); + $count = $this->count(); + if ( isset( $count ) ) { + $output .= ' <span class="rating-total">(' . + wfMessage( 'voteny-votes', $count )->parse() . ')</span>'; + } + $already_voted = $this->UserAlreadyVoted(); + if ( $already_voted && $wgUser->isLoggedIn() ) { + $output .= '<div class="rating-voted">' . + wfMessage( 'voteny-gave-this', $already_voted )->parse() . + " </div> + <a href=\"javascript:void(0);\" class=\"vote-remove-stars-link\" data-page-id=\"{$this->PageID}\" data-vote-id=\"{$id}\">(" + . wfMessage( 'voteny-remove' )->plain() . + ')</a>'; + } + $output .= '</div> + <div class="rating-clear"> + </div>'; + + $output .= '</div>'; + return $output; + } + + /** + * Displays the actual star images, depending on the state of the user's mouse + * + * @param int $id ID of the rating (div) element + * @param int $rating Average rating + * @param int $voted + * @return string Generated <img> tag + */ + function displayStars( $id, $rating, $voted ) { + global $wgExtensionAssetsPath; + + if ( !$rating ) { + $rating = 0; + } + if ( !$voted ) { + $voted = 0; + } + $output = ''; + + for ( $x = 1; $x <= $this->maxRating; $x++ ) { + if ( !$id ) { + $action = 3; + } else { + $action = 5; + } + $output .= "<img class=\"vote-rating-star\" data-vote-the-vote=\"{$x}\"" . + " data-page-id=\"{$this->PageID}\"" . + " data-vote-id=\"{$id}\" data-vote-action=\"{$action}\" data-vote-rating=\"{$rating}\"" . + " data-vote-voted=\"{$voted}\" id=\"rating_{$id}_{$x}\"" . + " src=\"{$wgExtensionAssetsPath}/VoteNY/resources/images/star_"; + switch ( true ) { + case $rating >= $x: + if ( $voted ) { + $output .= 'voted'; + } else { + $output .= 'on'; + } + break; + case ( $rating > 0 && $rating < $x && $rating > ( $x - 1 ) ): + $output .= 'half'; + break; + case ( $rating < $x ): + $output .= 'off'; + break; + } + + $output .= '.gif" alt="" />'; + } + + return $output; + } + + /** + * Displays the average score for the current page + * and the total amount of votes. + * + * @return string + */ + function displayScore() { + $count = $this->count(); + return wfMessage( 'voteny-community-score', '<b>' . $this->getAverageVote() . '</b>' ) + ->numParams( $count )->text() . + ' (' . wfMessage( 'voteny-ratings' )->numParams( $count )->parse() . ')'; + } + +} diff --git a/ApiVoteNY.php b/includes/api/ApiVoteNY.php similarity index 100% rename from ApiVoteNY.php rename to includes/api/ApiVoteNY.php diff --git a/SpecialTopRatings.php b/includes/specials/SpecialTopRatings.php similarity index 100% rename from SpecialTopRatings.php rename to includes/specials/SpecialTopRatings.php diff --git a/Vote.css b/resources/css/Vote.css similarity index 100% rename from Vote.css rename to resources/css/Vote.css diff --git a/images/star_half.gif b/resources/images/star_half.gif similarity index 100% rename from images/star_half.gif rename to resources/images/star_half.gif Binary files differ diff --git a/images/star_off.gif b/resources/images/star_off.gif similarity index 100% rename from images/star_off.gif rename to resources/images/star_off.gif Binary files differ diff --git a/images/star_on.gif b/resources/images/star_on.gif similarity index 100% rename from images/star_on.gif rename to resources/images/star_on.gif Binary files differ diff --git a/images/star_voted.gif b/resources/images/star_voted.gif similarity index 100% rename from images/star_voted.gif rename to resources/images/star_voted.gif Binary files differ diff --git a/Vote.js b/resources/js/Vote.js similarity index 99% rename from Vote.js rename to resources/js/Vote.js index 6875294..6c5be0d 100644 --- a/Vote.js +++ b/resources/js/Vote.js @@ -16,7 +16,7 @@ this.voted_new = []; this.id = 0; this.last_id = 0; - this.imagePath = mw.config.get( 'wgExtensionAssetsPath' ) + '/VoteNY/images/'; + this.imagePath = mw.config.get( 'wgExtensionAssetsPath' ) + '/VoteNY/resources/images/'; /** * Called when voting through the green square voting box @@ -197,4 +197,4 @@ $( this ).data( 'vote-id' ) ); } ); -} ); \ No newline at end of file +} ); diff --git a/vote.mysql b/sql/vote.mysql similarity index 100% rename from vote.mysql rename to sql/vote.mysql diff --git a/vote.postgres b/sql/vote.postgres similarity index 100% rename from vote.postgres rename to sql/vote.postgres -- To view, visit https://gerrit.wikimedia.org/r/363768 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icb51972383d6342f292fe62d9ec93a189d4dbeca Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VoteNY Gerrit-Branch: master Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits