1<?php 2/** 3 * Plugin nspages : Displays nicely a list of the pages of a namespace 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 */ 7if(!defined('DOKU_INC')) die(); 8require_once 'namespacePreparer.php'; 9require_once 'pagePreparer.php'; 10 11class fileHelper { 12 private $files; 13 private $data; 14 15 private $customTitleAllowListMetadata; 16 17 function __construct($data, $customTitleAllowListMetadata){ 18 $this->data = $data; 19 $this->files = $this->searchFiles($data); 20 $this->customTitleAllowListMetadata = $customTitleAllowListMetadata; 21 } 22 23 private function searchFiles(){ 24 global $conf; 25 $opt = array( 26 'depth' => $this->data['maxDepth'], 'keeptxt'=> false, 'listfiles'=> !$this->data['nopages'], 27 'listdirs' => $this->data['subns'], 'pagesonly'=> true, 'skipacl'=> false, 28 'sneakyacl' => true, 'hash'=> false, 'meta'=> true, 'showmsg'=> false, 29 'showhidden'=> $this->data['showhidden'], 'firsthead'=> true 30 ); 31 $files = array(); 32 search($files, $conf['datadir'], 'search_universal', $opt, $this->data['wantedDir']); 33 return $files; 34 } 35 36 function getPages(){ 37 $preparer = new pagePreparer($this->data['excludedNS'], $this->data['excludedPages'], $this->data['pregPagesOn'], 38 $this->data['pregPagesOff'], $this->data['pregPagesTitleOn'], $this->data['pregPagesTitleOff'], $this->data['title'], 39 $this->data['sortid'], $this->data['idAndTitle'], $this->data['sortDate'], $this->data['sortByCreationDate'], 40 $this->data['customTitle'], $this->customTitleAllowListMetadata, $this->data['sortByMetadata']); 41 return $this->getFiles($preparer); 42 } 43 44 function getSubnamespaces(){ 45 $preparer = new namespacePreparer($this->data['excludedNS'], $this->data['pregNSOn'], $this->data['pregNSOff'], 46 $this->data['pregNSTitleOn'], $this->data['pregNSTitleOff'], $this->data['title'], $this->data['sortid'], 47 $this->data['idAndTitle'], $this->data['sortDate'], $this->data['sortByCreationDate']); 48 return $this->getFiles($preparer); 49 } 50 51 private function getFiles($preparer){ 52 $files = array(); 53 foreach($this->files as $item) { 54 $preparer->prepareFileTitle($item); 55 if($preparer->isFileWanted($item, false) && $preparer->isFileWanted($item, true)) { 56 $preparer->prepareFile($item); 57 $files[] = $item; 58 } 59 } 60 return $files; 61 } 62} 63