Index: trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php |
— | — | @@ -61,32 +61,28 @@ |
62 | 62 | * |
63 | 63 | * @return bool Acceptable |
64 | 64 | */ |
65 | | - private static function acceptNewUserName( $userName, &$message ) { |
| 65 | + private static function acceptNewUserName( $userName, &$err ) { |
66 | 66 | global $wgTitleBlacklist; |
67 | 67 | efInitTitleBlacklist(); |
68 | | - $title = Title::newFromText( $userName ); |
| 68 | + $title = Title::newFromText( $userName, NS_USER ); |
69 | 69 | $blacklisted = $wgTitleBlacklist->isBlacklisted( $title, 'new-account' ); |
70 | 70 | if( !( $blacklisted instanceof TitleBlacklistEntry ) ) |
71 | 71 | $blacklisted = $wgTitleBlacklist->isBlacklisted( $title, 'create' ); |
72 | 72 | if( $blacklisted instanceof TitleBlacklistEntry ) { |
73 | 73 | wfLoadExtensionMessages( 'TitleBlacklist' ); |
74 | 74 | $message = $blacklisted->getCustomMessage(); |
75 | | - if( is_null( $message ) ) |
76 | | - $message = wfMsgWikiHtml( 'titleblacklist-forbidden-new-account', |
77 | | - $blacklisted->getRaw(), |
78 | | - $userName ); |
79 | | - $result = array( $message, |
80 | | - htmlspecialchars( $blacklisted->getRaw() ), |
81 | | - $title->getFullText() ); |
| 75 | + if ( is_null( $message ) ) |
| 76 | + $message = 'titleblacklist-forbidden-new-account'; |
| 77 | + $err = wfMsgWikiHtml( $message, $blacklisted->getRaw(), $userName ); |
82 | 78 | return false; |
83 | 79 | } |
84 | 80 | return true; |
85 | 81 | } |
86 | 82 | |
87 | 83 | /** AbortNewAccount hook */ |
88 | | - public static function abortNewAccount($user, &$message) { |
| 84 | + public static function abortNewAccount( $user, &$message ) { |
89 | 85 | global $wgUser; |
90 | | - if ( $wgUser->isAllowed( 'tboverride' ) ) |
| 86 | + if( $wgUser->isAllowed( 'tboverride' ) ) |
91 | 87 | return true; |
92 | 88 | return self::acceptNewUserName( $user->getName(), $message ); |
93 | 89 | } |
— | — | @@ -96,7 +92,7 @@ |
97 | 93 | $message = ''; # Will be ignored |
98 | 94 | return self::acceptNewUserName( $userName, $message ); |
99 | 95 | } |
100 | | - |
| 96 | + |
101 | 97 | /** EditFilter hook */ |
102 | 98 | public static function validateBlacklist( $editor, $text, $section, $error ) { |
103 | 99 | global $wgTitleBlacklist; |
— | — | @@ -113,28 +109,28 @@ |
114 | 110 | wfLoadExtensionMessages( 'TitleBlacklist' ); |
115 | 111 | $errmsg = wfMsgExt( 'titleblacklist-invalid', array( 'parsemag' ), count( $ok ) ); |
116 | 112 | $errlines = '* <tt>' . implode( "</tt>\n* <tt>", array_map( 'wfEscapeWikiText', $ok ) ) . '</tt>'; |
117 | | - $error = '<div class="errorbox">' . |
| 113 | + $error = Html::openElement( 'div', array( 'class' => 'errorbox' ) ) . |
118 | 114 | $errmsg . |
119 | 115 | "\n" . |
120 | 116 | $errlines . |
121 | | - "</div>\n" . |
122 | | - "<br clear='all' />\n"; |
123 | | - |
| 117 | + Html::closeElement( 'div' ) . "\n" . |
| 118 | + Html::element( 'br', array( 'clear' => 'all' ) ) . "\n"; |
| 119 | + |
124 | 120 | // $error will be displayed by the edit class |
125 | 121 | return true; |
126 | | - } else if (!$section) { |
| 122 | + } elseif( !$section ) { |
127 | 123 | # Block redirects to nonexistent blacklisted titles |
128 | 124 | $retitle = Title::newFromRedirect( $text ); |
129 | | - if ( $retitle !== null && !$retitle->exists() ) { |
| 125 | + if( $retitle !== null && !$retitle->exists() ) { |
130 | 126 | $blacklisted = $wgTitleBlacklist->isBlacklisted( $retitle, 'create' ); |
131 | | - if ( $blacklisted instanceof TitleBlacklistEntry ) { |
| 127 | + if( $blacklisted instanceof TitleBlacklistEntry ) { |
132 | 128 | wfLoadExtensionMessages( 'TitleBlacklist' ); |
133 | | - $error = ( '<div class="errorbox">' . |
134 | | - wfMsg( 'titleblacklist-forbidden-edit', |
135 | | - htmlspecialchars( $blacklisted->getRaw() ), |
136 | | - $retitle->getFullText() ) . |
137 | | - "</div>\n" . |
138 | | - "<br clear='all' />\n" ); |
| 129 | + $error = Html::openElement( 'div', array( 'class' => 'errorbox' ) ) . |
| 130 | + wfMsg( 'titleblacklist-forbidden-edit', |
| 131 | + htmlspecialchars( $blacklisted->getRaw() ), |
| 132 | + $retitle->getFullText() ) . |
| 133 | + Html::closeElement( 'div' ) . "\n" . |
| 134 | + Html::element( 'br', array( 'clear' => 'all' ) ) . "\n"; |
139 | 135 | } |
140 | 136 | } |
141 | 137 | |
— | — | @@ -142,10 +138,11 @@ |
143 | 139 | } |
144 | 140 | return true; |
145 | 141 | } |
146 | | - |
| 142 | + |
147 | 143 | /** ArticleSaveComplete hook */ |
148 | 144 | public static function clearBlacklist( &$article, &$user, |
149 | | - $text, $summary, $isminor, $iswatch, $section ) { |
| 145 | + $text, $summary, $isminor, $iswatch, $section ) |
| 146 | + { |
150 | 147 | $title = $article->getTitle(); |
151 | 148 | if( $title->getNamespace() == NS_MEDIAWIKI && $title->getDBkey() == 'Titleblacklist' ) { |
152 | 149 | global $wgTitleBlacklist; |