* (bug 8760) Allow wiki links in "protectexpiry" message
authorRob Church <robchurch@users.mediawiki.org>
Thu, 7 Jun 2007 22:16:19 +0000 (22:16 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Thu, 7 Jun 2007 22:16:19 +0000 (22:16 +0000)
* Introduce wfMsgWithLinks() and a content-language counterpart, wfMsgForContentWithLinks(); these escape HTML and render wiki links in text, so should be suitable for labels and so on
* Make Linker::formatLinksInComment() public

RELEASE-NOTES
includes/GlobalFunctions.php
includes/Linker.php
includes/ProtectionForm.php

index 913830d..d946df0 100644 (file)
@@ -66,6 +66,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   files
 * (bug 7997) Allow users to be blocked from using Special:Emailuser
 * (bug 8989) Blacklist 'mhtml' and 'mht' files from upload
+* (bug 8760) Allow wiki links in "protectexpiry" message
 
 == Bugfixes since 1.10 ==
 
index 6ab81e5..b39a8ab 100644 (file)
@@ -326,6 +326,20 @@ function wfMsg( $key ) {
        return wfMsgReal( $key, $args, true );
 }
 
+/**
+ * Get a message in the user interface language and replace wiki
+ * links with clickable ones, escaping other HTML
+ *
+ * @param string $key Message key
+ * @return string
+ */
+function wfMsgWithLinks( $key ) {
+       global $wgUser;
+       $args = func_get_args();
+       return $wgUser->getSkin()->formatLinksInComment( htmlspecialchars(
+               call_user_func_array( 'wfMsg', $args ) ) );
+}
+
 /**
  * Same as above except doesn't transform the message
  */
@@ -368,6 +382,19 @@ function wfMsgForContent( $key ) {
        return wfMsgReal( $key, $args, true, $forcontent );
 }
 
+/**
+ * Get a message in the content language and replace wiki
+ * links with clickable ones, escaping other HTML
+ *
+ * @param string $key Message key
+ * @return string
+ */
+function wfMsgForContentWithLinks( $key ) {
+       global $wgUser;
+       return $wgUser->getSkin()->formatLinksInComment( htmlspecialchars(
+               call_user_func_array( 'wfMsgForContent', func_get_args() ) ) );
+}
+
 /**
  * Same as above except doesn't transform the message
  */
index 548505c..989a289 100644 (file)
@@ -926,12 +926,13 @@ class Linker {
        }
 
        /**
-        * Format regular and media links - all other wiki formatting is ignored
-        * Called by Linker::formatComment.
-        * @param $comment The comment text.
-        * @return Comment text with links using HTML.
+        * Formats wiki links and media links in text; all other wiki formatting
+        * is ignored
+        *
+        * @param string $comment Text to format links in
+        * @return string
         */
-       private function formatLinksInComment( $comment ) {
+       public function formatLinksInComment( $comment ) {
                global $wgContLang;
 
                $medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
index 02aa421..d261358 100644 (file)
@@ -318,22 +318,11 @@ class ProtectionForm {
        }
 
        function buildExpiryInput() {
-               $id = 'mwProtect-expiry';
-
-               $ci = "<tr><td align=\"right\">";
-               $ci .= wfElement( 'label', array (
-                               'id' => "$id-label",
-                               'for' => $id ),
-                               wfMsg( 'protectexpiry' ) );
-               $ci .= "</td> <td align=\"left\">";
-               $ci .= wfElement( 'input', array(
-                               'size' => 60,
-                               'name' => $id,
-                               'id' => $id,
-                               'value' => $this->mExpiry ) + $this->disabledAttrib );
-               $ci .= "</td></tr>";
-
-               return $ci;
+               $attribs = array( 'id' => 'expires' ) + $this->disabledAttrib;
+               return '<tr>'
+                       . '<td><label for="expires">' . wfMsgWithLinks( 'protectexpiry' ) . '</label></td>'
+                       . '<td>' . Xml::input( 'mwProtect-expiry', 60, $this->mExpiry, $attribs ) . '</td>'
+                       . '</tr>';
        }
        
        function buildWatchInput() {