ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
FileListRetrieval.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2024 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5declare(strict_types=1);
6
8
13use ILIAS\Repository\RetrievalBase;
14use ilPCFileList;
15use ilObject;
16
21{
22 use RetrievalBase;
23
26
27 public function __construct(
30 ) {
31 $this->domain_service = $domain_service;
32 $this->file_list = $file_list;
33 }
34
35 public function getData(
36 array $fields,
37 ?Range $range = null,
38 ?Order $order = null,
39 array $filter = [],
40 array $parameters = []
41 ): \Generator {
42 $data = $this->collectData();
43 foreach ($data as $row) {
44 yield $row;
45 }
46 }
47
48 public function count(
49 array $filter,
50 array $parameters
51 ): int {
52 return count($this->collectData());
53 }
54
55 protected function collectData(): array
56 {
57 $data = $this->file_list->getFileList();
58 foreach ($data as $k => $v) {
59 $data[$k]["file_id"] = 0;
60 $data[$k]["file_name"] = "";
61 $entry = explode("_", $v["entry"]);
62 if (count($entry) === 4) {
63 if ($entry[1] === "") {
64 $file_id = (int) $entry[3];
65 if (\ilObject::_lookupType($file_id) === "file") {
66 $data[$k]["file_id"] = $file_id;
67 $file = new \ilObjFile($file_id, false);
68 $data[$k]["file_name"] = $file->getFileName();
69 }
70 }
71 }
72 $class = ($v["class"] == "")
73 ? "FileListItem"
74 : $v["class"];
75 $data[$k]["class"] = $class;
76 $data[$k]["id"] = $v["hier_id"] . ":" . $v["pc_id"];
77 }
78 return $data;
79 }
80
81 public function isFieldNumeric(string $field): bool
82 {
83 return false;
84 }
85}
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
count(array $filter, array $parameters)
__construct(InternalDomainService $domain_service, ilPCFileList $file_list)
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
Class ilObject Basic functions for all objects.
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...