From 8f416baead93a48e5799e44b8bd2e2c4859f4e04 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 14 Sep 2007 13:18:58 +0200 Subject: auf Version 1.11 aktualisiert; Login-Bug behoben --- includes/api/ApiFormatBase.php | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'includes/api/ApiFormatBase.php') diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 782a4161..861310d2 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -5,7 +5,7 @@ * * API for MediaWiki 1.8+ * - * Copyright (C) 2006 Yuri Astrakhan + * Copyright (C) 2006 Yuri Astrakhan @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 @@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) { } /** + * This is the abstract base class for API formatters. + * * @addtogroup API */ abstract class ApiFormatBase extends ApiBase { @@ -36,7 +38,8 @@ abstract class ApiFormatBase extends ApiBase { private $mIsHtml, $mFormat; /** - * Constructor + * Create a new instance of the formatter. + * If the format name ends with 'fm', wrap its output in the proper HTML. */ public function __construct($main, $format) { parent :: __construct($main, $format); @@ -56,6 +59,11 @@ abstract class ApiFormatBase extends ApiBase { */ public abstract function getMimeType(); + /** + * If formatter outputs data results as is, the results must first be sanitized. + * An XML formatter on the other hand uses special tags, such as "_element" for special handling, + * and thus needs to override this function to return true. + */ public function getNeedsRawData() { return false; } @@ -77,6 +85,7 @@ abstract class ApiFormatBase extends ApiBase { function initPrinter($isError) { $isHtml = $this->getIsHtml(); $mime = $isHtml ? 'text/html' : $this->getMimeType(); + $script = wfScript( 'api' ); // Some printers (ex. Feed) do their own header settings, // in which case $mime will be set to null @@ -96,14 +105,14 @@ abstract class ApiFormatBase extends ApiBase {
-You are looking at the HTML representation of the mFormat?> format.
+You are looking at the HTML representation of the mFormat ); ?> format.
HTML is good for debugging, but probably is not suitable for your application.
-Please see "format" parameter documentation at the API help -for more information. +See complete documentation, or +API help for more information.
getIsHtml()) echo $this->formatHTML($text); @@ -152,9 +165,9 @@ for more information. $text = preg_replace('/\<(!--.*?--|.*?)\>/', '<\1>', $text); // identify URLs $protos = "http|https|ftp|gopher"; - $text = ereg_replace("($protos)://[^ '\"()<\n]+", '\\0', $text); + $text = ereg_replace("($protos)://[^ \\'\"()<\n]+", '\\0', $text); // identify requests to api.php - $text = ereg_replace("api\\.php\\?[^ ()<\n\t]+", '\\0', $text); + $text = ereg_replace("api\\.php\\?[^ \\()<\n\t]+", '\\0', $text); // make strings inside * bold $text = ereg_replace("\\*[^<>\n]+\\*", '\\0', $text); // make strings inside $ italic @@ -175,7 +188,7 @@ for more information. } public static function getBaseVersion() { - return __CLASS__ . ': $Id: ApiFormatBase.php 21402 2007-04-20 08:55:14Z nickj $'; + return __CLASS__ . ': $Id: ApiFormatBase.php 25746 2007-09-10 21:36:51Z brion $'; } } @@ -190,7 +203,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase { } /** - * Call this method to initialize output data + * Call this method to initialize output data. See self::execute() */ public static function setResult($result, $feed, $feedItems) { // Store output in the Result data. @@ -214,6 +227,11 @@ class ApiFormatFeedWrapper extends ApiFormatBase { return true; } + /** + * This class expects the result data to be in a custom format set by self::setResult() + * $result['_feed'] - an instance of one of the $wgFeedClasses classes + * $result['_feeditems'] - an array of FeedItem instances + */ public function execute() { $data = $this->getResultData(); if (isset ($data['_feed']) && isset ($data['_feeditems'])) { @@ -232,7 +250,6 @@ class ApiFormatFeedWrapper extends ApiFormatBase { } public function getVersion() { - return __CLASS__ . ': $Id: ApiFormatBase.php 21402 2007-04-20 08:55:14Z nickj $'; + return __CLASS__ . ': $Id: ApiFormatBase.php 25746 2007-09-10 21:36:51Z brion $'; } } -?> -- cgit v1.2.3-54-g00ecf