Index: trunk/extensions/SemanticForms/includes/SF_Utils.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | * - this function doubles as a function to get all categories on |
100 | 100 | * the site, if no article is specified |
101 | 101 | */ |
102 | | - static function getCategoriesForPage( $title = NULL ) { |
| 102 | + static function getCategoriesForPage( $title = null ) { |
103 | 103 | $categories = array(); |
104 | 104 | $db = wfGetDB( DB_SLAVE ); |
105 | 105 | $conditions = null; |
— | — | @@ -147,12 +147,14 @@ |
148 | 148 | /** |
149 | 149 | * Creates HTML linking to a wiki page |
150 | 150 | */ |
151 | | - static function linkText( $namespace, $name, $text = NULL ) { |
| 151 | + static function linkText( $namespace, $name, $text = null ) { |
152 | 152 | $title = Title::makeTitleSafe( $namespace, $name ); |
153 | | - if ( $title === NULL ) { |
| 153 | + if ( is_null( $title ) ) { |
154 | 154 | return $name; // TODO maybe report an error here? |
155 | 155 | } |
156 | | - if ( NULL === $text ) $text = $title->getText(); |
| 156 | + if ( is_null( $text ) ) { |
| 157 | + $text = $title->getText(); |
| 158 | + } |
157 | 159 | $l = class_exists('DummyLinker') ? new DummyLinker : new Linker; |
158 | 160 | return $l->makeLinkObj( $title, htmlspecialchars( $text ) ); |
159 | 161 | } |
— | — | @@ -235,18 +237,54 @@ |
236 | 238 | } |
237 | 239 | |
238 | 240 | /** |
| 241 | + * Javascript files to be added regardless of the MediaWiki version |
| 242 | + * (i.e., even if the ResourceLoader is installed). |
| 243 | + */ |
| 244 | + static function addJavascriptFiles( $parser ) { |
| 245 | + global $wgOut, $wgFCKEditorDir, $wgScriptPath, $wgJsMimeType; |
| 246 | + |
| 247 | + $scripts = array(); |
| 248 | + |
| 249 | + wfRunHooks( 'sfAddJavascriptFiles', array( &$scripts ) ); |
| 250 | + |
| 251 | + // The FCKeditor extension has no defined ResourceLoader |
| 252 | + // modules yet, so we have to call the scripts directly. |
| 253 | + // @TODO Move this code into the FCKeditor extension. |
| 254 | + if ( $wgFCKEditorDir && class_exists( 'FCKEditor' ) ) { |
| 255 | + $scripts[] = "$wgScriptPath/$wgFCKEditorDir/fckeditor.js"; |
| 256 | + } |
| 257 | + |
| 258 | + foreach ( $scripts as $js ) { |
| 259 | + if ( $parser ) { |
| 260 | + $script = "<script type=\"$wgJsMimeType\" src=\"$js\"></script>\n"; |
| 261 | + $parser->getOutput()->addHeadItem( $script ); |
| 262 | + } else { |
| 263 | + $wgOut->addScriptFile( $js ); |
| 264 | + } |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + /** |
239 | 269 | * Includes the necessary Javascript and CSS files for the form |
240 | 270 | * to display and work correctly |
241 | 271 | * |
242 | 272 | * Accepts an optional Parser instance, or uses $wgOut if omitted. |
243 | 273 | */ |
244 | | - static function addJavascriptAndCSS( $parser = NULL ) { |
| 274 | + static function addJavascriptAndCSS( $parser = null ) { |
| 275 | + global $wgOut; |
| 276 | + |
| 277 | + if ( !$parser ) { |
| 278 | + $wgOut->addMeta( 'robots', 'noindex,nofollow' ); |
| 279 | + } |
| 280 | + |
| 281 | + self::addJavascriptFiles( $parser ); |
| 282 | + |
245 | 283 | // MW 1.17 + |
246 | 284 | if ( class_exists( 'ResourceLoader' ) ) { |
247 | 285 | self::loadJavascriptAndCSS( $parser ); |
248 | 286 | return; |
249 | 287 | } |
250 | | - global $wgOut, $sfgScriptPath, $smwgScriptPath, $wgScriptPath, $wgFCKEditorDir, $wgJsMimeType, $sfgUseFormEditPage; |
| 288 | + global $sfgScriptPath, $smwgScriptPath, $wgScriptPath, $wgJsMimeType, $sfgUseFormEditPage; |
251 | 289 | global $smwgJQueryIncluded, $smwgJQUIAutoIncluded; |
252 | 290 | // jQuery and jQuery UI are used so often in forms, we might as |
253 | 291 | // well assume they'll always be used, and include them in |
— | — | @@ -305,9 +343,6 @@ |
306 | 344 | $scripts[] = "$sfgScriptPath/libs/jquery.fancybox.js"; |
307 | 345 | $scripts[] = "$sfgScriptPath/libs/SF_autogrow.js"; |
308 | 346 | $scripts[] = "$sfgScriptPath/libs/SF_submit.js"; |
309 | | - |
310 | | - if ( $wgFCKEditorDir ) |
311 | | - $scripts[] = "$wgScriptPath/$wgFCKEditorDir/fckeditor.js"; |
312 | 347 | $scripts[] = "$sfgScriptPath/libs/SemanticForms.js"; |
313 | 348 | |
314 | 349 | global $wgOut; |
— | — | @@ -319,8 +354,6 @@ |
320 | 355 | $wgOut->addScriptFile( $js ); |
321 | 356 | } |
322 | 357 | } |
323 | | - if ( !$parser ) |
324 | | - $wgOut->addMeta( 'robots', 'noindex,nofollow' ); |
325 | 358 | } |
326 | 359 | |
327 | 360 | /** |