Plugin Directory

Changeset 151977


Ignore:
Timestamp:
09/04/2009 01:45:29 PM (17 years ago)
Author:
zhykos
Message:

Version 1.1.
Add French and English translations.
Add screenshots for the install.

Location:
comment-contest/trunk
Files:
10 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • comment-contest/trunk/comment-contest.php

    r151444 r151977  
    22/*
    33Plugin Name: Comment Contest
    4 Plugin URI: http://www.nozzhy.com
     4Plugin URI: http://www.nozzhy.com/un-plugin-pour-gerer-un-concours-par-commentaires-sur-votre-blog/
    55Description: If you create a contest on your website, you can draw all comments in a specific post (only in French for now)
    66Author: Thomas "Zhykos" Cicognani
    7 Version: 1.0
     7Version: 1.1
    88Author URI: http://www.nozzhy.com
    99*/
     
    1616class CommentContest {
    1717    var $domain = '';
    18     var $version = '1.0'; //Changer pour correspondre à la version courante
     18    var $version = '1.1'; // Current version
    1919    var $option_ns = '';
    2020    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;
    2631        if (! $num) {
    2732            $fonction .= $num;
    2833        }
    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     */
    3240    function CommentContest() {
    33         // Initialisation des variables
     41        // Initialization
    3442        if ($this->domain == '')
    3543            $this->domain = get_class ( $this );
     44       
    3645        if ($this->option_ns == '')
    3746            $this->option_ns = get_class ( $this );
    38             // Récupération des options
     47           
     48        // Get options
    3949        $this->options = get_option ( $this->option_ns );
    4050       
    41         // Doit-on lancer l'installation ?
     51        // Launch the install?
    4252        if (! isset ( $this->options ['install'] ) or ($this->options ['install'] != $this->version))
    4353            $this->install ();
    4454           
    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
    4961        foreach ( get_class_methods ( get_class ( $this ) ) as $methode ) {
    5062            if (substr ( $methode, 0, 7 ) == 'action_') {
     
    5567    }
    5668   
     69    /**
     70     * Things to do in the administration menu<br />
     71     * Here we add "Comment Contest" in the plugin menu
     72     */
    5773    function action_admin_menu() {
    5874        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     */
    6384    function set($option, $value) {
    6485        $this->options [$option] = $value;
    6586    }
    6687   
     88    /**
     89     * Get the option's value
     90     * @param $option The option we want to get
     91     * @return The option's value
     92     */
    6793    function get($option) {
    6894        if (isset ( $this->options [$option] )) {
     
    7399    }
    74100   
     101    /**
     102     * Update the options
     103     */
    75104    function update_options() {
    76105        return update_option ( $this->option_ns, $this->options );
     
    78107   
    79108    //---------------------------------------------
    80     // Editez à partir d'ici
     109    // Please edit this file from here
    81110    //---------------------------------------------
    82111   
    83112
     113    /**
     114     * Method launched when we install the plugin
     115     * @return unknown_type
     116     */
    84117    function install() {
    85         // Fonction permettant l'installation de votre plugin (création de tables, de paramètres...)
    86118        $this->set ( 'install', $this->version );
    87119        $this->set ( 'page', 0 );
     
    94126     */
    95127    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>
    97141        <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 />
    100144        <table>
    101145            <tr style='vertical-align: top'>
    102                 <td>Rangs autoris&eacute;s pour participation :</td>
     146                <td>$allowedRanks:</td>
    103147                <td>
    104                     <input type='checkbox' name='rank[]' value='10' /> Administrateur<br />
    105                     <input type='checkbox' name='rank[]' value='7' /> &Eacute;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&eacute;<br />
    109                     <input type='checkbox' name='rank[]' value='-1' checked='checked' /> Utilisateur normal
     148                    <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
    110154                </td>
    111155            </tr>
    112156        </table>
    113         <br /><input type='submit' name='features' value='Ok !' /></form>";
     157        <br /><input type='submit' name='features' value='$ok' /></form>";
    114158    }
    115159   
     
    125169        global $wpdb;
    126170        $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'>";
    128177        $query = "SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_type='post' ORDER BY post_date DESC";
    129178        $posts = $wpdb->get_results ( $query );
     
    140189            <input type='hidden' name='postnumber' id='postnumber' value='' /></form>";
    141190            if (count ( $posts ) > $maxArticles) {
    142                 echo "<br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php&amp;pagepost=" . ($currentPage + $maxArticles) . "'>Plus...</a>";
     191                echo "<br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php&amp;pagepost=" . ($currentPage + $maxArticles) . "'>$more</a>";
    143192            }
    144193        } else {
    145             $this->error ( "Aucun article !", array ("home" ) );
     194            $this->error ( $noPost, array ("home") );
    146195        }
    147196    }
     
    158207        global $wpdb;
    159208       
    160         echo "<h1>Comment Contest - Choisir les commentaires &agrave; 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>";
    161214       
    162215        $filter = null;
     
    213266            <input type='hidden' name='numWinners' value='$numWinners' />
    214267            <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>";
    216269        } else {
    217             $this->error ( "Aucun commentaire !", array ("home" ) );
     270            $this->error ( $noComment, array ("home") );
    218271        }
    219272    }
     
    229282        global $wpdb;
    230283       
     284        $winners = __("Winners", $this->localizationName);
     285        $commentWord = __("Comment", $this->localizationName);
     286        $say = __("says", $this->localizationName);
     287       
    231288        $tab = null;
    232289        foreach ( $comments as $comment => $value ) {
     
    235292       
    236293        shuffle ( $tab );
    237         echo "<h1>Comment Contest - Les gagnants</h1>";
     294        echo "<h1>Comment Contest - $winners</h1>";
    238295        $stop = false;
    239296        $i = 1;
     
    248305                $i ++;
    249306                $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 />";
    251308            }
    252309           
     
    265322        $url = get_bloginfo ( 'url' );
    266323        if ($args [0] == 'post') {
     324            $chooseComment = __("Choose comments", $this->localizationName);
     325           
    267326            die ( "$message<br /><br />
    268327            <form action='plugins.php?page=comment-contest.php' method='post'>
     
    271330            <input type='hidden' name='numWinners' value='$args[3]' />
    272331            <input type='hidden' name='numParticipation' value='$args[4]' />
    273             <input type='submit' value='Rechoisir les commentaires' /></form>" );
     332            <input type='submit' value='$chooseComment' /></form>" );
    274333        } elseif ($args [0] == 'home') {
    275             die ( "$message<br /><br /><a href='$url/wp-admin/plugins.php?page=comment-contest.php'>Retour au d&eacute;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     */
    279343    function AdminHelpPage() {
    280344        if (isset ( $_POST ['postnumber'] )) { // Step 3 : Choose comments
     
    284348           
    285349            if ($comments == null || count ( $comments ) == 0) {
    286                 $this->error ( "Veuillez s&eacute;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'] ) );
    287352            } elseif (count ( $comments ) <= $_POST ['numWinners']) {
    288                 $this->error ( "Veuillez s&eacute;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'] ) );
    289355            } else {
    290356                $this->displayWinners ( $comments, $_POST ['numWinners'], $_POST ['numParticipation'] );
     
    299365            $numParticipation = intval ( $_POST ['number'] );
    300366            if (count ( $_POST ['rank'] ) == 0) {
    301                 $this->error ( "Veuillez s&eacute;lectionner au moins un rang !", array ("home" ) );
     367                $selectOneRank = __("Please select one rank at least!", $this->localizationName);
     368                $this->error ( $selectOneRank, array ("home" ) );
    302369            } elseif ($numWinners == null || $numWinners <= 0) {
    303                 $this->error ( "Veuillez sp&eacute;cifier un nombre correct de gagnants !", array ("home" ) );
     370                $winnerFormat = __("Wrong winners format!", $this->localizationName);
     371                $this->error ( $winnerFormat, array ("home" ) );
    304372            } elseif ($numParticipation == null || $numParticipation <= 0) {
    305                 $this->error ( "Veuillez sp&eacute;cifier un nombre correct de participations !", array ("home" ) );
     373                $participationsFormat = __("Wrong participations format!", $this->localizationName);
     374                $this->error ( $participationsFormat, array ("home" ) );
    306375            } else {
    307376                $this->choosePost ( $page, implode ( ",", $_POST ['rank'] ), $numWinners, $numParticipation );
     
    312381    }
    313382   
    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;
    316389    }
    317390   
    318391//---------------------------------------------
    319 // Fin de la partie d'édition
     392// Stop edit from here
    320393//---------------------------------------------
    321394
  • comment-contest/trunk/readme.txt

    r151444 r151977  
    2626
    2727== Screenshots ==
    28 screenshot1.png The first page of the plugin : set the contest's features
     281. The first page of the plugin : set the contest's features
     292. Choose the article in which the contest is running
     303. Choose the comments
     314. The winners are displayed
    2932
    3033== Changelog ==
     
    3336* Release version
    3437* 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.