LivePreview: Support section=new for preview
[lhc/web/wiklou.git] / includes / skins / BaseTemplate.php
index 6dc33ac..25df0f9 100644 (file)
@@ -55,7 +55,6 @@ abstract class BaseTemplate extends QuickTemplate {
         * @return array
         */
        function getToolbox() {
-               wfProfileIn( __METHOD__ );
 
                $toolbox = array();
                if ( isset( $this->data['nav_urls']['whatlinkshere'] )
@@ -112,8 +111,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        $toolbox['info']['id'] = 't-info';
                }
 
-               wfRunHooks( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
-               wfProfileOut( __METHOD__ );
+               Hooks::run( 'BaseTemplateToolbox', array( &$this, &$toolbox ) );
                return $toolbox;
        }
 
@@ -228,7 +226,7 @@ abstract class BaseTemplate extends QuickTemplate {
                        ob_start();
                        // We pass an extra 'true' at the end so extensions using BaseTemplateToolbox
                        // can abort and avoid outputting double toolbox links
-                       wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
+                       Hooks::run( 'SkinTemplateToolboxEnd', array( &$this, true ) );
                        $hookContents = ob_get_contents();
                        ob_end_clean();
                        if ( !trim( $hookContents ) ) {
@@ -285,7 +283,7 @@ abstract class BaseTemplate extends QuickTemplate {
         */
        protected function renderAfterPortlet( $name ) {
                $content = '';
-               wfRunHooks( 'BaseTemplateAfterPortlet', array( $this, $name, &$content ) );
+               Hooks::run( 'BaseTemplateAfterPortlet', array( $this, $name, &$content ) );
 
                if ( $content !== '' ) {
                        echo "<div class='after-portlet after-portlet-$name'>$content</div>";
@@ -600,12 +598,44 @@ abstract class BaseTemplate extends QuickTemplate {
                return $footericons;
        }
 
+       /**
+        * Get the suggested HTML for page status indicators: icons (or short text snippets) usually
+        * displayed in the top-right corner of the page, outside of the main content.
+        *
+        * Your skin may implement this differently, for example by handling some indicator names
+        * specially with a different UI. However, it is recommended to use a `<div class="mw-indicator"
+        * id="mw-indicator-<id>" />` as a wrapper element for each indicator, for better compatibility
+        * with extensions and user scripts.
+        *
+        * The raw data is available in `$this->data['indicators']` as an associative array (keys:
+        * identifiers, values: contents) internally ordered by keys.
+        *
+        * @return string HTML
+        * @since 1.25
+        */
+       public function getIndicators() {
+               $out = "<div class=\"mw-indicators\">\n";
+               foreach ( $this->data['indicators'] as $id => $content ) {
+                       $out .= Html::rawElement(
+                               'div',
+                               array(
+                                       'id' => Sanitizer::escapeId( "mw-indicator-$id" ),
+                                       'class' => 'mw-indicator',
+                               ),
+                               $content
+                       ) . "\n";
+               }
+               $out .= "</div>\n";
+               return $out;
+       }
+
        /**
         * Output the basic end-page trail including bottomscripts, reporttime, and
         * debug stuff. This should be called right before outputting the closing
         * body and html tags.
         */
-       function printTrail() { ?>
+       function printTrail() {
+?>
 <?php echo MWDebug::getDebugHTML( $this->getSkin()->getContext() ); ?>
 <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
 <?php $this->html( 'reporttime' ) ?>