1<?php 2 3/** 4 * DokuWiki WebDAV Plugin - Tags Collection 5 * 6 * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @link https://dokuwiki.org/plugin:webdav 9 */ 10 11namespace dokuwiki\plugin\webdav\core\DAV\Collection\Tags; 12 13use dokuwiki\plugin\webdav\core\DAV\AbstractDirectory; 14 15class Directory extends AbstractDirectory 16{ 17 const ROOT = 'tags'; 18 const DIRECTORY = 'datadir'; 19 20 /** @inheritdoc */ 21 public function getChildren() 22 { 23 global $conf; 24 25 $tag_helper = plugin_load('helper', 'tag'); 26 27 $children = []; 28 $data = []; 29 $class_type = $this->getClassType(); 30 31 if ($this->info['id']) { 32 foreach ($tag_helper->getTopic('', null, $this->info['id']) as $tag) { 33 $tag_id = $tag['id']; 34 $file_path = wikiFN($tag_id); 35 $data[] = [ 36 'type' => 'f', 37 'id' => $tag_id, 38 'path' => $file_path, 39 'ns' => getNS($tag_id), 40 'size' => filesize($file_path), 41 'mtime' => filemtime($file_path), 42 'perm' => auth_quickaclcheck($tag_id), 43 'hash' => sha1_file($file_path), 44 'filename' => $tag_id . '.txt', 45 'dir' => self::DIRECTORY, 46 ]; 47 } 48 } else { 49 foreach ($tag_helper->tagOccurrences([], null, true) as $tag => $length) { 50 $data[] = [ 51 'type' => 'd', 52 'dirname' => $tag, 53 'id' => $tag, 54 ]; 55 } 56 } 57 58 foreach ($data as $item) { 59 if ($item['type'] == 'd') { 60 $child_class = $class_type . '\\Directory'; 61 } else { 62 $child_class = $class_type . '\\File'; 63 } 64 65 $children[] = new $child_class($item); 66 } 67 68 return $children; 69 } 70} 71