r17077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17076‎ | r17077 | r17078 >
Date:06:32, 18 October 2006
Author:yurik
Status:old
Tags:
Comment:
API * HTML is now valid HTML Transitional (thansk nickj)
* Fixed watchlist ordering bug
Modified paths:
  • /trunk/phase3/includes/api/ApiFeedWatchlist.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatBase.php
@@ -75,40 +75,41 @@
7676 function initPrinter($isError) {
7777 $isHtml = $this->getIsHtml();
7878 $mime = $isHtml ? 'text/html' : $this->getMimeType();
79 -
 79+
8080 // Some printers (ex. Feed) do their own header settings,
8181 // in which case $mime will be set to null
8282 if (is_null($mime))
83 - return; // skip any initialization
84 -
 83+ return; // skip any initialization
 84+
8585 header("Content-Type: $mime; charset=utf-8;");
8686 header("Cache-Control: private, s-maxage=0, max-age=0");
87 -
 87+
8888 if ($isHtml) {
8989 ?>
90 - <html>
91 - <head>
92 - <title>MediaWiki API</title>
93 - </head>
94 - <body>
 90+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 91+<html>
 92+<head>
 93+ <title>MediaWiki API</title>
 94+</head>
 95+<body>
9596 <?php
9697
9798
9899 if (!$isError) {
99100 ?>
100 - <br/>
101 - <small>
102 - You are looking at the HTML representation of the <?=$this->mFormat?> format.<br/>
103 - HTML is good for debugging, but probably not suitable for your application.<br/>
104 - Please see "format" parameter documentation at the <a href='api.php'>API help</a>
105 - for more information.<br/>
106 - </small>
 101+<br/>
 102+<small>
 103+You are looking at the HTML representation of the <?=$this->mFormat?> format.<br/>
 104+HTML is good for debugging, but probably not suitable for your application.<br/>
 105+Please see "format" parameter documentation at the <a href='api.php'>API help</a>
 106+for more information.
 107+</small>
107108 <?php
108109
109110
110111 }
111112 ?>
112 - <pre>
 113+<pre>
113114 <?php
114115
115116
@@ -121,8 +122,10 @@
122123 public function closePrinter() {
123124 if ($this->getIsHtml()) {
124125 ?>
125 - </pre>
126 - </body>
 126+
 127+</pre>
 128+</body>
 129+</html>
127130 <?php
128131
129132
@@ -142,7 +145,7 @@
143146 */
144147 protected function formatHTML($text) {
145148 // encode all tags as safe blue strings
146 - $text = ereg_replace('\<([^>]+)\>', '<font color=blue>&lt;\1&gt;</font>', $text);
 149+ $text = ereg_replace('\<([^>]+)\>', '<span style="color:blue;">&lt;\1&gt;</span>', $text);
147150 // identify URLs
148151 $text = ereg_replace("[a-zA-Z]+://[^ '\"()<\n]+", '<a href="\\0">\\0</a>', $text);
149152 // identify requests to api.php
@@ -182,7 +185,7 @@
183186 public static function setResult($result, $feed, $feedItems) {
184187 // Store output in the Result data.
185188 // This way we can check during execution if any error has occured
186 - $data =& $result->getData();
 189+ $data = & $result->getData();
187190 $data['_feed'] = $feed;
188191 $data['_feeditems'] = $feedItems;
189192 }
@@ -200,15 +203,15 @@
201204 public function getNeedsRawData() {
202205 return true;
203206 }
204 -
 207+
205208 public function execute() {
206 - $data =& $this->getResultData();
207 - if (isset($data['_feed']) && isset($data['_feeditems'])) {
208 - $feed =& $data['_feed'];
209 - $items =& $data['_feeditems'];
 209+ $data = & $this->getResultData();
 210+ if (isset ($data['_feed']) && isset ($data['_feeditems'])) {
 211+ $feed = & $data['_feed'];
 212+ $items = & $data['_feeditems'];
210213
211214 $feed->outHeader();
212 - foreach($items as &$item)
 215+ foreach ($items as & $item)
213216 $feed->outItem($item);
214217 $feed->outFooter();
215218 } else {
Index: trunk/phase3/includes/api/ApiFeedWatchlist.php
@@ -53,7 +53,7 @@
5454 'wlstart' => wfTimestamp(TS_MW, time() - intval( 1 * 86400 )), // limit to 1 day
5555 'wllimit' => 50
5656 ));
57 -
 57+
5858 // Execute
5959 $module = new ApiMain($params);
6060 $module->execute();
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -55,8 +55,8 @@
5656 $db = $this->getDB();
5757
5858 $dirNewer = ($dir === 'newer');
59 - $before = ($dirNewer ? '<=' : '>=');
60 - $after = ($dirNewer ? '>=' : '<=');
 59+ $after = ($dirNewer ? '<=' : '>=');
 60+ $before = ($dirNewer ? '>=' : '<=');
6161
6262 $tables = array (
6363 'watchlist',