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 $this->data['excludeSelfPage']); 42 return $this->getFiles($preparer); 43 } 44 45 function getSubnamespaces(){ 46 $preparer = new namespacePreparer($this->data['excludedNS'], $this->data['pregNSOn'], $this->data['pregNSOff'], 47 $this->data['pregNSTitleOn'], $this->data['pregNSTitleOff'], $this->data['title'], $this->data['sortid'], 48 $this->data['idAndTitle'], $this->data['sortDate'], $this->data['sortByCreationDate']); 49 return $this->getFiles($preparer); 50 } 51 52 private function getFiles($preparer){ 53 $files = array(); 54 foreach($this->files as $item) { 55 $preparer->prepareFileTitle($item); 56 if($preparer->isFileWanted($item, false) && $preparer->isFileWanted($item, true)) { 57 $preparer->prepareFile($item); 58 $files[] = $item; 59 } 60 } 61 return $files; 62 } 63} 64