| Index: branches/RL2/extensions/Gadgets/api/ApiQueryGadgets.php |
| — | — | @@ -81,8 +81,9 @@ |
| 82 | 82 | if ( isset( $this->props['name'] ) ) { |
| 83 | 83 | $row['name'] = $name; |
| 84 | 84 | } |
| 85 | | - if ( isset( $this->props['json'] ) ) { |
| 86 | | - $row['json'] = $g->getJSON(); |
| | 85 | + if ( isset( $this->props['metadata'] ) ) { |
| | 86 | + $row['metadata'] = $g->getMetadata(); |
| | 87 | + $this->setIndexedTagNameForMetadata( $row['metadata'] ); |
| 87 | 88 | } |
| 88 | 89 | if ( isset( $this->props['timestamp'] ) ) { |
| 89 | 90 | $context = ResourceLoaderContext::newDummyContext(); |
| — | — | @@ -120,15 +121,35 @@ |
| 121 | 122 | && ( !$this->listShared || $gadget->isShared() ) |
| 122 | 123 | && ( !$this->categories || isset( $this->categories[$g->getCategory()] ) ); |
| 123 | 124 | } |
| | 125 | + |
| | 126 | + private function setIndexedTagNameForMetadata( &$metadata ) { |
| | 127 | + static $tagNames = array( |
| | 128 | + 'rights' => 'right', |
| | 129 | + 'scripts' => 'script', |
| | 130 | + 'styles' => 'style', |
| | 131 | + 'dependencies' => 'dependency', |
| | 132 | + 'messages' => 'message', |
| | 133 | + ); |
| | 134 | + |
| | 135 | + $result = $this->getResult(); |
| | 136 | + foreach ( $metadata as $type => &$data ) { |
| | 137 | + foreach ( $data as $key => &$value ) { |
| | 138 | + if ( is_array( $value ) ) { |
| | 139 | + $tag = isset( $tagNames[$key] ) ? $tagNames[$key] : $key; |
| | 140 | + $result->setIndexedTagName( $value, $tag ); |
| | 141 | + } |
| | 142 | + } |
| | 143 | + } |
| | 144 | + } |
| 124 | 145 | |
| 125 | 146 | public function getAllowedParams() { |
| 126 | 147 | return array( |
| 127 | 148 | 'prop' => array( |
| 128 | | - ApiBase::PARAM_DFLT => 'name|json', |
| | 149 | + ApiBase::PARAM_DFLT => 'name|metadata', |
| 129 | 150 | ApiBase::PARAM_ISMULTI => true, |
| 130 | 151 | ApiBase::PARAM_TYPE => array( |
| 131 | 152 | 'name', |
| 132 | | - 'json', |
| | 153 | + 'metadata', |
| 133 | 154 | 'timestamp', |
| 134 | 155 | 'definitiontimestamp', |
| 135 | 156 | 'desc', |
| — | — | @@ -162,7 +183,7 @@ |
| 163 | 184 | 'prop' => array( |
| 164 | 185 | 'What gadget information to get:', |
| 165 | 186 | ' name - Internal gadget name', |
| 166 | | - ' json - JSON representation of the gadget metadata.', |
| | 187 | + ' metadata - The gadget metadata', |
| 167 | 188 | ' timestamp - Last changed timestamp of the gadget module, including any files it references', |
| 168 | 189 | ' definitiontimestamp - Last changed timestamp of the gadget metadata', |
| 169 | 190 | ' desc - Gadget description translated in the given language and transformed into HTML (can be slow, use only if really needed)', |