Revision: 50750
Author:   siebrand
Date:     2009-05-18 20:27:13 +0000 (Mon, 18 May 2009)

Log Message:
-----------
* add right- messages
* make array of 'author' in extension credits
* remove trailing whitespace, update indentation, stylize.php
* bump version

Modified Paths:
--------------
    trunk/extensions/Todo/SpecialTodo.i18n.php
    trunk/extensions/Todo/SpecialTodo.php
    trunk/extensions/Todo/TodoForm.php

Modified: trunk/extensions/Todo/SpecialTodo.i18n.php
===================================================================
--- trunk/extensions/Todo/SpecialTodo.i18n.php  2009-05-18 20:21:12 UTC (rev 
50749)
+++ trunk/extensions/Todo/SpecialTodo.i18n.php  2009-05-18 20:27:13 UTC (rev 
50750)
@@ -36,8 +36,10 @@
        'todo-new-item'         => 'New item',
        'todo-issue-summary'    => 'Issue summary:',
        'todo-form-details'     => 'Details:',
-       'todo-form-email'       => 'To receive notification by e-mail when the 
item is closed, type your address here:',
+       'todo-form-email'       => 'To receive notification by e-mail when the 
item is closed, provide your address:',
        'todo-form-submit'      => 'Submit query',
+       'right-todo'            => 'Have todo list',
+       'right-todosubmit'      => 'Restrict user\'s todo list right',
 );
 
 /** Message documentation (Message documentation)

Modified: trunk/extensions/Todo/SpecialTodo.php
===================================================================
--- trunk/extensions/Todo/SpecialTodo.php       2009-05-18 20:21:12 UTC (rev 
50749)
+++ trunk/extensions/Todo/SpecialTodo.php       2009-05-18 20:27:13 UTC (rev 
50750)
@@ -1,5 +1,4 @@
 <?php
-
 /*
 CREATE TABLE todolist (
 todo_id INT AUTO_INCREMENT,
@@ -20,17 +19,17 @@
 $wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'Todo',
-       'version' => '0.2',
+       'version' => '0.3',
        'url' => 'http://www.mediawiki.org/wiki/Extension:Todo',
        'description' => 'Experimental personal todo list extension',
-       'author' => 'Brion Vibber, Bertrand Grondin',
+       'author' => array( 'Brion Vibber', 'Bertrand Grondin' ),
        'descriptionmsg' => 'todo-desc',
 );
 
 $wgExtensionFunctions[] = 'todoSetup';
 $wgHooks['SkinTemplateTabs'][] = 'todoAddTab';
 
-$dir = dirname(__FILE__) . '/';
+$dir = dirname( __FILE__ ) . '/';
 $wgExtensionMessagesFiles['todoAddTab'] = $dir . 'SpecialTodo.i18n.php';
 
 // Creates a group of users who can have todo lists
@@ -43,11 +42,13 @@
 $wgAvailableRights[] = 'todo';
 $wgAvailableRights[] = 'todosubmit';
 
+// FIXME: use $wgSpecialPages and delay message loading
 function todoSetup() {
        wfLoadExtensionMessages( 'todoAddTab' );
        SpecialPage::addPage( new SpecialPage( 'Todo' ) );
 }
 
+// FIXME: use class file(s) to delay loading
 /**
  * Add a 'todo' tab on user pages
  * @param SkinTemplate $skin
@@ -56,10 +57,10 @@
  */
 function todoAddTab( &$skin, &$actions ) {
        global $wgTitle;
-       if( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == 
NS_USER_TALK ) {
+       if ( $wgTitle->getNamespace() == NS_USER || $wgTitle->getNamespace() == 
NS_USER_TALK ) {
                $title = Title::makeTitle( NS_SPECIAL, 'Todo/' . 
$wgTitle->getText() );
                $actions['todo'] = array(
-                       'text' => wfMsg('todo-tab'),
+                       'text' => wfMsg( 'todo-tab' ),
                        'href' => $title->getLocalUrl() );
        }
        return true;
@@ -69,20 +70,20 @@
  * Entry-point function for Special:Todo
  * @param mixed $par Will contain username to view on
  */
-function wfSpecialTodo( $par=null ) {
-       if( is_null( $par ) || $par == '' ) {
+function wfSpecialTodo( $par = null ) {
+       if ( is_null( $par ) || $par == '' ) {
                global $wgUser;
                $user = $wgUser;
        } else {
                $user = User::newFromName( $par );
        }
-       if( is_null( $user ) || !$user->isAllowed( 'todo' ) ) {
+       if ( is_null( $user ) || !$user->isAllowed( 'todo' ) ) {
                global $wgOut;
-               $wgOut->fatalError( wfMsgHtml('todo-user-invalide') );
+               $wgOut->fatalError( wfMsgHtml( 'todo-user-invalide' ) );
        } else {
                global $wgRequest;
                $todo = new TodoForm( $user );
-               if( $wgRequest->wasPosted() ) {
+               if ( $wgRequest->wasPosted() ) {
                        $todo->submit( $wgRequest );
                } else {
                        $todo->show();
@@ -97,9 +98,9 @@
        }
 
        function submit( $request ) {
-               if( $request->getVal( 'wpNewItem' ) ) {
+               if ( $request->getVal( 'wpNewItem' ) ) {
                        $this->submitNew( $request );
-               } elseif( $request->getVal( 'wpUpdateField' ) ) {
+               } elseif ( $request->getVal( 'wpUpdateField' ) ) {
                        $this->submitUpdate( $request );
                }
                $this->showError( $result );
@@ -118,13 +119,13 @@
        function submitUpdate( $request ) {
                $id = $request->getInt( 'wpItem' );
                $item = TodoItem::loadFromId( $id );
-               if( is_null( $item ) ) {
-                       return new WikiError( wfMsgHtml('todo-invalid-item') );
+               if ( is_null( $item ) ) {
+                       return new WikiError( wfMsgHtml( 'todo-invalid-item' ) 
);
                }
 
                global $wgUser;
-               if( $item->owner != $wgUser->getId() ) {
-                       return new WikiError( 
wfMsgHtml('todo-update-else-item') );
+               if ( $item->owner != $wgUser->getId() ) {
+                       return new WikiError( wfMsgHtml( 
'todo-update-else-item' ) );
                }
 
                switch( $request->getVal( 'wpUpdateField' ) ) {
@@ -144,19 +145,19 @@
 
        function show() {
                global $wgOut, $IP, $wgUser, $wgScriptPath;
-               $wgOut->setPageTitle( wfMsgHtml('todo-list-for', 
$this->target->getName() ) );
+               $wgOut->setPageTitle( wfMsgHtml( 'todo-list-for', 
$this->target->getName() ) );
 
 
-               $wgOut->addWikiText( "== ".wfMsg('todo-new-item')." ==\n" );
+               $wgOut->addWikiText( "== " . wfMsg( 'todo-new-item' ) . " ==\n" 
);
 
-               require_once ('TodoForm.php');
+               require_once ( 'TodoForm.php' );
                $form = new TodoTemplate();
                $form->set( 'action', $this->self->getLocalUrl( 'action=submit' 
) );
                $form->set( 'script', "$wgScriptPath/extensions/Todo/todo.js" );
                $wgOut->addTemplate( $form );
 
-               if( $wgUser->getName() == $this->target->getName() ) {
-                       $wgOut->addWikiText( "== ". wfMsg('todo-item-list') ." 
==\n" );
+               if ( $wgUser->getName() == $this->target->getName() ) {
+                       $wgOut->addWikiText( "== " . wfMsg( 'todo-item-list' ) 
. " ==\n" );
                        $list = new TodoList( $this->target );
                        $list->show();
                }
@@ -164,7 +165,7 @@
 
        function showError( $result ) {
                global $wgOut;
-               if( WikiError::isError( $result ) ) {
+               if ( WikiError::isError( $result ) ) {
                        $wgOut->addHTML( '<p class="error">' .
                                htmlspecialcahrs( $result->getMessage() ) .
                                "</p>\n" );
@@ -190,7 +191,7 @@
                        array( 'ORDER BY' => 
'todo_owner,todo_status,todo_queue,todo_timestamp DESC' ) );
 
                $this->items = array();
-               while( $row = $dbr->fetchObject( $result ) ) {
+               while ( $row = $dbr->fetchObject( $result ) ) {
                        $item = new TodoItem( $row );
                        $this->items[$item->queue][] = $item;
                }
@@ -203,18 +204,18 @@
                $queues = array_keys( $this->items );
                usort( $queues, array( 'TodoList', 'queueSort' ) );
 
-               if( count( $queues ) == 0 ) {
-                       $wgOut->addWikiText( wfMsg('todo-no-item'));
+               if ( count( $queues ) == 0 ) {
+                       $wgOut->addWikiText( wfMsg( 'todo-no-item' ) );
                        return;
                }
 
                $wgOut->addHTML( "<table>\n<tr>" );
-               foreach( $queues as $queue ) {
+               foreach ( $queues as $queue ) {
                        $wgOut->addHTML( Xml::element( 'th', null, $queue ) );
                }
                $wgOut->addHTML( "</tr>\n<tr>\n" );
 
-               foreach( $queues as $queue ) {
+               foreach ( $queues as $queue ) {
                        $wgOut->addHTML( "<td valign='top'>\n<table 
border='1'>\n" );
                        $this->showQueue( $queue, $queues );
                        $wgOut->addHTML( "</table>\n</td>\n" );
@@ -231,13 +232,13 @@
         */
        function queueSort( $a, $b ) {
                $new = wfMsgForContent( 'todo-new-queue' );
-               if( $a == $b ) {
+               if ( $a == $b ) {
                        return 0;
                }
-               if( $a == $new ) {
-                       return -1;
+               if ( $a == $new ) {
+                       return - 1;
                }
-               if( $b == $new ) {
+               if ( $b == $new ) {
                        return 1;
                }
                return strcmp( $a, $b );
@@ -245,7 +246,7 @@
 
        function showQueue( $queue, $queues ) {
                global $wgOut;
-               foreach( $this->items[$queue] as $item ) {
+               foreach ( $this->items[$queue] as $item ) {
                        $wgOut->addHTML( "<tr><td><div>" );
                        $item->show( $queues );
                        $wgOut->addHTML( "</div></td></tr>\n" );
@@ -275,7 +276,7 @@
                        '*',
                        array( 'todo_id' => intval( $id ) ),
                        'TodoForm::loadFromId' );
-               if( $row ) {
+               if ( $row ) {
                        return new TodoItem( $row );
                } else {
                        return null;
@@ -359,11 +360,11 @@
                        "<br />\n" .
                        Xml::element( 'input', array(
                                'type' => 'submit',
-                               'value' => wfMsg('todo-list-change') ) ) .
+                               'value' => wfMsg( 'todo-list-change' ) ) ) .
                        " " .
                        Xml::element( 'input', array(
                                'type' => 'button',
-                               'value' => wfMsg('todo-list-cancel'),
+                               'value' => wfMsg( 'todo-list-cancel' ),
                                'onclick' => "todoEdit{$capField}($id,false)" ) 
) .
                        "</form></div>\n";
        }
@@ -388,18 +389,18 @@
 
        function buildMoveSelector( $queues ) {
                $out = "<select name='wpQueue' id='mwTodoQueue" . $this->id . 
"' onchange='todoMoveQueue(" . $this->id . ")'>";
-               foreach( $queues as $queue ) {
-                       if( $queue == $this->queue ) {
+               foreach ( $queues as $queue ) {
+                       if ( $queue == $this->queue ) {
                                $out .= Xml::element( 'option',
                                        array( 'value' => '', 'selected' => 
'selected' ),
-                                       wfMsgHtml('todo-move-queue') );
+                                       wfMsgHtml( 'todo-move-queue' ) );
                        } else {
                                $out .= Xml::element( 'option',
                                        array( 'value' => $queue ),
                                        $queue );
                        }
                }
-               $out .= "<option value='+' 
/>".wfMsgHtml('todo-add-queue')."</option>\n";
+               $out .= "<option value='+' />" . wfMsgHtml( 'todo-add-queue' ) 
. "</option>\n";
                $out .= "</select>";
                return $out;
        }
@@ -435,7 +436,7 @@
        function close( $comment, $sendMail ) {
                $this->status = 'closed';
                $this->updateRecord( array( 'todo_status' => 'closed' ) );
-               if( $sendMail && $this->email ) {
+               if ( $sendMail && $this->email ) {
                        $this->sendConfirmationMail( $comment );
                }
        }
@@ -449,8 +450,8 @@
                global $wgContLang;
 
                $owner = User::newFromId( $this->owner );
-               if( is_null( $owner ) ) {
-                       return new WikiError( wfMsgHtml('todo-invalid-owner') );
+               if ( is_null( $owner ) ) {
+                       return new WikiError( wfMsgHtml( 'todo-invalid-owner' ) 
);
                }
 
                $sender = new MailAddress( $owner );

Modified: trunk/extensions/Todo/TodoForm.php
===================================================================
--- trunk/extensions/Todo/TodoForm.php  2009-05-18 20:21:12 UTC (rev 50749)
+++ trunk/extensions/Todo/TodoForm.php  2009-05-18 20:27:13 UTC (rev 50750)
@@ -1,16 +1,16 @@
 <?php
 
-if( !defined( 'MEDIAWIKI' ) )
+if ( !defined( 'MEDIAWIKI' ) )
        die();
 
 class TodoTemplate extends QuickTemplate {
        function execute() {
        global $wgOut, $tododetail, $todosummary, $todoemail, $todosubmit;
-       $todosummary = wfMsg('todo-issue-summary');
-       $tododetail=wfMsg('todo-form-details');
-       $todoemail=wfMsg('todo-form-email');
-       $todosubmit=wfMsg('todo-form-submit');
-       $wgOut->addHTML("
+       $todosummary = wfMsg( 'todo-issue-summary' );
+       $tododetail = wfMsg( 'todo-form-details' );
+       $todoemail = wfMsg( 'todo-form-email' );
+       $todosubmit = wfMsg( 'todo-form-submit' );
+       $wgOut->addHTML( "
 <style type=\"text/css\">
 .mwTodoNewForm {
        border: solid 1px #ccc;
@@ -22,15 +22,15 @@
 .mwTodoTitle {
        font-weight: bold;
 }
-</style>");
+</style>" );
 ?>
-<script type="text/javascript" src="<?php $this->text('script') ?>"></script>
+<script type="text/javascript" src="<?php $this->text( 'script' ) ?>"></script>
 
-<form action="<?php $this->text('action') ?>" method="post">
+<form action="<?php $this->text( 'action' ) ?>" method="post">
        <input type="hidden" name="wpNewItem" value="1" />
                <p>
 <?php
-$wgOut->addHTML("
+$wgOut->addHTML( "
                <div class=\"mwTodoNewForm\">
                        <label for=\"wpSummary\">{$todosummary}</label>
                        <br />



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to