http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72093

Revision: 72093
Author:   nikerabbit
Date:     2010-09-01 09:31:30 +0000 (Wed, 01 Sep 2010)

Log Message:
-----------
Docu updates

Modified Paths:
--------------
    trunk/extensions/Translate/Translate.php
    trunk/extensions/Translate/utils/HTMLJsSelectToInputField.php
    trunk/extensions/Translate/utils/JsSelectToInput.php

Modified: trunk/extensions/Translate/Translate.php
===================================================================
--- trunk/extensions/Translate/Translate.php    2010-09-01 09:14:36 UTC (rev 
72092)
+++ trunk/extensions/Translate/Translate.php    2010-09-01 09:31:30 UTC (rev 
72093)
@@ -417,6 +417,8 @@
 
 /**
  * Initialises the extension.
+ * Does late-initialization that is not possible at file level,
+ * because it depends on user configuration.
  * @private
  */
 function efTranslateInit() {
@@ -429,32 +431,22 @@
        global $wgReservedUsernames, $wgTranslateFuzzyBotName;
        $wgReservedUsernames[] = $wgTranslateFuzzyBotName;
 
-       /**
-        * Hook for database schema.
-        */
+       // Hook for database schema.
        $wgHooks['LoadExtensionSchemaUpdates'][] = 
'PageTranslationHooks::schemaUpdates';
 
-       /**
-        * Do not activate hooks if not setup properly
-        */
+       // Do not activate hooks if not setup properly
        global $wgEnablePageTranslation;
        if ( !efTranslateCheckPT() ) {
                $wgEnablePageTranslation = false;
                return true;
        }
 
-       /**
-        * Fuzzy tags for speed.
-        */
+       // Fuzzy tags for speed.
        $wgHooks['ArticleSaveComplete'][] = 'TranslateEditAddons::onSave';
 
-       /**
-        * Page translation setup check and init if enabled.
-        */
+       // Page translation setup check and init if enabled.
        if ( $wgEnablePageTranslation ) {
-               /**
-                * Special page and the right to use it
-                */
+               // Special page and the right to use it
                global $wgSpecialPages, $wgAvailableRights;
                $wgSpecialPages['PageTranslation'] = 'SpecialPageTranslation';
                $wgSpecialPageGroups['PageTranslation'] = 'pagetools';
@@ -491,24 +483,16 @@
                $wgNamespacesWithSubpages[NS_TRANSLATIONS]      = true;
                $wgNamespacesWithSubpages[NS_TRANSLATIONS_TALK] = true;
 
-               /**
-                * Standard protection and register it for filtering
-                */
+               // Standard protection and register it for filtering
                $wgNamespaceProtection[NS_TRANSLATIONS] = array( 'translate' );
                $wgTranslateMessageNamespaces[] = NS_TRANSLATIONS;
 
-               /**
-                * Page translation hooks
-                */
+               /// Page translation hooks
 
-               /**
-                * Register our css, is there a better place for this?
-                */
+               /// @todo Register our css, is there a better place for this?
                $wgHooks['OutputPageBeforeHTML'][] = 
'PageTranslationHooks::injectCss';
 
-               /**
-                * Add transver tags and update translation target pages
-                */
+               // Add transver tags and update translation target pages
                $wgHooks['ArticleSaveComplete'][] = 
'PageTranslationHooks::onSectionSave';
 
                /**
@@ -516,51 +500,38 @@
                 */
                # $wgHooks['SkinTemplateOutputPageBeforeExec'][] = 
'TranslateTagHooks::addSidebar';
 
-               /**
-                * Register \<languages/>
-                */
+               // Register \<languages/>
                $wgHooks['ParserFirstCallInit'][] = 'efTranslateInitTags';
 
-               /**
-                * Strip \<translate> tags etc. from source pages when rendering
-                */
+               // Strip \<translate> tags etc. from source pages when rendering
                $wgHooks['ParserBeforeStrip'][] = 
'PageTranslationHooks::renderTagPage';
 
-               /**
-                * Check syntax for \<translate>
-                */
+               // Check syntax for \<translate>
                $wgHooks['ArticleSave'][] = 
'PageTranslationHooks::tpSyntaxCheck';
                $wgHooks['EditFilterMerged'][] = 
'PageTranslationHooks::tpSyntaxCheckForEditPage';
 
-               /**
-                * Add transtag to page props for discovery
-                */
+               // Add transtag to page props for discovery
                $wgHooks['ArticleSaveComplete'][] = 
'PageTranslationHooks::addTranstag';
 
-               /**
-                * Prevent editing of unknown pages in Translations namespace
-                */
+               // Prevent editing of unknown pages in Translations namespace
                $wgHooks['getUserPermissionsErrorsExpensive'][] = 
'PageTranslationHooks::translationsCheck';
 
-               /**
-                * Locking during page moves
-                */
+               // Locking during page moves
                $wgHooks['getUserPermissionsErrorsExpensive'][] = 
'PageTranslationHooks::lockedPagesCheck';
 
+               // Our custom header for translation pages
                $wgHooks['ArticleViewHeader'][] = 'PageTranslationHooks::test';
 
+               // Our tables are needed for parser tests
                $wgHooks['ParserTestTables'][] = 
'PageTranslationHooks::parserTestTables';
 
+               // The unuseful export all translations item in the toolbox
                $wgHooks['SkinTemplateToolboxEnd'][] = 
'PageTranslationHooks::exportToolbox';
 
-               /**
-                * Prevent section pages appearing in categories
-                */
+               // Prevent section pages appearing in categories
                $wgHooks['LinksUpdate'][] = 
'PageTranslationHooks::preventCategorization';
 
-               /**
-                * Custom move page that can move all the associated pages too
-                */
+               // Custom move page that can move all the associated pages too
                $wgHooks['SpecialPage_initList'][] = 
'PageTranslationHooks::replaceMovePage';
        }
 }
