r76747 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76746‎ | r76747 | r76748 >
Date:00:52, 16 November 2010
Author:nad
Status:deferred
Tags:
Comment:
allow normal edit functionmality using nora=1 in querystring, and wrap record templates in noincludes
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin.php (modified) (history)
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -52,8 +52,11 @@
5353 * Add record forms to page edit view
5454 */
5555 function onEditPage( $editPage ) {
56 - global $wgOut, $wgJsMimeType, $wgStylePath;
 56+ global $wgOut, $wgJsMimeType, $wgStylePath, $wgRequest;
5757
 58+ # Allow normal edit operation if 'nora' in request
 59+ if( $wgRequest->getText( 'nora' ) ) return true;
 60+
5861 # Extract each of the top-level template calls in the content that have associated forms
5962 # - note multiple records are now allowed in an article, but only one of each type
6063 $records = array();
@@ -78,7 +81,7 @@
7982 # Add the prefs JS for the tabset
8083 #$wgOut->addScript( "<script src=\"$wgStylePath/common/prefs.js\"></script>" );
8184
82 - $editPage->textbox1 = str_replace( "\x07", "", $content );
 85+ $editPage->textbox1 = preg_replace( "|(<noinclude>)?\s*\x07+\s*(</noinclude>)?|", "", $content );
8386
8487 $jsFormsList = array();
8588 $tabset = "<div class=\"tabset\">";
@@ -149,6 +152,9 @@
150153 }
151154 }
152155
 156+ # Bail if no record data was posted
 157+ if( count( $data ) == 0 ) return true;
 158+
153159 # Build the template syntax for the posted record data
154160 $templates = '';
155161 foreach( $data as $type => $values ) {
@@ -158,7 +164,8 @@
159165 }
160166
161167 # Prepend the template syntax to the posted wikitext (which had them removed by onEditPage)
162 - $text = $templates . $text;
 168+ # - wrap them in noincludes as these should never show in enbeded articles
 169+ $text = "<noinclude>$templates</noinclude>$text";
163170 return true;
164171 }
165172
Index: trunk/extensions/RecordAdmin/RecordAdmin.php
@@ -10,7 +10,7 @@
1111 * @author Siebrand Mazeland
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
14 -define( 'RECORDADMIN_VERSION', '1.1.2, 2010-11-14' );
 14+define( 'RECORDADMIN_VERSION', '1.1.3, 2010-11-16' );
1515
1616 $dir = dirname( __FILE__ ) . '/';
1717 $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php';

Status & tagging log