Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -38,12 +38,14 @@ |
39 | 39 | /** |
40 | 40 | * This is the function that extracts metadata from the article body on the first view. |
41 | 41 | * To turn the feature on, set $wgUseMetadataEdit = true ; in LocalSettings |
| 42 | + * and set $wgMetadataWhitelist to the *full* title of the template whitelist |
42 | 43 | */ |
43 | 44 | function extractMetaDataFromArticle () |
44 | 45 | { |
45 | | - global $wgUseMetadataEdit , $wgLang ; |
| 46 | + global $wgUseMetadataEdit , $wgMetadataWhitelist , $wgLang ; |
46 | 47 | $this->mMetaData = "" ; |
47 | 48 | if ( !$wgUseMetadataEdit ) return ; |
| 49 | + if ( $wgMetadataWhitelist == "" ) return ; |
48 | 50 | $s = "" ; |
49 | 51 | $t = $this->mArticle->getContent ( true ) ; |
50 | 52 | |
— | — | @@ -78,8 +80,28 @@ |
79 | 81 | if ( count ( $ll ) ) $s .= implode ( " " , $ll ) . "\n" ; |
80 | 82 | $t = implode ( "\n" , $t ) ; |
81 | 83 | |
| 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 | + |
82 | 105 | # Templates, but only some |
83 | | - $sat = array ( "meta-template" ) ; # stand-alone-templates; must be lowercase |
84 | 106 | $t = explode ( "{{" , $t ) ; |
85 | 107 | $tl = array () ; |
86 | 108 | foreach ( $t AS $key => $x ) |