Changeset 151977
- Timestamp:
- 09/04/2009 01:45:29 PM (17 years ago)
- Location:
- comment-contest/trunk
- Files:
-
- 10 added
- 1 deleted
- 2 edited
-
comment-contest.php (modified) (18 diffs)
-
languages (added)
-
languages/commentContest-en_US.mo (added)
-
languages/commentContest-en_US.po (added)
-
languages/commentContest-en_US.pot (added)
-
languages/commentContest-fr_FR.mo (added)
-
languages/commentContest-fr_FR.po (added)
-
readme.txt (modified) (2 diffs)
-
screenshot-1.jpg (added)
-
screenshot-2.jpg (added)
-
screenshot-3.jpg (added)
-
screenshot-4.jpg (added)
-
screenshot1.png (deleted)
Legend:
- Unmodified
- Added
- Removed
-
comment-contest/trunk/comment-contest.php
r151444 r151977 2 2 /* 3 3 Plugin Name: Comment Contest 4 Plugin URI: http://www.nozzhy.com 4 Plugin URI: http://www.nozzhy.com/un-plugin-pour-gerer-un-concours-par-commentaires-sur-votre-blog/ 5 5 Description: If you create a contest on your website, you can draw all comments in a specific post (only in French for now) 6 6 Author: Thomas "Zhykos" Cicognani 7 Version: 1. 07 Version: 1.1 8 8 Author URI: http://www.nozzhy.com 9 9 */ … … 16 16 class CommentContest { 17 17 var $domain = ''; 18 var $version = '1. 0'; //Changer pour correspondre à la version courante18 var $version = '1.1'; // Current version 19 19 var $option_ns = ''; 20 20 var $options = array (); 21 22 // Raccourci interne pour ajouter des actions 23 function add_action($nom, $num = 0) { 24 $hook = $nom; 25 $fonction = $nom; 21 var $localizationName = "commentContest"; 22 23 /** 24 * Add action to do (auto-generated method) 25 * @param $name The action's name 26 * @param $num ? 27 */ 28 function add_action($name, $num = 0) { 29 $hook = $name; 30 $fonction = $name; 26 31 if (! $num) { 27 32 $fonction .= $num; 28 33 } 29 add_action ( $hook, array (&$this, 'action_' . $nom ) ); 30 } 31 34 add_action ( $hook, array (&$this, 'action_' . $name ) ); 35 } 36 37 /** 38 * Create a new contest 39 */ 32 40 function CommentContest() { 33 // Initiali sation des variables41 // Initialization 34 42 if ($this->domain == '') 35 43 $this->domain = get_class ( $this ); 44 36 45 if ($this->option_ns == '') 37 46 $this->option_ns = get_class ( $this ); 38 // Récupération des options 47 48 // Get options 39 49 $this->options = get_option ( $this->option_ns ); 40 50 41 // Doit-on lancer l'installation?51 // Launch the install? 42 52 if (! isset ( $this->options ['install'] ) or ($this->options ['install'] != $this->version)) 43 53 $this->install (); 44 54 45 //Charger les données de localisation 46 load_plugin_textdomain ( $this->domain ); 47 48 // gestion automatique des actions 55 // Load translation files 56 $wp_ajax_edit_comments_locale = get_locale(); 57 $wp_ajax_edit_comments_mofile = WP_CONTENT_DIR . "/plugins/comment-contest/languages/" . $this->localizationName . "-". $wp_ajax_edit_comments_locale.".mo"; 58 load_textdomain($this->localizationName, $wp_ajax_edit_comments_mofile); 59 60 // Manage actions 49 61 foreach ( get_class_methods ( get_class ( $this ) ) as $methode ) { 50 62 if (substr ( $methode, 0, 7 ) == 'action_') { … … 55 67 } 56 68 69 /** 70 * Things to do in the administration menu<br /> 71 * Here we add "Comment Contest" in the plugin menu 72 */ 57 73 function action_admin_menu() { 58 74 if (function_exists ( 'add_submenu_page' )) { 59 add_submenu_page ( 'plugins.php', __ ( 'Comment Contest', $this->domain ), __ ( 'Comment Contest', $this->domain ), 3, basename ( __FILE__ ), array (&$this, 'AdminHelpPage' ) ); 60 } 61 } 62 75 add_submenu_page ( 'plugins.php', __ ( 'Comment Contest', $this->localizationName ), __ ( 'Comment Contest', $this->localizationName ), 3, basename ( __FILE__ ), array (&$this, 'AdminHelpPage' ) ); 76 } 77 } 78 79 /** 80 * Set an option 81 * @param $option The option to change 82 * @param $value The new value for the option 83 */ 63 84 function set($option, $value) { 64 85 $this->options [$option] = $value; 65 86 } 66 87 88 /** 89 * Get the option's value 90 * @param $option The option we want to get 91 * @return The option's value 92 */ 67 93 function get($option) { 68 94 if (isset ( $this->options [$option] )) { … … 73 99 } 74 100 101 /** 102 * Update the options 103 */ 75 104 function update_options() { 76 105 return update_option ( $this->option_ns, $this->options ); … … 78 107 79 108 //--------------------------------------------- 80 // Editez à partir d'ici109 // Please edit this file from here 81 110 //--------------------------------------------- 82 111 83 112 113 /** 114 * Method launched when we install the plugin 115 * @return unknown_type 116 */ 84 117 function install() { 85 // Fonction permettant l'installation de votre plugin (création de tables, de paramètres...)86 118 $this->set ( 'install', $this->version ); 87 119 $this->set ( 'page', 0 ); … … 94 126 */ 95 127 private function configure() { 96 echo "<h1>Comment Contest - Configurations du tirage au sort</h1> 128 $configureContest = __("Configure the contest", $this->localizationName); 129 $winnersNumber = __("Winners' number", $this->localizationName); 130 $participationsNumber = __("Maximum participations' number per person", $this->localizationName); 131 $allowedRanks = __("Allowed ranks to participate", $this->localizationName); 132 $administrator = __("Administrator", $this->localizationName); 133 $editor = __("Editor", $this->localizationName); 134 $author = __("Author", $this->localizationName); 135 $contributor = __("Contributor", $this->localizationName); 136 $subscriber = __("Subscriber", $this->localizationName); 137 $user = __("Normal user", $this->localizationName); 138 $ok = __("Ok!", $this->localizationName); 139 140 echo "<h1>Comment Contest - $configureContest</h1> 97 141 <form action='plugins.php?page=comment-contest.php' method='post'> 98 Nombre de gagnants: <input type='text' name='winners' value='2' /><br />99 Nombre maximum de participations par personne: <input type='text' name='number' value='1' /><br />142 $winnersNumber: <input type='text' name='winners' value='2' /><br /> 143 $participationsNumber: <input type='text' name='number' value='1' /><br /> 100 144 <table> 101 145 <tr style='vertical-align: top'> 102 <td> Rangs autorisés pour participation:</td>146 <td>$allowedRanks:</td> 103 147 <td> 104 <input type='checkbox' name='rank[]' value='10' /> Administrateur<br />105 <input type='checkbox' name='rank[]' value='7' /> Éditeur<br />106 <input type='checkbox' name='rank[]' value='2' /> Auteur<br />107 <input type='checkbox' name='rank[]' value='1' /> Contributeur<br />108 <input type='checkbox' name='rank[]' value='0' /> Abonné<br />109 <input type='checkbox' name='rank[]' value='-1' checked='checked' /> Utilisateur normal148 <input type='checkbox' name='rank[]' value='10' /> $administrator<br /> 149 <input type='checkbox' name='rank[]' value='7' /> $editor<br /> 150 <input type='checkbox' name='rank[]' value='2' /> $author<br /> 151 <input type='checkbox' name='rank[]' value='1' /> $contributor<br /> 152 <input type='checkbox' name='rank[]' value='0' /> $subscriber<br /> 153 <input type='checkbox' name='rank[]' value='-1' checked='checked' /> $user 110 154 </td> 111 155 </tr> 112 156 </table> 113 <br /><input type='submit' name='features' value=' Ok !' /></form>";157 <br /><input type='submit' name='features' value='$ok' /></form>"; 114 158 } 115 159 … … 125 169 global $wpdb; 126 170 $maxArticles = 20; 127 echo '<h1>Comment Contest - Choisir un article</h1><form id="postForm" action="plugins.php?page=comment-contest.php" method="post">'; 171 172 $choosePost = __("Choose a post", $this->localizationName); 173 $more = __("More...", $this->localizationName); 174 $noPost = __("No post found!", $this->localizationName); 175 176 echo "<h1>Comment Contest - $choosePost</h1><form id='postForm' action='plugins.php?page=comment-contest.php' method='post'>"; 128 177 $query = "SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_type='post' ORDER BY post_date DESC"; 129 178 $posts = $wpdb->get_results ( $query ); … … 140 189 <input type='hidden' name='postnumber' id='postnumber' value='' /></form>"; 141 190 if (count ( $posts ) > $maxArticles) { 142 echo "<br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php&pagepost=" . ($currentPage + $maxArticles) . "'> Plus...</a>";191 echo "<br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php&pagepost=" . ($currentPage + $maxArticles) . "'>$more</a>"; 143 192 } 144 193 } else { 145 $this->error ( "Aucun article !", array ("home") );194 $this->error ( $noPost, array ("home") ); 146 195 } 147 196 } … … 158 207 global $wpdb; 159 208 160 echo "<h1>Comment Contest - Choisir les commentaires à inclure dans le concours</h1>"; 209 $chooseComments = __("Choose comments to include in the contest", $this->localizationName); 210 $launchContest = __("Launch the contest", $this->localizationName); 211 $noComment = __("No comment found!", $this->localizationName); 212 213 echo "<h1>Comment Contest - $chooseComments</h1>"; 161 214 162 215 $filter = null; … … 213 266 <input type='hidden' name='numWinners' value='$numWinners' /> 214 267 <input type='hidden' name='numParticipation' value='$numParticipation' /> 215 <input type='submit' value=' Lancer le tirage au sort' /></form>";268 <input type='submit' value='$launchContest' /></form>"; 216 269 } else { 217 $this->error ( "Aucun commentaire !", array ("home") );270 $this->error ( $noComment, array ("home") ); 218 271 } 219 272 } … … 229 282 global $wpdb; 230 283 284 $winners = __("Winners", $this->localizationName); 285 $commentWord = __("Comment", $this->localizationName); 286 $say = __("says", $this->localizationName); 287 231 288 $tab = null; 232 289 foreach ( $comments as $comment => $value ) { … … 235 292 236 293 shuffle ( $tab ); 237 echo "<h1>Comment Contest - Les gagnants</h1>";294 echo "<h1>Comment Contest - $winners</h1>"; 238 295 $stop = false; 239 296 $i = 1; … … 248 305 $i ++; 249 306 $author = $from; 250 echo "<strong> Commentaire de</strong> $from <strong>avec</strong> $c->comment_content <br /><br />";307 echo "<strong>$commentWord</strong> $from <strong>$say</strong> $c->comment_content <br /><br />"; 251 308 } 252 309 … … 265 322 $url = get_bloginfo ( 'url' ); 266 323 if ($args [0] == 'post') { 324 $chooseComment = __("Choose comments", $this->localizationName); 325 267 326 die ( "$message<br /><br /> 268 327 <form action='plugins.php?page=comment-contest.php' method='post'> … … 271 330 <input type='hidden' name='numWinners' value='$args[3]' /> 272 331 <input type='hidden' name='numParticipation' value='$args[4]' /> 273 <input type='submit' value=' Rechoisir les commentaires' /></form>" );332 <input type='submit' value='$chooseComment' /></form>" ); 274 333 } elseif ($args [0] == 'home') { 275 die ( "$message<br /><br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php'>Retour au début</a>" ); 276 } 277 } 278 334 $back = __("Back", $this->localizationName); 335 336 die ( "$message<br /><br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php'>$back</a>" ); 337 } 338 } 339 340 /** 341 * The page to display in the administration menu 342 */ 279 343 function AdminHelpPage() { 280 344 if (isset ( $_POST ['postnumber'] )) { // Step 3 : Choose comments … … 284 348 285 349 if ($comments == null || count ( $comments ) == 0) { 286 $this->error ( "Veuillez sélectionner au moins un gagnant !", array ("post", $_POST ['post'], $_POST ['rank'], $_POST ['numWinners'], $_POST ['numParticipation'] ) ); 350 $selectOneWinner = __("Please select one winner at least!", $this->localizationName); 351 $this->error ( $selectOneWinner, array ("post", $_POST ['post'], $_POST ['rank'], $_POST ['numWinners'], $_POST ['numParticipation'] ) ); 287 352 } elseif (count ( $comments ) <= $_POST ['numWinners']) { 288 $this->error ( "Veuillez sélectionner plus de participants que de gagnants !", array ("post", $_POST ['post'], $_POST ['rank'], $_POST ['numWinners'], $_POST ['numParticipation'] ) ); 353 $selectMoreWinner = __("Please select more participants than winners!", $this->localizationName); 354 $this->error ( $selectMoreWinner, array ("post", $_POST ['post'], $_POST ['rank'], $_POST ['numWinners'], $_POST ['numParticipation'] ) ); 289 355 } else { 290 356 $this->displayWinners ( $comments, $_POST ['numWinners'], $_POST ['numParticipation'] ); … … 299 365 $numParticipation = intval ( $_POST ['number'] ); 300 366 if (count ( $_POST ['rank'] ) == 0) { 301 $this->error ( "Veuillez sélectionner au moins un rang !", array ("home" ) ); 367 $selectOneRank = __("Please select one rank at least!", $this->localizationName); 368 $this->error ( $selectOneRank, array ("home" ) ); 302 369 } elseif ($numWinners == null || $numWinners <= 0) { 303 $this->error ( "Veuillez spécifier un nombre correct de gagnants !", array ("home" ) ); 370 $winnerFormat = __("Wrong winners format!", $this->localizationName); 371 $this->error ( $winnerFormat, array ("home" ) ); 304 372 } elseif ($numParticipation == null || $numParticipation <= 0) { 305 $this->error ( "Veuillez spécifier un nombre correct de participations !", array ("home" ) ); 373 $participationsFormat = __("Wrong participations format!", $this->localizationName); 374 $this->error ( $participationsFormat, array ("home" ) ); 306 375 } else { 307 376 $this->choosePost ( $page, implode ( ",", $_POST ['rank'] ), $numWinners, $numParticipation ); … … 312 381 } 313 382 314 function action_wp_title($titre) { 315 return $titre; 383 /** 384 * Change the website's title 385 * @param $title The new title 386 */ 387 function action_wp_title($title) { 388 return $title; 316 389 } 317 390 318 391 //--------------------------------------------- 319 // Fin de la partie d'édition392 // Stop edit from here 320 393 //--------------------------------------------- 321 394 -
comment-contest/trunk/readme.txt
r151444 r151977 26 26 27 27 == Screenshots == 28 screenshot1.png The first page of the plugin : set the contest's features 28 1. The first page of the plugin : set the contest's features 29 2. Choose the article in which the contest is running 30 3. Choose the comments 31 4. The winners are displayed 29 32 30 33 == Changelog == … … 33 36 * Release version 34 37 * Only French language is available 38 39 = 1.1 = 40 * Translation in English and French 41 * Comments are included in the source code 42 * Screenshots are available in the install
Note: See TracChangeset
for help on using the changeset viewer.