libitem = $libitem; $this->libitem->format(); } public function getChildren() { debug_event('webdav', 'Directory getChildren', 5); $children = array(); $childs = $this->libitem->get_childrens(); foreach ($childs as $key => $child) { if (is_string($key)) { foreach ($child as $schild) { $children[] = WebDAV_Directory::getChildFromArray($schild); } } else { $children[] = WebDAV_Directory::getChildFromArray($child); } } return $children; } public function getChild($name) { // Clean song name if (strtolower(get_class($this->libitem)) === "album") { $splitname = explode('-', $name, 3); $name = trim($splitname[count($splitname) - 1]); $nameinfo = pathinfo($name); $name = $nameinfo['filename']; } debug_event('webdav', 'Directory getChild: ' . $name, 5); $matches = $this->libitem->search_childrens($name); // Always return first match // Warning: this means that two items with the same name will not be supported for now if (count($matches) > 0) { return WebDAV_Directory::getChildFromArray($matches[0]); } throw new DAV\Exception\NotFound('The child with name: ' . $name . ' could not be found'); ; } public static function getChildFromArray($array) { $libitem = new $array['object_type']($array['object_id']); if (!$libitem->id) { throw new DAV\Exception\NotFound('The library item `' . $array['object_type'] . '` with id `' . $array['object_id'] . '` could not be found'); } if ($libitem instanceof media) { return new WebDAV_File($libitem); } else { return new WebDAV_Directory($libitem); } } public function childExists($name) { $matches = $this->libitem->search_childrens($name); return (count($matches) > 0); } public function getName() { return $this->libitem->get_fullname(); } }