r6888 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r6887‎ | r6888 | r6889 >
Date:14:39, 29 December 2004
Author:magnus_manske
Status:old
Tags:
Comment:
reads whitelist from database
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -38,12 +38,14 @@
3939 /**
4040 * This is the function that extracts metadata from the article body on the first view.
4141 * To turn the feature on, set $wgUseMetadataEdit = true ; in LocalSettings
 42+ * and set $wgMetadataWhitelist to the *full* title of the template whitelist
4243 */
4344 function extractMetaDataFromArticle ()
4445 {
45 - global $wgUseMetadataEdit , $wgLang ;
 46+ global $wgUseMetadataEdit , $wgMetadataWhitelist , $wgLang ;
4647 $this->mMetaData = "" ;
4748 if ( !$wgUseMetadataEdit ) return ;
 49+ if ( $wgMetadataWhitelist == "" ) return ;
4850 $s = "" ;
4951 $t = $this->mArticle->getContent ( true ) ;
5052
@@ -78,8 +80,28 @@
7981 if ( count ( $ll ) ) $s .= implode ( " " , $ll ) . "\n" ;
8082 $t = implode ( "\n" , $t ) ;
8183
 84+ # Load whitelist
 85+ $sat = array () ; # stand-alone-templates; must be lowercase
 86+ $wl_title = Title::newFromText ( $wgMetadataWhitelist ) ;
 87+ $wl_article = new Article ( $wl_title ) ;
 88+ $wl = explode ( "\n" , $wl_article->getContent(true) ) ;
 89+ foreach ( $wl AS $x )
 90+ {
 91+ $isentry = false ;
 92+ $x = trim ( $x ) ;
 93+ while ( substr ( $x , 0 , 1 ) == "*" )
 94+ {
 95+ $isentry = true ;
 96+ $x = trim ( substr ( $x , 1 ) ) ;
 97+ }
 98+ if ( $isentry )
 99+ {
 100+ $sat[] = strtolower ( $x ) ;
 101+ }
 102+
 103+ }
 104+
82105 # Templates, but only some
83 - $sat = array ( "meta-template" ) ; # stand-alone-templates; must be lowercase
84106 $t = explode ( "{{" , $t ) ;
85107 $tl = array () ;
86108 foreach ( $t AS $key => $x )

Status & tagging log