New hook: AjaxAddScript. Used to load some more ajax javascripts
authorAntoine Musso <hashar@users.mediawiki.org>
Sun, 21 Jan 2007 16:46:36 +0000 (16:46 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sun, 21 Jan 2007 16:46:36 +0000 (16:46 +0000)
docs/hooks.txt
includes/OutputPage.php
skins/MonoBook.php

index 213171e..c63b8a2 100644 (file)
@@ -554,5 +554,9 @@ $content_actions: The array of content actions
                     Can be used to set custom CSS/JS
 $out: OutputPage object
 
+'AjaxAddScript': Called in output page just before the initialisation
+of the javascript ajax engine. The hook is only called when ajax
+is enabled ( $wgUseAjax = true; ).
+
 More hooks might be available but undocumented, you can execute
 ./maintenance/findhooks.php to find hidden one.
index 1dd4212..1244830 100644 (file)
@@ -69,7 +69,7 @@ class OutputPage {
        # To add an http-equiv meta tag, precede the name with "http:"
        function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
        function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
-       function addScript( $script ) { $this->mScripts .= $script; }
+       function addScript( $script ) { $this->mScripts .= "\t\t".$script; }
 
        /**
         * Add a self-contained script tag with the given contents
@@ -549,6 +549,9 @@ class OutputPage {
 
                if ( $wgUseAjax ) {
                        $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" );
+
+                       wfRunHooks( 'AjaxAddScript', array( &$this ) );
+
                        if( $wgAjaxSearch ) {
                                $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js\"></script>\n" );
                                $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
index dcdddcb..50d7f00 100644 (file)
@@ -89,7 +89,7 @@ class MonoBookTemplate extends QuickTemplate {
 <?php  }
                if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
                <!-- Head Scripts -->
-               <?php $this->html('headscripts') ?>
+<?php $this->html('headscripts') ?>
        </head>
 <body <?php if($this->data['body_ondblclick']) { ?>ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
 <?php if($this->data['body_onload'    ]) { ?>onload="<?php     $this->text('body_onload')     ?>"<?php } ?>