1<?php
2/**
3 * This is the Dokuwiki export for FINDOLOGIC.
4 *
5 * If any bugs occur, please submit a new issue
6 * @see https://github.com/findologic/dokuwiki-plugin-findologic-xml-export/issues/new
7 * @author Dominik Brader <support@findologic.com>
8 */
9
10class PageGetter
11{
12
13    /**
14     * Get all pages that do not have specified a title.
15     * Pages that do not have a description are deleted pages.
16     *
17     * @return array All pages that do not have a title set.
18     */
19    static function getPagesWithoutTitle()
20    {
21        $indexer = new Doku_Indexer();
22        $allPages = $indexer->getPages();
23
24        // Get all pages that do have a description, because pages that don't, are deleted pages.
25        // And only get pages that do not have a title set.
26        $allPagesWithoutTitle = array_filter($allPages, function ($page, $k) {
27            return (p_get_metadata($page)['description'] !== '' && !p_get_metadata($page)['title']);
28        }, ARRAY_FILTER_USE_BOTH);
29
30        // Create DokuWikiPage objects
31        $pagesData = [];
32        foreach ($allPagesWithoutTitle as $key => $sortedPage) {
33            $pagesData[] = new DokuwikiPage($sortedPage);
34        }
35
36        // Sort pages by lastEdit
37        usort($pagesData, function($object1, $object2){
38            return ($object1->lastEdit < $object2->lastEdit) ? 1 : -1;
39        });
40
41        return $pagesData;
42    }
43
44}