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

Revision: 72874
Author:   nikerabbit
Date:     2010-09-12 17:13:32 +0000 (Sun, 12 Sep 2010)

Log Message:
-----------
Current implementation of code browser support

Modified Paths:
--------------
    trunk/extensions/Translate/groups/StatusNet/StatusNet.yaml
    trunk/extensions/Translate/utils/TranslationHelpers.php

Modified: trunk/extensions/Translate/groups/StatusNet/StatusNet.yaml
===================================================================
--- trunk/extensions/Translate/groups/StatusNet/StatusNet.yaml  2010-09-12 
17:13:06 UTC (rev 72873)
+++ trunk/extensions/Translate/groups/StatusNet/StatusNet.yaml  2010-09-12 
17:13:32 UTC (rev 72874)
@@ -6,6 +6,7 @@
   namespace: NS_STATUSNET
   display: out/statusnet/
   class: FileBasedMessageGroup
+  codeBrowser: 
http://gitorious.org/statusnet/mainline/blobs/master/%FILE%#line%LINE%
 
 FILES:
   class: GettextFFS

Modified: trunk/extensions/Translate/utils/TranslationHelpers.php
===================================================================
--- trunk/extensions/Translate/utils/TranslationHelpers.php     2010-09-12 
17:13:06 UTC (rev 72873)
+++ trunk/extensions/Translate/utils/TranslationHelpers.php     2010-09-12 
17:13:32 UTC (rev 72874)
@@ -660,6 +660,20 @@
                        $class = 'mw-sp-translate-edit-noinfo';
                }
 
+               $info .= $this->formatGettextComments();
+               $class .= ' mw-sp-translate-message-documentation';
+
+               $contents = $wgOut->parse( $info );
+               // Remove whatever block element wrapup the parser likes to add
+               $contents = preg_replace( '~^<([a-z]+)>(.*)</\1>$~us', '\2', 
$contents );
+
+               return TranslateUtils::fieldset(
+                       wfMsgHtml( 'translate-edit-information', $edit , $page 
), $contents, array( 'class' => $class )
+               );
+
+       }
+
+       protected function formatGettextComments() {
                if ( $this->group instanceof GettextMessageGroup ) {
                        $reader = $this->group->getReader( 'en' );
                        if ( $reader ) {
@@ -670,21 +684,46 @@
                                $help = trim( 
GettextFormatWriter::formatComments( @$data[$mykey]['comments'], false, 
@$data[$mykey]['flags'] ) );
                                // Do not display an empty comment. That's no 
help and takes up unnecessary space.
                                if ( $help !== '#:' ) {
-                                       $info .= "<hr /><pre>$help</pre>";
+                                       return "<hr /><pre>$help</pre>";
                                }
                        }
                }
 
-               $class .= ' mw-sp-translate-message-documentation';
+               if ( $this->group instanceof FileBasedMessageGroup ) {
+                       $ffs = $this->group->getFFS();
+                       if ( $ffs instanceof GettextFFS ) {
+                               global $wgContLang;
+                               $mykey = $wgContLang->lcfirst( $this->page );
+                               $data = $ffs->read( 'en' );
+                               $help = $data['TEMPLATE'][$mykey]['comments'];
+                               // Do not display an empty comment. That's no 
help and takes up unnecessary space.
+                               $conf = $this->group->getConfiguration();
+                               if ( isset( $conf['BASIC']['codeBrowser'] ) ) {
+                                       $out = '';
+                                       $pattern = 
$conf['BASIC']['codeBrowser'];
+                                       $pattern = str_replace( '%FILE%', '\1', 
$pattern );
+                                       $pattern = str_replace( '%LINE%', '\2', 
$pattern );
+                                       $pattern = "[$pattern \\1:\\2]";
+                                       foreach ( $help as $type => $lines ) {
+                                               if ( $type === ':' ) {
+                                                       $files = '';
+                                                       foreach ( $lines as 
$index => $line ) {
+                                                               $files .= ' ' . 
preg_replace( '/([^ :]+):(\d+)/', $pattern, $line );
+                                                       }
+                                                       $out .= 
"<nowiki>#:</nowiki> $files<br />";
+                                               } else {
+                                                       foreach ( $lines as 
$index => $line ) {
+                                                               $out .= 
"<nowiki>#$type</nowiki> $line<br />";
+                                                       }
+                                               }
+                                       }
+                                       
+                               }
+                               return "<hr />$out";
+                       }
+               }
 
-               $contents = $wgOut->parse( $info );
-               // Remove whatever block element wrapup the parser likes to add
-               $contents = preg_replace( '~^<([a-z]+)>(.*)</\1>$~us', '\2', 
$contents );
-
-               return TranslateUtils::fieldset(
-                       wfMsgHtml( 'translate-edit-information', $edit , $page 
), $contents, array( 'class' => $class )
-               );
-
+               return '';
        }
 
        protected function getPageDiff() {



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

Reply via email to