Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -92,9 +92,9 @@ |
93 | 93 | if (is_null($resultPageSet)) { |
94 | 94 | $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
95 | 95 | if ($title->userCanRead()) { |
96 | | - $data[intval($row->page_id)] = array( |
97 | | - 'pageid' => $row->page_id, |
98 | | - 'ns' => $title->getNamespace(), |
| 96 | + $data[] = array( |
| 97 | + 'pageid' => intval($row->page_id), |
| 98 | + 'ns' => intval($title->getNamespace()), |
99 | 99 | 'title' => $title->getPrefixedText()); |
100 | 100 | } |
101 | 101 | } else { |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -29,7 +29,16 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | | - * This is the main API class, used for both external and internal processing. |
| 33 | + * This is the main API class, used for both external and internal processing. |
| 34 | + * When executed, it will create the requested formatter object, |
| 35 | + * instantiate and execute an object associated with the needed action, |
| 36 | + * and use formatter to print results. |
| 37 | + * In case of an exception, an error message will be printed using the same formatter. |
| 38 | + * |
| 39 | + * To use API from another application, run it using FauxRequest object, in which |
| 40 | + * case any internal exceptions will not be handled but passed up to the caller. |
| 41 | + * After successful execution, use getResult() for the resulting data. |
| 42 | + * |
34 | 43 | * @addtogroup API |
35 | 44 | */ |
36 | 45 | class ApiMain extends ApiBase { |
— | — | @@ -43,11 +52,11 @@ |
44 | 53 | * List of available modules: action name => module class |
45 | 54 | */ |
46 | 55 | private static $Modules = array ( |
47 | | - 'help' => 'ApiHelp', |
48 | 56 | // 'login' => 'ApiLogin', // LOGIN is temporarily disabled until it becomes more secure |
49 | 57 | 'query' => 'ApiQuery', |
50 | 58 | 'opensearch' => 'ApiOpenSearch', |
51 | | - 'feedwatchlist' => 'ApiFeedWatchlist' |
| 59 | + 'feedwatchlist' => 'ApiFeedWatchlist', |
| 60 | + 'help' => 'ApiHelp', |
52 | 61 | ); |
53 | 62 | |
54 | 63 | /** |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -176,11 +176,13 @@ |
177 | 177 | if ($showContent) |
178 | 178 | ApiResult :: setContent($vals, Revision :: getRevisionText($row)); |
179 | 179 | |
180 | | - $this->getResult()->addValue(array ( |
181 | | - 'query', |
182 | | - 'pages', |
183 | | - intval($row->rev_page |
184 | | - ), 'revisions'), intval($row->rev_id), $vals); |
| 180 | + $this->getResult()->addValue( |
| 181 | + array ( |
| 182 | + 'query', |
| 183 | + 'pages', |
| 184 | + intval($row->rev_page), |
| 185 | + 'revisions'), |
| 186 | + null, $vals); |
185 | 187 | } |
186 | 188 | } |
187 | 189 | $db->freeResult($res); |
Index: trunk/phase3/includes/api/ApiResult.php |
— | — | @@ -125,7 +125,8 @@ |
126 | 126 | /** |
127 | 127 | * Add value to the output data at the given path. |
128 | 128 | * Path is an indexed array, each element specifing the branch at which to add the new value |
129 | | - * Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value |
| 129 | + * Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value |
| 130 | + * If $name is empty, the $value is added as a next list element data[] = $value |
130 | 131 | */ |
131 | 132 | public function addValue($path, $name, $value) { |
132 | 133 | |
— | — | @@ -145,7 +146,10 @@ |
146 | 147 | } |
147 | 148 | } |
148 | 149 | |
149 | | - ApiResult :: setElement($data, $name, $value); |
| 150 | + if (empty($name)) |
| 151 | + $data[] = $value; // Add list element |
| 152 | + else |
| 153 | + ApiResult :: setElement($data, $name, $value); // Add named element |
150 | 154 | } |
151 | 155 | |
152 | 156 | public function execute() { |
Index: trunk/phase3/includes/api/ApiQueryInfo.php |
— | — | @@ -40,8 +40,11 @@ |
41 | 41 | public function requestExtraData() { |
42 | 42 | $pageSet = $this->getPageSet(); |
43 | 43 | $pageSet->requestField('page_is_redirect'); |
| 44 | + $pageSet->requestField('page_is_new'); |
| 45 | + $pageSet->requestField('page_counter'); |
44 | 46 | $pageSet->requestField('page_touched'); |
45 | 47 | $pageSet->requestField('page_latest'); |
| 48 | + $pageSet->requestField('page_len'); |
46 | 49 | } |
47 | 50 | |
48 | 51 | public function execute() { |
— | — | @@ -51,18 +54,26 @@ |
52 | 55 | $result = $this->getResult(); |
53 | 56 | |
54 | 57 | $pageIsRedir = $pageSet->getCustomField('page_is_redirect'); |
| 58 | + $pageIsNew = $pageSet->getCustomField('page_is_new'); |
| 59 | + $pageCounter = $pageSet->getCustomField('page_counter'); |
55 | 60 | $pageTouched = $pageSet->getCustomField('page_touched'); |
56 | 61 | $pageLatest = $pageSet->getCustomField('page_latest'); |
| 62 | + $pageLength = $pageSet->getCustomField('page_len'); |
57 | 63 | |
58 | 64 | foreach ( $titles as $pageid => $unused ) { |
59 | 65 | $pageInfo = array ( |
60 | 66 | 'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]), |
61 | | - 'lastrevid' => intval($pageLatest[$pageid]) |
| 67 | + 'lastrevid' => intval($pageLatest[$pageid]), |
| 68 | + 'counter' => $pageCounter[$pageid], |
| 69 | + 'length' => $pageLength[$pageid], |
62 | 70 | ); |
63 | 71 | |
64 | 72 | if ($pageIsRedir[$pageid]) |
65 | 73 | $pageInfo['redirect'] = ''; |
66 | 74 | |
| 75 | + if ($pageIsNew[$pageid]) |
| 76 | + $pageInfo['new'] = ''; |
| 77 | + |
67 | 78 | $result->addValue(array ( |
68 | 79 | 'query', |
69 | 80 | 'pages' |
Index: trunk/phase3/includes/api/ApiFormatBase.php |
— | — | @@ -149,9 +149,9 @@ |
150 | 150 | $text = ereg_replace('\<([^>]+)\>', '<span style="color:blue;"><\1></span>', $text); |
151 | 151 | // identify URLs |
152 | 152 | $protos = "http|https|ftp|gopher"; |
153 | | - $text = ereg_replace("($protos)://[^ '\"()<\n]+", '<a href="\\0">\\0</a>', $text); |
| 153 | + $text = ereg_replace("($protos)://[^ \\'\"()<\n]+", '<a href="\\0">\\0</a>', $text); |
154 | 154 | // identify requests to api.php |
155 | | - $text = ereg_replace("api\\.php\\?[^ ()<\n\t]+", '<a href="\\0">\\0</a>', $text); |
| 155 | + $text = ereg_replace("api\\.php\\?[^ \\()<\n\t]+", '<a href="\\0">\\0</a>', $text); |
156 | 156 | // make strings inside * bold |
157 | 157 | $text = ereg_replace("\\*[^<>\n]+\\*", '<b>\\0</b>', $text); |
158 | 158 | // make strings inside $ italic |