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