@@ -588,6 +559,7 @@
 
        /** Add our tags if they are not registered yet
         *  tp:tag is called also the ready tag
+        * @todo Remove useless complication that is revtag_type table.
         */
        $tags = array( 'tp:mark', 'tp:tag', 'tp:transver', 'fuzzy' );
 
@@ -598,9 +570,7 @@
        }
 
        foreach ( $tags as $tag ) {
-               /**
-                * @todo: use insert ignore
-                */
+               /// @todo: use insert ignore
                $field = array( 'rtt_name' => $tag );
                $ret = $dbw->selectField( 'revtag_type', 'rtt_name', $field, 
__METHOD__ );
 
@@ -635,7 +605,7 @@
  * @return \bool true
  */
 function efTranslateInitTags( $parser ) {
-        // For nice language list in-page
+       // For nice language list in-page
        $parser->setHook( 'languages', array( 'PageTranslationHooks', 
'languages' ) );
        return true;
 }

Modified: trunk/extensions/Translate/utils/HTMLJsSelectToInputField.php
===================================================================
--- trunk/extensions/Translate/utils/HTMLJsSelectToInputField.php       
2010-09-01 09:14:36 UTC (rev 72092)
+++ trunk/extensions/Translate/utils/HTMLJsSelectToInputField.php       
2010-09-01 09:31:30 UTC (rev 72093)
@@ -1,11 +1,14 @@
 <?php
 /**
- * @todo Needs documentation.
+ * Implementation of JsSelectToInput class which is compatible with 
MediaWiki's preferences system.
  * @file
+ * @author Niklas Laxström
+ * @copyright Copyright © 2010 Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
  */
 
 /**
- * @todo Needs documentation.
+* Implementation of JsSelectToInput class which is extends HTMLTextField.
  */
 class HTMLJsSelectToInputField extends HTMLTextField {
        function getInputHTML( $value ) {
@@ -54,7 +57,6 @@
 
        function filter( $value, $alldata ) {
                $value = parent::filter( $value, $alldata );
-
                return implode( ', ', $this->tidy( $value ) );
        }
 }

Modified: trunk/extensions/Translate/utils/JsSelectToInput.php
===================================================================
--- trunk/extensions/Translate/utils/JsSelectToInput.php        2010-09-01 
09:14:36 UTC (rev 72092)
+++ trunk/extensions/Translate/utils/JsSelectToInput.php        2010-09-01 
09:31:30 UTC (rev 72093)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @todo Needs documentation.
+ * Code for JavaScript enhanced \<option> selectors.
  * @file
  * @author Niklas Laxström
  * @copyright Copyright © 2010 Niklas Laxström
@@ -8,42 +8,68 @@
  */
 
 /**
- * @todo Needs documentation.
+ * Code for JavaScript enhanced \<option> selectors.
  */
 class JsSelectToInput {
-       protected $targetId, $sourceId;
+       /// Id of the text field where stuff is appended
+       protected $targetId
+       /// Id of the \<option> field
+       protected $sourceId;
+       /// XmlSelect
        protected $select;
+       /// Id on the button
        protected $buttonId;
+       /// Text for the append button
        protected $msg = 'translate-jssti-add';
 
+       /// Constructor
        public function __construct( XmlSelect $select = null ) {
                $this->select = $select;
        }
 
+       /**
+        * Set the source id of the selector
+        * @param $id \string
+        */
        public function setSourceId( $id ) {
                $this->sourceId = $id;
        }
 
+       /// @return \string
        public function getSourceId() {
                return $this->sourceId;
        }
 
+       /**
+        * Set the id of the target text field
+        * @param $id \string
+        */
        public function setTargetId( $id ) {
                $this->targetId = $id;
        }
 
+       /// @return \string
        public function getTargetId() {
                return $this->targetId;
        }
 
+       /**
+        * Set the message key.
+        * @param $message \string
+        */
        public function setMessage( $message ) {
                $this->msg = $message;
        }
 
+       /// @return \string Message key.
        public function getMessage() {
                return $this->msg;
        }
 
+       /**
+        * Returns the whole input element and injects needed JavaScript
+        * @return \string Html code.
+        */
        public function getHtmlAndPrepareJS() {
                if ( $this->sourceId === false ) {
                        if ( is_callable( array( $select, 'getAttribute' ) ) ) {
@@ -62,6 +88,12 @@
                return $html;
        }
 
+       /**
+        * Constructs the append button.
+        * @param $msg \string Message key.
+        * @param $source \string Html id.
+        * @param $target \string Html id.
+        */
        protected function getButton( $msg, $source, $target ) {
                $source = Xml::escapeJsString( $source );
                $target = Xml::escapeJsString( $target );
@@ -74,15 +106,12 @@
                return $html;
        }
 
+       /// Inject needed JavaScript in the page.
        public static function injectJs() {
                static $done = false;
+               if ( $done ) return;
 
-               if ( $done ) {
-                       return;
-               }
-
                global $wgOut;
-
                $wgOut->addScriptFile( TranslateUtils::assetPath( 
'utils/JsSelectToInput.js' ) );
        }
 }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to