API: coding style cleanup, fix copyright symbol, more braces
[lhc/web/wiklou.git] / includes / api / ApiFormatBase.php
index d5f1ea4..3ad1419 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
-/*
+/**
  * Created on Sep 19, 2006
  *
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ( 'ApiBase.php' );
+       require_once( 'ApiBase.php' );
 }
 
 /**
@@ -45,13 +45,14 @@ abstract class ApiFormatBase extends ApiBase {
         * @param $format string Format name
         */
        public function __construct( $main, $format ) {
-               parent :: __construct( $main, $format );
+               parent::__construct( $main, $format );
 
                $this->mIsHtml = ( substr( $format, - 2, 2 ) === 'fm' ); // ends with 'fm'
-               if ( $this->mIsHtml )
+               if ( $this->mIsHtml ) {
                        $this->mFormat = substr( $format, 0, - 2 ); // remove ending 'fm'
-               else
+               } else {
                        $this->mFormat = $format;
+               }
                $this->mFormat = strtoupper( $this->mFormat );
                $this->mCleared = false;
        }
@@ -125,8 +126,9 @@ abstract class ApiFormatBase extends ApiBase {
 
                // Some printers (ex. Feed) do their own header settings,
                // in which case $mime will be set to null
-               if ( is_null( $mime ) )
+               if ( is_null( $mime ) ) {
                        return; // skip any initialization
+               }
 
                header( "Content-Type: $mime; charset=utf-8" );
 
@@ -197,8 +199,7 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
                        // For non-HTML output, clear all errors that might have been
                        // displayed if display_errors=On
                        // Do this only once, of course
-                       if ( !$this->mCleared )
-                       {
+                       if ( !$this->mCleared ) {
                                ob_clean();
                                $this->mCleared = true;
                        }
@@ -228,11 +229,11 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
        }
 
        /**
-       * Prety-print various elements in HTML format, such as xml tags and
-       * URLs. This method also escapes characters like <
-       * @param $text string
-       * @return string
-       */
+        * Pretty-print various elements in HTML format, such as xml tags and
+        * URLs. This method also escapes characters like <
+        * @param $text string
+        * @return string
+        */
        protected function formatHTML( $text ) {
                global $wgUrlProtocols;
 
@@ -254,12 +255,15 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
                        $text = preg_replace( "#\\$[^<>\n]+\\$#", '<b><i>\\0</i></b>', $text );
                }
 
-               /* Temporary fix for bad links in help messages. As a special case,
+               /**
+                * Temporary fix for bad links in help messages. As a special case,
                 * XML-escaped metachars are de-escaped one level in the help message
-                * for legibility. Should be removed once we have completed a fully-html
-                * version of the help message. */
-               if ( $this->mUnescapeAmps )
+                * for legibility. Should be removed once we have completed a fully-HTML
+                * version of the help message.
+                */
+               if ( $this->mUnescapeAmps ) {
                        $text = preg_replace( '/&amp;(amp|quot|lt|gt);/', '&\1;', $text );
+               }
 
                return $text;
        }
@@ -284,7 +288,7 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
 class ApiFormatFeedWrapper extends ApiFormatBase {
 
        public function __construct( $main ) {
-               parent :: __construct( $main, 'feed' );
+               parent::__construct( $main, 'feed' );
        }
 
        /**
@@ -326,13 +330,14 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
         */
        public function execute() {
                $data = $this->getResultData();
-               if ( isset ( $data['_feed'] ) && isset ( $data['_feeditems'] ) ) {
+               if ( isset( $data['_feed'] ) && isset( $data['_feeditems'] ) ) {
                        $feed = $data['_feed'];
                        $items = $data['_feeditems'];
 
                        $feed->outHeader();
-                       foreach ( $items as & $item )
+                       foreach ( $items as & $item ) {
                                $feed->outItem( $item );
+                       }
                        $feed->outFooter();
                } else {
                        // Error has occured, print something useful