@@ -247,6 +247,18 @@ protected function writeJsonIndex() {
247247 json_encode ($ descriptions )
248248 );
249249 $ this ->outputHandler ->v ("Index written " , VERBOSE_FORMAT_RENDERING );
250+
251+ $ entries = $ this ->processCombinedJsonIndex ();
252+ file_put_contents (
253+ $ this ->getOutputDir () . "search-combined.json " ,
254+ json_encode ($ entries )
255+ );
256+ $ entries = 'var localSearchIndexes = ' . json_encode ($ entries ) .'; ' ;
257+ file_put_contents (
258+ $ this ->getOutputDir () . "search-combined.js " ,
259+ $ entries
260+ );
261+ $ this ->outputHandler ->v ("Combined Index written " , VERBOSE_FORMAT_RENDERING );
250262 }
251263
252264 /**
@@ -290,6 +302,80 @@ private function processJsonIndex(): array {
290302 return [$ entries , $ descriptions ];
291303 }
292304
305+ private function processCombinedJsonIndex (): array
306+ {
307+ $ alwaysIncludeElements = [
308+ 'refentry ' ,
309+ 'stream_wrapper ' ,
310+ 'phpdoc:classref ' ,
311+ 'phpdoc:exceptionref ' ,
312+ 'phpdoc:varentry ' ,
313+ ];
314+
315+ $ entries = [];
316+ $ indexes = $ this ->indexRepository ->getIndexesWithDuplicates ();
317+ foreach ($ indexes as $ index ) {
318+ if (
319+ (! in_array ($ index ['element ' ], $ alwaysIncludeElements , true ))
320+ && (! $ index ['chunk ' ])
321+ ) {
322+ continue ;
323+ }
324+
325+ if ($ index ["sdesc " ] === "" && $ index ["ldesc " ] !== "" ) {
326+ $ index ["sdesc " ] = $ index ["ldesc " ];
327+ $ bookOrSet = $ this ->findParentBookOrSet ($ index ['parent_id ' ]);
328+ if ($ bookOrSet ) {
329+ $ index ["ldesc " ] = Format::getLongDescription (
330+ $ bookOrSet ['docbook_id ' ]
331+ );
332+ }
333+ }
334+
335+ $ nameParts = explode (':: ' , $ index ['sdesc ' ]);
336+ $ methodName = array_pop ($ nameParts );
337+
338+ if (str_contains ('wrapper ' , $ index ['filename ' ])) {
339+ print "Combined index: adding " . $ index ['filename ' ] . " :: " . $ index ['sdesc ' ] . "\n" ;
340+ }
341+
342+ $ type = 'General ' ;
343+ switch ($ index ['element ' ]) {
344+ case "phpdoc:varentry " :
345+ $ type = "Variable " ;
346+ break ;
347+
348+ case "refentry " :
349+ $ type = "Function " ;
350+ break ;
351+
352+ case "phpdoc:exceptionref " :
353+ $ type = "Exception " ;
354+ break ;
355+
356+ case "phpdoc:classref " :
357+ $ type = "Class " ;
358+ break ;
359+
360+ case "set " :
361+ case "book " :
362+ case "reference " :
363+ $ type = "Extension " ;
364+ break ;
365+ }
366+
367+ $ entries [] = [
368+ 'id ' => $ index ['filename ' ],
369+ 'name ' => $ index ['sdesc ' ],
370+ 'description ' => html_entity_decode ($ index ['ldesc ' ]),
371+ 'tag ' => $ index ['element ' ],
372+ 'type ' => $ type ,
373+ 'methodName ' => $ methodName ,
374+ ];
375+ }
376+ return $ entries ;
377+ }
378+
293379 /**
294380 * Finds the closest parent book or set in the index hierarchy.
295381 */
0 commit comments