Add parameter for query/search to fetch augmented data.
authorStanislav Malyshev <smalyshev@gmail.com>
Wed, 6 Dec 2017 00:10:45 +0000 (16:10 -0800)
committerStanislav Malyshev <smalyshev@gmail.com>
Thu, 7 Dec 2017 22:49:07 +0000 (14:49 -0800)
Bug: T182145
Change-Id: I54b50a1474b885ebe52900fd50729d6353e07807

includes/api/ApiQuerySearch.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json

index f0c4180..2c681f5 100644 (file)
@@ -272,6 +272,16 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                if ( isset( $prop['isfilematch'] ) ) {
                        $vals['isfilematch'] = $result->isFileMatch();
                }
+
+               if ( isset( $prop['extensiondata'] ) ) {
+                       $extra = $result->getExtensionData();
+                       // Add augmented data to the result. The data would be organized as a map:
+                       // augmentorName => data
+                       if ( $extra ) {
+                               $vals['extensiondata'] = ApiResult::addMetadataToResultVars( $extra );
+                       }
+               }
+
                return $vals;
        }
 
@@ -372,6 +382,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                                        'categorysnippet',
                                        'score', // deprecated
                                        'hasrelated', // deprecated
+                                       'extensiondata',
                                ],
                                ApiBase::PARAM_ISMULTI => true,
                                ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
index 91c3e18..e1360c8 100644 (file)
        "apihelp-query+search-paramvalue-prop-sectiontitle": "Adds the title of the matching section.",
        "apihelp-query+search-paramvalue-prop-categorysnippet": "Adds a parsed snippet of the matching category.",
        "apihelp-query+search-paramvalue-prop-isfilematch": "Adds a boolean indicating if the search matched file content.",
+       "apihelp-query+search-paramvalue-prop-extensiondata": "Adds extra data generated by extensions.",
        "apihelp-query+search-paramvalue-prop-score": "Ignored.",
        "apihelp-query+search-paramvalue-prop-hasrelated": "Ignored.",
        "apihelp-query+search-param-limit": "How many total pages to return.",
index 47afdc1..1724fa9 100644 (file)
        "apihelp-query+search-paramvalue-prop-sectiontitle": "{{doc-apihelp-paramvalue|query+search|prop|sectiontitle}}",
        "apihelp-query+search-paramvalue-prop-categorysnippet": "{{doc-apihelp-paramvalue|query+search|prop|categorysnippet}}",
        "apihelp-query+search-paramvalue-prop-isfilematch": "{{doc-apihelp-paramvalue|query+search|prop|isfilematch}}",
+       "apihelp-query+search-paramvalue-prop-extensiondata": "{{doc-apihelp-paramvalue|query+search|prop|extensiondata}}",
        "apihelp-query+search-paramvalue-prop-score": "{{doc-apihelp-paramvalue|query+search|prop|score}}\n{{Identical|Ignored}}",
        "apihelp-query+search-paramvalue-prop-hasrelated": "{{doc-apihelp-paramvalue|query+search|prop|hasrelated}}\n{{Identical|Ignored}}",
        "apihelp-query+search-param-limit": "{{doc-apihelp-param|query+search|limit}}",