Index: trunk/phase3/includes/api/ApiQueryAllimages.php |
— | — | @@ -52,6 +52,9 @@ |
53 | 53 | } |
54 | 54 | |
55 | 55 | private function run($resultPageSet = null) { |
| 56 | + $repo = RepoGroup::singleton()->getLocalRepo(); |
| 57 | + if ( !is_a( $repo, 'LocalRepo' ) ) |
| 58 | + $this->dieUsage('Local file repository does not support querying all images', 'unsupportedrepo'); |
56 | 59 | |
57 | 60 | $db = $this->getDB(); |
58 | 61 | |
— | — | @@ -84,11 +87,7 @@ |
85 | 88 | $this->addTables('image'); |
86 | 89 | |
87 | 90 | $prop = array_flip($params['prop']); |
88 | | - $this->addFields('img_name'); |
89 | | - $this->addFieldsIf('img_size', isset($prop['size'])); |
90 | | - $this->addFieldsIf(array('img_width', 'img_height'), isset($prop['dimensions'])); |
91 | | - $this->addFieldsIf(array('img_major_mime', 'img_minor_mime'), isset($prop['mime'])); |
92 | | - $this->addFieldsIf('img_timestamp', isset($prop['timestamp'])); |
| 91 | + $this->addFields( LocalFile::selectFields() ); |
93 | 92 | |
94 | 93 | $limit = $params['limit']; |
95 | 94 | $this->addOption('LIMIT', $limit+1); |
— | — | @@ -108,7 +107,7 @@ |
109 | 108 | } |
110 | 109 | |
111 | 110 | if (is_null($resultPageSet)) { |
112 | | - $file = wfLocalFile( $row->img_name ); |
| 111 | + $file = $repo->newFileFromRow( $row ); |
113 | 112 | $item['name'] = $row->img_name; |
114 | 113 | if(isset($prop['size'])) |
115 | 114 | $item['size'] = $file->getSize(); |
— | — | @@ -118,13 +117,13 @@ |
119 | 118 | $item['height'] = $file->getHeight(); |
120 | 119 | } |
121 | 120 | if(isset($prop['mime'])) |
122 | | - $item['mime'] = $row->img_major_mime . '/' . $row->img_minor_mime; |
| 121 | + $item['mime'] = $file->getMimeType(); |
123 | 122 | if(isset($prop['sha1'])) |
124 | 123 | $item['sha1'] = wfBaseConvert($file->getSha1(), 36, 16, 31); |
125 | 124 | if(isset($prop['timestamp'])) |
126 | 125 | $item['timestamp'] = wfTimestamp(TS_ISO_8601, $file->getTimestamp()); |
127 | 126 | if(isset($prop['url'])) |
128 | | - $item['url'] = $file->getUrl(); |
| 127 | + $item['url'] = $file->getFullUrl(); |
129 | 128 | $data[] = $item; |
130 | 129 | } else { |
131 | 130 | $data[] = Title::makeTitle( NS_IMAGE, $row->img_name ); |